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 WebAXObjectProxy_h 32 #define WebAXObjectProxy_h 33 34 #include "CppBoundClass.h" 35 #include "public/web/WebAXObject.h" 36 #include <vector> 37 38 namespace WebTestRunner { 39 40 class WebAXObjectProxy : public CppBoundClass { 41 public: 42 class Factory { 43 public: 44 virtual ~Factory() { } 45 virtual WebAXObjectProxy* getOrCreate(const blink::WebAXObject&) = 0; 46 }; 47 48 WebAXObjectProxy(const blink::WebAXObject&, Factory*); 49 50 virtual WebAXObjectProxy* getChildAtIndex(unsigned); 51 virtual bool isRoot() const { return false; } 52 virtual bool isEqual(const blink::WebAXObject&); 53 54 virtual void notificationReceived(const char *notificationName); 55 56 protected: 57 const blink::WebAXObject& 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 void isClickableGetterCallback(CppVariant*); 101 102 // Bound methods. 103 void allAttributesCallback(const CppArgumentList&, CppVariant*); 104 void attributesOfChildrenCallback(const CppArgumentList&, CppVariant*); 105 void lineForIndexCallback(const CppArgumentList&, CppVariant*); 106 void boundsForRangeCallback(const CppArgumentList&, CppVariant*); 107 void childAtIndexCallback(const CppArgumentList&, CppVariant*); 108 void elementAtPointCallback(const CppArgumentList&, CppVariant*); 109 void tableHeaderCallback(const CppArgumentList&, CppVariant*); 110 void rowIndexRangeCallback(const CppArgumentList&, CppVariant*); 111 void columnIndexRangeCallback(const CppArgumentList&, CppVariant*); 112 void cellForColumnAndRowCallback(const CppArgumentList&, CppVariant*); 113 void titleUIElementCallback(const CppArgumentList&, CppVariant*); 114 void setSelectedTextRangeCallback(const CppArgumentList&, CppVariant*); 115 void isAttributeSettableCallback(const CppArgumentList&, CppVariant*); 116 void isPressActionSupportedCallback(const CppArgumentList&, CppVariant*); 117 void isIncrementActionSupportedCallback(const CppArgumentList&, CppVariant*); 118 void isDecrementActionSupportedCallback(const CppArgumentList&, CppVariant*); 119 void parentElementCallback(const CppArgumentList&, CppVariant*); 120 void incrementCallback(const CppArgumentList&, CppVariant*); 121 void decrementCallback(const CppArgumentList&, CppVariant*); 122 void showMenuCallback(const CppArgumentList&, CppVariant*); 123 void pressCallback(const CppArgumentList&, CppVariant*); 124 void isEqualCallback(const CppArgumentList&, CppVariant*); 125 void addNotificationListenerCallback(const CppArgumentList&, CppVariant*); 126 void removeNotificationListenerCallback(const CppArgumentList&, CppVariant*); 127 void takeFocusCallback(const CppArgumentList&, CppVariant*); 128 void scrollToMakeVisibleCallback(const CppArgumentList&, CppVariant*); 129 void scrollToMakeVisibleWithSubFocusCallback(const CppArgumentList&, CppVariant*); 130 void scrollToGlobalPointCallback(const CppArgumentList&, CppVariant*); 131 void wordStartCallback(const CppArgumentList&, CppVariant*); 132 void wordEndCallback(const CppArgumentList&, CppVariant*); 133 134 void fallbackCallback(const CppArgumentList&, CppVariant*); 135 136 blink::WebAXObject m_accessibilityObject; 137 Factory* m_factory; 138 std::vector<CppVariant> m_notificationCallbacks; 139 }; 140 141 142 class RootWebAXObjectProxy : public WebAXObjectProxy { 143 public: 144 RootWebAXObjectProxy(const blink::WebAXObject&, Factory*); 145 146 virtual WebAXObjectProxy* getChildAtIndex(unsigned); 147 virtual bool isRoot() const { return true; } 148 }; 149 150 151 // Provides simple lifetime management of the WebAXObjectProxy instances: 152 // all WebAXObjectProxys ever created from the controller are stored in 153 // a list and cleared explicitly. 154 class WebAXObjectProxyList : public WebAXObjectProxy::Factory { 155 public: 156 WebAXObjectProxyList() { } 157 virtual ~WebAXObjectProxyList(); 158 159 void clear(); 160 virtual WebAXObjectProxy* getOrCreate(const blink::WebAXObject&); 161 WebAXObjectProxy* createRoot(const blink::WebAXObject&); 162 163 private: 164 typedef std::vector<WebAXObjectProxy*> ElementList; 165 ElementList m_elements; 166 }; 167 168 } 169 170 #endif // WebAXObjectProxy_h 171