OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef AccessibleNode_h | 5 #ifndef AccessibleNode_h |
6 #define AccessibleNode_h | 6 #define AccessibleNode_h |
7 | 7 |
8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
9 #include "platform/bindings/ScriptWrappable.h" | 9 #include "platform/bindings/ScriptWrappable.h" |
10 #include "platform/wtf/HashMap.h" | 10 #include "platform/wtf/HashMap.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 kExpanded, | 45 kExpanded, |
46 kHidden, | 46 kHidden, |
47 kModal, | 47 kModal, |
48 kMultiline, | 48 kMultiline, |
49 kMultiselectable, | 49 kMultiselectable, |
50 kReadOnly, | 50 kReadOnly, |
51 kRequired, | 51 kRequired, |
52 kSelected | 52 kSelected |
53 }; | 53 }; |
54 | 54 |
| 55 // All of the properties of AccessibleNode that have an unsigned integer type. |
| 56 enum class AOMUIntProperty { |
| 57 kColIndex, |
| 58 kColSpan, |
| 59 kLevel, |
| 60 kPosInSet, |
| 61 kRowIndex, |
| 62 kRowSpan, |
| 63 }; |
| 64 |
| 65 // All of the properties of AccessibleNode that have a signed integer type. |
| 66 // (These all allow the value -1.) |
| 67 enum class AOMIntProperty { kColCount, kRowCount, kSetSize }; |
| 68 |
| 69 // All of the properties of AccessibleNode that have a floating-point type. |
| 70 enum class AOMFloatProperty { kValueMax, kValueMin, kValueNow }; |
| 71 |
55 // Accessibility Object Model node | 72 // Accessibility Object Model node |
56 // Explainer: https://github.com/WICG/aom/blob/master/explainer.md | 73 // Explainer: https://github.com/WICG/aom/blob/master/explainer.md |
57 // Spec: https://wicg.github.io/aom/spec/ | 74 // Spec: https://wicg.github.io/aom/spec/ |
58 class CORE_EXPORT AccessibleNode | 75 class CORE_EXPORT AccessibleNode |
59 : public GarbageCollectedFinalized<AccessibleNode>, | 76 : public GarbageCollectedFinalized<AccessibleNode>, |
60 public ScriptWrappable { | 77 public ScriptWrappable { |
61 DEFINE_WRAPPERTYPEINFO(); | 78 DEFINE_WRAPPERTYPEINFO(); |
62 | 79 |
63 public: | 80 public: |
64 explicit AccessibleNode(Element*); | 81 explicit AccessibleNode(Element*); |
65 virtual ~AccessibleNode(); | 82 virtual ~AccessibleNode(); |
66 | 83 |
67 // Returns the given string property if the Element has an AccessibleNode. | 84 // Returns the given string property if the Element has an AccessibleNode. |
68 static const AtomicString& GetProperty(Element*, AOMStringProperty); | 85 static const AtomicString& GetProperty(Element*, AOMStringProperty); |
69 | 86 |
70 // Returns the value of the given boolean property if the | 87 // Returns the value of the given property if the |
71 // Element has an AccessibleNode. Sets |isNull| if the property and | 88 // Element has an AccessibleNode. Sets |isNull| if the property and |
72 // attribute are not present. | 89 // attribute are not present. |
73 static bool GetProperty(Element*, AOMBooleanProperty, bool& is_null); | 90 static bool GetProperty(Element*, AOMBooleanProperty, bool& is_null); |
| 91 static float GetProperty(Element*, AOMFloatProperty, bool& is_null); |
| 92 static int32_t GetProperty(Element*, AOMIntProperty, bool& is_null); |
| 93 static uint32_t GetProperty(Element*, AOMUIntProperty, bool& is_null); |
74 | 94 |
75 // Returns the value of the given string property if the | 95 // Returns the value of the given string property if the |
76 // Element has an AccessibleNode, otherwise returns the equivalent | 96 // Element has an AccessibleNode, otherwise returns the equivalent |
77 // ARIA attribute. | 97 // ARIA attribute. |
78 static const AtomicString& GetPropertyOrARIAAttribute(Element*, | 98 static const AtomicString& GetPropertyOrARIAAttribute(Element*, |
79 AOMStringProperty); | 99 AOMStringProperty); |
80 | 100 |
81 // Returns the value of the given boolean property if the | 101 // Returns the value of the given property if the |
82 // Element has an AccessibleNode, otherwise returns the equivalent | 102 // Element has an AccessibleNode, otherwise returns the equivalent |
83 // ARIA attribute. Sets |isNull| if the property and attribute are not | 103 // ARIA attribute. Sets |isNull| if the property and attribute are not |
84 // present. | 104 // present. |
85 static bool GetPropertyOrARIAAttribute(Element*, | 105 static bool GetPropertyOrARIAAttribute(Element*, |
86 AOMBooleanProperty, | 106 AOMBooleanProperty, |
87 bool& is_null); | 107 bool& is_null); |
| 108 static float GetPropertyOrARIAAttribute(Element*, |
| 109 AOMFloatProperty, |
| 110 bool& is_null); |
| 111 static int32_t GetPropertyOrARIAAttribute(Element*, |
| 112 AOMIntProperty, |
| 113 bool& is_null); |
| 114 static uint32_t GetPropertyOrARIAAttribute(Element*, |
| 115 AOMUIntProperty, |
| 116 bool& is_null); |
88 | 117 |
89 bool atomic(bool&) const; | 118 bool atomic(bool& is_null) const; |
90 void setAtomic(bool, bool is_null); | 119 void setAtomic(bool, bool is_null); |
91 | 120 |
92 AtomicString autocomplete() const; | 121 AtomicString autocomplete() const; |
93 void setAutocomplete(const AtomicString&); | 122 void setAutocomplete(const AtomicString&); |
94 | 123 |
95 bool busy(bool&) const; | 124 bool busy(bool& is_null) const; |
96 void setBusy(bool, bool is_null); | 125 void setBusy(bool, bool is_null); |
97 | 126 |
98 AtomicString checked() const; | 127 AtomicString checked() const; |
99 void setChecked(const AtomicString&); | 128 void setChecked(const AtomicString&); |
100 | 129 |
| 130 int32_t colCount(bool& is_null) const; |
| 131 void setColCount(int32_t, bool is_null); |
| 132 |
| 133 uint32_t colIndex(bool& is_null) const; |
| 134 void setColIndex(uint32_t, bool is_null); |
| 135 |
| 136 uint32_t colSpan(bool& is_null) const; |
| 137 void setColSpan(uint32_t, bool is_null); |
| 138 |
101 AtomicString current() const; | 139 AtomicString current() const; |
102 void setCurrent(const AtomicString&); | 140 void setCurrent(const AtomicString&); |
103 | 141 |
104 bool disabled(bool&) const; | 142 bool disabled(bool& is_null) const; |
105 void setDisabled(bool, bool is_null); | 143 void setDisabled(bool, bool is_null); |
106 | 144 |
107 bool expanded(bool&) const; | 145 bool expanded(bool& is_null) const; |
108 void setExpanded(bool, bool is_null); | 146 void setExpanded(bool, bool is_null); |
109 | 147 |
110 bool hidden(bool&) const; | 148 bool hidden(bool& is_null) const; |
111 void setHidden(bool, bool is_null); | 149 void setHidden(bool, bool is_null); |
112 | 150 |
113 AtomicString invalid() const; | 151 AtomicString invalid() const; |
114 void setInvalid(const AtomicString&); | 152 void setInvalid(const AtomicString&); |
115 | 153 |
116 AtomicString keyShortcuts() const; | 154 AtomicString keyShortcuts() const; |
117 void setKeyShortcuts(const AtomicString&); | 155 void setKeyShortcuts(const AtomicString&); |
118 | 156 |
119 AtomicString label() const; | 157 AtomicString label() const; |
120 void setLabel(const AtomicString&); | 158 void setLabel(const AtomicString&); |
121 | 159 |
| 160 uint32_t level(bool& is_null) const; |
| 161 void setLevel(uint32_t, bool is_null); |
| 162 |
122 AtomicString live() const; | 163 AtomicString live() const; |
123 void setLive(const AtomicString&); | 164 void setLive(const AtomicString&); |
124 | 165 |
125 bool modal(bool&) const; | 166 bool modal(bool& is_null) const; |
126 void setModal(bool, bool is_null); | 167 void setModal(bool, bool is_null); |
127 | 168 |
128 bool multiline(bool&) const; | 169 bool multiline(bool& is_null) const; |
129 void setMultiline(bool, bool is_null); | 170 void setMultiline(bool, bool is_null); |
130 | 171 |
131 bool multiselectable(bool&) const; | 172 bool multiselectable(bool& is_null) const; |
132 void setMultiselectable(bool, bool is_null); | 173 void setMultiselectable(bool, bool is_null); |
133 | 174 |
134 AtomicString orientation() const; | 175 AtomicString orientation() const; |
135 void setOrientation(const AtomicString&); | 176 void setOrientation(const AtomicString&); |
136 | 177 |
137 AtomicString placeholder() const; | 178 AtomicString placeholder() const; |
138 void setPlaceholder(const AtomicString&); | 179 void setPlaceholder(const AtomicString&); |
139 | 180 |
140 bool readOnly(bool&) const; | 181 uint32_t posInSet(bool& is_null) const; |
| 182 void setPosInSet(uint32_t, bool is_null); |
| 183 |
| 184 bool readOnly(bool& is_null) const; |
141 void setReadOnly(bool, bool is_null); | 185 void setReadOnly(bool, bool is_null); |
142 | 186 |
143 AtomicString relevant() const; | 187 AtomicString relevant() const; |
144 void setRelevant(const AtomicString&); | 188 void setRelevant(const AtomicString&); |
145 | 189 |
146 bool required(bool&) const; | 190 bool required(bool& is_null) const; |
147 void setRequired(bool, bool is_null); | 191 void setRequired(bool, bool is_null); |
148 | 192 |
149 AtomicString role() const; | 193 AtomicString role() const; |
150 void setRole(const AtomicString&); | 194 void setRole(const AtomicString&); |
151 | 195 |
152 AtomicString roleDescription() const; | 196 AtomicString roleDescription() const; |
153 void setRoleDescription(const AtomicString&); | 197 void setRoleDescription(const AtomicString&); |
154 | 198 |
155 bool selected(bool&) const; | 199 int32_t rowCount(bool& is_null) const; |
| 200 void setRowCount(int32_t, bool is_null); |
| 201 |
| 202 uint32_t rowIndex(bool& is_null) const; |
| 203 void setRowIndex(uint32_t, bool is_null); |
| 204 |
| 205 uint32_t rowSpan(bool& is_null) const; |
| 206 void setRowSpan(uint32_t, bool is_null); |
| 207 |
| 208 bool selected(bool& is_null) const; |
156 void setSelected(bool, bool is_null); | 209 void setSelected(bool, bool is_null); |
157 | 210 |
| 211 int32_t setSize(bool& is_null) const; |
| 212 void setSetSize(int32_t, bool is_null); |
| 213 |
158 AtomicString sort() const; | 214 AtomicString sort() const; |
159 void setSort(const AtomicString&); | 215 void setSort(const AtomicString&); |
160 | 216 |
| 217 float valueMax(bool& is_null) const; |
| 218 void setValueMax(float, bool is_null); |
| 219 |
| 220 float valueMin(bool& is_null) const; |
| 221 void setValueMin(float, bool is_null); |
| 222 |
| 223 float valueNow(bool& is_null) const; |
| 224 void setValueNow(float, bool is_null); |
| 225 |
161 AtomicString valueText() const; | 226 AtomicString valueText() const; |
162 void setValueText(const AtomicString&); | 227 void setValueText(const AtomicString&); |
163 | 228 |
164 DECLARE_VIRTUAL_TRACE(); | 229 DECLARE_VIRTUAL_TRACE(); |
165 | 230 |
166 private: | 231 private: |
167 void SetStringProperty(AOMStringProperty, const AtomicString&); | 232 void SetStringProperty(AOMStringProperty, const AtomicString&); |
168 void SetBooleanProperty(AOMBooleanProperty, bool value, bool is_null); | 233 void SetBooleanProperty(AOMBooleanProperty, bool value, bool is_null); |
| 234 void SetFloatProperty(AOMFloatProperty, float value, bool is_null); |
| 235 void SetUIntProperty(AOMUIntProperty, uint32_t value, bool is_null); |
| 236 void SetIntProperty(AOMIntProperty, int32_t value, bool is_null); |
169 void NotifyAttributeChanged(const blink::QualifiedName&); | 237 void NotifyAttributeChanged(const blink::QualifiedName&); |
170 AXObjectCache* GetAXObjectCache(); | 238 AXObjectCache* GetAXObjectCache(); |
171 | 239 |
172 Vector<std::pair<AOMStringProperty, AtomicString>> string_properties_; | 240 Vector<std::pair<AOMStringProperty, AtomicString>> string_properties_; |
173 Vector<std::pair<AOMBooleanProperty, bool>> boolean_properties_; | 241 Vector<std::pair<AOMBooleanProperty, bool>> boolean_properties_; |
| 242 Vector<std::pair<AOMFloatProperty, float>> float_properties_; |
| 243 Vector<std::pair<AOMIntProperty, int32_t>> int_properties_; |
| 244 Vector<std::pair<AOMUIntProperty, uint32_t>> uint_properties_; |
174 | 245 |
175 // This object's owner Element. | 246 // This object's owner Element. |
176 Member<Element> element_; | 247 Member<Element> element_; |
177 }; | 248 }; |
178 | 249 |
179 } // namespace blink | 250 } // namespace blink |
180 | 251 |
181 #endif // AccessibleNode_h | 252 #endif // AccessibleNode_h |
OLD | NEW |