Revert "Fix broken channel icon in chrome://help on CrOS" and try again
[chromium-blink-merge.git] / components / test_runner / web_ax_object_proxy.h
bloba52809c8d4323030f3d42eb2e44f3b18037985a2
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 COMPONENTS_TEST_RUNNER_WEB_AX_OBJECT_PROXY_H_
6 #define COMPONENTS_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 test_runner {
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;
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::Local<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();
73 // The following selection functions return global information about the
74 // current selection and can be called on any object in the tree.
75 v8::Local<v8::Value> SelectionAnchorObject();
76 int SelectionAnchorOffset();
77 v8::Local<v8::Value> SelectionFocusObject();
78 int SelectionFocusOffset();
80 // The following selection functions return text offsets calculated starting
81 // at this object. They only report on a selection that is placed on the
82 // current object or on any of its descendants.
83 // For example, they can be used to retrieve the selection in an input or
84 // a textarea.
85 int SelectionStart();
86 int SelectionEnd();
87 int SelectionStartLineNumber();
88 int SelectionEndLineNumber();
90 bool IsEnabled();
91 bool IsRequired();
92 bool IsRichlyEditable();
93 bool IsFocused();
94 bool IsFocusable();
95 bool IsSelected();
96 bool IsSelectable();
97 bool IsMultiSelectable();
98 bool IsSelectedOptionActive();
99 bool IsExpanded();
100 bool IsChecked();
101 bool IsVisible();
102 bool IsOffScreen();
103 bool IsCollapsed();
104 bool HasPopup();
105 bool IsValid();
106 bool IsReadOnly();
107 unsigned int BackgroundColor();
108 unsigned int Color();
109 // For input elements of type color.
110 unsigned int ColorValue();
111 float FontSize();
112 std::string Orientation();
113 int PosInSet();
114 int SetSize();
115 int ClickPointX();
116 int ClickPointY();
117 int32_t RowCount();
118 int32_t RowHeadersCount();
119 int32_t ColumnCount();
120 int32_t ColumnHeadersCount();
121 bool IsClickable();
122 bool IsButtonStateMixed();
124 // Bound methods.
125 v8::Local<v8::Object> AriaControlsElementAtIndex(unsigned index);
126 v8::Local<v8::Object> AriaFlowToElementAtIndex(unsigned index);
127 v8::Local<v8::Object> AriaOwnsElementAtIndex(unsigned index);
128 std::string AllAttributes();
129 std::string AttributesOfChildren();
130 int LineForIndex(int index);
131 std::string BoundsForRange(int start, int end);
132 v8::Local<v8::Object> ChildAtIndex(int index);
133 v8::Local<v8::Object> ElementAtPoint(int x, int y);
134 v8::Local<v8::Object> TableHeader();
135 v8::Local<v8::Object> RowHeaderAtIndex(unsigned index);
136 v8::Local<v8::Object> ColumnHeaderAtIndex(unsigned index);
137 std::string RowIndexRange();
138 std::string ColumnIndexRange();
139 v8::Local<v8::Object> CellForColumnAndRow(int column, int row);
140 void SetSelectedTextRange(int selection_start, int length);
141 bool IsAttributeSettable(const std::string& attribute);
142 bool IsPressActionSupported();
143 bool IsIncrementActionSupported();
144 bool IsDecrementActionSupported();
145 v8::Local<v8::Object> ParentElement();
146 void Increment();
147 void Decrement();
148 void ShowMenu();
149 void Press();
150 bool IsEqual(v8::Local<v8::Object> proxy);
151 void SetNotificationListener(v8::Local<v8::Function> callback);
152 void UnsetNotificationListener();
153 void TakeFocus();
154 void ScrollToMakeVisible();
155 void ScrollToMakeVisibleWithSubFocus(int x, int y, int width, int height);
156 void ScrollToGlobalPoint(int x, int y);
157 int WordStart(int character_index);
158 int WordEnd(int character_index);
159 v8::Local<v8::Object> NextOnLine();
160 v8::Local<v8::Object> PreviousOnLine();
162 // DEPRECATED accessible name and description accessors
163 std::string DeprecatedTitle();
164 std::string DeprecatedDescription();
165 std::string DeprecatedHelpText();
166 v8::Local<v8::Object> DeprecatedTitleUIElement();
168 // NEW accessible name and description accessors
169 std::string Name();
170 std::string NameFrom();
171 int NameElementCount();
172 v8::Local<v8::Object> NameElementAtIndex(unsigned index);
174 blink::WebAXObject accessibility_object_;
175 Factory* factory_;
177 v8::Persistent<v8::Function> notification_callback_;
179 DISALLOW_COPY_AND_ASSIGN(WebAXObjectProxy);
182 class RootWebAXObjectProxy : public WebAXObjectProxy {
183 public:
184 RootWebAXObjectProxy(const blink::WebAXObject&, Factory*);
186 v8::Local<v8::Object> GetChildAtIndex(unsigned index) override;
187 bool IsRoot() const override;
191 // Provides simple lifetime management of the WebAXObjectProxy instances: all
192 // WebAXObjectProxys ever created from the controller are stored in a list and
193 // cleared explicitly.
194 class WebAXObjectProxyList : public WebAXObjectProxy::Factory {
195 public:
196 WebAXObjectProxyList();
197 ~WebAXObjectProxyList() override;
199 void Clear();
200 v8::Local<v8::Object> GetOrCreate(const blink::WebAXObject&) override;
202 private:
203 typedef v8::PersistentValueVector<v8::Object> ElementList;
204 ElementList elements_;
207 } // namespace test_runner
209 #endif // COMPONENTS_TEST_RUNNER_WEB_AX_OBJECT_PROXY_H_