WebKitTools/DumpRenderTree/AccessibilityUIElement.h
changeset 0 4f2f89ce4247
equal deleted inserted replaced
-1:000000000000 0:4f2f89ce4247
       
     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 #if PLATFORM(MAC)
       
    55 #ifdef __OBJC__
       
    56 typedef id NotificationHandler;
       
    57 #else
       
    58 typedef struct objc_object* NotificationHandler;
       
    59 #endif
       
    60 #endif
       
    61 
       
    62 class AccessibilityUIElement {
       
    63 public:
       
    64     AccessibilityUIElement(PlatformUIElement);
       
    65     AccessibilityUIElement(const AccessibilityUIElement&);
       
    66     ~AccessibilityUIElement();
       
    67 
       
    68     PlatformUIElement platformUIElement() { return m_element; }
       
    69 
       
    70     static JSObjectRef makeJSAccessibilityUIElement(JSContextRef, const AccessibilityUIElement&);
       
    71 
       
    72     bool isEqual(AccessibilityUIElement* otherElement) { return platformUIElement() == otherElement->platformUIElement(); }
       
    73     
       
    74     void getLinkedUIElements(Vector<AccessibilityUIElement>&);
       
    75     void getDocumentLinks(Vector<AccessibilityUIElement>&);
       
    76     void getChildren(Vector<AccessibilityUIElement>&);
       
    77     void getChildrenWithRange(Vector<AccessibilityUIElement>&, unsigned location, unsigned length);
       
    78     
       
    79     AccessibilityUIElement elementAtPoint(int x, int y);
       
    80     AccessibilityUIElement getChildAtIndex(unsigned);
       
    81     unsigned indexOfChild(AccessibilityUIElement*);
       
    82     int childrenCount();
       
    83     AccessibilityUIElement titleUIElement();
       
    84     AccessibilityUIElement parentElement();
       
    85 
       
    86     void takeFocus();
       
    87     void takeSelection();
       
    88     void addSelection();
       
    89     void removeSelection();
       
    90 
       
    91     // Methods - platform-independent implementations
       
    92     JSStringRef allAttributes();
       
    93     JSStringRef attributesOfLinkedUIElements();
       
    94     AccessibilityUIElement linkedUIElementAtIndex(unsigned);
       
    95     
       
    96     JSStringRef attributesOfDocumentLinks();
       
    97     JSStringRef attributesOfChildren();
       
    98     JSStringRef parameterizedAttributeNames();
       
    99     void increment();
       
   100     void decrement();
       
   101     void showMenu();
       
   102     void press();
       
   103 
       
   104     // Attributes - platform-independent implementations
       
   105     JSStringRef stringAttributeValue(JSStringRef attribute);
       
   106     bool boolAttributeValue(JSStringRef attribute);
       
   107     bool isAttributeSupported(JSStringRef attribute);
       
   108     bool isAttributeSettable(JSStringRef attribute);
       
   109     bool isActionSupported(JSStringRef action);
       
   110     JSStringRef role();
       
   111     JSStringRef subrole();
       
   112     JSStringRef roleDescription();
       
   113     JSStringRef title();
       
   114     JSStringRef description();
       
   115     JSStringRef language();
       
   116     JSStringRef stringValue();
       
   117     JSStringRef accessibilityValue() const;
       
   118     JSStringRef helpText() const;
       
   119     JSStringRef orientation() const;
       
   120     double x();
       
   121     double y();
       
   122     double width();
       
   123     double height();
       
   124     double intValue() const;
       
   125     double minValue();
       
   126     double maxValue();
       
   127     JSStringRef valueDescription();
       
   128     int insertionPointLineNumber();
       
   129     JSStringRef selectedTextRange();
       
   130     bool isEnabled();
       
   131     bool isRequired() const;
       
   132     bool isSelected() const;
       
   133     bool isSelectable() const;
       
   134     bool isMultiSelectable() const;
       
   135     bool isExpanded() const;
       
   136     bool isChecked() const;
       
   137     bool isVisible() const;
       
   138     bool isOffScreen() const;
       
   139     bool isCollapsed() const;
       
   140     bool hasPopup() const;
       
   141     int hierarchicalLevel() const;
       
   142     double clickPointX();
       
   143     double clickPointY();
       
   144     JSStringRef documentEncoding();
       
   145     JSStringRef documentURI();
       
   146     JSStringRef url();
       
   147 
       
   148     // Table-specific attributes
       
   149     JSStringRef attributesOfColumnHeaders();
       
   150     JSStringRef attributesOfRowHeaders();
       
   151     JSStringRef attributesOfColumns();
       
   152     JSStringRef attributesOfRows();
       
   153     JSStringRef attributesOfVisibleCells();
       
   154     JSStringRef attributesOfHeader();
       
   155     int indexInTable();
       
   156     JSStringRef rowIndexRange();
       
   157     JSStringRef columnIndexRange();
       
   158     int rowCount();
       
   159     int columnCount();
       
   160     
       
   161     // Tree/Outline specific attributes
       
   162     AccessibilityUIElement selectedRowAtIndex(unsigned);
       
   163     AccessibilityUIElement disclosedByRow();
       
   164     AccessibilityUIElement disclosedRowAtIndex(unsigned);
       
   165 
       
   166     // ARIA specific
       
   167     AccessibilityUIElement ariaOwnsElementAtIndex(unsigned);
       
   168     AccessibilityUIElement ariaFlowToElementAtIndex(unsigned);
       
   169 
       
   170     // ARIA Drag and Drop
       
   171     bool ariaIsGrabbed() const;
       
   172     // A space concatentated string of all the drop effects.
       
   173     JSStringRef ariaDropEffects() const;
       
   174     
       
   175     // Parameterized attributes
       
   176     int lineForIndex(int);
       
   177     JSStringRef boundsForRange(unsigned location, unsigned length);
       
   178     void setSelectedTextRange(unsigned location, unsigned length);
       
   179     JSStringRef stringForRange(unsigned location, unsigned length);
       
   180     
       
   181     // Table-specific
       
   182     AccessibilityUIElement cellForColumnAndRow(unsigned column, unsigned row);
       
   183 
       
   184     // Notifications
       
   185     // Function callback should take one argument, the name of the notification.
       
   186     bool addNotificationListener(JSObjectRef functionCallback);
       
   187     // Make sure you call remove, because you can't rely on objects being deallocated in a timely fashion.
       
   188     void removeNotificationListener();
       
   189     
       
   190 private:
       
   191     static JSClassRef getJSClass();
       
   192     PlatformUIElement m_element;
       
   193     
       
   194     // A retained, platform specific object used to help manage notifications for this object.
       
   195 #if PLATFORM(MAC)
       
   196     NotificationHandler m_notificationHandler;
       
   197 #endif
       
   198 };
       
   199 
       
   200 #endif // AccessibilityUIElement_h