| 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 "core/dom/QualifiedName.h" | 9 #include "core/dom/QualifiedName.h" |
| 10 #include "platform/bindings/ScriptWrappable.h" | 10 #include "platform/bindings/ScriptWrappable.h" |
| 11 #include "platform/wtf/HashMap.h" | 11 #include "platform/wtf/HashMap.h" |
| 12 #include "platform/wtf/HashSet.h" | 12 #include "platform/wtf/HashSet.h" |
| 13 #include "platform/wtf/text/AtomicString.h" | 13 #include "platform/wtf/text/AtomicString.h" |
| 14 #include "platform/wtf/text/AtomicStringHash.h" | 14 #include "platform/wtf/text/AtomicStringHash.h" |
| 15 | 15 |
| 16 namespace blink { | 16 namespace blink { |
| 17 | 17 |
| 18 class AccessibleNodeList; |
| 18 class AXObjectCache; | 19 class AXObjectCache; |
| 19 class Element; | 20 class Element; |
| 20 class QualifiedName; | 21 class QualifiedName; |
| 21 | 22 |
| 22 // All of the properties of AccessibleNode that have type "string". | 23 // All of the properties of AccessibleNode that have type "string". |
| 23 enum class AOMStringProperty { | 24 enum class AOMStringProperty { |
| 24 kAutocomplete, | 25 kAutocomplete, |
| 25 kChecked, | 26 kChecked, |
| 26 kCurrent, | 27 kCurrent, |
| 27 kInvalid, | 28 kInvalid, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 kRowIndex, | 63 kRowIndex, |
| 63 kRowSpan, | 64 kRowSpan, |
| 64 }; | 65 }; |
| 65 | 66 |
| 66 enum class AOMRelationProperty { | 67 enum class AOMRelationProperty { |
| 67 kActiveDescendant, | 68 kActiveDescendant, |
| 68 kDetails, | 69 kDetails, |
| 69 kErrorMessage, | 70 kErrorMessage, |
| 70 }; | 71 }; |
| 71 | 72 |
| 73 enum class AOMRelationListProperty { |
| 74 kDescribedBy, |
| 75 kControls, |
| 76 kFlowTo, |
| 77 kLabeledBy, |
| 78 kOwns, |
| 79 }; |
| 80 |
| 72 // All of the properties of AccessibleNode that have a signed integer type. | 81 // All of the properties of AccessibleNode that have a signed integer type. |
| 73 // (These all allow the value -1.) | 82 // (These all allow the value -1.) |
| 74 enum class AOMIntProperty { kColCount, kRowCount, kSetSize }; | 83 enum class AOMIntProperty { kColCount, kRowCount, kSetSize }; |
| 75 | 84 |
| 76 // All of the properties of AccessibleNode that have a floating-point type. | 85 // All of the properties of AccessibleNode that have a floating-point type. |
| 77 enum class AOMFloatProperty { kValueMax, kValueMin, kValueNow }; | 86 enum class AOMFloatProperty { kValueMax, kValueMin, kValueNow }; |
| 78 | 87 |
| 79 class AccessibleNode; | 88 class AccessibleNode; |
| 80 | 89 |
| 81 class CORE_EXPORT AOMPropertyClient { | 90 class CORE_EXPORT AOMPropertyClient { |
| 82 public: | 91 public: |
| 83 virtual void AddStringProperty(AOMStringProperty, const String&) = 0; | 92 virtual void AddStringProperty(AOMStringProperty, const String&) = 0; |
| 84 virtual void AddBooleanProperty(AOMBooleanProperty, bool) = 0; | 93 virtual void AddBooleanProperty(AOMBooleanProperty, bool) = 0; |
| 85 virtual void AddIntProperty(AOMIntProperty, int32_t) = 0; | 94 virtual void AddIntProperty(AOMIntProperty, int32_t) = 0; |
| 86 virtual void AddUIntProperty(AOMUIntProperty, uint32_t) = 0; | 95 virtual void AddUIntProperty(AOMUIntProperty, uint32_t) = 0; |
| 87 virtual void AddFloatProperty(AOMFloatProperty, float) = 0; | 96 virtual void AddFloatProperty(AOMFloatProperty, float) = 0; |
| 88 virtual void AddRelationProperty(AOMRelationProperty, | 97 virtual void AddRelationProperty(AOMRelationProperty, |
| 89 const AccessibleNode&) = 0; | 98 const AccessibleNode&) = 0; |
| 99 virtual void AddRelationListProperty(AOMRelationListProperty, |
| 100 const AccessibleNodeList&) = 0; |
| 90 }; | 101 }; |
| 91 | 102 |
| 92 // Accessibility Object Model node | 103 // Accessibility Object Model node |
| 93 // Explainer: https://github.com/WICG/aom/blob/master/explainer.md | 104 // Explainer: https://github.com/WICG/aom/blob/master/explainer.md |
| 94 // Spec: https://wicg.github.io/aom/spec/ | 105 // Spec: https://wicg.github.io/aom/spec/ |
| 95 class CORE_EXPORT AccessibleNode | 106 class CORE_EXPORT AccessibleNode |
| 96 : public GarbageCollectedFinalized<AccessibleNode>, | 107 : public GarbageCollectedFinalized<AccessibleNode>, |
| 97 public ScriptWrappable { | 108 public ScriptWrappable { |
| 98 DEFINE_WRAPPERTYPEINFO(); | 109 DEFINE_WRAPPERTYPEINFO(); |
| 99 | 110 |
| 100 public: | 111 public: |
| 101 explicit AccessibleNode(Element*); | 112 explicit AccessibleNode(Element*); |
| 102 virtual ~AccessibleNode(); | 113 virtual ~AccessibleNode(); |
| 103 | 114 |
| 104 // Gets the associated element, if any. | 115 // Gets the associated element, if any. |
| 105 Element* element() const { return element_; } | 116 Element* element() const { return element_; } |
| 106 | 117 |
| 107 // Returns the given string property if the Element has an AccessibleNode. | 118 // Returns the given string property if the Element has an AccessibleNode. |
| 108 static const AtomicString& GetProperty(Element*, AOMStringProperty); | 119 static const AtomicString& GetProperty(Element*, AOMStringProperty); |
| 109 | 120 |
| 110 // Returns the given relation property if the Element has an AccessibleNode. | 121 // Returns the given relation property if the Element has an AccessibleNode. |
| 111 static AccessibleNode* GetProperty(Element*, AOMRelationProperty); | 122 static AccessibleNode* GetProperty(Element*, AOMRelationProperty); |
| 112 | 123 |
| 124 // Returns the given relation list property if the Element has an |
| 125 // AccessibleNode. |
| 126 static AccessibleNodeList* GetProperty(Element*, AOMRelationListProperty); |
| 127 static bool GetProperty(Element*, |
| 128 AOMRelationListProperty, |
| 129 HeapVector<Member<Element>>&); |
| 130 |
| 113 // Returns the value of the given property if the | 131 // Returns the value of the given property if the |
| 114 // Element has an AccessibleNode. Sets |isNull| if the property and | 132 // Element has an AccessibleNode. Sets |isNull| if the property and |
| 115 // attribute are not present. | 133 // attribute are not present. |
| 116 static bool GetProperty(Element*, AOMBooleanProperty, bool& is_null); | 134 static bool GetProperty(Element*, AOMBooleanProperty, bool& is_null); |
| 117 static float GetProperty(Element*, AOMFloatProperty, bool& is_null); | 135 static float GetProperty(Element*, AOMFloatProperty, bool& is_null); |
| 118 static int32_t GetProperty(Element*, AOMIntProperty, bool& is_null); | 136 static int32_t GetProperty(Element*, AOMIntProperty, bool& is_null); |
| 119 static uint32_t GetProperty(Element*, AOMUIntProperty, bool& is_null); | 137 static uint32_t GetProperty(Element*, AOMUIntProperty, bool& is_null); |
| 120 | 138 |
| 121 // Returns the value of the given string property if the | 139 // Returns the value of the given string property if the |
| 122 // Element has an AccessibleNode, otherwise returns the equivalent | 140 // Element has an AccessibleNode, otherwise returns the equivalent |
| 123 // ARIA attribute. | 141 // ARIA attribute. |
| 124 static const AtomicString& GetPropertyOrARIAAttribute(Element*, | 142 static const AtomicString& GetPropertyOrARIAAttribute(Element*, |
| 125 AOMStringProperty); | 143 AOMStringProperty); |
| 126 | 144 |
| 127 // Returns the given relation property if the Element has an AccessibleNode, | 145 // Returns the given relation property if the Element has an AccessibleNode, |
| 128 // otherwise returns the equivalent ARIA attribute. | 146 // otherwise returns the equivalent ARIA attribute. |
| 129 static AccessibleNode* GetPropertyOrARIAAttribute(Element*, | 147 static AccessibleNode* GetPropertyOrARIAAttribute(Element*, |
| 130 AOMRelationProperty); | 148 AOMRelationProperty); |
| 131 | 149 |
| 150 // Returns true and provides the the value of the given relation |
| 151 // list property if the Element has an AccessibleNode, or if it has |
| 152 // the equivalent ARIA attribute. Otherwise returns false. |
| 153 static bool GetPropertyOrARIAAttribute(Element*, |
| 154 AOMRelationListProperty, |
| 155 HeapVector<Member<Element>>&); |
| 156 |
| 132 // Returns the value of the given property if the | 157 // Returns the value of the given property if the |
| 133 // Element has an AccessibleNode, otherwise returns the equivalent | 158 // Element has an AccessibleNode, otherwise returns the equivalent |
| 134 // ARIA attribute. Sets |isNull| if the property and attribute are not | 159 // ARIA attribute. Sets |isNull| if the property and attribute are not |
| 135 // present. | 160 // present. |
| 136 static bool GetPropertyOrARIAAttribute(Element*, | 161 static bool GetPropertyOrARIAAttribute(Element*, |
| 137 AOMBooleanProperty, | 162 AOMBooleanProperty, |
| 138 bool& is_null); | 163 bool& is_null); |
| 139 static float GetPropertyOrARIAAttribute(Element*, | 164 static float GetPropertyOrARIAAttribute(Element*, |
| 140 AOMFloatProperty, | 165 AOMFloatProperty, |
| 141 bool& is_null); | 166 bool& is_null); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 172 | 197 |
| 173 int32_t colCount(bool& is_null) const; | 198 int32_t colCount(bool& is_null) const; |
| 174 void setColCount(int32_t, bool is_null); | 199 void setColCount(int32_t, bool is_null); |
| 175 | 200 |
| 176 uint32_t colIndex(bool& is_null) const; | 201 uint32_t colIndex(bool& is_null) const; |
| 177 void setColIndex(uint32_t, bool is_null); | 202 void setColIndex(uint32_t, bool is_null); |
| 178 | 203 |
| 179 uint32_t colSpan(bool& is_null) const; | 204 uint32_t colSpan(bool& is_null) const; |
| 180 void setColSpan(uint32_t, bool is_null); | 205 void setColSpan(uint32_t, bool is_null); |
| 181 | 206 |
| 207 AccessibleNodeList* controls() const; |
| 208 void setControls(AccessibleNodeList*); |
| 209 |
| 182 AtomicString current() const; | 210 AtomicString current() const; |
| 183 void setCurrent(const AtomicString&); | 211 void setCurrent(const AtomicString&); |
| 184 | 212 |
| 213 AccessibleNodeList* describedBy(); |
| 214 void setDescribedBy(AccessibleNodeList*); |
| 215 |
| 185 AccessibleNode* details() const; | 216 AccessibleNode* details() const; |
| 186 void setDetails(AccessibleNode*); | 217 void setDetails(AccessibleNode*); |
| 187 | 218 |
| 188 bool disabled(bool& is_null) const; | 219 bool disabled(bool& is_null) const; |
| 189 void setDisabled(bool, bool is_null); | 220 void setDisabled(bool, bool is_null); |
| 190 | 221 |
| 191 AccessibleNode* errorMessage() const; | 222 AccessibleNode* errorMessage() const; |
| 192 void setErrorMessage(AccessibleNode*); | 223 void setErrorMessage(AccessibleNode*); |
| 193 | 224 |
| 194 bool expanded(bool& is_null) const; | 225 bool expanded(bool& is_null) const; |
| 195 void setExpanded(bool, bool is_null); | 226 void setExpanded(bool, bool is_null); |
| 196 | 227 |
| 228 AccessibleNodeList* flowTo() const; |
| 229 void setFlowTo(AccessibleNodeList*); |
| 230 |
| 197 bool hidden(bool& is_null) const; | 231 bool hidden(bool& is_null) const; |
| 198 void setHidden(bool, bool is_null); | 232 void setHidden(bool, bool is_null); |
| 199 | 233 |
| 200 AtomicString invalid() const; | 234 AtomicString invalid() const; |
| 201 void setInvalid(const AtomicString&); | 235 void setInvalid(const AtomicString&); |
| 202 | 236 |
| 203 AtomicString keyShortcuts() const; | 237 AtomicString keyShortcuts() const; |
| 204 void setKeyShortcuts(const AtomicString&); | 238 void setKeyShortcuts(const AtomicString&); |
| 205 | 239 |
| 206 AtomicString label() const; | 240 AtomicString label() const; |
| 207 void setLabel(const AtomicString&); | 241 void setLabel(const AtomicString&); |
| 208 | 242 |
| 243 AccessibleNodeList* labeledBy(); |
| 244 void setLabeledBy(AccessibleNodeList*); |
| 245 |
| 209 uint32_t level(bool& is_null) const; | 246 uint32_t level(bool& is_null) const; |
| 210 void setLevel(uint32_t, bool is_null); | 247 void setLevel(uint32_t, bool is_null); |
| 211 | 248 |
| 212 AtomicString live() const; | 249 AtomicString live() const; |
| 213 void setLive(const AtomicString&); | 250 void setLive(const AtomicString&); |
| 214 | 251 |
| 215 bool modal(bool& is_null) const; | 252 bool modal(bool& is_null) const; |
| 216 void setModal(bool, bool is_null); | 253 void setModal(bool, bool is_null); |
| 217 | 254 |
| 218 bool multiline(bool& is_null) const; | 255 bool multiline(bool& is_null) const; |
| 219 void setMultiline(bool, bool is_null); | 256 void setMultiline(bool, bool is_null); |
| 220 | 257 |
| 221 bool multiselectable(bool& is_null) const; | 258 bool multiselectable(bool& is_null) const; |
| 222 void setMultiselectable(bool, bool is_null); | 259 void setMultiselectable(bool, bool is_null); |
| 223 | 260 |
| 224 AtomicString orientation() const; | 261 AtomicString orientation() const; |
| 225 void setOrientation(const AtomicString&); | 262 void setOrientation(const AtomicString&); |
| 226 | 263 |
| 264 AccessibleNodeList* owns() const; |
| 265 void setOwns(AccessibleNodeList*); |
| 266 |
| 227 AtomicString placeholder() const; | 267 AtomicString placeholder() const; |
| 228 void setPlaceholder(const AtomicString&); | 268 void setPlaceholder(const AtomicString&); |
| 229 | 269 |
| 230 uint32_t posInSet(bool& is_null) const; | 270 uint32_t posInSet(bool& is_null) const; |
| 231 void setPosInSet(uint32_t, bool is_null); | 271 void setPosInSet(uint32_t, bool is_null); |
| 232 | 272 |
| 233 AtomicString pressed() const; | 273 AtomicString pressed() const; |
| 234 void setPressed(const AtomicString&); | 274 void setPressed(const AtomicString&); |
| 235 | 275 |
| 236 bool readOnly(bool& is_null) const; | 276 bool readOnly(bool& is_null) const; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 void setValueMin(float, bool is_null); | 313 void setValueMin(float, bool is_null); |
| 274 | 314 |
| 275 float valueNow(bool& is_null) const; | 315 float valueNow(bool& is_null) const; |
| 276 void setValueNow(float, bool is_null); | 316 void setValueNow(float, bool is_null); |
| 277 | 317 |
| 278 AtomicString valueText() const; | 318 AtomicString valueText() const; |
| 279 void setValueText(const AtomicString&); | 319 void setValueText(const AtomicString&); |
| 280 | 320 |
| 281 DECLARE_VIRTUAL_TRACE(); | 321 DECLARE_VIRTUAL_TRACE(); |
| 282 | 322 |
| 323 protected: |
| 324 friend class AccessibleNodeList; |
| 325 void OnRelationListChanged(AOMRelationListProperty); |
| 326 |
| 283 private: | 327 private: |
| 284 void SetStringProperty(AOMStringProperty, const AtomicString&); | 328 void SetStringProperty(AOMStringProperty, const AtomicString&); |
| 285 void SetRelationProperty(AOMRelationProperty, AccessibleNode*); | 329 void SetRelationProperty(AOMRelationProperty, AccessibleNode*); |
| 330 void SetRelationListProperty(AOMRelationListProperty, AccessibleNodeList*); |
| 286 void SetBooleanProperty(AOMBooleanProperty, bool value, bool is_null); | 331 void SetBooleanProperty(AOMBooleanProperty, bool value, bool is_null); |
| 287 void SetFloatProperty(AOMFloatProperty, float value, bool is_null); | 332 void SetFloatProperty(AOMFloatProperty, float value, bool is_null); |
| 288 void SetUIntProperty(AOMUIntProperty, uint32_t value, bool is_null); | 333 void SetUIntProperty(AOMUIntProperty, uint32_t value, bool is_null); |
| 289 void SetIntProperty(AOMIntProperty, int32_t value, bool is_null); | 334 void SetIntProperty(AOMIntProperty, int32_t value, bool is_null); |
| 290 void NotifyAttributeChanged(const blink::QualifiedName&); | 335 void NotifyAttributeChanged(const blink::QualifiedName&); |
| 291 AXObjectCache* GetAXObjectCache(); | 336 AXObjectCache* GetAXObjectCache(); |
| 292 | 337 |
| 293 Vector<std::pair<AOMStringProperty, AtomicString>> string_properties_; | 338 Vector<std::pair<AOMStringProperty, AtomicString>> string_properties_; |
| 294 Vector<std::pair<AOMBooleanProperty, bool>> boolean_properties_; | 339 Vector<std::pair<AOMBooleanProperty, bool>> boolean_properties_; |
| 295 Vector<std::pair<AOMFloatProperty, float>> float_properties_; | 340 Vector<std::pair<AOMFloatProperty, float>> float_properties_; |
| 296 Vector<std::pair<AOMIntProperty, int32_t>> int_properties_; | 341 Vector<std::pair<AOMIntProperty, int32_t>> int_properties_; |
| 297 Vector<std::pair<AOMUIntProperty, uint32_t>> uint_properties_; | 342 Vector<std::pair<AOMUIntProperty, uint32_t>> uint_properties_; |
| 298 HeapVector<std::pair<AOMRelationProperty, Member<AccessibleNode>>> | 343 HeapVector<std::pair<AOMRelationProperty, Member<AccessibleNode>>> |
| 299 relation_properties_; | 344 relation_properties_; |
| 345 HeapVector<std::pair<AOMRelationListProperty, Member<AccessibleNodeList>>> |
| 346 relation_list_properties_; |
| 300 | 347 |
| 301 // This object's owner Element. | 348 // This object's owner Element. |
| 302 Member<Element> element_; | 349 Member<Element> element_; |
| 303 }; | 350 }; |
| 304 | 351 |
| 305 } // namespace blink | 352 } // namespace blink |
| 306 | 353 |
| 307 #endif // AccessibleNode_h | 354 #endif // AccessibleNode_h |
| OLD | NEW |