2 * Copyright (C) 2011 Apple Inc. All Rights Reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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.
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.
26 #ifndef AccessibilityUIElement_h
27 #define AccessibilityUIElement_h
29 #include "AccessibilityTextMarker.h"
30 #include "AccessibilityTextMarkerRange.h"
31 #include "JSWrappable.h"
33 #include <JavaScriptCore/JSObjectRef.h>
34 #include <JavaScriptCore/JSRetainPtr.h>
35 #include <wtf/Platform.h>
36 #include <wtf/Vector.h>
40 typedef id PlatformUIElement;
42 typedef struct objc_object* PlatformUIElement;
46 #define _WINSOCKAPI_ // Prevent inclusion of winsock.h in windows.h
48 #include <WebCore/COMPtr.h>
51 typedef COMPtr<IAccessible> PlatformUIElement;
54 typedef AtkObject* PlatformUIElement;
56 typedef void* PlatformUIElement;
61 typedef id NotificationHandler;
63 typedef struct objc_object* NotificationHandler;
69 class AccessibilityUIElement : public JSWrappable {
71 static PassRefPtr<AccessibilityUIElement> create(PlatformUIElement);
72 static PassRefPtr<AccessibilityUIElement> create(const AccessibilityUIElement&);
74 ~AccessibilityUIElement();
76 PlatformUIElement platformUIElement() { return m_element; }
77 virtual JSClassRef wrapperClass();
79 static JSObjectRef makeJSAccessibilityUIElement(JSContextRef, const AccessibilityUIElement&);
81 bool isEqual(AccessibilityUIElement* otherElement);
83 PassRefPtr<AccessibilityUIElement> elementAtPoint(int x, int y);
84 PassRefPtr<AccessibilityUIElement> childAtIndex(unsigned);
85 unsigned indexOfChild(AccessibilityUIElement*);
87 PassRefPtr<AccessibilityUIElement> titleUIElement();
88 PassRefPtr<AccessibilityUIElement> parentElement();
93 void removeSelection();
95 // Methods - platform-independent implementations
96 JSRetainPtr<JSStringRef> allAttributes();
97 JSRetainPtr<JSStringRef> attributesOfLinkedUIElements();
98 PassRefPtr<AccessibilityUIElement> linkedUIElementAtIndex(unsigned);
100 JSRetainPtr<JSStringRef> attributesOfDocumentLinks();
101 JSRetainPtr<JSStringRef> attributesOfChildren();
102 JSRetainPtr<JSStringRef> parameterizedAttributeNames();
108 // Attributes - platform-independent implementations
109 JSRetainPtr<JSStringRef> stringAttributeValue(JSStringRef attribute);
110 double numberAttributeValue(JSStringRef attribute);
111 PassRefPtr<AccessibilityUIElement> uiElementAttributeValue(JSStringRef attribute) const;
112 bool boolAttributeValue(JSStringRef attribute);
113 bool isAttributeSupported(JSStringRef attribute);
114 bool isAttributeSettable(JSStringRef attribute);
115 bool isActionSupported(JSStringRef action);
116 JSRetainPtr<JSStringRef> role();
117 JSRetainPtr<JSStringRef> subrole();
118 JSRetainPtr<JSStringRef> roleDescription();
119 JSRetainPtr<JSStringRef> title();
120 JSRetainPtr<JSStringRef> description();
121 JSRetainPtr<JSStringRef> language();
122 JSRetainPtr<JSStringRef> stringValue();
123 JSRetainPtr<JSStringRef> accessibilityValue() const;
124 JSRetainPtr<JSStringRef> helpText() const;
125 JSRetainPtr<JSStringRef> orientation() const;
130 double intValue() const;
133 JSRetainPtr<JSStringRef> valueDescription();
134 int insertionPointLineNumber();
135 JSRetainPtr<JSStringRef> selectedTextRange();
137 bool isRequired() const;
139 bool isFocused() const;
140 bool isFocusable() const;
141 bool isSelected() const;
142 bool isSelectable() const;
143 bool isMultiSelectable() const;
144 void setSelectedChild(AccessibilityUIElement*) const;
145 unsigned selectedChildrenCount() const;
146 PassRefPtr<AccessibilityUIElement> selectedChildAtIndex(unsigned) const;
148 bool isValid() const;
149 bool isExpanded() const;
150 bool isChecked() const;
151 bool isVisible() const;
152 bool isOffScreen() const;
153 bool isCollapsed() const;
154 bool isIgnored() const;
155 bool hasPopup() const;
156 int hierarchicalLevel() const;
157 double clickPointX();
158 double clickPointY();
159 JSRetainPtr<JSStringRef> documentEncoding();
160 JSRetainPtr<JSStringRef> documentURI();
161 JSRetainPtr<JSStringRef> url();
163 // CSS3-speech properties.
164 JSRetainPtr<JSStringRef> speak();
166 // Table-specific attributes
167 JSRetainPtr<JSStringRef> attributesOfColumnHeaders();
168 JSRetainPtr<JSStringRef> attributesOfRowHeaders();
169 JSRetainPtr<JSStringRef> attributesOfColumns();
170 JSRetainPtr<JSStringRef> attributesOfRows();
171 JSRetainPtr<JSStringRef> attributesOfVisibleCells();
172 JSRetainPtr<JSStringRef> attributesOfHeader();
174 JSRetainPtr<JSStringRef> rowIndexRange();
175 JSRetainPtr<JSStringRef> columnIndexRange();
179 // Tree/Outline specific attributes
180 PassRefPtr<AccessibilityUIElement> selectedRowAtIndex(unsigned);
181 PassRefPtr<AccessibilityUIElement> disclosedByRow();
182 PassRefPtr<AccessibilityUIElement> disclosedRowAtIndex(unsigned);
183 PassRefPtr<AccessibilityUIElement> rowAtIndex(unsigned);
186 PassRefPtr<AccessibilityUIElement> ariaOwnsElementAtIndex(unsigned);
187 PassRefPtr<AccessibilityUIElement> ariaFlowToElementAtIndex(unsigned);
189 // ARIA Drag and Drop
190 bool ariaIsGrabbed() const;
191 // A space concatentated string of all the drop effects.
192 JSRetainPtr<JSStringRef> ariaDropEffects() const;
194 // Parameterized attributes
195 int lineForIndex(int);
196 JSRetainPtr<JSStringRef> rangeForLine(int);
197 JSRetainPtr<JSStringRef> boundsForRange(unsigned location, unsigned length);
198 void setSelectedTextRange(unsigned location, unsigned length);
199 JSRetainPtr<JSStringRef> stringForRange(unsigned location, unsigned length);
200 JSRetainPtr<JSStringRef> attributedStringForRange(unsigned location, unsigned length);
201 bool attributedStringRangeIsMisspelled(unsigned location, unsigned length);
202 PassRefPtr<AccessibilityUIElement> uiElementForSearchPredicate(AccessibilityUIElement* startElement, bool isDirectionNext, JSStringRef searchKey, JSStringRef searchText);
205 PassRefPtr<AccessibilityUIElement> cellForColumnAndRow(unsigned column, unsigned row);
207 // Scrollarea-specific
208 PassRefPtr<AccessibilityUIElement> horizontalScrollbar() const;
209 PassRefPtr<AccessibilityUIElement> verticalScrollbar() const;
212 PassRefPtr<AccessibilityTextMarkerRange> textMarkerRangeForElement(AccessibilityUIElement*);
213 PassRefPtr<AccessibilityTextMarkerRange> textMarkerRangeForMarkers(AccessibilityTextMarker* startMarker, AccessibilityTextMarker* endMarker);
214 PassRefPtr<AccessibilityTextMarker> startTextMarkerForTextMarkerRange(AccessibilityTextMarkerRange*);
215 PassRefPtr<AccessibilityTextMarker> endTextMarkerForTextMarkerRange(AccessibilityTextMarkerRange*);
216 PassRefPtr<AccessibilityTextMarker> textMarkerForPoint(int x, int y);
217 PassRefPtr<AccessibilityTextMarker> previousTextMarker(AccessibilityTextMarker*);
218 PassRefPtr<AccessibilityTextMarker> nextTextMarker(AccessibilityTextMarker*);
219 PassRefPtr<AccessibilityUIElement> accessibilityElementForTextMarker(AccessibilityTextMarker*);
220 JSRetainPtr<JSStringRef> stringForTextMarkerRange(AccessibilityTextMarkerRange*);
221 int textMarkerRangeLength(AccessibilityTextMarkerRange*);
222 bool attributedStringForTextMarkerRangeContainsAttribute(JSStringRef, AccessibilityTextMarkerRange*);
223 int indexForTextMarker(AccessibilityTextMarker*);
224 bool isTextMarkerValid(AccessibilityTextMarker*);
225 PassRefPtr<AccessibilityTextMarker> textMarkerForIndex(int);
228 // Function callback should take one argument, the name of the notification.
229 bool addNotificationListener(JSValueRef functionCallback);
230 // Make sure you call remove, because you can't rely on objects being deallocated in a timely fashion.
231 bool removeNotificationListener();
234 AccessibilityUIElement(PlatformUIElement);
235 AccessibilityUIElement(const AccessibilityUIElement&);
237 PlatformUIElement m_element;
239 // A retained, platform specific object used to help manage notifications for this object.
241 NotificationHandler m_notificationHandler;
243 void getLinkedUIElements(Vector<RefPtr<AccessibilityUIElement> >&);
244 void getDocumentLinks(Vector<RefPtr<AccessibilityUIElement> >&);
245 void getChildren(Vector<RefPtr<AccessibilityUIElement> >&);
246 void getChildrenWithRange(Vector<RefPtr<AccessibilityUIElement> >&, unsigned location, unsigned length);
252 #endif // AccessibilityUIElement_h