Fix accessibilityController.rootElement
[chromium-blink-merge.git] / content / shell / renderer / test_runner / web_ax_object_proxy.h
blob0c1eea0267060daa4c336418aaece9e637fe4c1e
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.
5 #ifndef CONTENT_SHELL_RENDERER_TEST_RUNNER_WEB_AX_OBJECT_PROXY_H_
6 #define CONTENT_SHELL_RENDERER_TEST_RUNNER_WEB_AX_OBJECT_PROXY_H_
8 #include <string>
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"
17 namespace blink {
18 class WebFrame;
21 namespace content {
23 class WebAXObjectProxy : public gin::Wrappable<WebAXObjectProxy> {
24 public:
25 class Factory {
26 public:
27 virtual ~Factory() { }
28 virtual v8::Handle<v8::Object> GetOrCreate(
29 const blink::WebAXObject& object) = 0;
32 static gin::WrapperInfo kWrapperInfo;
34 WebAXObjectProxy(const blink::WebAXObject& object, Factory* factory);
35 ~WebAXObjectProxy() override;
37 // gin::Wrappable:
38 gin::ObjectTemplateBuilder GetObjectTemplateBuilder(
39 v8::Isolate* isolate) override;
41 virtual v8::Handle<v8::Object> GetChildAtIndex(unsigned index);
42 virtual bool IsRoot() const;
43 bool IsEqualToObject(const blink::WebAXObject& object);
45 void NotificationReceived(blink::WebFrame* frame,
46 const std::string& notification_name);
47 void Reset();
49 protected:
50 const blink::WebAXObject& accessibility_object() const {
51 return accessibility_object_;
54 Factory* factory() const { return factory_; }
56 private:
57 friend class WebAXObjectProxyBindings;
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 // TODO(nektar): Remove this function after updating tests.
77 int InsertionPointLineNumber();
78 // TODO(nektar): Remove this function after updating tests.
79 std::string SelectedTextRange();
80 bool IsEnabled();
81 bool IsRequired();
82 bool IsFocused();
83 bool IsFocusable();
84 bool IsSelected();
85 bool IsSelectable();
86 bool IsMultiSelectable();
87 bool IsSelectedOptionActive();
88 bool IsExpanded();
89 bool IsChecked();
90 bool IsVisible();
91 bool IsOffScreen();
92 bool IsCollapsed();
93 bool HasPopup();
94 bool IsValid();
95 bool IsReadOnly();
96 std::string Orientation();
97 int ClickPointX();
98 int ClickPointY();
99 int32_t RowCount();
100 int32_t RowHeadersCount();
101 int32_t ColumnCount();
102 int32_t ColumnHeadersCount();
103 bool IsClickable();
104 bool IsButtonStateMixed();
106 // Bound methods.
107 v8::Handle<v8::Object> AriaControlsElementAtIndex(unsigned index);
108 v8::Handle<v8::Object> AriaFlowToElementAtIndex(unsigned index);
109 v8::Handle<v8::Object> AriaOwnsElementAtIndex(unsigned index);
110 std::string AllAttributes();
111 std::string AttributesOfChildren();
112 int LineForIndex(int index);
113 std::string BoundsForRange(int start, int end);
114 v8::Handle<v8::Object> ChildAtIndex(int index);
115 v8::Handle<v8::Object> ElementAtPoint(int x, int y);
116 v8::Handle<v8::Object> TableHeader();
117 v8::Handle<v8::Object> RowHeaderAtIndex(unsigned index);
118 v8::Handle<v8::Object> ColumnHeaderAtIndex(unsigned index);
119 std::string RowIndexRange();
120 std::string ColumnIndexRange();
121 v8::Handle<v8::Object> CellForColumnAndRow(int column, int row);
122 void SetSelectedTextRange(int selection_start, int length);
123 bool IsAttributeSettable(const std::string& attribute);
124 bool IsPressActionSupported();
125 bool IsIncrementActionSupported();
126 bool IsDecrementActionSupported();
127 v8::Handle<v8::Object> ParentElement();
128 void Increment();
129 void Decrement();
130 void ShowMenu();
131 void Press();
132 bool IsEqual(v8::Handle<v8::Object> proxy);
133 void SetNotificationListener(v8::Handle<v8::Function> callback);
134 void UnsetNotificationListener();
135 void TakeFocus();
136 void ScrollToMakeVisible();
137 void ScrollToMakeVisibleWithSubFocus(int x, int y, int width, int height);
138 void ScrollToGlobalPoint(int x, int y);
139 int WordStart(int character_index);
140 int WordEnd(int character_index);
142 // DEPRECATED accessible name and description accessors
143 std::string DeprecatedTitle();
144 std::string DeprecatedDescription();
145 std::string DeprecatedHelpText();
146 v8::Handle<v8::Object> DeprecatedTitleUIElement();
148 // NEW accessible name and description accessors
149 std::string Name();
150 std::string NameFrom();
151 int NameElementCount();
152 v8::Handle<v8::Object> NameElementAtIndex(unsigned index);
154 blink::WebAXObject accessibility_object_;
155 Factory* factory_;
157 v8::Persistent<v8::Function> notification_callback_;
159 DISALLOW_COPY_AND_ASSIGN(WebAXObjectProxy);
162 class RootWebAXObjectProxy : public WebAXObjectProxy {
163 public:
164 RootWebAXObjectProxy(const blink::WebAXObject&, Factory*);
166 v8::Handle<v8::Object> GetChildAtIndex(unsigned index) override;
167 bool IsRoot() const override;
171 // Provides simple lifetime management of the WebAXObjectProxy instances: all
172 // WebAXObjectProxys ever created from the controller are stored in a list and
173 // cleared explicitly.
174 class WebAXObjectProxyList : public WebAXObjectProxy::Factory {
175 public:
176 WebAXObjectProxyList();
177 ~WebAXObjectProxyList() override;
179 void Clear();
180 v8::Handle<v8::Object> GetOrCreate(const blink::WebAXObject&) override;
182 private:
183 typedef v8::PersistentValueVector<v8::Object> ElementList;
184 ElementList elements_;
187 } // namespace content
189 #endif // CONTENT_SHELL_RENDERER_TEST_RUNNER_WEB_AX_OBJECT_PROXY_H_