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();
74 int SelectionStartLineNumber();
75 int SelectionEndLineNumber();
78 bool IsRichlyEditable();
83 bool IsMultiSelectable();
84 bool IsSelectedOptionActive();
93 unsigned int BackgroundColor();
95 // For input elements of type color.
96 unsigned int ColorValue();
98 std::string
Orientation();
104 int32_t RowHeadersCount();
105 int32_t ColumnCount();
106 int32_t ColumnHeadersCount();
108 bool IsButtonStateMixed();
111 v8::Local
<v8::Object
> AriaControlsElementAtIndex(unsigned index
);
112 v8::Local
<v8::Object
> AriaFlowToElementAtIndex(unsigned index
);
113 v8::Local
<v8::Object
> AriaOwnsElementAtIndex(unsigned index
);
114 std::string
AllAttributes();
115 std::string
AttributesOfChildren();
116 int LineForIndex(int index
);
117 std::string
BoundsForRange(int start
, int end
);
118 v8::Local
<v8::Object
> ChildAtIndex(int index
);
119 v8::Local
<v8::Object
> ElementAtPoint(int x
, int y
);
120 v8::Local
<v8::Object
> TableHeader();
121 v8::Local
<v8::Object
> RowHeaderAtIndex(unsigned index
);
122 v8::Local
<v8::Object
> ColumnHeaderAtIndex(unsigned index
);
123 std::string
RowIndexRange();
124 std::string
ColumnIndexRange();
125 v8::Local
<v8::Object
> CellForColumnAndRow(int column
, int row
);
126 void SetSelectedTextRange(int selection_start
, int length
);
127 bool IsAttributeSettable(const std::string
& attribute
);
128 bool IsPressActionSupported();
129 bool IsIncrementActionSupported();
130 bool IsDecrementActionSupported();
131 v8::Local
<v8::Object
> ParentElement();
136 bool IsEqual(v8::Local
<v8::Object
> proxy
);
137 void SetNotificationListener(v8::Local
<v8::Function
> callback
);
138 void UnsetNotificationListener();
140 void ScrollToMakeVisible();
141 void ScrollToMakeVisibleWithSubFocus(int x
, int y
, int width
, int height
);
142 void ScrollToGlobalPoint(int x
, int y
);
143 int WordStart(int character_index
);
144 int WordEnd(int character_index
);
145 v8::Local
<v8::Object
> NextOnLine();
146 v8::Local
<v8::Object
> PreviousOnLine();
148 // DEPRECATED accessible name and description accessors
149 std::string
DeprecatedTitle();
150 std::string
DeprecatedDescription();
151 std::string
DeprecatedHelpText();
152 v8::Local
<v8::Object
> DeprecatedTitleUIElement();
154 // NEW accessible name and description accessors
156 std::string
NameFrom();
157 int NameElementCount();
158 v8::Local
<v8::Object
> NameElementAtIndex(unsigned index
);
160 blink::WebAXObject accessibility_object_
;
163 v8::Persistent
<v8::Function
> notification_callback_
;
165 DISALLOW_COPY_AND_ASSIGN(WebAXObjectProxy
);
168 class RootWebAXObjectProxy
: public WebAXObjectProxy
{
170 RootWebAXObjectProxy(const blink::WebAXObject
&, Factory
*);
172 v8::Local
<v8::Object
> GetChildAtIndex(unsigned index
) override
;
173 bool IsRoot() const override
;
177 // Provides simple lifetime management of the WebAXObjectProxy instances: all
178 // WebAXObjectProxys ever created from the controller are stored in a list and
179 // cleared explicitly.
180 class WebAXObjectProxyList
: public WebAXObjectProxy::Factory
{
182 WebAXObjectProxyList();
183 ~WebAXObjectProxyList() override
;
186 v8::Local
<v8::Object
> GetOrCreate(const blink::WebAXObject
&) override
;
189 typedef v8::PersistentValueVector
<v8::Object
> ElementList
;
190 ElementList elements_
;
193 } // namespace test_runner
195 #endif // COMPONENTS_TEST_RUNNER_WEB_AX_OBJECT_PROXY_H_