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_
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"
21 namespace test_runner
{
23 class WebAXObjectProxy
: public gin::Wrappable
<WebAXObjectProxy
> {
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
;
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
);
50 const blink::WebAXObject
& accessibility_object() const {
51 return accessibility_object_
;
54 Factory
* factory() const { return factory_
; }
57 friend class WebAXObjectProxyBindings
;
61 std::string
StringValue();
62 std::string
Language();
70 std::string
ValueDescription();
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
87 int SelectionStartLineNumber();
88 int SelectionEndLineNumber();
92 bool IsRichlyEditable();
97 bool IsMultiSelectable();
98 bool IsSelectedOptionActive();
107 unsigned int BackgroundColor();
108 unsigned int Color();
109 // For input elements of type color.
110 unsigned int ColorValue();
112 std::string
Orientation();
118 int32_t RowHeadersCount();
119 int32_t ColumnCount();
120 int32_t ColumnHeadersCount();
122 bool IsButtonStateMixed();
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();
150 bool IsEqual(v8::Local
<v8::Object
> proxy
);
151 void SetNotificationListener(v8::Local
<v8::Function
> callback
);
152 void UnsetNotificationListener();
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
170 std::string
NameFrom();
171 int NameElementCount();
172 v8::Local
<v8::Object
> NameElementAtIndex(unsigned index
);
174 blink::WebAXObject accessibility_object_
;
177 v8::Persistent
<v8::Function
> notification_callback_
;
179 DISALLOW_COPY_AND_ASSIGN(WebAXObjectProxy
);
182 class RootWebAXObjectProxy
: public WebAXObjectProxy
{
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
{
196 WebAXObjectProxyList();
197 ~WebAXObjectProxyList() override
;
200 v8::Local
<v8::Object
> GetOrCreate(const blink::WebAXObject
&) override
;
203 typedef v8::PersistentValueVector
<v8::Object
> ElementList
;
204 ElementList elements_
;
207 } // namespace test_runner
209 #endif // COMPONENTS_TEST_RUNNER_WEB_AX_OBJECT_PROXY_H_