• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 /*
3  * Copyright (C) 2008 Apple Inc. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1.  Redistributions of source code must retain the above copyright
10  *     notice, this list of conditions and the following disclaimer.
11  * 2.  Redistributions in binary form must reproduce the above copyright
12  *     notice, this list of conditions and the following disclaimer in the
13  *     documentation and/or other materials provided with the distribution.
14  * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
15  *     its contributors may be used to endorse or promote products derived
16  *     from this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
19  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21  * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
22  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 #ifndef AccessibilityRenderObject_h
31 #define AccessibilityRenderObject_h
32 
33 #include "AccessibilityObject.h"
34 #include <wtf/Forward.h>
35 
36 namespace WebCore {
37 
38 class AXObjectCache;
39 class Element;
40 class Frame;
41 class FrameView;
42 class HitTestResult;
43 class HTMLAnchorElement;
44 class HTMLAreaElement;
45 class HTMLElement;
46 class HTMLLabelElement;
47 class HTMLMapElement;
48 class HTMLSelectElement;
49 class IntPoint;
50 class IntSize;
51 class Node;
52 class RenderListBox;
53 class RenderTextControl;
54 class RenderView;
55 class VisibleSelection;
56 class Widget;
57 
58 class AccessibilityRenderObject : public AccessibilityObject {
59 protected:
60     AccessibilityRenderObject(RenderObject*);
61 public:
62     static PassRefPtr<AccessibilityRenderObject> create(RenderObject*);
63     virtual ~AccessibilityRenderObject();
64 
isAccessibilityRenderObject()65     bool isAccessibilityRenderObject() const { return true; }
66 
67     virtual bool isAnchor() const;
68     virtual bool isAttachment() const;
69     virtual bool isHeading() const;
70     virtual bool isLink() const;
71     virtual bool isImageButton() const;
72     virtual bool isImage() const;
73     virtual bool isNativeImage() const;
74     virtual bool isPasswordField() const;
75     virtual bool isNativeTextControl() const;
76     virtual bool isWebArea() const;
77     virtual bool isFileUploadButton() const;
78     virtual bool isInputImage() const;
79     virtual bool isProgressIndicator() const;
80     virtual bool isSlider() const;
81     virtual bool isMenuRelated() const;
82     virtual bool isMenu() const;
83     virtual bool isMenuBar() const;
84     virtual bool isMenuButton() const;
85     virtual bool isMenuItem() const;
86     virtual bool isControl() const;
87     virtual bool isFieldset() const;
88     virtual bool isGroup() const;
89 
90     virtual bool isEnabled() const;
91     virtual bool isSelected() const;
92     virtual bool isFocused() const;
93     virtual bool isChecked() const;
94     virtual bool isHovered() const;
95     virtual bool isIndeterminate() const;
96     virtual bool isLoaded() const;
97     virtual bool isMultiSelectable() const;
98     virtual bool isOffScreen() const;
99     virtual bool isPressed() const;
100     virtual bool isReadOnly() const;
101     virtual bool isVisited() const;
102     virtual bool isRequired() const;
103     virtual bool isLinked() const;
104     virtual void setIsExpanded(bool);
105 
106     virtual bool canSetFocusAttribute() const;
107     virtual bool canSetTextRangeAttributes() const;
108     virtual bool canSetValueAttribute() const;
109     virtual bool canSetExpandedAttribute() const;
110 
111     virtual void setAccessibleName(String&);
112 
113     // Provides common logic used by all elements when determining isIgnored.
114     AccessibilityObjectInclusion accessibilityIsIgnoredBase() const;
115     virtual bool accessibilityIsIgnored() const;
116 
117     virtual int headingLevel() const;
118     virtual AccessibilityButtonState checkboxOrRadioValue() const;
119     virtual String valueDescription() const;
120     virtual float valueForRange() const;
121     virtual float maxValueForRange() const;
122     virtual float minValueForRange() const;
123     virtual AccessibilityObject* selectedRadioButton();
124     virtual AccessibilityObject* selectedTabItem();
125     virtual int layoutCount() const;
126     virtual double estimatedLoadingProgress() const;
127 
128     virtual AccessibilityObject* firstChild() const;
129     virtual AccessibilityObject* lastChild() const;
130     virtual AccessibilityObject* previousSibling() const;
131     virtual AccessibilityObject* nextSibling() const;
132     virtual AccessibilityObject* parentObject() const;
133     virtual AccessibilityObject* parentObjectIfExists() const;
134     virtual AccessibilityObject* observableObject() const;
135     virtual void linkedUIElements(AccessibilityChildrenVector&) const;
136     virtual bool exposesTitleUIElement() const;
137     virtual AccessibilityObject* titleUIElement() const;
138     virtual AccessibilityObject* correspondingControlForLabelElement() const;
139     virtual AccessibilityObject* correspondingLabelForControlElement() const;
140 
141     virtual void ariaOwnsElements(AccessibilityChildrenVector&) const;
142     virtual bool supportsARIAOwns() const;
143     virtual AccessibilityRole ariaRoleAttribute() const;
144     virtual bool isPresentationalChildOfAriaRole() const;
145     virtual bool ariaRoleHasPresentationalChildren() const;
146     void updateAccessibilityRole();
147 
148     // Should be called on the root accessibility object to kick off a hit test.
149     virtual AccessibilityObject* accessibilityHitTest(const IntPoint&) const;
150 
151     virtual Element* actionElement() const;
152     Element* mouseButtonListener() const;
153     FrameView* frameViewIfRenderView() const;
154     virtual Element* anchorElement() const;
155     AccessibilityObject* menuForMenuButton() const;
156     AccessibilityObject* menuButtonForMenu() const;
157 
158     virtual IntRect boundingBoxRect() const;
159     virtual IntRect elementRect() const;
160     virtual IntSize size() const;
161     virtual IntPoint clickPoint() const;
162 
setRenderer(RenderObject * renderer)163     void setRenderer(RenderObject* renderer) { m_renderer = renderer; }
renderer()164     virtual RenderObject* renderer() const { return m_renderer; }
165     RenderBoxModelObject* renderBoxModelObject() const;
166     virtual Node* node() const;
167 
168     RenderView* topRenderer() const;
169     RenderTextControl* textControl() const;
170     Document* document() const;
171     FrameView* topDocumentFrameView() const;
172     HTMLLabelElement* labelElementContainer() const;
173 
174     virtual KURL url() const;
175     virtual PlainTextRange selectedTextRange() const;
176     virtual VisibleSelection selection() const;
177     virtual String stringValue() const;
178     virtual String ariaLabeledByAttribute() const;
179     virtual String title() const;
180     virtual String ariaDescribedByAttribute() const;
181     virtual String accessibilityDescription() const;
182     virtual String helpText() const;
183     virtual String textUnderElement() const;
184     virtual String text() const;
185     virtual int textLength() const;
186     virtual String selectedText() const;
187     virtual const AtomicString& accessKey() const;
188     virtual const String& actionVerb() const;
189     virtual Widget* widget() const;
190     virtual Widget* widgetForAttachmentView() const;
191     virtual void getDocumentLinks(AccessibilityChildrenVector&);
192     virtual FrameView* documentFrameView() const;
193     virtual unsigned hierarchicalLevel() const;
194 
195     virtual const AccessibilityChildrenVector& children();
196     virtual void clearChildren();
197     virtual void updateChildrenIfNecessary();
198 
199     virtual void setFocused(bool);
200     virtual void setSelectedTextRange(const PlainTextRange&);
201     virtual void setValue(const String&);
202     virtual void setSelected(bool);
203     virtual void setSelectedRows(AccessibilityChildrenVector&);
204     virtual void changeValueByPercent(float percentChange);
205     virtual AccessibilityOrientation orientation() const;
206     virtual void increment();
207     virtual void decrement();
208 
209     virtual void detach();
210     virtual void childrenChanged();
211     virtual void contentChanged();
212     virtual void addChildren();
213     virtual bool canHaveChildren() const;
214     virtual void selectedChildren(AccessibilityChildrenVector&);
215     virtual void visibleChildren(AccessibilityChildrenVector&);
216     virtual void tabChildren(AccessibilityChildrenVector&);
217     virtual bool shouldFocusActiveDescendant() const;
218     virtual AccessibilityObject* activeDescendant() const;
219     virtual void handleActiveDescendantChanged();
220     virtual void handleAriaExpandedChanged();
221 
222     virtual VisiblePositionRange visiblePositionRange() const;
223     virtual VisiblePositionRange visiblePositionRangeForLine(unsigned) const;
224     virtual IntRect boundsForVisiblePositionRange(const VisiblePositionRange&) const;
225     virtual void setSelectedVisiblePositionRange(const VisiblePositionRange&) const;
226     virtual bool supportsARIAFlowTo() const;
227     virtual void ariaFlowToElements(AccessibilityChildrenVector&) const;
228     virtual bool ariaHasPopup() const;
229 
230     virtual bool supportsARIADropping() const;
231     virtual bool supportsARIADragging() const;
232     virtual bool isARIAGrabbed();
233     virtual void setARIAGrabbed(bool);
234     virtual void determineARIADropEffects(Vector<String>&);
235 
236     virtual VisiblePosition visiblePositionForPoint(const IntPoint&) const;
237     virtual VisiblePosition visiblePositionForIndex(unsigned indexValue, bool lastIndexOK) const;
238     virtual int index(const VisiblePosition&) const;
239 
240     virtual VisiblePosition visiblePositionForIndex(int) const;
241     virtual int indexForVisiblePosition(const VisiblePosition&) const;
242 
243     virtual PlainTextRange doAXRangeForLine(unsigned) const;
244     virtual PlainTextRange doAXRangeForIndex(unsigned) const;
245 
246     virtual String doAXStringForRange(const PlainTextRange&) const;
247     virtual IntRect doAXBoundsForRange(const PlainTextRange&) const;
248 
249     virtual void updateBackingStore();
250 
251     virtual String stringValueForMSAA() const;
252     virtual String stringRoleForMSAA() const;
253     virtual String nameForMSAA() const;
254     virtual String descriptionForMSAA() const;
255     virtual AccessibilityRole roleValueForMSAA() const;
256 
257 protected:
258     RenderObject* m_renderer;
259     AccessibilityRole m_ariaRole;
260     mutable bool m_childrenDirty;
261 
setRenderObject(RenderObject * renderer)262     void setRenderObject(RenderObject* renderer) { m_renderer = renderer; }
263     void ariaLabeledByElements(Vector<Element*>& elements) const;
needsToUpdateChildren()264     bool needsToUpdateChildren() const { return m_childrenDirty; }
265 
isDetached()266     virtual bool isDetached() const { return !m_renderer; }
267 
268 private:
269     void ariaListboxSelectedChildren(AccessibilityChildrenVector&);
270     void ariaListboxVisibleChildren(AccessibilityChildrenVector&);
271     bool ariaIsHidden() const;
272     bool isDescendantOfBarrenParent() const;
273     bool isAllowedChildOfTree() const;
274     bool hasTextAlternative() const;
275     String positionalDescriptionForMSAA() const;
276     PlainTextRange ariaSelectedTextRange() const;
277 
278     Element* menuElementForMenuButton() const;
279     Element* menuItemElementForMenu() const;
280     AccessibilityRole determineAccessibilityRole();
281     AccessibilityRole determineAriaRoleAttribute() const;
282 
283     bool isTabItemSelected() const;
284     bool isNativeCheckboxOrRadio() const;
285     IntRect checkboxOrRadioRect() const;
286     void addRadioButtonGroupMembers(AccessibilityChildrenVector& linkedUIElements) const;
287     AccessibilityObject* internalLinkElement() const;
288     AccessibilityObject* accessibilityImageMapHitTest(HTMLAreaElement*, const IntPoint&) const;
289     AccessibilityObject* accessibilityParentForImageMap(HTMLMapElement*) const;
290     bool renderObjectIsObservable(RenderObject*) const;
291     RenderObject* renderParentObject() const;
292 
293     void ariaSelectedRows(AccessibilityChildrenVector&);
294 
295     bool elementAttributeValue(const QualifiedName&) const;
296     void setElementAttributeValue(const QualifiedName&, bool);
297 
298     String accessibilityDescriptionForElements(Vector<Element*> &elements) const;
299     void elementsFromAttribute(Vector<Element*>& elements, const QualifiedName&) const;
300     String ariaAccessibilityDescription() const;
301 
302     virtual ESpeak speakProperty() const;
303 
304     virtual const AtomicString& ariaLiveRegionStatus() const;
305     virtual const AtomicString& ariaLiveRegionRelevant() const;
306     virtual bool ariaLiveRegionAtomic() const;
307     virtual bool ariaLiveRegionBusy() const;
308 
309     bool inheritsPresentationalRole() const;
setNeedsToUpdateChildren()310     void setNeedsToUpdateChildren() const { m_childrenDirty = true; }
311 
312     mutable AccessibilityRole m_roleForMSAA;
313 };
314 
toAccessibilityRenderObject(AccessibilityObject * object)315 inline AccessibilityRenderObject* toAccessibilityRenderObject(AccessibilityObject* object)
316 {
317     ASSERT(!object || object->isAccessibilityRenderObject());
318     return static_cast<AccessibilityRenderObject*>(object);
319 }
320 
toAccessibilityRenderObject(const AccessibilityObject * object)321 inline const AccessibilityRenderObject* toAccessibilityRenderObject(const AccessibilityObject* object)
322 {
323     ASSERT(!object || object->isAccessibilityRenderObject());
324     return static_cast<const AccessibilityRenderObject*>(object);
325 }
326 
327 // This will catch anyone doing an unnecessary cast.
328 void toAccessibilityRenderObject(const AccessibilityRenderObject*);
329 
330 } // namespace WebCore
331 
332 #endif // AccessibilityRenderObject_h
333