Infobar material design refresh: bg color
[chromium-blink-merge.git] / components / test_runner / web_ax_object_proxy.h
blob1f4408b82b5ffba7e25f7c81bb7378e462ff06a9
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 void SetSelection(v8::Local<v8::Value> anchor_object, int anchor_offset,
142 v8::Local<v8::Value> focus_object, int focus_offset);
143 bool IsAttributeSettable(const std::string& attribute);
144 bool IsPressActionSupported();
145 bool IsIncrementActionSupported();
146 bool IsDecrementActionSupported();
147 v8::Local<v8::Object> ParentElement();
148 void Increment();
149 void Decrement();
150 void ShowMenu();
151 void Press();
152 bool IsEqual(v8::Local<v8::Object> proxy);
153 void SetNotificationListener(v8::Local<v8::Function> callback);
154 void UnsetNotificationListener();
155 void TakeFocus();
156 void ScrollToMakeVisible();
157 void ScrollToMakeVisibleWithSubFocus(int x, int y, int width, int height);
158 void ScrollToGlobalPoint(int x, int y);
159 int WordStart(int character_index);
160 int WordEnd(int character_index);
161 v8::Local<v8::Object> NextOnLine();
162 v8::Local<v8::Object> PreviousOnLine();
164 // DEPRECATED accessible name and description accessors
165 std::string DeprecatedTitle();
166 std::string DeprecatedDescription();
167 std::string DeprecatedHelpText();
168 v8::Local<v8::Object> DeprecatedTitleUIElement();
170 // NEW accessible name and description accessors
171 std::string Name();
172 std::string NameFrom();
173 int NameElementCount();
174 v8::Local<v8::Object> NameElementAtIndex(unsigned index);
176 blink::WebAXObject accessibility_object_;
177 Factory* factory_;
179 v8::Persistent<v8::Function> notification_callback_;
181 DISALLOW_COPY_AND_ASSIGN(WebAXObjectProxy);
184 class RootWebAXObjectProxy : public WebAXObjectProxy {
185 public:
186 RootWebAXObjectProxy(const blink::WebAXObject&, Factory*);
188 v8::Local<v8::Object> GetChildAtIndex(unsigned index) override;
189 bool IsRoot() const override;
193 // Provides simple lifetime management of the WebAXObjectProxy instances: all
194 // WebAXObjectProxys ever created from the controller are stored in a list and
195 // cleared explicitly.
196 class WebAXObjectProxyList : public WebAXObjectProxy::Factory {
197 public:
198 WebAXObjectProxyList();
199 ~WebAXObjectProxyList() override;
201 void Clear();
202 v8::Local<v8::Object> GetOrCreate(const blink::WebAXObject&) override;
204 private:
205 typedef v8::PersistentValueVector<v8::Object> ElementList;
206 ElementList elements_;
209 } // namespace test_runner
211 #endif // COMPONENTS_TEST_RUNNER_WEB_AX_OBJECT_PROXY_H_