summaryrefslogtreecommitdiffstats
path: root/chromium/third_party/WebKit/Source/core/accessibility/AXRenderObject.h
blob: 160d0d7db3aa34da2e86e70d81318c6d28d42964 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
/*
 * Copyright (C) 2008 Apple Inc. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1.  Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 * 2.  Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in the
 *     documentation and/or other materials provided with the distribution.
 * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
 *     its contributors may be used to endorse or promote products derived
 *     from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef AXRenderObject_h
#define AXRenderObject_h

#include "core/accessibility/AXNodeObject.h"
#include "platform/geometry/LayoutRect.h"
#include "wtf/Forward.h"

namespace WebCore {

class AXSVGRoot;
class AXObjectCache;
class Element;
class Frame;
class FrameView;
class HitTestResult;
class HTMLAnchorElement;
class HTMLAreaElement;
class HTMLElement;
class HTMLLabelElement;
class HTMLMapElement;
class HTMLSelectElement;
class IntPoint;
class IntSize;
class Node;
class RenderListBox;
class RenderTextControl;
class RenderView;
class VisibleSelection;
class Widget;

class AXRenderObject : public AXNodeObject {
protected:
    explicit AXRenderObject(RenderObject*);
public:
    static PassRefPtr<AXRenderObject> create(RenderObject*);
    virtual ~AXRenderObject();

    // Public, overridden from AXObject.
    virtual RenderObject* renderer() const OVERRIDE { return m_renderer; }
    virtual LayoutRect elementRect() const OVERRIDE;

    void setRenderer(RenderObject*);
    RenderBoxModelObject* renderBoxModelObject() const;
    RenderView* topRenderer() const;
    Document* topDocument() const;
    bool shouldNotifyActiveDescendant() const;
    bool needsToUpdateChildren() const { return m_childrenDirty; }
    ScrollableArea* getScrollableAreaIfScrollable() const;
    virtual AccessibilityRole determineAccessibilityRole() OVERRIDE;
    void checkCachedElementRect() const;
    void updateCachedElementRect() const;

protected:
    RenderObject* m_renderer;
    mutable LayoutRect m_cachedElementRect;
    mutable LayoutRect m_cachedFrameRect;
    mutable IntPoint m_cachedScrollPosition;
    mutable bool m_cachedElementRectDirty;

    //
    // Overridden from AXObject.
    //

    virtual void init() OVERRIDE;
    virtual void detach() OVERRIDE;
    virtual bool isDetached() const OVERRIDE { return !m_renderer; }
    virtual bool isAXRenderObject() const OVERRIDE { return true; }

    // Check object role or purpose.
    virtual bool isAttachment() const OVERRIDE;
    virtual bool isFileUploadButton() const OVERRIDE;
    virtual bool isLinked() const OVERRIDE;
    virtual bool isLoaded() const OVERRIDE;
    virtual bool isOffScreen() const OVERRIDE;
    virtual bool isReadOnly() const OVERRIDE;
    virtual bool isVisited() const OVERRIDE;

    // Check object state.
    virtual bool isFocused() const OVERRIDE;
    virtual bool isSelected() const OVERRIDE;

    // Whether objects are ignored, i.e. not included in the tree.
    virtual AXObjectInclusion defaultObjectInclusion() const OVERRIDE;
    virtual bool computeAccessibilityIsIgnored() const OVERRIDE;

    // Properties of static elements.
    virtual const AtomicString& accessKey() const OVERRIDE;
    virtual AccessibilityOrientation orientation() const OVERRIDE;
    virtual String text() const OVERRIDE;
    virtual int textLength() const OVERRIDE;
    virtual KURL url() const OVERRIDE;

    // Properties of interactive elements.
    virtual String actionVerb() const OVERRIDE;
    virtual void selectedChildren(AccessibilityChildrenVector&) OVERRIDE;
    virtual String stringValue() const OVERRIDE;

    // ARIA attributes.
    virtual AXObject* activeDescendant() const OVERRIDE;
    virtual void ariaFlowToElements(AccessibilityChildrenVector&) const OVERRIDE;
    virtual bool ariaHasPopup() const OVERRIDE;
    virtual bool ariaRoleHasPresentationalChildren() const OVERRIDE;
    virtual bool isPresentationalChildOfAriaRole() const OVERRIDE;
    virtual bool shouldFocusActiveDescendant() const OVERRIDE;
    virtual bool supportsARIADragging() const OVERRIDE;
    virtual bool supportsARIADropping() const OVERRIDE;
    virtual bool supportsARIAFlowTo() const OVERRIDE;
    virtual bool supportsARIAOwns() const OVERRIDE;

    // ARIA live-region features.
    virtual const AtomicString& ariaLiveRegionStatus() const OVERRIDE;
    virtual const AtomicString& ariaLiveRegionRelevant() const OVERRIDE;
    virtual bool ariaLiveRegionAtomic() const OVERRIDE;
    virtual bool ariaLiveRegionBusy() const OVERRIDE;

    // Accessibility Text.
    virtual String textUnderElement() const OVERRIDE;

    // Accessibility Text - (To be deprecated).
    virtual String helpText() const OVERRIDE;

    // Location and click point in frame-relative coordinates.
    virtual void markCachedElementRectDirty() const OVERRIDE;
    virtual IntPoint clickPoint() OVERRIDE;

    // Hit testing.
    virtual AXObject* accessibilityHitTest(const IntPoint&) const OVERRIDE;
    virtual AXObject* elementAccessibilityHitTest(const IntPoint&) const OVERRIDE;

    // High-level accessibility tree access. Other modules should only use these functions.
    virtual AXObject* parentObject() const OVERRIDE;
    virtual AXObject* parentObjectIfExists() const OVERRIDE;

    // Low-level accessibility tree exploration, only for use within the accessibility module.
    virtual AXObject* firstChild() const OVERRIDE;
    virtual AXObject* nextSibling() const OVERRIDE;
    virtual void addChildren() OVERRIDE;
    virtual bool canHaveChildren() const OVERRIDE;
    virtual void updateChildrenIfNecessary() OVERRIDE;
    virtual void setNeedsToUpdateChildren() OVERRIDE { m_childrenDirty = true; }
    virtual void clearChildren() OVERRIDE;
    virtual AXObject* observableObject() const OVERRIDE;

    // Properties of the object's owning document or page.
    virtual double estimatedLoadingProgress() const OVERRIDE;

    // DOM and Render tree access.
    virtual Node* node() const OVERRIDE;
    virtual Document* document() const OVERRIDE;
    virtual FrameView* documentFrameView() const OVERRIDE;
    virtual Element* anchorElement() const OVERRIDE;
    virtual Widget* widgetForAttachmentView() const OVERRIDE;

    // Selected text.
    virtual PlainTextRange selectedTextRange() const OVERRIDE;
    virtual String selectedText() const OVERRIDE;

    // Modify or take an action on an object.
    virtual void setSelectedTextRange(const PlainTextRange&) OVERRIDE;
    virtual void setValue(const String&) OVERRIDE;
    virtual void scrollTo(const IntPoint&) const OVERRIDE;

    // Notifications that this object may have changed.
    virtual void handleActiveDescendantChanged() OVERRIDE;
    virtual void handleAriaExpandedChanged() OVERRIDE;
    virtual void textChanged() OVERRIDE;

    // Text metrics. Most of these should be deprecated, needs major cleanup.
    virtual int index(const VisiblePosition&) const OVERRIDE;
    virtual VisiblePosition visiblePositionForIndex(int) const OVERRIDE;
    virtual void lineBreaks(Vector<int>&) const OVERRIDE;

private:
    bool isAllowedChildOfTree() const;
    void ariaListboxSelectedChildren(AccessibilityChildrenVector&);
    PlainTextRange ariaSelectedTextRange() const;
    bool nodeIsTextControl(const Node*) const;
    bool isTabItemSelected() const;
    AXObject* internalLinkElement() const;
    AXObject* accessibilityImageMapHitTest(HTMLAreaElement*, const IntPoint&) const;
    bool renderObjectIsObservable(RenderObject*) const;
    RenderObject* renderParentObject() const;
    bool isDescendantOfElementType(const QualifiedName& tagName) const;
    bool isSVGImage() const;
    void detachRemoteSVGRoot();
    AXSVGRoot* remoteSVGRootElement() const;
    AXObject* remoteSVGElementHitTest(const IntPoint&) const;
    void offsetBoundingBoxForRemoteSVGElement(LayoutRect&) const;
    void addHiddenChildren();
    void addTextFieldChildren();
    void addImageMapChildren();
    void addCanvasChildren();
    void addAttachmentChildren();
    void addRemoteSVGChildren();
    void addInlineTextBoxChildren();

    void ariaSelectedRows(AccessibilityChildrenVector&);
    bool elementAttributeValue(const QualifiedName&) const;
    bool inheritsPresentationalRole() const;
    LayoutRect computeElementRect() const;
    VisibleSelection selection() const;
    String stringForRange(const PlainTextRange&) const;
    int indexForVisiblePosition(const VisiblePosition&) const;
};

DEFINE_AX_OBJECT_TYPE_CASTS(AXRenderObject, isAXRenderObject());

} // namespace WebCore

#endif // AXRenderObject_h