AccessibilityUIElement.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  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. #ifndef AccessibilityUIElement_h
  26. #define AccessibilityUIElement_h
  27. #include "AccessibilityTextMarker.h"
  28. #include <JavaScriptCore/JSObjectRef.h>
  29. #include <wtf/Platform.h>
  30. #include <wtf/Vector.h>
  31. #if PLATFORM(MAC)
  32. #ifdef __OBJC__
  33. typedef id PlatformUIElement;
  34. #else
  35. typedef struct objc_object* PlatformUIElement;
  36. #endif
  37. #elif PLATFORM(WIN)
  38. #undef _WINSOCKAPI_
  39. #define _WINSOCKAPI_ // Prevent inclusion of winsock.h in windows.h
  40. #include <WebCore/COMPtr.h>
  41. #include <oleacc.h>
  42. typedef COMPtr<IAccessible> PlatformUIElement;
  43. #elif HAVE(ACCESSIBILITY) && (PLATFORM(GTK) || PLATFORM(EFL))
  44. #include <atk/atk.h>
  45. typedef AtkObject* PlatformUIElement;
  46. #else
  47. typedef void* PlatformUIElement;
  48. #endif
  49. #if PLATFORM(MAC)
  50. #ifdef __OBJC__
  51. typedef id NotificationHandler;
  52. #else
  53. typedef struct objc_object* NotificationHandler;
  54. #endif
  55. #endif
  56. class AccessibilityUIElement {
  57. public:
  58. AccessibilityUIElement(PlatformUIElement);
  59. AccessibilityUIElement(const AccessibilityUIElement&);
  60. ~AccessibilityUIElement();
  61. PlatformUIElement platformUIElement() { return m_element; }
  62. static JSObjectRef makeJSAccessibilityUIElement(JSContextRef, const AccessibilityUIElement&);
  63. bool isEqual(AccessibilityUIElement* otherElement);
  64. void getLinkedUIElements(Vector<AccessibilityUIElement>&);
  65. void getDocumentLinks(Vector<AccessibilityUIElement>&);
  66. void getChildren(Vector<AccessibilityUIElement>&);
  67. void getChildrenWithRange(Vector<AccessibilityUIElement>&, unsigned location, unsigned length);
  68. AccessibilityUIElement elementAtPoint(int x, int y);
  69. AccessibilityUIElement getChildAtIndex(unsigned);
  70. unsigned indexOfChild(AccessibilityUIElement*);
  71. int childrenCount();
  72. AccessibilityUIElement titleUIElement();
  73. AccessibilityUIElement parentElement();
  74. void takeFocus();
  75. void takeSelection();
  76. void addSelection();
  77. void removeSelection();
  78. // Methods - platform-independent implementations
  79. JSStringRef allAttributes();
  80. JSStringRef attributesOfLinkedUIElements();
  81. AccessibilityUIElement linkedUIElementAtIndex(unsigned);
  82. JSStringRef attributesOfDocumentLinks();
  83. JSStringRef attributesOfChildren();
  84. JSStringRef parameterizedAttributeNames();
  85. void increment();
  86. void decrement();
  87. void showMenu();
  88. void press();
  89. // Attributes - platform-independent implementations
  90. JSStringRef stringAttributeValue(JSStringRef attribute);
  91. double numberAttributeValue(JSStringRef attribute);
  92. AccessibilityUIElement uiElementAttributeValue(JSStringRef attribute) const;
  93. bool boolAttributeValue(JSStringRef attribute);
  94. bool isAttributeSupported(JSStringRef attribute);
  95. bool isAttributeSettable(JSStringRef attribute);
  96. bool isPressActionSupported();
  97. bool isIncrementActionSupported();
  98. bool isDecrementActionSupported();
  99. JSStringRef role();
  100. JSStringRef subrole();
  101. JSStringRef roleDescription();
  102. JSStringRef title();
  103. JSStringRef description();
  104. JSStringRef language();
  105. JSStringRef stringValue();
  106. JSStringRef accessibilityValue() const;
  107. JSStringRef helpText() const;
  108. JSStringRef orientation() const;
  109. double x();
  110. double y();
  111. double width();
  112. double height();
  113. double intValue() const;
  114. double minValue();
  115. double maxValue();
  116. JSStringRef pathDescription() const;
  117. JSStringRef valueDescription();
  118. int insertionPointLineNumber();
  119. JSStringRef selectedTextRange();
  120. bool isEnabled();
  121. bool isRequired() const;
  122. bool isFocused() const;
  123. bool isFocusable() const;
  124. bool isSelected() const;
  125. bool isSelectable() const;
  126. bool isMultiSelectable() const;
  127. bool isSelectedOptionActive() const;
  128. void setSelectedChild(AccessibilityUIElement*) const;
  129. unsigned selectedChildrenCount() const;
  130. AccessibilityUIElement selectedChildAtIndex(unsigned) const;
  131. bool isExpanded() const;
  132. bool isChecked() const;
  133. bool isVisible() const;
  134. bool isOffScreen() const;
  135. bool isCollapsed() const;
  136. bool isIgnored() const;
  137. bool hasPopup() const;
  138. int hierarchicalLevel() const;
  139. double clickPointX();
  140. double clickPointY();
  141. JSStringRef documentEncoding();
  142. JSStringRef documentURI();
  143. JSStringRef url();
  144. // CSS3-speech properties.
  145. JSStringRef speak();
  146. // Table-specific attributes
  147. JSStringRef attributesOfColumnHeaders();
  148. JSStringRef attributesOfRowHeaders();
  149. JSStringRef attributesOfColumns();
  150. JSStringRef attributesOfRows();
  151. JSStringRef attributesOfVisibleCells();
  152. JSStringRef attributesOfHeader();
  153. int indexInTable();
  154. JSStringRef rowIndexRange();
  155. JSStringRef columnIndexRange();
  156. int rowCount();
  157. int columnCount();
  158. // Tree/Outline specific attributes
  159. AccessibilityUIElement selectedRowAtIndex(unsigned);
  160. AccessibilityUIElement disclosedByRow();
  161. AccessibilityUIElement disclosedRowAtIndex(unsigned);
  162. AccessibilityUIElement rowAtIndex(unsigned);
  163. // ARIA specific
  164. AccessibilityUIElement ariaOwnsElementAtIndex(unsigned);
  165. AccessibilityUIElement ariaFlowToElementAtIndex(unsigned);
  166. // ARIA Drag and Drop
  167. bool ariaIsGrabbed() const;
  168. // A space concatentated string of all the drop effects.
  169. JSStringRef ariaDropEffects() const;
  170. // Parameterized attributes
  171. int lineForIndex(int);
  172. JSStringRef rangeForLine(int);
  173. JSStringRef rangeForPosition(int x, int y);
  174. JSStringRef boundsForRange(unsigned location, unsigned length);
  175. void setSelectedTextRange(unsigned location, unsigned length);
  176. JSStringRef stringForRange(unsigned location, unsigned length);
  177. JSStringRef attributedStringForRange(unsigned location, unsigned length);
  178. bool attributedStringRangeIsMisspelled(unsigned location, unsigned length);
  179. AccessibilityUIElement uiElementForSearchPredicate(JSContextRef, AccessibilityUIElement* startElement, bool isDirectionNext, JSValueRef searchKey, JSStringRef searchText, bool visibleOnly);
  180. #if PLATFORM(IOS)
  181. void elementsForRange(unsigned location, unsigned length, Vector<AccessibilityUIElement>& elements);
  182. JSStringRef stringForSelection();
  183. void increaseTextSelection();
  184. void decreaseTextSelection();
  185. AccessibilityUIElement linkedElement();
  186. #endif
  187. // Table-specific
  188. AccessibilityUIElement cellForColumnAndRow(unsigned column, unsigned row);
  189. // Scrollarea-specific
  190. AccessibilityUIElement horizontalScrollbar() const;
  191. AccessibilityUIElement verticalScrollbar() const;
  192. // Text markers.
  193. AccessibilityTextMarkerRange textMarkerRangeForElement(AccessibilityUIElement*);
  194. AccessibilityTextMarkerRange textMarkerRangeForMarkers(AccessibilityTextMarker* startMarker, AccessibilityTextMarker* endMarker);
  195. AccessibilityTextMarker startTextMarkerForTextMarkerRange(AccessibilityTextMarkerRange*);
  196. AccessibilityTextMarker endTextMarkerForTextMarkerRange(AccessibilityTextMarkerRange*);
  197. AccessibilityTextMarker textMarkerForPoint(int x, int y);
  198. AccessibilityTextMarker previousTextMarker(AccessibilityTextMarker*);
  199. AccessibilityTextMarker nextTextMarker(AccessibilityTextMarker*);
  200. AccessibilityUIElement accessibilityElementForTextMarker(AccessibilityTextMarker*);
  201. JSStringRef stringForTextMarkerRange(AccessibilityTextMarkerRange*);
  202. int textMarkerRangeLength(AccessibilityTextMarkerRange*);
  203. bool attributedStringForTextMarkerRangeContainsAttribute(JSStringRef, AccessibilityTextMarkerRange*);
  204. int indexForTextMarker(AccessibilityTextMarker*);
  205. bool isTextMarkerValid(AccessibilityTextMarker*);
  206. AccessibilityTextMarker textMarkerForIndex(int);
  207. void scrollToMakeVisible();
  208. void scrollToMakeVisibleWithSubFocus(int x, int y, int width, int height);
  209. void scrollToGlobalPoint(int x, int y);
  210. // Notifications
  211. // Function callback should take one argument, the name of the notification.
  212. bool addNotificationListener(JSObjectRef functionCallback);
  213. // Make sure you call remove, because you can't rely on objects being deallocated in a timely fashion.
  214. void removeNotificationListener();
  215. #if PLATFORM(IOS)
  216. JSStringRef iphoneLabel();
  217. JSStringRef iphoneValue();
  218. JSStringRef iphoneTraits();
  219. JSStringRef iphoneHint();
  220. JSStringRef iphoneIdentifier();
  221. bool iphoneIsElement();
  222. int iphoneElementTextPosition();
  223. int iphoneElementTextLength();
  224. AccessibilityUIElement headerElementAtIndex(unsigned);
  225. // This will simulate the accessibilityDidBecomeFocused API in UIKit.
  226. void assistiveTechnologySimulatedFocus();
  227. #endif // PLATFORM(IOS)
  228. #if PLATFORM(MAC) && !PLATFORM(IOS)
  229. // Returns an ordered list of supported actions for an element.
  230. JSStringRef supportedActions();
  231. // A general description of the elements making up multiscript pre/post objects.
  232. JSStringRef mathPostscriptsDescription() const;
  233. JSStringRef mathPrescriptsDescription() const;
  234. #endif
  235. private:
  236. static JSClassRef getJSClass();
  237. PlatformUIElement m_element;
  238. // A retained, platform specific object used to help manage notifications for this object.
  239. #if PLATFORM(MAC)
  240. NotificationHandler m_notificationHandler;
  241. #endif
  242. };
  243. #endif // AccessibilityUIElement_h