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 19 matching lines...) Expand all Loading... |
30 kLive, | 30 kLive, |
31 kOrientation, | 31 kOrientation, |
32 kPlaceholder, | 32 kPlaceholder, |
33 kRelevant, | 33 kRelevant, |
34 kRole, | 34 kRole, |
35 kRoleDescription, | 35 kRoleDescription, |
36 kSort, | 36 kSort, |
37 kValueText | 37 kValueText |
38 }; | 38 }; |
39 | 39 |
| 40 // All of the properties of AccessibleNode that have type "boolean". |
| 41 enum class AOMBooleanProperty { |
| 42 kAtomic, |
| 43 kBusy, |
| 44 kDisabled, |
| 45 kExpanded, |
| 46 kHidden, |
| 47 kModal, |
| 48 kMultiline, |
| 49 kMultiselectable, |
| 50 kReadOnly, |
| 51 kRequired, |
| 52 kSelected |
| 53 }; |
| 54 |
40 // Accessibility Object Model node | 55 // Accessibility Object Model node |
41 // Explainer: https://github.com/WICG/aom/blob/master/explainer.md | 56 // Explainer: https://github.com/WICG/aom/blob/master/explainer.md |
42 // Spec: https://wicg.github.io/aom/spec/ | 57 // Spec: https://wicg.github.io/aom/spec/ |
43 class CORE_EXPORT AccessibleNode | 58 class CORE_EXPORT AccessibleNode |
44 : public GarbageCollectedFinalized<AccessibleNode>, | 59 : public GarbageCollectedFinalized<AccessibleNode>, |
45 public ScriptWrappable { | 60 public ScriptWrappable { |
46 DEFINE_WRAPPERTYPEINFO(); | 61 DEFINE_WRAPPERTYPEINFO(); |
47 | 62 |
48 public: | 63 public: |
49 explicit AccessibleNode(Element*); | 64 explicit AccessibleNode(Element*); |
50 virtual ~AccessibleNode(); | 65 virtual ~AccessibleNode(); |
51 | 66 |
52 // Returns the given string property if the Element has an AccessibleNode. | 67 // Returns the given string property if the Element has an AccessibleNode. |
53 static const AtomicString& GetProperty(Element*, AOMStringProperty); | 68 static const AtomicString& GetProperty(Element*, AOMStringProperty); |
54 | 69 |
55 // Returns the given string property if the Element has an AccessibleNode, | 70 // Returns the value of the given boolean property if the |
56 // otherwise returns the equivalent ARIA attribute. | 71 // Element has an AccessibleNode. Sets |isNull| if the property and |
| 72 // attribute are not present. |
| 73 static bool GetProperty(Element*, AOMBooleanProperty, bool& is_null); |
| 74 |
| 75 // Returns the value of the given string property if the |
| 76 // Element has an AccessibleNode, otherwise returns the equivalent |
| 77 // ARIA attribute. |
57 static const AtomicString& GetPropertyOrARIAAttribute(Element*, | 78 static const AtomicString& GetPropertyOrARIAAttribute(Element*, |
58 AOMStringProperty); | 79 AOMStringProperty); |
59 | 80 |
| 81 // Returns the value of the given boolean property if the |
| 82 // Element has an AccessibleNode, otherwise returns the equivalent |
| 83 // ARIA attribute. Sets |isNull| if the property and attribute are not |
| 84 // present. |
| 85 static bool GetPropertyOrARIAAttribute(Element*, |
| 86 AOMBooleanProperty, |
| 87 bool& is_null); |
| 88 |
| 89 bool atomic(bool&) const; |
| 90 void setAtomic(bool, bool is_null); |
| 91 |
60 AtomicString autocomplete() const; | 92 AtomicString autocomplete() const; |
61 void setAutocomplete(const AtomicString&); | 93 void setAutocomplete(const AtomicString&); |
62 | 94 |
| 95 bool busy(bool&) const; |
| 96 void setBusy(bool, bool is_null); |
| 97 |
63 AtomicString checked() const; | 98 AtomicString checked() const; |
64 void setChecked(const AtomicString&); | 99 void setChecked(const AtomicString&); |
65 | 100 |
66 AtomicString current() const; | 101 AtomicString current() const; |
67 void setCurrent(const AtomicString&); | 102 void setCurrent(const AtomicString&); |
68 | 103 |
| 104 bool disabled(bool&) const; |
| 105 void setDisabled(bool, bool is_null); |
| 106 |
| 107 bool expanded(bool&) const; |
| 108 void setExpanded(bool, bool is_null); |
| 109 |
| 110 bool hidden(bool&) const; |
| 111 void setHidden(bool, bool is_null); |
| 112 |
69 AtomicString invalid() const; | 113 AtomicString invalid() const; |
70 void setInvalid(const AtomicString&); | 114 void setInvalid(const AtomicString&); |
71 | 115 |
72 AtomicString keyShortcuts() const; | 116 AtomicString keyShortcuts() const; |
73 void setKeyShortcuts(const AtomicString&); | 117 void setKeyShortcuts(const AtomicString&); |
74 | 118 |
75 AtomicString label() const; | 119 AtomicString label() const; |
76 void setLabel(const AtomicString&); | 120 void setLabel(const AtomicString&); |
77 | 121 |
78 AtomicString live() const; | 122 AtomicString live() const; |
79 void setLive(const AtomicString&); | 123 void setLive(const AtomicString&); |
80 | 124 |
| 125 bool modal(bool&) const; |
| 126 void setModal(bool, bool is_null); |
| 127 |
| 128 bool multiline(bool&) const; |
| 129 void setMultiline(bool, bool is_null); |
| 130 |
| 131 bool multiselectable(bool&) const; |
| 132 void setMultiselectable(bool, bool is_null); |
| 133 |
81 AtomicString orientation() const; | 134 AtomicString orientation() const; |
82 void setOrientation(const AtomicString&); | 135 void setOrientation(const AtomicString&); |
83 | 136 |
84 AtomicString placeholder() const; | 137 AtomicString placeholder() const; |
85 void setPlaceholder(const AtomicString&); | 138 void setPlaceholder(const AtomicString&); |
86 | 139 |
| 140 bool readOnly(bool&) const; |
| 141 void setReadOnly(bool, bool is_null); |
| 142 |
87 AtomicString relevant() const; | 143 AtomicString relevant() const; |
88 void setRelevant(const AtomicString&); | 144 void setRelevant(const AtomicString&); |
89 | 145 |
| 146 bool required(bool&) const; |
| 147 void setRequired(bool, bool is_null); |
| 148 |
90 AtomicString role() const; | 149 AtomicString role() const; |
91 void setRole(const AtomicString&); | 150 void setRole(const AtomicString&); |
92 | 151 |
93 AtomicString roleDescription() const; | 152 AtomicString roleDescription() const; |
94 void setRoleDescription(const AtomicString&); | 153 void setRoleDescription(const AtomicString&); |
95 | 154 |
| 155 bool selected(bool&) const; |
| 156 void setSelected(bool, bool is_null); |
| 157 |
96 AtomicString sort() const; | 158 AtomicString sort() const; |
97 void setSort(const AtomicString&); | 159 void setSort(const AtomicString&); |
98 | 160 |
99 AtomicString valueText() const; | 161 AtomicString valueText() const; |
100 void setValueText(const AtomicString&); | 162 void setValueText(const AtomicString&); |
101 | 163 |
102 DECLARE_VIRTUAL_TRACE(); | 164 DECLARE_VIRTUAL_TRACE(); |
103 | 165 |
104 private: | 166 private: |
105 void SetStringProperty(AOMStringProperty, const AtomicString&); | 167 void SetStringProperty(AOMStringProperty, const AtomicString&); |
| 168 void SetBooleanProperty(AOMBooleanProperty, bool value, bool is_null); |
106 void NotifyAttributeChanged(const blink::QualifiedName&); | 169 void NotifyAttributeChanged(const blink::QualifiedName&); |
107 AXObjectCache* GetAXObjectCache(); | 170 AXObjectCache* GetAXObjectCache(); |
108 | 171 |
109 Vector<std::pair<AOMStringProperty, AtomicString>> string_properties_; | 172 Vector<std::pair<AOMStringProperty, AtomicString>> string_properties_; |
| 173 Vector<std::pair<AOMBooleanProperty, bool>> boolean_properties_; |
110 | 174 |
111 // This object's owner Element. | 175 // This object's owner Element. |
112 Member<Element> element_; | 176 Member<Element> element_; |
113 }; | 177 }; |
114 | 178 |
115 } // namespace blink | 179 } // namespace blink |
116 | 180 |
117 #endif // AccessibleNode_h | 181 #endif // AccessibleNode_h |
OLD | NEW |