[email protected] | 3338bcf | 2012-05-09 20:26:15 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 9599173 | 2009-10-14 22:18:16 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef WEBKIT_TOOLS_TEST_SHELL_ACCESSIBILITY_UI_ELEMENT_H_ |
| 6 | #define WEBKIT_TOOLS_TEST_SHELL_ACCESSIBILITY_UI_ELEMENT_H_ |
| 7 | |
| 8 | #include "webkit/glue/cpp_bound_class.h" |
[email protected] | c1d9cdc | 2011-01-17 06:50:01 | [diff] [blame] | 9 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityObject.h" |
[email protected] | 9599173 | 2009-10-14 22:18:16 | [diff] [blame] | 10 | |
[email protected] | 3338bcf | 2012-05-09 20:26:15 | [diff] [blame] | 11 | class AccessibilityUIElement : public webkit_glue::CppBoundClass { |
[email protected] | 9599173 | 2009-10-14 22:18:16 | [diff] [blame] | 12 | public: |
| 13 | class Factory { |
| 14 | public: |
| 15 | virtual ~Factory() { } |
| 16 | virtual AccessibilityUIElement* Create( |
| 17 | const WebKit::WebAccessibilityObject& object) = 0; |
| 18 | }; |
| 19 | |
| 20 | AccessibilityUIElement( |
| 21 | const WebKit::WebAccessibilityObject& accessibility_object, |
| 22 | Factory* factory); |
[email protected] | fadc607b6 | 2011-02-07 17:55:50 | [diff] [blame] | 23 | virtual ~AccessibilityUIElement(); |
[email protected] | 9599173 | 2009-10-14 22:18:16 | [diff] [blame] | 24 | |
| 25 | virtual AccessibilityUIElement* GetChildAtIndex(unsigned index); |
[email protected] | fadc607b6 | 2011-02-07 17:55:50 | [diff] [blame] | 26 | virtual bool IsRoot() const; |
[email protected] | 9599173 | 2009-10-14 22:18:16 | [diff] [blame] | 27 | |
[email protected] | 9599173 | 2009-10-14 22:18:16 | [diff] [blame] | 28 | protected: |
| 29 | const WebKit::WebAccessibilityObject& accessibility_object() const { |
| 30 | return accessibility_object_; |
| 31 | } |
| 32 | Factory* factory() const { return factory_; } |
| 33 | |
| 34 | private: |
| 35 | // Bound methods and properties. |
[email protected] | 3338bcf | 2012-05-09 20:26:15 | [diff] [blame] | 36 | void AllAttributesCallback( |
| 37 | const webkit_glue::CppArgumentList& args, |
| 38 | webkit_glue::CppVariant* result); |
[email protected] | 9599173 | 2009-10-14 22:18:16 | [diff] [blame] | 39 | void AttributesOfLinkedUIElementsCallback( |
[email protected] | 3338bcf | 2012-05-09 20:26:15 | [diff] [blame] | 40 | const webkit_glue::CppArgumentList& args, |
| 41 | webkit_glue::CppVariant* result); |
[email protected] | 9599173 | 2009-10-14 22:18:16 | [diff] [blame] | 42 | void AttributesOfDocumentLinksCallback( |
[email protected] | 3338bcf | 2012-05-09 20:26:15 | [diff] [blame] | 43 | const webkit_glue::CppArgumentList& args, |
| 44 | webkit_glue::CppVariant* result); |
[email protected] | 9599173 | 2009-10-14 22:18:16 | [diff] [blame] | 45 | void AttributesOfChildrenCallback( |
[email protected] | 3338bcf | 2012-05-09 20:26:15 | [diff] [blame] | 46 | const webkit_glue::CppArgumentList& args, |
| 47 | webkit_glue::CppVariant* result); |
[email protected] | 9599173 | 2009-10-14 22:18:16 | [diff] [blame] | 48 | void ParametrizedAttributeNamesCallback( |
[email protected] | 3338bcf | 2012-05-09 20:26:15 | [diff] [blame] | 49 | const webkit_glue::CppArgumentList& args, |
| 50 | webkit_glue::CppVariant* result); |
| 51 | void LineForIndexCallback( |
| 52 | const webkit_glue::CppArgumentList& args, |
| 53 | webkit_glue::CppVariant* result); |
| 54 | void BoundsForRangeCallback( |
| 55 | const webkit_glue::CppArgumentList& args, |
| 56 | webkit_glue::CppVariant* result); |
| 57 | void StringForRangeCallback( |
| 58 | const webkit_glue::CppArgumentList& args, |
| 59 | webkit_glue::CppVariant* result); |
| 60 | void ChildAtIndexCallback( |
| 61 | const webkit_glue::CppArgumentList& args, |
| 62 | webkit_glue::CppVariant* result); |
| 63 | void ElementAtPointCallback( |
| 64 | const webkit_glue::CppArgumentList& args, |
| 65 | webkit_glue::CppVariant* result); |
[email protected] | 9599173 | 2009-10-14 22:18:16 | [diff] [blame] | 66 | void AttributesOfColumnHeadersCallback( |
[email protected] | 3338bcf | 2012-05-09 20:26:15 | [diff] [blame] | 67 | const webkit_glue::CppArgumentList& args, |
| 68 | webkit_glue::CppVariant* result); |
[email protected] | 9599173 | 2009-10-14 22:18:16 | [diff] [blame] | 69 | void AttributesOfRowHeadersCallback( |
[email protected] | 3338bcf | 2012-05-09 20:26:15 | [diff] [blame] | 70 | const webkit_glue::CppArgumentList& args, |
| 71 | webkit_glue::CppVariant* result); |
[email protected] | 9599173 | 2009-10-14 22:18:16 | [diff] [blame] | 72 | void AttributesOfColumnsCallback( |
[email protected] | 3338bcf | 2012-05-09 20:26:15 | [diff] [blame] | 73 | const webkit_glue::CppArgumentList& args, |
| 74 | webkit_glue::CppVariant* result); |
[email protected] | 9599173 | 2009-10-14 22:18:16 | [diff] [blame] | 75 | void AttributesOfRowsCallback( |
[email protected] | 3338bcf | 2012-05-09 20:26:15 | [diff] [blame] | 76 | const webkit_glue::CppArgumentList& args, |
| 77 | webkit_glue::CppVariant* result); |
[email protected] | 9599173 | 2009-10-14 22:18:16 | [diff] [blame] | 78 | void AttributesOfVisibleCellsCallback( |
[email protected] | 3338bcf | 2012-05-09 20:26:15 | [diff] [blame] | 79 | const webkit_glue::CppArgumentList& args, |
| 80 | webkit_glue::CppVariant* result); |
[email protected] | 9599173 | 2009-10-14 22:18:16 | [diff] [blame] | 81 | void AttributesOfHeaderCallback( |
[email protected] | 3338bcf | 2012-05-09 20:26:15 | [diff] [blame] | 82 | const webkit_glue::CppArgumentList& args, |
| 83 | webkit_glue::CppVariant* result); |
| 84 | void IndexInTableCallback( |
| 85 | const webkit_glue::CppArgumentList& args, |
| 86 | webkit_glue::CppVariant* result); |
| 87 | void RowIndexRangeCallback( |
| 88 | const webkit_glue::CppArgumentList& args, |
| 89 | webkit_glue::CppVariant* result); |
[email protected] | 9599173 | 2009-10-14 22:18:16 | [diff] [blame] | 90 | void ColumnIndexRangeCallback( |
[email protected] | 3338bcf | 2012-05-09 20:26:15 | [diff] [blame] | 91 | const webkit_glue::CppArgumentList& args, |
| 92 | webkit_glue::CppVariant* result); |
[email protected] | 9599173 | 2009-10-14 22:18:16 | [diff] [blame] | 93 | void CellForColumnAndRowCallback( |
[email protected] | 3338bcf | 2012-05-09 20:26:15 | [diff] [blame] | 94 | const webkit_glue::CppArgumentList& args, |
| 95 | webkit_glue::CppVariant* result); |
| 96 | void TitleUIElementCallback( |
| 97 | const webkit_glue::CppArgumentList& args, |
| 98 | webkit_glue::CppVariant* result); |
[email protected] | 9599173 | 2009-10-14 22:18:16 | [diff] [blame] | 99 | void SetSelectedTextRangeCallback( |
[email protected] | 3338bcf | 2012-05-09 20:26:15 | [diff] [blame] | 100 | const webkit_glue::CppArgumentList& args, |
| 101 | webkit_glue::CppVariant* result); |
| 102 | void AttributeValueCallback( |
| 103 | const webkit_glue::CppArgumentList& args, |
| 104 | webkit_glue::CppVariant* result); |
[email protected] | 9599173 | 2009-10-14 22:18:16 | [diff] [blame] | 105 | void IsAttributeSettableCallback( |
[email protected] | 3338bcf | 2012-05-09 20:26:15 | [diff] [blame] | 106 | const webkit_glue::CppArgumentList& args, |
| 107 | webkit_glue::CppVariant* result); |
[email protected] | 9599173 | 2009-10-14 22:18:16 | [diff] [blame] | 108 | void IsActionSupportedCallback( |
[email protected] | 3338bcf | 2012-05-09 20:26:15 | [diff] [blame] | 109 | const webkit_glue::CppArgumentList& args, |
| 110 | webkit_glue::CppVariant* result); |
| 111 | void ParentElementCallback( |
| 112 | const webkit_glue::CppArgumentList& args, |
| 113 | webkit_glue::CppVariant* result); |
| 114 | void IncrementCallback( |
| 115 | const webkit_glue::CppArgumentList& args, |
| 116 | webkit_glue::CppVariant* result); |
| 117 | void DecrementCallback( |
| 118 | const webkit_glue::CppArgumentList& args, |
| 119 | webkit_glue::CppVariant* result); |
| 120 | void FallbackCallback( |
| 121 | const webkit_glue::CppArgumentList& args, |
| 122 | webkit_glue::CppVariant* result); |
[email protected] | 9599173 | 2009-10-14 22:18:16 | [diff] [blame] | 123 | |
[email protected] | 3338bcf | 2012-05-09 20:26:15 | [diff] [blame] | 124 | void ChildrenCountGetterCallback(webkit_glue::CppVariant* result); |
| 125 | void DescriptionGetterCallback(webkit_glue::CppVariant* result); |
| 126 | void IsEnabledGetterCallback(webkit_glue::CppVariant* result); |
| 127 | void IsSelectedGetterCallback(webkit_glue::CppVariant* result); |
| 128 | void RoleGetterCallback(webkit_glue::CppVariant* result); |
| 129 | void TitleGetterCallback(webkit_glue::CppVariant* result); |
[email protected] | 9599173 | 2009-10-14 22:18:16 | [diff] [blame] | 130 | |
[email protected] | 3338bcf | 2012-05-09 20:26:15 | [diff] [blame] | 131 | webkit_glue::CppVariant subrole_; |
| 132 | webkit_glue::CppVariant language_; |
| 133 | webkit_glue::CppVariant x_; |
| 134 | webkit_glue::CppVariant y_; |
| 135 | webkit_glue::CppVariant width_; |
| 136 | webkit_glue::CppVariant height_; |
| 137 | webkit_glue::CppVariant click_point_x_; |
| 138 | webkit_glue::CppVariant click_point_y_; |
| 139 | webkit_glue::CppVariant int_value_; |
| 140 | webkit_glue::CppVariant min_value_; |
| 141 | webkit_glue::CppVariant max_value_; |
| 142 | webkit_glue::CppVariant children_count_; |
| 143 | webkit_glue::CppVariant insertion_point_line_number_; |
| 144 | webkit_glue::CppVariant selected_text_range; |
| 145 | webkit_glue::CppVariant is_required_; |
| 146 | webkit_glue::CppVariant value_description_; |
[email protected] | 9599173 | 2009-10-14 22:18:16 | [diff] [blame] | 147 | |
| 148 | WebKit::WebAccessibilityObject accessibility_object_; |
| 149 | Factory* factory_; |
| 150 | }; |
| 151 | |
| 152 | |
| 153 | class RootAccessibilityUIElement : public AccessibilityUIElement { |
| 154 | public: |
| 155 | RootAccessibilityUIElement( |
| 156 | const WebKit::WebAccessibilityObject& accessibility_object, |
| 157 | Factory* factory); |
[email protected] | fadc607b6 | 2011-02-07 17:55:50 | [diff] [blame] | 158 | virtual ~RootAccessibilityUIElement(); |
[email protected] | 9599173 | 2009-10-14 22:18:16 | [diff] [blame] | 159 | |
[email protected] | 0da6b445 | 2011-11-16 21:36:16 | [diff] [blame] | 160 | virtual AccessibilityUIElement* GetChildAtIndex(unsigned index) OVERRIDE; |
| 161 | virtual bool IsRoot() const OVERRIDE; |
[email protected] | 9599173 | 2009-10-14 22:18:16 | [diff] [blame] | 162 | }; |
| 163 | |
| 164 | |
| 165 | // Provides simple lifetime management of the AccessibilityUIElement instances: |
| 166 | // all AccessibilityUIElements ever created from the controller are stored in |
| 167 | // a list and cleared explicitly. |
| 168 | class AccessibilityUIElementList : public AccessibilityUIElement::Factory { |
| 169 | public: |
[email protected] | fadc607b6 | 2011-02-07 17:55:50 | [diff] [blame] | 170 | AccessibilityUIElementList(); |
[email protected] | 9599173 | 2009-10-14 22:18:16 | [diff] [blame] | 171 | virtual ~AccessibilityUIElementList(); |
| 172 | |
| 173 | void Clear(); |
| 174 | virtual AccessibilityUIElement* Create( |
[email protected] | 0da6b445 | 2011-11-16 21:36:16 | [diff] [blame] | 175 | const WebKit::WebAccessibilityObject& object) OVERRIDE; |
[email protected] | 9599173 | 2009-10-14 22:18:16 | [diff] [blame] | 176 | AccessibilityUIElement* CreateRoot( |
| 177 | const WebKit::WebAccessibilityObject& object); |
| 178 | |
| 179 | private: |
| 180 | typedef std::vector<AccessibilityUIElement*> ElementList; |
| 181 | ElementList elements_; |
| 182 | }; |
| 183 | |
| 184 | #endif // WEBKIT_TOOLS_TEST_SHELL_ACCESSIBILITY_UI_ELEMENT_H_ |