Fix clearing text issue of email composer
[framework/web/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     AccessibilityUIElement rowAtIndex(unsigned);
181
182     // ARIA specific
183     AccessibilityUIElement ariaOwnsElementAtIndex(unsigned);
184     AccessibilityUIElement ariaFlowToElementAtIndex(unsigned);
185
186     // ARIA Drag and Drop
187     bool ariaIsGrabbed() const;
188     // A space concatentated string of all the drop effects.
189     JSStringRef ariaDropEffects() const;
190     
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);
201     
202     // Table-specific
203     AccessibilityUIElement cellForColumnAndRow(unsigned column, unsigned row);
204
205     // Scrollarea-specific
206     AccessibilityUIElement horizontalScrollbar() const;
207     AccessibilityUIElement verticalScrollbar() const;
208
209     // Text markers.
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);
224     
225     void scrollToMakeVisible();
226     void scrollToMakeVisibleWithSubFocus(int x, int y, int width, int height);
227     void scrollToGlobalPoint(int x, int y);
228
229     // Notifications
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();
234     
235 private:
236     static JSClassRef getJSClass();
237     PlatformUIElement m_element;
238     
239     // A retained, platform specific object used to help manage notifications for this object.
240 #if PLATFORM(MAC)
241     NotificationHandler m_notificationHandler;
242 #endif
243 };
244
245 #endif // AccessibilityUIElement_h