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_
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"
23 class WebAXObjectProxy
: public gin::Wrappable
<WebAXObjectProxy
> {
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
;
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
);
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();
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();
86 bool IsMultiSelectable();
87 bool IsSelectedOptionActive();
96 std::string
Orientation();
100 int32_t RowHeadersCount();
101 int32_t ColumnCount();
102 int32_t ColumnHeadersCount();
104 bool IsButtonStateMixed();
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();
132 bool IsEqual(v8::Handle
<v8::Object
> proxy
);
133 void SetNotificationListener(v8::Handle
<v8::Function
> callback
);
134 void UnsetNotificationListener();
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
150 std::string
NameFrom();
151 int NameElementCount();
152 v8::Handle
<v8::Object
> NameElementAtIndex(unsigned index
);
154 blink::WebAXObject accessibility_object_
;
157 v8::Persistent
<v8::Function
> notification_callback_
;
159 DISALLOW_COPY_AND_ASSIGN(WebAXObjectProxy
);
162 class RootWebAXObjectProxy
: public WebAXObjectProxy
{
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
{
176 WebAXObjectProxyList();
177 ~WebAXObjectProxyList() override
;
180 v8::Handle
<v8::Object
> GetOrCreate(const blink::WebAXObject
&) override
;
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_