accessible/src/html/HTMLSelectAccessible.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #ifndef mozilla_a11y_HTMLSelectAccessible_h__
     7 #define mozilla_a11y_HTMLSelectAccessible_h__
     9 #include "HTMLFormControlAccessible.h"
    11 class nsIMutableArray;
    13 namespace mozilla {
    14 namespace a11y {
    16 /**
    17   *  Selects, Listboxes and Comboboxes, are made up of a number of different
    18   *  widgets, some of which are shared between the two. This file contains
    19   *  all of the widgets for both of the Selects, for HTML only.
    20   *
    21   *  Listbox:
    22   *     - HTMLSelectListAccessible
    23   *        - HTMLSelectOptionAccessible
    24   *
    25   *  Comboboxes:
    26   *     - HTMLComboboxAccessible
    27   *        - HTMLComboboxListAccessible  [ inserted in accessible tree ]
    28   *           - HTMLSelectOptionAccessible(s)
    29   */
    31 /*
    32  * The list that contains all the options in the select.
    33  */
    34 class HTMLSelectListAccessible : public AccessibleWrap
    35 {
    36 public:
    38   HTMLSelectListAccessible(nsIContent* aContent, DocAccessible* aDoc);
    39   virtual ~HTMLSelectListAccessible() {}
    41   // Accessible
    42   virtual a11y::role NativeRole();
    43   virtual uint64_t NativeState();
    45   // SelectAccessible
    46   virtual bool SelectAll();
    47   virtual bool UnselectAll();
    49   // Widgets
    50   virtual bool IsWidget() const;
    51   virtual bool IsActiveWidget() const;
    52   virtual bool AreItemsOperable() const;
    53   virtual Accessible* CurrentItem();
    54   virtual void SetCurrentItem(Accessible* aItem);
    56 protected:
    58   // Accessible
    59   virtual void CacheChildren();
    60 };
    62 /*
    63  * Options inside the select, contained within the list
    64  */
    65 class HTMLSelectOptionAccessible : public HyperTextAccessibleWrap
    66 {
    67 public:
    68   enum { eAction_Select = 0 };
    70   HTMLSelectOptionAccessible(nsIContent* aContent, DocAccessible* aDoc);
    71   virtual ~HTMLSelectOptionAccessible() {}
    73   // nsIAccessible
    74   NS_IMETHOD DoAction(uint8_t index);
    75   NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
    76   NS_IMETHOD SetSelected(bool aSelect);
    78   // Accessible
    79   virtual a11y::role NativeRole();
    80   virtual uint64_t NativeState();
    81   virtual uint64_t NativeInteractiveState() const;
    83   virtual int32_t GetLevelInternal();
    84   virtual void GetBoundsRect(nsRect& aTotalBounds, nsIFrame** aBoundingFrame);
    86   // ActionAccessible
    87   virtual uint8_t ActionCount();
    89   // Widgets
    90   virtual Accessible* ContainerWidget() const;
    92 protected:
    93   // Accessible
    94   virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
    96 private:
    98   /**
    99    * Return a select accessible the option belongs to if any.
   100    */
   101   Accessible* GetSelect() const
   102   {
   103     Accessible* parent = mParent;
   104     if (parent && parent->IsHTMLOptGroup())
   105       parent = parent->Parent();
   107     if (parent && parent->IsListControl()) {
   108       Accessible* combobox = parent->Parent();
   109       return combobox && combobox->IsCombobox() ? combobox : mParent.get();
   110     }
   112     return nullptr;
   113   }
   115   /**
   116    * Return a combobox accessible the option belongs to if any.
   117    */
   118   Accessible* GetCombobox() const
   119   {
   120     Accessible* parent = mParent;
   121     if (parent && parent->IsHTMLOptGroup())
   122       parent = parent->Parent();
   124     if (parent && parent->IsListControl()) {
   125       Accessible* combobox = parent->Parent();
   126       return combobox && combobox->IsCombobox() ? combobox : nullptr;
   127     }
   129     return nullptr;
   130   }
   131 };
   133 /*
   134  * Opt Groups inside the select, contained within the list
   135  */
   136 class HTMLSelectOptGroupAccessible : public HTMLSelectOptionAccessible
   137 {
   138 public:
   140   HTMLSelectOptGroupAccessible(nsIContent* aContent, DocAccessible* aDoc) :
   141     HTMLSelectOptionAccessible(aContent, aDoc)
   142     { mType = eHTMLOptGroupType; }
   143   virtual ~HTMLSelectOptGroupAccessible() {}
   145   // nsIAccessible
   146   NS_IMETHOD DoAction(uint8_t index);
   147   NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
   149   // Accessible
   150   virtual a11y::role NativeRole();
   151   virtual uint64_t NativeInteractiveState() const;
   153   // ActionAccessible
   154   virtual uint8_t ActionCount();
   155 };
   157 /** ------------------------------------------------------ */
   158 /**  Finally, the Combobox widgets                         */
   159 /** ------------------------------------------------------ */
   161 class HTMLComboboxListAccessible;
   163 /*
   164  * A class the represents the HTML Combobox widget.
   165  */
   166 class HTMLComboboxAccessible : public AccessibleWrap
   167 {
   168 public:
   169   enum { eAction_Click = 0 };
   171   HTMLComboboxAccessible(nsIContent* aContent, DocAccessible* aDoc);
   172   virtual ~HTMLComboboxAccessible() {}
   174   // nsIAccessible
   175   NS_IMETHOD DoAction(uint8_t index);
   176   NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
   178   // Accessible
   179   virtual void Shutdown();
   180   virtual void Description(nsString& aDescription);
   181   virtual void Value(nsString& aValue);
   182   virtual a11y::role NativeRole();
   183   virtual uint64_t NativeState();
   184   virtual void InvalidateChildren();
   186   // ActionAccessible
   187   virtual uint8_t ActionCount();
   189   // Widgets
   190   virtual bool IsWidget() const;
   191   virtual bool IsActiveWidget() const;
   192   virtual bool AreItemsOperable() const;
   193   virtual Accessible* CurrentItem();
   194   virtual void SetCurrentItem(Accessible* aItem);
   196 protected:
   197   // Accessible
   198   virtual void CacheChildren();
   200   /**
   201    * Return selected option.
   202    */
   203   Accessible* SelectedOption() const;
   205 private:
   206   nsRefPtr<HTMLComboboxListAccessible> mListAccessible;
   207 };
   209 /*
   210  * A class that represents the window that lives to the right
   211  * of the drop down button inside the Select. This is the window
   212  * that is made visible when the button is pressed.
   213  */
   214 class HTMLComboboxListAccessible : public HTMLSelectListAccessible
   215 {
   216 public:
   218   HTMLComboboxListAccessible(nsIAccessible* aParent, nsIContent* aContent,
   219                              DocAccessible* aDoc);
   220   virtual ~HTMLComboboxListAccessible() {}
   222   // Accessible
   223   virtual nsIFrame* GetFrame() const;
   224   virtual a11y::role NativeRole();
   225   virtual uint64_t NativeState();
   226   virtual void GetBoundsRect(nsRect& aBounds, nsIFrame** aBoundingFrame);
   228   // Widgets
   229   virtual bool IsActiveWidget() const;
   230   virtual bool AreItemsOperable() const;
   231 };
   233 } // namespace a11y
   234 } // namespace mozilla
   236 #endif

mercurial