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