2 * Copyright (C) 2008 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 <JavaScriptCore/JSObjectRef.h>
31 #include <wtf/Platform.h>
32 #include <wtf/Vector.h>
36 typedef id PlatformUIElement;
38 typedef struct objc_object* PlatformUIElement;
42 #define _WINSOCKAPI_ // Prevent inclusion of winsock.h in windows.h
44 #include <WebCore/COMPtr.h>
47 typedef COMPtr<IAccessible> PlatformUIElement;
50 typedef AtkObject* PlatformUIElement;
52 typedef void* PlatformUIElement;
57 typedef id NotificationHandler;
59 typedef struct objc_object* NotificationHandler;
63 class AccessibilityUIElement {
65 AccessibilityUIElement(PlatformUIElement);
66 AccessibilityUIElement(const AccessibilityUIElement&);
67 ~AccessibilityUIElement();
69 PlatformUIElement platformUIElement() { return m_element; }
71 static JSObjectRef makeJSAccessibilityUIElement(JSContextRef, const AccessibilityUIElement&);
73 bool isEqual(AccessibilityUIElement* otherElement);
75 void getLinkedUIElements(Vector<AccessibilityUIElement>&);
76 void getDocumentLinks(Vector<AccessibilityUIElement>&);
77 void getChildren(Vector<AccessibilityUIElement>&);
78 void getChildrenWithRange(Vector<AccessibilityUIElement>&, unsigned location, unsigned length);
80 AccessibilityUIElement elementAtPoint(int x, int y);
81 AccessibilityUIElement getChildAtIndex(unsigned);
82 unsigned indexOfChild(AccessibilityUIElement*);
84 AccessibilityUIElement titleUIElement();
85 AccessibilityUIElement parentElement();
90 void removeSelection();
92 // Methods - platform-independent implementations
93 JSStringRef allAttributes();
94 JSStringRef attributesOfLinkedUIElements();
95 AccessibilityUIElement linkedUIElementAtIndex(unsigned);
97 JSStringRef attributesOfDocumentLinks();
98 JSStringRef attributesOfChildren();
99 JSStringRef parameterizedAttributeNames();
105 // Attributes - platform-independent implementations
106 JSStringRef stringAttributeValue(JSStringRef attribute);
107 double numberAttributeValue(JSStringRef attribute);
108 AccessibilityUIElement uiElementAttributeValue(JSStringRef attribute) const;
109 bool boolAttributeValue(JSStringRef attribute);
110 bool isAttributeSupported(JSStringRef attribute);
111 bool isAttributeSettable(JSStringRef attribute);
112 bool isActionSupported(JSStringRef action);
114 JSStringRef subrole();
115 JSStringRef roleDescription();
117 JSStringRef description();
118 JSStringRef language();
119 JSStringRef stringValue();
120 JSStringRef accessibilityValue() const;
121 JSStringRef helpText() const;
122 JSStringRef orientation() const;
127 double intValue() const;
130 JSStringRef valueDescription();
131 int insertionPointLineNumber();
132 JSStringRef selectedTextRange();
134 bool isRequired() const;
136 bool isFocused() const;
137 bool isFocusable() const;
138 bool isSelected() const;
139 bool isSelectable() const;
140 bool isMultiSelectable() const;
141 bool isSelectedOptionActive() const;
142 void setSelectedChild(AccessibilityUIElement*) const;
143 unsigned selectedChildrenCount() const;
144 AccessibilityUIElement selectedChildAtIndex(unsigned) const;
146 bool isExpanded() const;
147 bool isChecked() const;
148 bool isVisible() const;
149 bool isOffScreen() const;
150 bool isCollapsed() const;
151 bool isIgnored() const;
152 bool hasPopup() const;
153 int hierarchicalLevel() const;
154 double clickPointX();
155 double clickPointY();
156 JSStringRef documentEncoding();
157 JSStringRef documentURI();
160 // CSS3-speech properties.
163 // Table-specific attributes
164 JSStringRef attributesOfColumnHeaders();
165 JSStringRef attributesOfRowHeaders();
166 JSStringRef attributesOfColumns();
167 JSStringRef attributesOfRows();
168 JSStringRef attributesOfVisibleCells();
169 JSStringRef attributesOfHeader();
171 JSStringRef rowIndexRange();
172 JSStringRef columnIndexRange();
176 // Tree/Outline specific attributes
177 AccessibilityUIElement selectedRowAtIndex(unsigned);
178 AccessibilityUIElement disclosedByRow();
179 AccessibilityUIElement disclosedRowAtIndex(unsigned);
180 AccessibilityUIElement rowAtIndex(unsigned);
183 AccessibilityUIElement ariaOwnsElementAtIndex(unsigned);
184 AccessibilityUIElement ariaFlowToElementAtIndex(unsigned);
186 // ARIA Drag and Drop
187 bool ariaIsGrabbed() const;
188 // A space concatentated string of all the drop effects.
189 JSStringRef ariaDropEffects() const;
191 // Parameterized attributes
192 int lineForIndex(int);
193 JSStringRef rangeForLine(int);
194 JSStringRef rangeForPosition(int x, int y);
195 JSStringRef boundsForRange(unsigned location, unsigned length);
196 void setSelectedTextRange(unsigned location, unsigned length);
197 JSStringRef stringForRange(unsigned location, unsigned length);
198 JSStringRef attributedStringForRange(unsigned location, unsigned length);
199 bool attributedStringRangeIsMisspelled(unsigned location, unsigned length);
200 AccessibilityUIElement uiElementForSearchPredicate(AccessibilityUIElement* startElement, bool isDirectionNext, JSStringRef searchKey, JSStringRef searchText);
203 AccessibilityUIElement cellForColumnAndRow(unsigned column, unsigned row);
205 // Scrollarea-specific
206 AccessibilityUIElement horizontalScrollbar() const;
207 AccessibilityUIElement verticalScrollbar() const;
210 AccessibilityTextMarkerRange textMarkerRangeForElement(AccessibilityUIElement*);
211 AccessibilityTextMarkerRange textMarkerRangeForMarkers(AccessibilityTextMarker* startMarker, AccessibilityTextMarker* endMarker);
212 AccessibilityTextMarker startTextMarkerForTextMarkerRange(AccessibilityTextMarkerRange*);
213 AccessibilityTextMarker endTextMarkerForTextMarkerRange(AccessibilityTextMarkerRange*);
214 AccessibilityTextMarker textMarkerForPoint(int x, int y);
215 AccessibilityTextMarker previousTextMarker(AccessibilityTextMarker*);
216 AccessibilityTextMarker nextTextMarker(AccessibilityTextMarker*);
217 AccessibilityUIElement accessibilityElementForTextMarker(AccessibilityTextMarker*);
218 JSStringRef stringForTextMarkerRange(AccessibilityTextMarkerRange*);
219 int textMarkerRangeLength(AccessibilityTextMarkerRange*);
220 bool attributedStringForTextMarkerRangeContainsAttribute(JSStringRef, AccessibilityTextMarkerRange*);
221 int indexForTextMarker(AccessibilityTextMarker*);
222 bool isTextMarkerValid(AccessibilityTextMarker*);
223 AccessibilityTextMarker textMarkerForIndex(int);
225 void scrollToMakeVisible();
226 void scrollToMakeVisibleWithSubFocus(int x, int y, int width, int height);
227 void scrollToGlobalPoint(int x, int y);
230 // Function callback should take one argument, the name of the notification.
231 bool addNotificationListener(JSObjectRef functionCallback);
232 // Make sure you call remove, because you can't rely on objects being deallocated in a timely fashion.
233 void removeNotificationListener();
236 static JSClassRef getJSClass();
237 PlatformUIElement m_element;
239 // A retained, platform specific object used to help manage notifications for this object.
241 NotificationHandler m_notificationHandler;
245 #endif // AccessibilityUIElement_h