1 /* 2 * Copyright (C) 2010 Google 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 are 6 * met: 7 * 8 * * Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * * Redistributions in binary form must reproduce the above 11 * copyright notice, this list of conditions and the following disclaimer 12 * in the documentation and/or other materials provided with the 13 * distribution. 14 * * Neither the name of Google Inc. nor the names of its 15 * contributors may be used to endorse or promote products derived from 16 * this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31 #ifndef AccessibilityUIElementChromium_h 32 #define AccessibilityUIElementChromium_h 33 34 #include "CppBoundClass.h" 35 #include "public/web/WebAccessibilityObject.h" 36 #include <vector> 37 38 namespace WebTestRunner { 39 40 class AccessibilityUIElement : public CppBoundClass { 41 public: 42 class Factory { 43 public: 44 virtual ~Factory() { } 45 virtual AccessibilityUIElement* getOrCreate(const WebKit::WebAccessibilityObject&) = 0; 46 }; 47 48 AccessibilityUIElement(const WebKit::WebAccessibilityObject&, Factory*); 49 50 virtual AccessibilityUIElement* getChildAtIndex(unsigned); 51 virtual bool isRoot() const { return false; } 52 virtual bool isEqual(const WebKit::WebAccessibilityObject&); 53 54 virtual void notificationReceived(const char *notificationName); 55 56 protected: 57 const WebKit::WebAccessibilityObject& accessibilityObject() const { return m_accessibilityObject; } 58 59 Factory* factory() const { return m_factory; } 60 61 private: 62 // Bound properties. 63 void roleGetterCallback(CppVariant*); 64 void titleGetterCallback(CppVariant*); 65 void descriptionGetterCallback(CppVariant*); 66 void helpTextGetterCallback(CppVariant*); 67 void stringValueGetterCallback(CppVariant*); 68 void xGetterCallback(CppVariant*); 69 void yGetterCallback(CppVariant*); 70 void widthGetterCallback(CppVariant*); 71 void heightGetterCallback(CppVariant*); 72 void intValueGetterCallback(CppVariant*); 73 void minValueGetterCallback(CppVariant*); 74 void maxValueGetterCallback(CppVariant*); 75 void valueDescriptionGetterCallback(CppVariant*); 76 void childrenCountGetterCallback(CppVariant*); 77 void insertionPointLineNumberGetterCallback(CppVariant*); 78 void selectedTextRangeGetterCallback(CppVariant*); 79 void isEnabledGetterCallback(CppVariant*); 80 void isRequiredGetterCallback(CppVariant*); 81 void isFocusedGetterCallback(CppVariant*); 82 void isFocusableGetterCallback(CppVariant*); 83 void isSelectedGetterCallback(CppVariant*); 84 void isSelectableGetterCallback(CppVariant*); 85 void isMultiSelectableGetterCallback(CppVariant*); 86 void isSelectedOptionActiveGetterCallback(CppVariant*); 87 void isExpandedGetterCallback(CppVariant*); 88 void isCheckedGetterCallback(CppVariant*); 89 void isVisibleGetterCallback(CppVariant*); 90 void isOffScreenGetterCallback(CppVariant*); 91 void isCollapsedGetterCallback(CppVariant*); 92 void hasPopupGetterCallback(CppVariant*); 93 void isValidGetterCallback(CppVariant*); 94 void isReadOnlyGetterCallback(CppVariant*); 95 void orientationGetterCallback(CppVariant*); 96 void clickPointXGetterCallback(CppVariant*); 97 void clickPointYGetterCallback(CppVariant*); 98 void rowCountGetterCallback(CppVariant*); 99 void columnCountGetterCallback(CppVariant*); 100 101 // Bound methods. 102 void allAttributesCallback(const CppArgumentList&, CppVariant*); 103 void attributesOfLinkedUIElementsCallback(const CppArgumentList&, CppVariant*); 104 void attributesOfDocumentLinksCallback(const CppArgumentList&, CppVariant*); 105 void attributesOfChildrenCallback(const CppArgumentList&, CppVariant*); 106 void parametrizedAttributeNamesCallback(const CppArgumentList&, CppVariant*); 107 void lineForIndexCallback(const CppArgumentList&, CppVariant*); 108 void boundsForRangeCallback(const CppArgumentList&, CppVariant*); 109 void stringForRangeCallback(const CppArgumentList&, CppVariant*); 110 void childAtIndexCallback(const CppArgumentList&, CppVariant*); 111 void elementAtPointCallback(const CppArgumentList&, CppVariant*); 112 void attributesOfColumnHeadersCallback(const CppArgumentList&, CppVariant*); 113 void attributesOfRowHeadersCallback(const CppArgumentList&, CppVariant*); 114 void attributesOfColumnsCallback(const CppArgumentList&, CppVariant*); 115 void attributesOfRowsCallback(const CppArgumentList&, CppVariant*); 116 void attributesOfVisibleCellsCallback(const CppArgumentList&, CppVariant*); 117 void attributesOfHeaderCallback(const CppArgumentList&, CppVariant*); 118 void tableHeaderCallback(const CppArgumentList&, CppVariant*); 119 void indexInTableCallback(const CppArgumentList&, CppVariant*); 120 void rowIndexRangeCallback(const CppArgumentList&, CppVariant*); 121 void columnIndexRangeCallback(const CppArgumentList&, CppVariant*); 122 void cellForColumnAndRowCallback(const CppArgumentList&, CppVariant*); 123 void titleUIElementCallback(const CppArgumentList&, CppVariant*); 124 void setSelectedTextRangeCallback(const CppArgumentList&, CppVariant*); 125 void attributeValueCallback(const CppArgumentList&, CppVariant*); 126 void isAttributeSettableCallback(const CppArgumentList&, CppVariant*); 127 void isPressActionSupportedCallback(const CppArgumentList&, CppVariant*); 128 void isIncrementActionSupportedCallback(const CppArgumentList&, CppVariant*); 129 void isDecrementActionSupportedCallback(const CppArgumentList&, CppVariant*); 130 void parentElementCallback(const CppArgumentList&, CppVariant*); 131 void incrementCallback(const CppArgumentList&, CppVariant*); 132 void decrementCallback(const CppArgumentList&, CppVariant*); 133 void showMenuCallback(const CppArgumentList&, CppVariant*); 134 void pressCallback(const CppArgumentList&, CppVariant*); 135 void isEqualCallback(const CppArgumentList&, CppVariant*); 136 void addNotificationListenerCallback(const CppArgumentList&, CppVariant*); 137 void removeNotificationListenerCallback(const CppArgumentList&, CppVariant*); 138 void takeFocusCallback(const CppArgumentList&, CppVariant*); 139 void scrollToMakeVisibleCallback(const CppArgumentList&, CppVariant*); 140 void scrollToMakeVisibleWithSubFocusCallback(const CppArgumentList&, CppVariant*); 141 void scrollToGlobalPointCallback(const CppArgumentList&, CppVariant*); 142 143 void fallbackCallback(const CppArgumentList&, CppVariant*); 144 145 WebKit::WebAccessibilityObject m_accessibilityObject; 146 Factory* m_factory; 147 std::vector<CppVariant> m_notificationCallbacks; 148 }; 149 150 151 class RootAccessibilityUIElement : public AccessibilityUIElement { 152 public: 153 RootAccessibilityUIElement(const WebKit::WebAccessibilityObject&, Factory*); 154 155 virtual AccessibilityUIElement* getChildAtIndex(unsigned); 156 virtual bool isRoot() const { return true; } 157 }; 158 159 160 // Provides simple lifetime management of the AccessibilityUIElement instances: 161 // all AccessibilityUIElements ever created from the controller are stored in 162 // a list and cleared explicitly. 163 class AccessibilityUIElementList : public AccessibilityUIElement::Factory { 164 public: 165 AccessibilityUIElementList() { } 166 virtual ~AccessibilityUIElementList(); 167 168 void clear(); 169 virtual AccessibilityUIElement* getOrCreate(const WebKit::WebAccessibilityObject&); 170 AccessibilityUIElement* createRoot(const WebKit::WebAccessibilityObject&); 171 172 private: 173 typedef std::vector<AccessibilityUIElement*> ElementList; 174 ElementList m_elements; 175 }; 176 177 } 178 179 #endif // AccessibilityUIElementChromium_h 180