tizen beta release
[profile/ivi/webkit-efl.git] / Tools / DumpRenderTree / AccessibilityUIElement.h
1 /*
2  * Copyright (C) 2008 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 #ifndef AccessibilityUIElement_h
27 #define AccessibilityUIElement_h
28
29 #include "AccessibilityTextMarker.h"
30 #include <JavaScriptCore/JSObjectRef.h>
31 #include <wtf/Platform.h>
32 #include <wtf/Vector.h>
33
34 #if PLATFORM(MAC)
35 #ifdef __OBJC__
36 typedef id PlatformUIElement;
37 #else
38 typedef struct objc_object* PlatformUIElement;
39 #endif
40 #elif PLATFORM(WIN)
41 #undef _WINSOCKAPI_
42 #define _WINSOCKAPI_ // Prevent inclusion of winsock.h in windows.h
43
44 #include <WebCore/COMPtr.h>
45 #include <oleacc.h>
46
47 typedef COMPtr<IAccessible> PlatformUIElement;
48 #elif PLATFORM(GTK)
49 #include <atk/atk.h>
50 typedef AtkObject* PlatformUIElement;
51 #else
52 typedef void* PlatformUIElement;
53 #endif
54
55 #if PLATFORM(MAC)
56 #ifdef __OBJC__
57 typedef id NotificationHandler;
58 #else
59 typedef struct objc_object* NotificationHandler;
60 #endif
61 #endif
62
63 class AccessibilityUIElement {
64 public:
65     AccessibilityUIElement(PlatformUIElement);
66     AccessibilityUIElement(const AccessibilityUIElement&);
67     ~AccessibilityUIElement();
68
69     PlatformUIElement platformUIElement() { return m_element; }
70
71     static JSObjectRef makeJSAccessibilityUIElement(JSContextRef, const AccessibilityUIElement&);
72
73     bool isEqual(AccessibilityUIElement* otherElement);
74
75     void getLinkedUIElements(Vector<AccessibilityUIElement>&);
76     void getDocumentLinks(Vector<AccessibilityUIElement>&);
77     void getChildren(Vector<AccessibilityUIElement>&);
78     void getChildrenWithRange(Vector<AccessibilityUIElement>&, unsigned location, unsigned length);
79     
80     AccessibilityUIElement elementAtPoint(int x, int y);
81     AccessibilityUIElement getChildAtIndex(unsigned);
82     unsigned indexOfChild(AccessibilityUIElement*);
83     int childrenCount();
84     AccessibilityUIElement titleUIElement();
85     AccessibilityUIElement parentElement();
86
87     void takeFocus();
88     void takeSelection();
89     void addSelection();
90     void removeSelection();
91
92     // Methods - platform-independent implementations
93     JSStringRef allAttributes();
94     JSStringRef attributesOfLinkedUIElements();
95     AccessibilityUIElement linkedUIElementAtIndex(unsigned);
96     
97     JSStringRef attributesOfDocumentLinks();
98     JSStringRef attributesOfChildren();
99     JSStringRef parameterizedAttributeNames();
100     void increment();
101     void decrement();
102     void showMenu();
103     void press();
104
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);
113     JSStringRef role();
114     JSStringRef subrole();
115     JSStringRef roleDescription();
116     JSStringRef title();
117     JSStringRef description();
118     JSStringRef language();
119     JSStringRef stringValue();
120     JSStringRef accessibilityValue() const;
121     JSStringRef helpText() const;
122     JSStringRef orientation() const;
123     double x();
124     double y();
125     double width();
126     double height();
127     double intValue() const;
128     double minValue();
129     double maxValue();
130     JSStringRef valueDescription();
131     int insertionPointLineNumber();
132     JSStringRef selectedTextRange();
133     bool isEnabled();
134     bool isRequired() const;
135     
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;
145     
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();
158     JSStringRef url();
159
160     // CSS3-speech properties.
161     JSStringRef speak();
162     
163     // Table-specific attributes
164     JSStringRef attributesOfColumnHeaders();
165     JSStringRef attributesOfRowHeaders();
166     JSStringRef attributesOfColumns();
167     JSStringRef attributesOfRows();
168     JSStringRef attributesOfVisibleCells();
169     JSStringRef attributesOfHeader();
170     int indexInTable();
171     JSStringRef rowIndexRange();
172     JSStringRef columnIndexRange();
173     int rowCount();
174     int columnCount();
175     
176     // Tree/Outline specific attributes
177     AccessibilityUIElement selectedRowAtIndex(unsigned);
178     AccessibilityUIElement disclosedByRow();
179     AccessibilityUIElement disclosedRowAtIndex(unsigned);
180
181     // ARIA specific
182     AccessibilityUIElement ariaOwnsElementAtIndex(unsigned);
183     AccessibilityUIElement ariaFlowToElementAtIndex(unsigned);
184
185     // ARIA Drag and Drop
186     bool ariaIsGrabbed() const;
187     // A space concatentated string of all the drop effects.
188     JSStringRef ariaDropEffects() const;
189     
190     // Parameterized attributes
191     int lineForIndex(int);
192     JSStringRef rangeForLine(int);
193     JSStringRef boundsForRange(unsigned location, unsigned length);
194     void setSelectedTextRange(unsigned location, unsigned length);
195     JSStringRef stringForRange(unsigned location, unsigned length);
196     JSStringRef attributedStringForRange(unsigned location, unsigned length);
197     bool attributedStringRangeIsMisspelled(unsigned location, unsigned length);
198     AccessibilityUIElement uiElementForSearchPredicate(AccessibilityUIElement* startElement, bool isDirectionNext, JSStringRef searchKey, JSStringRef searchText);
199     
200     // Table-specific
201     AccessibilityUIElement cellForColumnAndRow(unsigned column, unsigned row);
202
203     // Scrollarea-specific
204     AccessibilityUIElement horizontalScrollbar() const;
205     AccessibilityUIElement verticalScrollbar() const;
206
207     // Text markers.
208     AccessibilityTextMarkerRange textMarkerRangeForElement(AccessibilityUIElement*);    
209     AccessibilityTextMarkerRange textMarkerRangeForMarkers(AccessibilityTextMarker* startMarker, AccessibilityTextMarker* endMarker);
210     AccessibilityTextMarker startTextMarkerForTextMarkerRange(AccessibilityTextMarkerRange*);
211     AccessibilityTextMarker endTextMarkerForTextMarkerRange(AccessibilityTextMarkerRange*);
212     AccessibilityTextMarker textMarkerForPoint(int x, int y);
213     AccessibilityTextMarker previousTextMarker(AccessibilityTextMarker*);
214     AccessibilityTextMarker nextTextMarker(AccessibilityTextMarker*);
215     AccessibilityUIElement accessibilityElementForTextMarker(AccessibilityTextMarker*);
216     JSStringRef stringForTextMarkerRange(AccessibilityTextMarkerRange*);
217     int textMarkerRangeLength(AccessibilityTextMarkerRange*);
218     
219     // Notifications
220     // Function callback should take one argument, the name of the notification.
221     bool addNotificationListener(JSObjectRef functionCallback);
222     // Make sure you call remove, because you can't rely on objects being deallocated in a timely fashion.
223     void removeNotificationListener();
224     
225 private:
226     static JSClassRef getJSClass();
227     PlatformUIElement m_element;
228     
229     // A retained, platform specific object used to help manage notifications for this object.
230 #if PLATFORM(MAC)
231     NotificationHandler m_notificationHandler;
232 #endif
233 };
234
235 #endif // AccessibilityUIElement_h