Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / public / web / WebAXObject.h
1 /*
2  * Copyright (C) 2009 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 are
6  * met:
7  *
8  *     * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *     * Redistributions in binary form must reproduce the above
11  * copyright notice, this list of conditions and the following disclaimer
12  * in the documentation and/or other materials provided with the
13  * distribution.
14  *     * Neither the name of Google Inc. nor the names of its
15  * contributors may be used to endorse or promote products derived from
16  * this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30
31 #ifndef WebAXObject_h
32 #define WebAXObject_h
33
34 #include "../platform/WebCommon.h"
35 #include "../platform/WebPrivatePtr.h"
36 #include "../platform/WebVector.h"
37 #include "WebAXEnums.h"
38
39 #if BLINK_IMPLEMENTATION
40 namespace WTF { template <typename T> class PassRefPtr; }
41 #endif
42
43 namespace WebCore { class AXObject; }
44
45 namespace blink {
46
47 class WebNode;
48 class WebDocument;
49 class WebString;
50 class WebURL;
51 struct WebPoint;
52 struct WebRect;
53
54 // A container for passing around a reference to AXObject.
55 class WebAXObject {
56 public:
57     ~WebAXObject() { reset(); }
58
59     WebAXObject() { }
60     WebAXObject(const WebAXObject& o) { assign(o); }
61     WebAXObject& operator=(const WebAXObject& o)
62     {
63         assign(o);
64         return *this;
65     }
66
67     BLINK_EXPORT void reset();
68     BLINK_EXPORT void assign(const WebAXObject&);
69     BLINK_EXPORT bool equals(const WebAXObject&) const;
70
71     bool isNull() const { return m_private.isNull(); }
72     // isDetached also checks for null, so it's safe to just call isDetached.
73     BLINK_EXPORT bool isDetached() const;
74
75     // Static methods for enabling accessibility.
76     BLINK_EXPORT static void enableAccessibility();
77     BLINK_EXPORT static bool accessibilityEnabled();
78
79     // Temporary: this flag will only be toggleable until Chromium has it on by default.
80     BLINK_EXPORT static void enableInlineTextBoxAccessibility();
81
82     BLINK_EXPORT int axID() const;
83
84     // Update the underlying tree, and return true if this object is
85     // still valid (not detached). Note that calling this method
86     // can cause other WebAXObjects to become invalid, too,
87     // so always call isDetached if updateBackingStoreAndCheckValidity
88     // has been called on any object, or if any other WebCore code has run.
89     BLINK_EXPORT bool updateBackingStoreAndCheckValidity();
90
91     BLINK_EXPORT WebString accessibilityDescription() const;
92     BLINK_EXPORT unsigned childCount() const;
93
94     BLINK_EXPORT WebAXObject childAt(unsigned) const;
95     BLINK_EXPORT WebAXObject parentObject() const;
96
97     BLINK_EXPORT bool isAnchor() const;
98     BLINK_EXPORT bool isAriaReadOnly() const;
99     BLINK_EXPORT bool isButtonStateMixed() const;
100     BLINK_EXPORT bool isChecked() const;
101     BLINK_EXPORT bool isClickable() const;
102     BLINK_EXPORT bool isCollapsed() const;
103     BLINK_EXPORT bool isControl() const;
104     BLINK_EXPORT bool isEnabled() const;
105     BLINK_EXPORT bool isFocused() const;
106     BLINK_EXPORT bool isHovered() const;
107     BLINK_EXPORT bool isIndeterminate() const;
108     BLINK_EXPORT bool isLinked() const;
109     BLINK_EXPORT bool isLoaded() const;
110     BLINK_EXPORT bool isMultiSelectable() const;
111     BLINK_EXPORT bool isOffScreen() const;
112     BLINK_EXPORT bool isPasswordField() const;
113     BLINK_EXPORT bool isPressed() const;
114     BLINK_EXPORT bool isReadOnly() const;
115     BLINK_EXPORT bool isRequired() const;
116     BLINK_EXPORT bool isSelected() const;
117     BLINK_EXPORT bool isSelectedOptionActive() const;
118     BLINK_EXPORT bool isVertical() const;
119     BLINK_EXPORT bool isVisible() const;
120     BLINK_EXPORT bool isVisited() const;
121
122     BLINK_EXPORT WebString accessKey() const;
123     BLINK_EXPORT WebAXObject ariaActiveDescendant() const;
124     BLINK_EXPORT bool ariaControls(WebVector<WebAXObject>& controlsElements) const;
125     BLINK_EXPORT bool ariaDescribedby(WebVector<WebAXObject>& describedbyElements) const;
126     BLINK_EXPORT bool ariaFlowTo(WebVector<WebAXObject>& flowToElements) const;
127     BLINK_EXPORT bool ariaHasPopup() const;
128     BLINK_EXPORT bool ariaLabelledby(WebVector<WebAXObject>& labelledbyElements) const;
129     BLINK_EXPORT bool ariaLiveRegionAtomic() const;
130     BLINK_EXPORT bool ariaLiveRegionBusy() const;
131     BLINK_EXPORT WebString ariaLiveRegionRelevant() const;
132     BLINK_EXPORT WebString ariaLiveRegionStatus() const;
133     BLINK_EXPORT bool ariaOwns(WebVector<WebAXObject>& ownsElements) const;
134     BLINK_EXPORT WebRect boundingBoxRect() const;
135     BLINK_EXPORT bool canvasHasFallbackContent() const;
136     BLINK_EXPORT WebPoint clickPoint() const;
137     BLINK_EXPORT void colorValue(int& r, int& g, int& b) const;
138     BLINK_EXPORT double estimatedLoadingProgress() const;
139     BLINK_EXPORT WebString helpText() const;
140     BLINK_EXPORT int headingLevel() const;
141     BLINK_EXPORT int hierarchicalLevel() const;
142     BLINK_EXPORT WebAXObject hitTest(const WebPoint&) const;
143     BLINK_EXPORT WebString keyboardShortcut() const;
144     BLINK_EXPORT WebAXRole role() const;
145     BLINK_EXPORT unsigned selectionEnd() const;
146     BLINK_EXPORT unsigned selectionEndLineNumber() const;
147     BLINK_EXPORT unsigned selectionStart() const;
148     BLINK_EXPORT unsigned selectionStartLineNumber() const;
149     BLINK_EXPORT WebString stringValue() const;
150     BLINK_EXPORT WebString title() const;
151     BLINK_EXPORT WebAXObject titleUIElement() const;
152     BLINK_EXPORT WebURL url() const;
153
154     BLINK_EXPORT bool supportsRangeValue() const;
155     BLINK_EXPORT WebString valueDescription() const;
156     BLINK_EXPORT float valueForRange() const;
157     BLINK_EXPORT float maxValueForRange() const;
158     BLINK_EXPORT float minValueForRange() const;
159
160     BLINK_EXPORT WebNode node() const;
161     BLINK_EXPORT WebDocument document() const;
162     BLINK_EXPORT bool hasComputedStyle() const;
163     BLINK_EXPORT WebString computedStyleDisplay() const;
164     BLINK_EXPORT bool accessibilityIsIgnored() const;
165     BLINK_EXPORT bool lineBreaks(WebVector<int>&) const;
166
167     // Actions
168     BLINK_EXPORT WebString actionVerb() const; // The verb corresponding to performDefaultAction.
169     BLINK_EXPORT bool canDecrement() const;
170     BLINK_EXPORT bool canIncrement() const;
171     BLINK_EXPORT bool canPress() const;
172     BLINK_EXPORT bool canSetFocusAttribute() const;
173     BLINK_EXPORT bool canSetSelectedAttribute() const;
174     BLINK_EXPORT bool canSetValueAttribute() const;
175     BLINK_EXPORT bool performDefaultAction() const;
176     BLINK_EXPORT bool press() const;
177     BLINK_EXPORT bool increment() const;
178     BLINK_EXPORT bool decrement() const;
179     BLINK_EXPORT void setFocused(bool) const;
180     BLINK_EXPORT void setSelectedTextRange(int selectionStart, int selectionEnd) const;
181
182     // For a table
183     BLINK_EXPORT unsigned columnCount() const;
184     BLINK_EXPORT unsigned rowCount() const;
185     BLINK_EXPORT WebAXObject cellForColumnAndRow(unsigned column, unsigned row) const;
186     BLINK_EXPORT WebAXObject headerContainerObject() const;
187     BLINK_EXPORT WebAXObject rowAtIndex(unsigned rowIndex) const;
188     BLINK_EXPORT WebAXObject columnAtIndex(unsigned columnIndex) const;
189
190     // For a table row
191     BLINK_EXPORT unsigned rowIndex() const;
192     BLINK_EXPORT WebAXObject rowHeader() const;
193
194     // For a table column
195     BLINK_EXPORT unsigned columnIndex() const;
196     BLINK_EXPORT WebAXObject columnHeader() const;
197
198     // For a table cell
199     BLINK_EXPORT unsigned cellColumnIndex() const;
200     BLINK_EXPORT unsigned cellColumnSpan() const;
201     BLINK_EXPORT unsigned cellRowIndex() const;
202     BLINK_EXPORT unsigned cellRowSpan() const;
203
204     // For an inline text box.
205     BLINK_EXPORT WebAXTextDirection textDirection() const;
206     BLINK_EXPORT void characterOffsets(WebVector<int>&) const;
207     BLINK_EXPORT void wordBoundaries(WebVector<int>& starts, WebVector<int>& ends) const;
208
209     // Make this object visible by scrolling as many nested scrollable views as needed.
210     BLINK_EXPORT void scrollToMakeVisible() const;
211     // Same, but if the whole object can't be made visible, try for this subrect, in local coordinates.
212     BLINK_EXPORT void scrollToMakeVisibleWithSubFocus(const WebRect&) const;
213     // Scroll this object to a given point in global coordinates of the top-level window.
214     BLINK_EXPORT void scrollToGlobalPoint(const WebPoint&) const;
215
216 #if BLINK_IMPLEMENTATION
217     WebAXObject(const WTF::PassRefPtr<WebCore::AXObject>&);
218     WebAXObject& operator=(const WTF::PassRefPtr<WebCore::AXObject>&);
219     operator WTF::PassRefPtr<WebCore::AXObject>() const;
220 #endif
221
222 private:
223     WebPrivatePtr<WebCore::AXObject> m_private;
224 };
225
226 } // namespace blink
227
228 #endif