| 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 "platform/bindings/ScriptWrappable.h" | 10 #include "platform/bindings/ScriptWrappable.h" |
| 10 #include "platform/wtf/HashMap.h" | 11 #include "platform/wtf/HashMap.h" |
| 12 #include "platform/wtf/HashSet.h" |
| 11 #include "platform/wtf/text/AtomicString.h" | 13 #include "platform/wtf/text/AtomicString.h" |
| 12 #include "platform/wtf/text/AtomicStringHash.h" | 14 #include "platform/wtf/text/AtomicStringHash.h" |
| 13 | 15 |
| 14 namespace blink { | 16 namespace blink { |
| 15 | 17 |
| 16 class AXObjectCache; | 18 class AXObjectCache; |
| 17 class Element; | 19 class Element; |
| 18 class QualifiedName; | 20 class QualifiedName; |
| 19 | 21 |
| 20 // All of the properties of AccessibleNode that have type "string". | 22 // All of the properties of AccessibleNode that have type "string". |
| 21 // TODO(dmazzoni): Add similar enums for all of the properties with | |
| 22 // type bool, float, reference, and reference list. | |
| 23 enum class AOMStringProperty { | 23 enum class AOMStringProperty { |
| 24 kAutocomplete, | 24 kAutocomplete, |
| 25 kChecked, | 25 kChecked, |
| 26 kCurrent, | 26 kCurrent, |
| 27 kInvalid, | 27 kInvalid, |
| 28 kKeyShortcuts, | 28 kKeyShortcuts, |
| 29 kLabel, | 29 kLabel, |
| 30 kLive, | 30 kLive, |
| 31 kOrientation, | 31 kOrientation, |
| 32 kPlaceholder, | 32 kPlaceholder, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 56 // All of the properties of AccessibleNode that have an unsigned integer type. | 56 // All of the properties of AccessibleNode that have an unsigned integer type. |
| 57 enum class AOMUIntProperty { | 57 enum class AOMUIntProperty { |
| 58 kColIndex, | 58 kColIndex, |
| 59 kColSpan, | 59 kColSpan, |
| 60 kLevel, | 60 kLevel, |
| 61 kPosInSet, | 61 kPosInSet, |
| 62 kRowIndex, | 62 kRowIndex, |
| 63 kRowSpan, | 63 kRowSpan, |
| 64 }; | 64 }; |
| 65 | 65 |
| 66 enum class AOMRelationProperty { |
| 67 kActiveDescendant, |
| 68 kDetails, |
| 69 kErrorMessage, |
| 70 }; |
| 71 |
| 66 // All of the properties of AccessibleNode that have a signed integer type. | 72 // All of the properties of AccessibleNode that have a signed integer type. |
| 67 // (These all allow the value -1.) | 73 // (These all allow the value -1.) |
| 68 enum class AOMIntProperty { kColCount, kRowCount, kSetSize }; | 74 enum class AOMIntProperty { kColCount, kRowCount, kSetSize }; |
| 69 | 75 |
| 70 // All of the properties of AccessibleNode that have a floating-point type. | 76 // All of the properties of AccessibleNode that have a floating-point type. |
| 71 enum class AOMFloatProperty { kValueMax, kValueMin, kValueNow }; | 77 enum class AOMFloatProperty { kValueMax, kValueMin, kValueNow }; |
| 72 | 78 |
| 79 class AccessibleNode; |
| 80 |
| 81 class CORE_EXPORT AOMPropertyClient { |
| 82 public: |
| 83 virtual void AddStringProperty(AOMStringProperty, const String&) = 0; |
| 84 virtual void AddBooleanProperty(AOMBooleanProperty, bool) = 0; |
| 85 virtual void AddIntProperty(AOMIntProperty, int32_t) = 0; |
| 86 virtual void AddUIntProperty(AOMUIntProperty, uint32_t) = 0; |
| 87 virtual void AddFloatProperty(AOMFloatProperty, float) = 0; |
| 88 virtual void AddRelationProperty(AOMRelationProperty, |
| 89 const AccessibleNode&) = 0; |
| 90 }; |
| 91 |
| 73 // Accessibility Object Model node | 92 // Accessibility Object Model node |
| 74 // Explainer: https://github.com/WICG/aom/blob/master/explainer.md | 93 // Explainer: https://github.com/WICG/aom/blob/master/explainer.md |
| 75 // Spec: https://wicg.github.io/aom/spec/ | 94 // Spec: https://wicg.github.io/aom/spec/ |
| 76 class CORE_EXPORT AccessibleNode | 95 class CORE_EXPORT AccessibleNode |
| 77 : public GarbageCollectedFinalized<AccessibleNode>, | 96 : public GarbageCollectedFinalized<AccessibleNode>, |
| 78 public ScriptWrappable { | 97 public ScriptWrappable { |
| 79 DEFINE_WRAPPERTYPEINFO(); | 98 DEFINE_WRAPPERTYPEINFO(); |
| 80 | 99 |
| 81 public: | 100 public: |
| 82 explicit AccessibleNode(Element*); | 101 explicit AccessibleNode(Element*); |
| 83 virtual ~AccessibleNode(); | 102 virtual ~AccessibleNode(); |
| 84 | 103 |
| 104 // Gets the associated element, if any. |
| 105 Element* element() const { return element_; } |
| 106 |
| 85 // Returns the given string property if the Element has an AccessibleNode. | 107 // Returns the given string property if the Element has an AccessibleNode. |
| 86 static const AtomicString& GetProperty(Element*, AOMStringProperty); | 108 static const AtomicString& GetProperty(Element*, AOMStringProperty); |
| 87 | 109 |
| 110 // Returns the given relation property if the Element has an AccessibleNode. |
| 111 static AccessibleNode* GetProperty(Element*, AOMRelationProperty); |
| 112 |
| 88 // Returns the value of the given property if the | 113 // Returns the value of the given property if the |
| 89 // Element has an AccessibleNode. Sets |isNull| if the property and | 114 // Element has an AccessibleNode. Sets |isNull| if the property and |
| 90 // attribute are not present. | 115 // attribute are not present. |
| 91 static bool GetProperty(Element*, AOMBooleanProperty, bool& is_null); | 116 static bool GetProperty(Element*, AOMBooleanProperty, bool& is_null); |
| 92 static float GetProperty(Element*, AOMFloatProperty, bool& is_null); | 117 static float GetProperty(Element*, AOMFloatProperty, bool& is_null); |
| 93 static int32_t GetProperty(Element*, AOMIntProperty, bool& is_null); | 118 static int32_t GetProperty(Element*, AOMIntProperty, bool& is_null); |
| 94 static uint32_t GetProperty(Element*, AOMUIntProperty, bool& is_null); | 119 static uint32_t GetProperty(Element*, AOMUIntProperty, bool& is_null); |
| 95 | 120 |
| 96 // Returns the value of the given string property if the | 121 // Returns the value of the given string property if the |
| 97 // Element has an AccessibleNode, otherwise returns the equivalent | 122 // Element has an AccessibleNode, otherwise returns the equivalent |
| 98 // ARIA attribute. | 123 // ARIA attribute. |
| 99 static const AtomicString& GetPropertyOrARIAAttribute(Element*, | 124 static const AtomicString& GetPropertyOrARIAAttribute(Element*, |
| 100 AOMStringProperty); | 125 AOMStringProperty); |
| 101 | 126 |
| 127 // Returns the given relation property if the Element has an AccessibleNode, |
| 128 // otherwise returns the equivalent ARIA attribute. |
| 129 static AccessibleNode* GetPropertyOrARIAAttribute(Element*, |
| 130 AOMRelationProperty); |
| 131 |
| 102 // Returns the value of the given property if the | 132 // Returns the value of the given property if the |
| 103 // Element has an AccessibleNode, otherwise returns the equivalent | 133 // Element has an AccessibleNode, otherwise returns the equivalent |
| 104 // ARIA attribute. Sets |isNull| if the property and attribute are not | 134 // ARIA attribute. Sets |isNull| if the property and attribute are not |
| 105 // present. | 135 // present. |
| 106 static bool GetPropertyOrARIAAttribute(Element*, | 136 static bool GetPropertyOrARIAAttribute(Element*, |
| 107 AOMBooleanProperty, | 137 AOMBooleanProperty, |
| 108 bool& is_null); | 138 bool& is_null); |
| 109 static float GetPropertyOrARIAAttribute(Element*, | 139 static float GetPropertyOrARIAAttribute(Element*, |
| 110 AOMFloatProperty, | 140 AOMFloatProperty, |
| 111 bool& is_null); | 141 bool& is_null); |
| 112 static int32_t GetPropertyOrARIAAttribute(Element*, | 142 static int32_t GetPropertyOrARIAAttribute(Element*, |
| 113 AOMIntProperty, | 143 AOMIntProperty, |
| 114 bool& is_null); | 144 bool& is_null); |
| 115 static uint32_t GetPropertyOrARIAAttribute(Element*, | 145 static uint32_t GetPropertyOrARIAAttribute(Element*, |
| 116 AOMUIntProperty, | 146 AOMUIntProperty, |
| 117 bool& is_null); | 147 bool& is_null); |
| 118 | 148 |
| 149 // Iterates over all AOM properties. For each one, calls AOMPropertyClient |
| 150 // with the value of the AOM property if set. Updates |
| 151 // |shadowed_aria_attributes| to contain a list of the ARIA attributes that |
| 152 // would be shadowed by these AOM properties. |
| 153 static void GetAllAOMProperties( |
| 154 Element*, |
| 155 AOMPropertyClient*, |
| 156 HashSet<QualifiedName>& shadowed_aria_attributes); |
| 157 |
| 158 AccessibleNode* activeDescendant() const; |
| 159 void setActiveDescendant(AccessibleNode*); |
| 160 |
| 119 bool atomic(bool& is_null) const; | 161 bool atomic(bool& is_null) const; |
| 120 void setAtomic(bool, bool is_null); | 162 void setAtomic(bool, bool is_null); |
| 121 | 163 |
| 122 AtomicString autocomplete() const; | 164 AtomicString autocomplete() const; |
| 123 void setAutocomplete(const AtomicString&); | 165 void setAutocomplete(const AtomicString&); |
| 124 | 166 |
| 125 bool busy(bool& is_null) const; | 167 bool busy(bool& is_null) const; |
| 126 void setBusy(bool, bool is_null); | 168 void setBusy(bool, bool is_null); |
| 127 | 169 |
| 128 AtomicString checked() const; | 170 AtomicString checked() const; |
| 129 void setChecked(const AtomicString&); | 171 void setChecked(const AtomicString&); |
| 130 | 172 |
| 131 int32_t colCount(bool& is_null) const; | 173 int32_t colCount(bool& is_null) const; |
| 132 void setColCount(int32_t, bool is_null); | 174 void setColCount(int32_t, bool is_null); |
| 133 | 175 |
| 134 uint32_t colIndex(bool& is_null) const; | 176 uint32_t colIndex(bool& is_null) const; |
| 135 void setColIndex(uint32_t, bool is_null); | 177 void setColIndex(uint32_t, bool is_null); |
| 136 | 178 |
| 137 uint32_t colSpan(bool& is_null) const; | 179 uint32_t colSpan(bool& is_null) const; |
| 138 void setColSpan(uint32_t, bool is_null); | 180 void setColSpan(uint32_t, bool is_null); |
| 139 | 181 |
| 140 AtomicString current() const; | 182 AtomicString current() const; |
| 141 void setCurrent(const AtomicString&); | 183 void setCurrent(const AtomicString&); |
| 142 | 184 |
| 185 AccessibleNode* details() const; |
| 186 void setDetails(AccessibleNode*); |
| 187 |
| 143 bool disabled(bool& is_null) const; | 188 bool disabled(bool& is_null) const; |
| 144 void setDisabled(bool, bool is_null); | 189 void setDisabled(bool, bool is_null); |
| 145 | 190 |
| 191 AccessibleNode* errorMessage() const; |
| 192 void setErrorMessage(AccessibleNode*); |
| 193 |
| 146 bool expanded(bool& is_null) const; | 194 bool expanded(bool& is_null) const; |
| 147 void setExpanded(bool, bool is_null); | 195 void setExpanded(bool, bool is_null); |
| 148 | 196 |
| 149 bool hidden(bool& is_null) const; | 197 bool hidden(bool& is_null) const; |
| 150 void setHidden(bool, bool is_null); | 198 void setHidden(bool, bool is_null); |
| 151 | 199 |
| 152 AtomicString invalid() const; | 200 AtomicString invalid() const; |
| 153 void setInvalid(const AtomicString&); | 201 void setInvalid(const AtomicString&); |
| 154 | 202 |
| 155 AtomicString keyShortcuts() const; | 203 AtomicString keyShortcuts() const; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 float valueNow(bool& is_null) const; | 275 float valueNow(bool& is_null) const; |
| 228 void setValueNow(float, bool is_null); | 276 void setValueNow(float, bool is_null); |
| 229 | 277 |
| 230 AtomicString valueText() const; | 278 AtomicString valueText() const; |
| 231 void setValueText(const AtomicString&); | 279 void setValueText(const AtomicString&); |
| 232 | 280 |
| 233 DECLARE_VIRTUAL_TRACE(); | 281 DECLARE_VIRTUAL_TRACE(); |
| 234 | 282 |
| 235 private: | 283 private: |
| 236 void SetStringProperty(AOMStringProperty, const AtomicString&); | 284 void SetStringProperty(AOMStringProperty, const AtomicString&); |
| 285 void SetRelationProperty(AOMRelationProperty, AccessibleNode*); |
| 237 void SetBooleanProperty(AOMBooleanProperty, bool value, bool is_null); | 286 void SetBooleanProperty(AOMBooleanProperty, bool value, bool is_null); |
| 238 void SetFloatProperty(AOMFloatProperty, float value, bool is_null); | 287 void SetFloatProperty(AOMFloatProperty, float value, bool is_null); |
| 239 void SetUIntProperty(AOMUIntProperty, uint32_t value, bool is_null); | 288 void SetUIntProperty(AOMUIntProperty, uint32_t value, bool is_null); |
| 240 void SetIntProperty(AOMIntProperty, int32_t value, bool is_null); | 289 void SetIntProperty(AOMIntProperty, int32_t value, bool is_null); |
| 241 void NotifyAttributeChanged(const blink::QualifiedName&); | 290 void NotifyAttributeChanged(const blink::QualifiedName&); |
| 242 AXObjectCache* GetAXObjectCache(); | 291 AXObjectCache* GetAXObjectCache(); |
| 243 | 292 |
| 244 Vector<std::pair<AOMStringProperty, AtomicString>> string_properties_; | 293 Vector<std::pair<AOMStringProperty, AtomicString>> string_properties_; |
| 245 Vector<std::pair<AOMBooleanProperty, bool>> boolean_properties_; | 294 Vector<std::pair<AOMBooleanProperty, bool>> boolean_properties_; |
| 246 Vector<std::pair<AOMFloatProperty, float>> float_properties_; | 295 Vector<std::pair<AOMFloatProperty, float>> float_properties_; |
| 247 Vector<std::pair<AOMIntProperty, int32_t>> int_properties_; | 296 Vector<std::pair<AOMIntProperty, int32_t>> int_properties_; |
| 248 Vector<std::pair<AOMUIntProperty, uint32_t>> uint_properties_; | 297 Vector<std::pair<AOMUIntProperty, uint32_t>> uint_properties_; |
| 298 HeapVector<std::pair<AOMRelationProperty, Member<AccessibleNode>>> |
| 299 relation_properties_; |
| 249 | 300 |
| 250 // This object's owner Element. | 301 // This object's owner Element. |
| 251 Member<Element> element_; | 302 Member<Element> element_; |
| 252 }; | 303 }; |
| 253 | 304 |
| 254 } // namespace blink | 305 } // namespace blink |
| 255 | 306 |
| 256 #endif // AccessibleNode_h | 307 #endif // AccessibleNode_h |
| OLD | NEW |