OLD | NEW |
| (Empty) |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
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 CONTENT_SHELL_RENDERER_TEST_RUNNER_WEB_AX_OBJECT_PROXY_H_ | |
6 #define CONTENT_SHELL_RENDERER_TEST_RUNNER_WEB_AX_OBJECT_PROXY_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/basictypes.h" | |
11 #include "gin/object_template_builder.h" | |
12 #include "gin/wrappable.h" | |
13 #include "third_party/WebKit/public/web/WebAXObject.h" | |
14 #include "v8/include/v8-util.h" | |
15 #include "v8/include/v8.h" | |
16 | |
17 namespace blink { | |
18 class WebFrame; | |
19 } | |
20 | |
21 namespace content { | |
22 | |
23 class WebAXObjectProxy : public gin::Wrappable<WebAXObjectProxy> { | |
24 public: | |
25 class Factory { | |
26 public: | |
27 virtual ~Factory() { } | |
28 virtual v8::Local<v8::Object> GetOrCreate( | |
29 const blink::WebAXObject& object) = 0; | |
30 }; | |
31 | |
32 static gin::WrapperInfo kWrapperInfo; | |
33 | |
34 WebAXObjectProxy(const blink::WebAXObject& object, Factory* factory); | |
35 ~WebAXObjectProxy() override; | |
36 | |
37 // gin::Wrappable: | |
38 gin::ObjectTemplateBuilder GetObjectTemplateBuilder( | |
39 v8::Isolate* isolate) override; | |
40 | |
41 virtual v8::Local<v8::Object> GetChildAtIndex(unsigned index); | |
42 virtual bool IsRoot() const; | |
43 bool IsEqualToObject(const blink::WebAXObject& object); | |
44 | |
45 void NotificationReceived(blink::WebFrame* frame, | |
46 const std::string& notification_name); | |
47 void Reset(); | |
48 | |
49 protected: | |
50 const blink::WebAXObject& accessibility_object() const { | |
51 return accessibility_object_; | |
52 } | |
53 | |
54 Factory* factory() const { return factory_; } | |
55 | |
56 private: | |
57 friend class WebAXObjectProxyBindings; | |
58 | |
59 // Bound properties. | |
60 std::string Role(); | |
61 std::string StringValue(); | |
62 std::string Language(); | |
63 int X(); | |
64 int Y(); | |
65 int Width(); | |
66 int Height(); | |
67 int IntValue(); | |
68 int MinValue(); | |
69 int MaxValue(); | |
70 std::string ValueDescription(); | |
71 int ChildrenCount(); | |
72 int SelectionStart(); | |
73 int SelectionEnd(); | |
74 int SelectionStartLineNumber(); | |
75 int SelectionEndLineNumber(); | |
76 bool IsEnabled(); | |
77 bool IsRequired(); | |
78 bool IsFocused(); | |
79 bool IsFocusable(); | |
80 bool IsSelected(); | |
81 bool IsSelectable(); | |
82 bool IsMultiSelectable(); | |
83 bool IsSelectedOptionActive(); | |
84 bool IsExpanded(); | |
85 bool IsChecked(); | |
86 bool IsVisible(); | |
87 bool IsOffScreen(); | |
88 bool IsCollapsed(); | |
89 bool HasPopup(); | |
90 bool IsValid(); | |
91 bool IsReadOnly(); | |
92 unsigned int BackgroundColor(); | |
93 unsigned int Color(); | |
94 // For input elements of type color. | |
95 unsigned int ColorValue(); | |
96 float FontSize(); | |
97 std::string Orientation(); | |
98 int PosInSet(); | |
99 int SetSize(); | |
100 int ClickPointX(); | |
101 int ClickPointY(); | |
102 int32_t RowCount(); | |
103 int32_t RowHeadersCount(); | |
104 int32_t ColumnCount(); | |
105 int32_t ColumnHeadersCount(); | |
106 bool IsClickable(); | |
107 bool IsButtonStateMixed(); | |
108 | |
109 // Bound methods. | |
110 v8::Local<v8::Object> AriaControlsElementAtIndex(unsigned index); | |
111 v8::Local<v8::Object> AriaFlowToElementAtIndex(unsigned index); | |
112 v8::Local<v8::Object> AriaOwnsElementAtIndex(unsigned index); | |
113 std::string AllAttributes(); | |
114 std::string AttributesOfChildren(); | |
115 int LineForIndex(int index); | |
116 std::string BoundsForRange(int start, int end); | |
117 v8::Local<v8::Object> ChildAtIndex(int index); | |
118 v8::Local<v8::Object> ElementAtPoint(int x, int y); | |
119 v8::Local<v8::Object> TableHeader(); | |
120 v8::Local<v8::Object> RowHeaderAtIndex(unsigned index); | |
121 v8::Local<v8::Object> ColumnHeaderAtIndex(unsigned index); | |
122 std::string RowIndexRange(); | |
123 std::string ColumnIndexRange(); | |
124 v8::Local<v8::Object> CellForColumnAndRow(int column, int row); | |
125 void SetSelectedTextRange(int selection_start, int length); | |
126 bool IsAttributeSettable(const std::string& attribute); | |
127 bool IsPressActionSupported(); | |
128 bool IsIncrementActionSupported(); | |
129 bool IsDecrementActionSupported(); | |
130 v8::Local<v8::Object> ParentElement(); | |
131 void Increment(); | |
132 void Decrement(); | |
133 void ShowMenu(); | |
134 void Press(); | |
135 bool IsEqual(v8::Local<v8::Object> proxy); | |
136 void SetNotificationListener(v8::Local<v8::Function> callback); | |
137 void UnsetNotificationListener(); | |
138 void TakeFocus(); | |
139 void ScrollToMakeVisible(); | |
140 void ScrollToMakeVisibleWithSubFocus(int x, int y, int width, int height); | |
141 void ScrollToGlobalPoint(int x, int y); | |
142 int WordStart(int character_index); | |
143 int WordEnd(int character_index); | |
144 v8::Local<v8::Object> NextOnLine(); | |
145 v8::Local<v8::Object> PreviousOnLine(); | |
146 | |
147 // DEPRECATED accessible name and description accessors | |
148 std::string DeprecatedTitle(); | |
149 std::string DeprecatedDescription(); | |
150 std::string DeprecatedHelpText(); | |
151 v8::Local<v8::Object> DeprecatedTitleUIElement(); | |
152 | |
153 // NEW accessible name and description accessors | |
154 std::string Name(); | |
155 std::string NameFrom(); | |
156 int NameElementCount(); | |
157 v8::Local<v8::Object> NameElementAtIndex(unsigned index); | |
158 | |
159 blink::WebAXObject accessibility_object_; | |
160 Factory* factory_; | |
161 | |
162 v8::Persistent<v8::Function> notification_callback_; | |
163 | |
164 DISALLOW_COPY_AND_ASSIGN(WebAXObjectProxy); | |
165 }; | |
166 | |
167 class RootWebAXObjectProxy : public WebAXObjectProxy { | |
168 public: | |
169 RootWebAXObjectProxy(const blink::WebAXObject&, Factory*); | |
170 | |
171 v8::Local<v8::Object> GetChildAtIndex(unsigned index) override; | |
172 bool IsRoot() const override; | |
173 }; | |
174 | |
175 | |
176 // Provides simple lifetime management of the WebAXObjectProxy instances: all | |
177 // WebAXObjectProxys ever created from the controller are stored in a list and | |
178 // cleared explicitly. | |
179 class WebAXObjectProxyList : public WebAXObjectProxy::Factory { | |
180 public: | |
181 WebAXObjectProxyList(); | |
182 ~WebAXObjectProxyList() override; | |
183 | |
184 void Clear(); | |
185 v8::Local<v8::Object> GetOrCreate(const blink::WebAXObject&) override; | |
186 | |
187 private: | |
188 typedef v8::PersistentValueVector<v8::Object> ElementList; | |
189 ElementList elements_; | |
190 }; | |
191 | |
192 } // namespace content | |
193 | |
194 #endif // CONTENT_SHELL_RENDERER_TEST_RUNNER_WEB_AX_OBJECT_PROXY_H_ | |
OLD | NEW |