246460757999d454015f5e4f47bd8d37512e4aef
[WebKit-https.git] / Tools / WebKitTestRunner / InjectedBundle / AccessibilityUIElement.cpp
1 /*
2  * Copyright (C) 2011 Apple 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  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
24  */
25
26 #include "config.h"
27 #include "AccessibilityUIElement.h"
28
29 #include "JSAccessibilityUIElement.h"
30 #include <JavaScriptCore/JSRetainPtr.h>
31
32 namespace WTR {
33
34 PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::create(PlatformUIElement uiElement)
35 {
36     return adoptRef(new AccessibilityUIElement(uiElement));
37 }
38     
39 PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::create(const AccessibilityUIElement& uiElement)
40 {
41     return adoptRef(new AccessibilityUIElement(uiElement));
42 }
43
44 JSClassRef AccessibilityUIElement::wrapperClass()
45 {
46     return JSAccessibilityUIElement::accessibilityUIElementClass();
47 }
48     
49 // Implementation
50
51 bool AccessibilityUIElement::isValid() const
52 {
53     return m_element;            
54 }
55
56 // iOS specific methods
57 #if !PLATFORM(IOS)
58 JSRetainPtr<JSStringRef> AccessibilityUIElement::identifier() { return nullptr; }
59 JSRetainPtr<JSStringRef> AccessibilityUIElement::traits() { return nullptr; }
60 int AccessibilityUIElement::elementTextPosition() { return 0; }
61 int AccessibilityUIElement::elementTextLength() { return 0; }
62 JSRetainPtr<JSStringRef> AccessibilityUIElement::stringForSelection() { return nullptr; }
63 JSValueRef AccessibilityUIElement::elementsForRange(unsigned, unsigned) { return nullptr; }
64 void AccessibilityUIElement::increaseTextSelection() { }
65 void AccessibilityUIElement::decreaseTextSelection() { }
66 PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::linkedElement() { return nullptr; }
67 PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::headerElementAtIndex(unsigned) { return nullptr; }
68 void AccessibilityUIElement::assistiveTechnologySimulatedFocus() { return; }
69 bool AccessibilityUIElement::scrollPageUp() { return false; }
70 bool AccessibilityUIElement::scrollPageDown() { return false; }
71 bool AccessibilityUIElement::scrollPageLeft() { return false; }
72 bool AccessibilityUIElement::scrollPageRight() { return false; }
73 bool AccessibilityUIElement::hasContainedByFieldsetTrait() { return false; }
74 PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::fieldsetAncestorElement() { return nullptr; }
75 bool AccessibilityUIElement::isSearchField() const { return false; }
76 bool AccessibilityUIElement::isTextArea() const { return false; }
77
78 #endif
79     
80 // Unsupported methods on various platforms. As they're implemented on other platforms this list should be modified.
81 #if (!PLATFORM(GTK) && !PLATFORM(EFL)) || !HAVE(ACCESSIBILITY)
82 JSRetainPtr<JSStringRef> AccessibilityUIElement::characterAtOffset(int) { return 0; }
83 JSRetainPtr<JSStringRef> AccessibilityUIElement::wordAtOffset(int) { return 0; }
84 JSRetainPtr<JSStringRef> AccessibilityUIElement::lineAtOffset(int) { return 0; }
85 JSRetainPtr<JSStringRef> AccessibilityUIElement::sentenceAtOffset(int) { return 0; }
86 #endif
87
88 #if (!PLATFORM(COCOA) && !PLATFORM(GTK) && !PLATFORM(EFL)) || !HAVE(ACCESSIBILITY)
89 AccessibilityUIElement::AccessibilityUIElement(PlatformUIElement) { }
90 AccessibilityUIElement::AccessibilityUIElement(const AccessibilityUIElement&) { }
91 AccessibilityUIElement::~AccessibilityUIElement() { }
92 bool AccessibilityUIElement::isEqual(AccessibilityUIElement*) { return false; }
93 PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::elementAtPoint(int, int) { return 0; }
94 PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::childAtIndex(unsigned) { return 0; }
95 unsigned AccessibilityUIElement::indexOfChild(AccessibilityUIElement*) { return 0; }
96 int AccessibilityUIElement::childrenCount() { return 0; }
97 PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::titleUIElement() { return 0; }
98 PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::parentElement() { return 0; }
99 void AccessibilityUIElement::takeFocus() { }
100 void AccessibilityUIElement::takeSelection() { }
101 void AccessibilityUIElement::addSelection() { }
102 void AccessibilityUIElement::removeSelection() { }
103 JSRetainPtr<JSStringRef> AccessibilityUIElement::allAttributes() { return 0; }
104 JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfLinkedUIElements() { return 0; }
105 PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::linkedUIElementAtIndex(unsigned) { return 0; }
106 JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfDocumentLinks() { return 0; }
107 JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfChildren() { return 0; }
108 JSRetainPtr<JSStringRef> AccessibilityUIElement::parameterizedAttributeNames() { return 0; }
109 void AccessibilityUIElement::increment() { }
110 void AccessibilityUIElement::decrement() { }
111 void AccessibilityUIElement::showMenu() { }
112 void AccessibilityUIElement::press() { }
113 JSRetainPtr<JSStringRef> AccessibilityUIElement::stringAttributeValue(JSStringRef) { return 0; }
114 JSValueRef AccessibilityUIElement::uiElementArrayAttributeValue(JSStringRef) const { return nullptr; }
115 PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::uiElementAttributeValue(JSStringRef) const { return 0; }
116 double AccessibilityUIElement::numberAttributeValue(JSStringRef) { return 0; }
117 bool AccessibilityUIElement::boolAttributeValue(JSStringRef) { return false; }
118 bool AccessibilityUIElement::isAttributeSupported(JSStringRef) { return false; }
119 bool AccessibilityUIElement::isAttributeSettable(JSStringRef) { return false; }
120 bool AccessibilityUIElement::isPressActionSupported() { return false; }
121 bool AccessibilityUIElement::isIncrementActionSupported() { return false; }
122 bool AccessibilityUIElement::isDecrementActionSupported() { return false; }
123 JSRetainPtr<JSStringRef> AccessibilityUIElement::role() { return 0; }
124 JSRetainPtr<JSStringRef> AccessibilityUIElement::subrole() { return 0; }
125 JSRetainPtr<JSStringRef> AccessibilityUIElement::roleDescription() { return 0; }
126 JSRetainPtr<JSStringRef> AccessibilityUIElement::computedRoleString() { return 0; }
127 JSRetainPtr<JSStringRef> AccessibilityUIElement::title() { return 0; }
128 JSRetainPtr<JSStringRef> AccessibilityUIElement::description() { return 0; }
129 JSRetainPtr<JSStringRef> AccessibilityUIElement::language() { return 0; }
130 JSRetainPtr<JSStringRef> AccessibilityUIElement::stringValue() { return 0; }
131 JSRetainPtr<JSStringRef> AccessibilityUIElement::accessibilityValue() const { return 0; }
132 JSRetainPtr<JSStringRef> AccessibilityUIElement::helpText() const { return 0; }
133 JSRetainPtr<JSStringRef> AccessibilityUIElement::orientation() const { return 0; }
134 double AccessibilityUIElement::x() { return 0; }
135 double AccessibilityUIElement::y() { return 0; }
136 double AccessibilityUIElement::width() { return 0; }
137 double AccessibilityUIElement::height() { return 0; }
138 double AccessibilityUIElement::intValue() const { return 0; }
139 double AccessibilityUIElement::minValue() { return 0; }
140 double AccessibilityUIElement::maxValue() { return 0; }
141 JSRetainPtr<JSStringRef> AccessibilityUIElement::valueDescription() { return 0; }
142 int AccessibilityUIElement::insertionPointLineNumber() { return 0; }
143 JSRetainPtr<JSStringRef> AccessibilityUIElement::selectedTextRange() { return 0; }
144 bool AccessibilityUIElement::isEnabled() { return false; }
145 bool AccessibilityUIElement::isRequired() const { return false; }
146 bool AccessibilityUIElement::isFocused() const { return false; }
147 bool AccessibilityUIElement::isFocusable() const { return false; }
148 bool AccessibilityUIElement::isSelected() const { return false; }
149 bool AccessibilityUIElement::isSelectedOptionActive() const { return false; }
150 bool AccessibilityUIElement::isSelectable() const { return false; }
151 bool AccessibilityUIElement::isMultiSelectable() const { return false; }
152 void AccessibilityUIElement::setSelectedChild(AccessibilityUIElement*) const { }
153 void AccessibilityUIElement::setSelectedChildAtIndex(unsigned) const { }
154 void AccessibilityUIElement::removeSelectionAtIndex(unsigned) const { }
155 unsigned AccessibilityUIElement::selectedChildrenCount() const { return 0; }
156 PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::selectedChildAtIndex(unsigned) const { return 0; }
157 bool AccessibilityUIElement::isExpanded() const { return false; }
158 bool AccessibilityUIElement::isChecked() const { return false; }
159 bool AccessibilityUIElement::isIndeterminate() const { return false; }
160 bool AccessibilityUIElement::isVisible() const { return false; }
161 bool AccessibilityUIElement::isOffScreen() const { return false; }
162 bool AccessibilityUIElement::isCollapsed() const { return false; }
163 bool AccessibilityUIElement::isIgnored() const { return false; }
164 bool AccessibilityUIElement::hasPopup() const { return false; }
165 int AccessibilityUIElement::hierarchicalLevel() const { return 0; }
166 double AccessibilityUIElement::clickPointX() { return 0; }
167 double AccessibilityUIElement::clickPointY() { return 0; }
168 JSRetainPtr<JSStringRef> AccessibilityUIElement::documentEncoding() { return 0; }
169 JSRetainPtr<JSStringRef> AccessibilityUIElement::documentURI() { return 0; }
170 JSRetainPtr<JSStringRef> AccessibilityUIElement::url() { return 0; }
171 JSRetainPtr<JSStringRef> AccessibilityUIElement::speak() { return 0; }
172 JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfColumnHeaders() { return 0; }
173 JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfRowHeaders() { return 0; }
174 JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfColumns() { return 0; }
175 JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfRows() { return 0; }
176 JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfVisibleCells() { return 0; }
177 JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfHeader() { return 0; }
178 int AccessibilityUIElement::indexInTable() { return 0; }
179 JSRetainPtr<JSStringRef> AccessibilityUIElement::rowIndexRange() { return 0; }
180 JSRetainPtr<JSStringRef> AccessibilityUIElement::columnIndexRange() { return 0; }
181 int AccessibilityUIElement::rowCount() { return 0; }
182 int AccessibilityUIElement::columnCount() { return 0; }
183 JSValueRef AccessibilityUIElement::rowHeaders() const { return nullptr; }
184 JSValueRef AccessibilityUIElement::columnHeaders() const { return nullptr; }
185 PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::selectedRowAtIndex(unsigned) { return 0; }
186 PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::disclosedByRow() { return 0; }
187 PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::disclosedRowAtIndex(unsigned) { return 0; }
188 PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::rowAtIndex(unsigned) { return 0; }
189 PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::ariaOwnsElementAtIndex(unsigned) { return 0; }
190 PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::ariaFlowToElementAtIndex(unsigned) { return 0; }
191 PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::ariaControlsElementAtIndex(unsigned) { return nullptr; }
192 bool AccessibilityUIElement::ariaIsGrabbed() const { return false; }
193 JSRetainPtr<JSStringRef> AccessibilityUIElement::ariaDropEffects() const { return 0; }
194 JSRetainPtr<JSStringRef> AccessibilityUIElement::classList() const { return 0; }
195 int AccessibilityUIElement::lineForIndex(int) { return 0; }
196 JSRetainPtr<JSStringRef> AccessibilityUIElement::rangeForLine(int) { return 0; }
197 JSRetainPtr<JSStringRef> AccessibilityUIElement::rangeForPosition(int, int) { return 0; }
198 JSRetainPtr<JSStringRef> AccessibilityUIElement::boundsForRange(unsigned, unsigned) { return 0; }
199 bool AccessibilityUIElement::setSelectedTextRange(unsigned, unsigned) { return false; }
200 bool AccessibilityUIElement::setSelectedVisibleTextRange(AccessibilityTextMarkerRange*) { return false; }
201 JSRetainPtr<JSStringRef> AccessibilityUIElement::stringForRange(unsigned, unsigned) { return 0; }
202 JSRetainPtr<JSStringRef> AccessibilityUIElement::attributedStringForRange(unsigned, unsigned) { return 0; }
203 bool AccessibilityUIElement::attributedStringRangeIsMisspelled(unsigned, unsigned) { return false; }
204 unsigned AccessibilityUIElement::uiElementCountForSearchPredicate(JSContextRef, AccessibilityUIElement*, bool, JSValueRef, JSStringRef, bool, bool) { return 0; }
205 PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::uiElementForSearchPredicate(JSContextRef, AccessibilityUIElement*, bool, JSValueRef, JSStringRef, bool, bool) { return 0; }
206 JSRetainPtr<JSStringRef> AccessibilityUIElement::selectTextWithCriteria(JSContextRef, JSStringRef, JSValueRef, JSStringRef, JSStringRef) { return nullptr; }
207 PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::cellForColumnAndRow(unsigned, unsigned) { return 0; }
208 PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::horizontalScrollbar() const { return 0; }
209 PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::verticalScrollbar() const { return 0; }
210 bool AccessibilityUIElement::addNotificationListener(JSValueRef) { return false; }
211 bool AccessibilityUIElement::removeNotificationListener() { return false; }
212 PassRefPtr<AccessibilityTextMarkerRange> AccessibilityUIElement::lineTextMarkerRangeForTextMarker(AccessibilityTextMarker*) { return nullptr; }
213 PassRefPtr<AccessibilityTextMarkerRange> AccessibilityUIElement::textMarkerRangeForElement(AccessibilityUIElement*) { return 0; }
214 int AccessibilityUIElement::textMarkerRangeLength(AccessibilityTextMarkerRange*) { return 0; }
215 PassRefPtr<AccessibilityTextMarkerRange> AccessibilityUIElement::textMarkerRangeForMarkers(AccessibilityTextMarker*, AccessibilityTextMarker*) { return 0; }
216 PassRefPtr<AccessibilityTextMarker> AccessibilityUIElement::startTextMarkerForTextMarkerRange(AccessibilityTextMarkerRange*) { return 0; }
217 PassRefPtr<AccessibilityTextMarker> AccessibilityUIElement::endTextMarkerForTextMarkerRange(AccessibilityTextMarkerRange*) { return 0; }
218 PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::accessibilityElementForTextMarker(AccessibilityTextMarker*) { return 0; }
219 PassRefPtr<AccessibilityTextMarker> AccessibilityUIElement::endTextMarkerForBounds(int x, int y, int width, int height) { return 0; }
220 PassRefPtr<AccessibilityTextMarker> AccessibilityUIElement::startTextMarkerForBounds(int x, int y, int width, int height) { return 0; }
221 PassRefPtr<AccessibilityTextMarker> AccessibilityUIElement::textMarkerForPoint(int, int) { return 0; }
222 PassRefPtr<AccessibilityTextMarker> AccessibilityUIElement::previousTextMarker(AccessibilityTextMarker*) { return 0; }
223 PassRefPtr<AccessibilityTextMarker> AccessibilityUIElement::nextTextMarker(AccessibilityTextMarker*) { return 0; }
224 PassRefPtr<AccessibilityTextMarker> AccessibilityUIElement::startTextMarker() { return 0; }
225 PassRefPtr<AccessibilityTextMarker> AccessibilityUIElement::endTextMarker() { return 0; }
226 JSRetainPtr<JSStringRef> AccessibilityUIElement::stringForTextMarkerRange(AccessibilityTextMarkerRange*) { return 0; }
227 bool AccessibilityUIElement::attributedStringForTextMarkerRangeContainsAttribute(JSStringRef, AccessibilityTextMarkerRange*) { return false; }
228 int AccessibilityUIElement::indexForTextMarker(AccessibilityTextMarker*) { return -1; }
229 bool AccessibilityUIElement::isTextMarkerValid(AccessibilityTextMarker*) { return false; }
230 PassRefPtr<AccessibilityTextMarker> AccessibilityUIElement::textMarkerForIndex(int) { return 0; }
231 void AccessibilityUIElement::scrollToMakeVisible() { }
232 void AccessibilityUIElement::scrollToGlobalPoint(int, int) { }
233 void AccessibilityUIElement::scrollToMakeVisibleWithSubFocus(int, int, int, int) { }
234 JSRetainPtr<JSStringRef> AccessibilityUIElement::supportedActions() const { return 0; }
235 JSRetainPtr<JSStringRef> AccessibilityUIElement::mathPostscriptsDescription() const { return 0; }
236 JSRetainPtr<JSStringRef> AccessibilityUIElement::mathPrescriptsDescription() const { return 0; }
237 JSRetainPtr<JSStringRef> AccessibilityUIElement::pathDescription() const { return 0; }
238
239 #endif
240
241 #if !PLATFORM(MAC) || !HAVE(ACCESSIBILITY)
242 PassRefPtr<AccessibilityTextMarkerRange> AccessibilityUIElement::selectedTextMarkerRange() { return nullptr; }
243 void AccessibilityUIElement::resetSelectedTextMarkerRange() { }
244 void AccessibilityUIElement::setBoolAttributeValue(JSStringRef, bool) { }
245 #endif
246
247 #if (!PLATFORM(MAC) && !PLATFORM(IOS)) || !HAVE(ACCESSIBILITY)
248 PassRefPtr<AccessibilityTextMarkerRange> AccessibilityUIElement::leftWordTextMarkerRangeForTextMarker(AccessibilityTextMarker*) { return nullptr; }
249 PassRefPtr<AccessibilityTextMarkerRange> AccessibilityUIElement::rightWordTextMarkerRangeForTextMarker(AccessibilityTextMarker*) { return nullptr; }
250 PassRefPtr<AccessibilityTextMarker> AccessibilityUIElement::previousWordStartTextMarkerForTextMarker(AccessibilityTextMarker*) { return nullptr; }
251 PassRefPtr<AccessibilityTextMarker> AccessibilityUIElement::nextWordEndTextMarkerForTextMarker(AccessibilityTextMarker*) { return nullptr; }
252 #endif
253
254 } // namespace WTR
255