OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (C) 2012, Google Inc. All rights reserved. | |
3 * | |
4 * Redistribution and use in source and binary forms, with or without | |
5 * modification, are permitted provided that the following conditions | |
6 * are met: | |
7 * | |
8 * 1. Redistributions of source code must retain the above copyright | |
9 * notice, this list of conditions and the following disclaimer. | |
10 * 2. Redistributions in binary form must reproduce the above copyright | |
11 * notice, this list of conditions and the following disclaimer in the | |
12 * documentation and/or other materials provided with the distribution. | |
13 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of | |
14 * its contributors may be used to endorse or promote products derived | |
15 * from this software without specific prior written permission. | |
16 * | |
17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY | |
18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY | |
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
27 */ | |
28 | |
29 #ifndef AXNodeObject_h | |
30 #define AXNodeObject_h | |
31 | |
32 #include "core/accessibility/AXObject.h" | |
33 #include "wtf/Forward.h" | |
34 | |
35 namespace blink { | |
36 | |
37 class Element; | |
38 class HTMLLabelElement; | |
39 class LayoutRect; | |
40 class Node; | |
41 | |
42 class AXNodeObject : public AXObject { | |
43 protected: | |
44 explicit AXNodeObject(Node*); | |
45 | |
46 public: | |
47 static PassRefPtr<AXNodeObject> create(Node*); | |
48 virtual ~AXNodeObject(); | |
49 | |
50 protected: | |
51 // Protected data. | |
52 AccessibilityRole m_ariaRole; | |
53 bool m_childrenDirty; | |
54 #if ENABLE(ASSERT) | |
55 bool m_initialized; | |
56 #endif | |
57 | |
58 virtual bool computeAccessibilityIsIgnored() const override; | |
59 virtual AccessibilityRole determineAccessibilityRole(); | |
60 | |
61 String accessibilityDescriptionForElements(WillBeHeapVector<RawPtrWillBeMemb
er<Element> > &elements) const; | |
62 void alterSliderValue(bool increase); | |
63 String ariaAccessibilityDescription() const; | |
64 void ariaLabeledByElements(WillBeHeapVector<RawPtrWillBeMember<Element> >& e
lements) const; | |
65 void changeValueByStep(bool increase); | |
66 AccessibilityRole determineAriaRoleAttribute() const; | |
67 void elementsFromAttribute(WillBeHeapVector<RawPtrWillBeMember<Element> >& e
lements, const QualifiedName&) const; | |
68 bool hasContentEditableAttributeSet() const; | |
69 bool isDescendantOfBarrenParent() const; | |
70 // This returns true if it's focusable but it's not content editable and it'
s not a control or ARIA control. | |
71 bool isGenericFocusableElement() const; | |
72 HTMLLabelElement* labelForElement(Element*) const; | |
73 AXObject* menuButtonForMenu() const; | |
74 Element* menuItemElementForMenu() const; | |
75 Element* mouseButtonListener() const; | |
76 AccessibilityRole remapAriaRoleDueToParent(AccessibilityRole) const; | |
77 bool isNativeCheckboxOrRadio() const; | |
78 void setNode(Node*); | |
79 AXObject* correspondingControlForLabelElement() const; | |
80 HTMLLabelElement* labelElementContainer() const; | |
81 | |
82 // | |
83 // Overridden from AXObject. | |
84 // | |
85 | |
86 virtual void init() override; | |
87 virtual void detach() override; | |
88 virtual bool isDetached() const override { return !m_node; } | |
89 virtual bool isAXNodeObject() const override final { return true; } | |
90 | |
91 // Check object role or purpose. | |
92 virtual bool isAnchor() const override final; | |
93 virtual bool isControl() const override; | |
94 virtual bool isEmbeddedObject() const override final; | |
95 virtual bool isFieldset() const override final; | |
96 virtual bool isHeading() const override final; | |
97 virtual bool isHovered() const override final; | |
98 virtual bool isImage() const override final; | |
99 bool isImageButton() const; | |
100 virtual bool isInputImage() const override final; | |
101 virtual bool isLink() const override final; | |
102 virtual bool isMenu() const override final; | |
103 virtual bool isMenuButton() const override final; | |
104 virtual bool isMultiSelectable() const override; | |
105 bool isNativeImage() const; | |
106 virtual bool isNativeTextControl() const override final; | |
107 virtual bool isNonNativeTextControl() const override final; | |
108 virtual bool isPasswordField() const override final; | |
109 virtual bool isProgressIndicator() const override; | |
110 virtual bool isSlider() const override; | |
111 | |
112 // Check object state. | |
113 virtual bool isChecked() const override final; | |
114 virtual bool isClickable() const override final; | |
115 virtual bool isEnabled() const override; | |
116 virtual AccessibilityExpanded isExpanded() const override; | |
117 virtual bool isIndeterminate() const override final; | |
118 virtual bool isPressed() const override final; | |
119 virtual bool isReadOnly() const override; | |
120 virtual bool isRequired() const override final; | |
121 | |
122 // Check whether certain properties can be modified. | |
123 virtual bool canSetFocusAttribute() const override; | |
124 virtual bool canSetValueAttribute() const override; | |
125 | |
126 // Properties of static elements. | |
127 virtual bool canvasHasFallbackContent() const override final; | |
128 virtual bool exposesTitleUIElement() const override; | |
129 virtual int headingLevel() const override final; | |
130 virtual unsigned hierarchicalLevel() const override final; | |
131 virtual String text() const override; | |
132 virtual AXObject* titleUIElement() const override; | |
133 | |
134 // Properties of interactive elements. | |
135 virtual AccessibilityButtonState checkboxOrRadioValue() const override final
; | |
136 virtual void colorValue(int& r, int& g, int& b) const override final; | |
137 virtual String valueDescription() const override; | |
138 virtual float valueForRange() const override; | |
139 virtual float maxValueForRange() const override; | |
140 virtual float minValueForRange() const override; | |
141 virtual String stringValue() const override; | |
142 virtual const AtomicString& textInputType() const override; | |
143 | |
144 // ARIA attributes. | |
145 virtual String ariaDescribedByAttribute() const override final; | |
146 virtual String ariaLabeledByAttribute() const override final; | |
147 virtual AccessibilityRole ariaRoleAttribute() const override final; | |
148 | |
149 // Accessibility Text. | |
150 virtual String textUnderElement() const override; | |
151 | |
152 // Accessibility Text - (To be deprecated). | |
153 virtual String accessibilityDescription() const override; | |
154 virtual String title() const override; | |
155 virtual String helpText() const override; | |
156 | |
157 // Location and click point in frame-relative coordinates. | |
158 virtual LayoutRect elementRect() const override; | |
159 | |
160 // High-level accessibility tree access. | |
161 virtual AXObject* computeParent() const override; | |
162 virtual AXObject* computeParentIfExists() const override; | |
163 | |
164 // Low-level accessibility tree exploration. | |
165 virtual AXObject* firstChild() const override; | |
166 virtual AXObject* nextSibling() const override; | |
167 virtual void addChildren() override; | |
168 virtual bool canHaveChildren() const override; | |
169 void addChild(AXObject*); | |
170 void insertChild(AXObject*, unsigned index); | |
171 | |
172 // DOM and Render tree access. | |
173 virtual Element* actionElement() const override final; | |
174 virtual Element* anchorElement() const override; | |
175 virtual Document* document() const override; | |
176 virtual Node* node() const override { return m_node; } | |
177 | |
178 // Modify or take an action on an object. | |
179 virtual void setFocused(bool) override final; | |
180 virtual void increment() override final; | |
181 virtual void decrement() override final; | |
182 | |
183 // Notifications that this object may have changed. | |
184 virtual void childrenChanged() override; | |
185 virtual void selectionChanged() override final; | |
186 virtual void textChanged() override; | |
187 virtual void updateAccessibilityRole() override final; | |
188 | |
189 private: | |
190 Node* m_node; | |
191 | |
192 String alternativeTextForWebArea() const; | |
193 void alternativeText(Vector<AccessibilityText>&) const; | |
194 void ariaLabeledByText(Vector<AccessibilityText>&) const; | |
195 void changeValueByPercent(float percentChange); | |
196 float stepValueForRange() const; | |
197 }; | |
198 | |
199 DEFINE_AX_OBJECT_TYPE_CASTS(AXNodeObject, isAXNodeObject()); | |
200 | |
201 } // namespace blink | |
202 | |
203 #endif // AXNodeObject_h | |
OLD | NEW |