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 platformUIElement()60 PlatformUIElement platformUIElement() { return m_element; } 61 62 static JSObjectRef makeJSAccessibilityUIElement(JSContextRef, const AccessibilityUIElement&); 63 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 69 AccessibilityUIElement elementAtPoint(int x, int y); 70 AccessibilityUIElement getChildAtIndex(unsigned); 71 int childrenCount(); 72 AccessibilityUIElement titleUIElement(); 73 AccessibilityUIElement parentElement(); 74 75 // Methods - platform-independent implementations 76 JSStringRef allAttributes(); 77 JSStringRef attributesOfLinkedUIElements(); 78 JSStringRef attributesOfDocumentLinks(); 79 JSStringRef attributesOfChildren(); 80 JSStringRef parameterizedAttributeNames(); 81 void increment(); 82 void decrement(); 83 84 // Attributes - platform-independent implementations 85 JSStringRef attributeValue(JSStringRef attribute); 86 bool isAttributeSettable(JSStringRef attribute); 87 bool isActionSupported(JSStringRef action); 88 JSStringRef role(); 89 JSStringRef title(); 90 JSStringRef description(); 91 JSStringRef language(); 92 double x(); 93 double y(); 94 double width(); 95 double height(); 96 double intValue(); 97 double minValue(); 98 double maxValue(); 99 JSStringRef valueDescription(); 100 int insertionPointLineNumber(); 101 JSStringRef selectedTextRange(); 102 bool isEnabled(); 103 bool isRequired() const; 104 double clickPointX(); 105 double clickPointY(); 106 107 // Table-specific attributes 108 JSStringRef attributesOfColumnHeaders(); 109 JSStringRef attributesOfRowHeaders(); 110 JSStringRef attributesOfColumns(); 111 JSStringRef attributesOfRows(); 112 JSStringRef attributesOfVisibleCells(); 113 JSStringRef attributesOfHeader(); 114 int indexInTable(); 115 JSStringRef rowIndexRange(); 116 JSStringRef columnIndexRange(); 117 118 // Parameterized attributes 119 int lineForIndex(int); 120 JSStringRef boundsForRange(unsigned location, unsigned length); 121 void setSelectedTextRange(unsigned location, unsigned length); 122 123 // Table-specific 124 AccessibilityUIElement cellForColumnAndRow(unsigned column, unsigned row); 125 126 private: 127 static JSClassRef getJSClass(); 128 129 PlatformUIElement m_element; 130 }; 131 132 #endif // AccessibilityUIElement_h 133