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 <JavaScriptCore/JSObjectRef.h> 30 #include <wtf/Platform.h> 31 #include <wtf/Vector.h> 32 33 #if PLATFORM(MAC) 34 #ifdef __OBJC__ 35 typedef id PlatformUIElement; 36 #else 37 typedef struct objc_object* PlatformUIElement; 38 #endif 39 #elif PLATFORM(WIN) 40 #undef _WINSOCKAPI_ 41 #define _WINSOCKAPI_ // Prevent inclusion of winsock.h in windows.h 42 43 #include <oleacc.h> 44 #include <WebCore/COMPtr.h> 45 46 typedef COMPtr<IAccessible> PlatformUIElement; 47 #elif PLATFORM(GTK) 48 #include <atk/atk.h> 49 typedef AtkObject* PlatformUIElement; 50 #else 51 typedef void* PlatformUIElement; 52 #endif 53 54 class AccessibilityUIElement { 55 public: 56 AccessibilityUIElement(PlatformUIElement); 57 AccessibilityUIElement(const AccessibilityUIElement&); 58 ~AccessibilityUIElement(); 59 60 PlatformUIElement platformUIElement() { return m_element; } 61 62 static JSObjectRef makeJSAccessibilityUIElement(JSContextRef, const AccessibilityUIElement&); 63 64 bool isEqual(AccessibilityUIElement* otherElement) { return platformUIElement() == otherElement->platformUIElement(); } 65 66 void getLinkedUIElements(Vector<AccessibilityUIElement>&); 67 void getDocumentLinks(Vector<AccessibilityUIElement>&); 68 void getChildren(Vector<AccessibilityUIElement>&); 69 void getChildrenWithRange(Vector<AccessibilityUIElement>&, unsigned location, unsigned length); 70 71 AccessibilityUIElement elementAtPoint(int x, int y); 72 AccessibilityUIElement getChildAtIndex(unsigned); 73 unsigned indexOfChild(AccessibilityUIElement*); 74 int childrenCount(); 75 AccessibilityUIElement titleUIElement(); 76 AccessibilityUIElement parentElement(); 77 78 void takeFocus(); 79 void takeSelection(); 80 void addSelection(); 81 void removeSelection(); 82 83 // Methods - platform-independent implementations 84 JSStringRef allAttributes(); 85 JSStringRef attributesOfLinkedUIElements(); 86 JSStringRef attributesOfDocumentLinks(); 87 JSStringRef attributesOfChildren(); 88 JSStringRef parameterizedAttributeNames(); 89 void increment(); 90 void decrement(); 91 void showMenu(); 92 93 // Attributes - platform-independent implementations 94 JSStringRef stringAttributeValue(JSStringRef attribute); 95 bool boolAttributeValue(JSStringRef attribute); 96 bool isAttributeSupported(JSStringRef attribute); 97 bool isAttributeSettable(JSStringRef attribute); 98 bool isActionSupported(JSStringRef action); 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 orientation() const; 108 double x(); 109 double y(); 110 double width(); 111 double height(); 112 double intValue() const; 113 double minValue(); 114 double maxValue(); 115 JSStringRef valueDescription(); 116 int insertionPointLineNumber(); 117 JSStringRef selectedTextRange(); 118 bool isEnabled(); 119 bool isRequired() const; 120 bool isSelected() const; 121 bool isSelectable() const; 122 bool isMultiSelectable() const; 123 bool isExpanded() const; 124 bool isChecked() const; 125 bool isVisible() const; 126 bool isOffScreen() const; 127 bool isCollapsed() const; 128 bool hasPopup() const; 129 int hierarchicalLevel() const; 130 double clickPointX(); 131 double clickPointY(); 132 JSStringRef documentEncoding(); 133 JSStringRef documentURI(); 134 JSStringRef url(); 135 136 // Table-specific attributes 137 JSStringRef attributesOfColumnHeaders(); 138 JSStringRef attributesOfRowHeaders(); 139 JSStringRef attributesOfColumns(); 140 JSStringRef attributesOfRows(); 141 JSStringRef attributesOfVisibleCells(); 142 JSStringRef attributesOfHeader(); 143 int indexInTable(); 144 JSStringRef rowIndexRange(); 145 JSStringRef columnIndexRange(); 146 147 // Tree/Outline specific attributes 148 AccessibilityUIElement selectedRowAtIndex(unsigned); 149 AccessibilityUIElement disclosedByRow(); 150 AccessibilityUIElement disclosedRowAtIndex(unsigned); 151 152 // ARIA specific 153 AccessibilityUIElement ariaOwnsElementAtIndex(unsigned); 154 AccessibilityUIElement ariaFlowToElementAtIndex(unsigned); 155 156 // ARIA Drag and Drop 157 bool ariaIsGrabbed() const; 158 // A space concatentated string of all the drop effects. 159 JSStringRef ariaDropEffects() const; 160 161 // Parameterized attributes 162 int lineForIndex(int); 163 JSStringRef boundsForRange(unsigned location, unsigned length); 164 void setSelectedTextRange(unsigned location, unsigned length); 165 JSStringRef stringForRange(unsigned location, unsigned length); 166 167 // Table-specific 168 AccessibilityUIElement cellForColumnAndRow(unsigned column, unsigned row); 169 170 // Notifications 171 // Function callback should take one argument, the name of the notification. 172 bool addNotificationListener(JSObjectRef functionCallback); 173 174 private: 175 static JSClassRef getJSClass(); 176 177 PlatformUIElement m_element; 178 JSObjectRef m_notificationFunctionCallback; 179 }; 180 181 #endif // AccessibilityUIElement_h 182