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
;
62 std::string
Description();
63 std::string
HelpText();
64 std::string
StringValue();
65 std::string
Language();
73 std::string
ValueDescription();
75 int InsertionPointLineNumber();
76 std::string
SelectedTextRange();
83 bool IsMultiSelectable();
84 bool IsSelectedOptionActive();
93 std::string
Orientation();
97 int32_t RowHeadersCount();
98 int32_t ColumnCount();
99 int32_t ColumnHeadersCount();
101 bool IsButtonStateMixed();
104 v8::Handle
<v8::Object
> AriaControlsElementAtIndex(unsigned index
);
105 v8::Handle
<v8::Object
> AriaFlowToElementAtIndex(unsigned index
);
106 v8::Handle
<v8::Object
> AriaOwnsElementAtIndex(unsigned index
);
107 std::string
AllAttributes();
108 std::string
AttributesOfChildren();
109 int LineForIndex(int index
);
110 std::string
BoundsForRange(int start
, int end
);
111 v8::Handle
<v8::Object
> ChildAtIndex(int index
);
112 v8::Handle
<v8::Object
> ElementAtPoint(int x
, int y
);
113 v8::Handle
<v8::Object
> TableHeader();
114 v8::Handle
<v8::Object
> RowHeaderAtIndex(unsigned index
);
115 v8::Handle
<v8::Object
> ColumnHeaderAtIndex(unsigned index
);
116 std::string
RowIndexRange();
117 std::string
ColumnIndexRange();
118 v8::Handle
<v8::Object
> CellForColumnAndRow(int column
, int row
);
119 v8::Handle
<v8::Object
> TitleUIElement();
120 void SetSelectedTextRange(int selection_start
, int length
);
121 bool IsAttributeSettable(const std::string
& attribute
);
122 bool IsPressActionSupported();
123 bool IsIncrementActionSupported();
124 bool IsDecrementActionSupported();
125 v8::Handle
<v8::Object
> ParentElement();
130 bool IsEqual(v8::Handle
<v8::Object
> proxy
);
131 void SetNotificationListener(v8::Handle
<v8::Function
> callback
);
132 void UnsetNotificationListener();
134 void ScrollToMakeVisible();
135 void ScrollToMakeVisibleWithSubFocus(int x
, int y
, int width
, int height
);
136 void ScrollToGlobalPoint(int x
, int y
);
137 int WordStart(int character_index
);
138 int WordEnd(int character_index
);
140 blink::WebAXObject accessibility_object_
;
143 v8::Persistent
<v8::Function
> notification_callback_
;
145 DISALLOW_COPY_AND_ASSIGN(WebAXObjectProxy
);
148 class RootWebAXObjectProxy
: public WebAXObjectProxy
{
150 RootWebAXObjectProxy(const blink::WebAXObject
&, Factory
*);
152 v8::Handle
<v8::Object
> GetChildAtIndex(unsigned index
) override
;
153 bool IsRoot() const override
;
157 // Provides simple lifetime management of the WebAXObjectProxy instances: all
158 // WebAXObjectProxys ever created from the controller are stored in a list and
159 // cleared explicitly.
160 class WebAXObjectProxyList
: public WebAXObjectProxy::Factory
{
162 WebAXObjectProxyList();
163 ~WebAXObjectProxyList() override
;
166 v8::Handle
<v8::Object
> GetOrCreate(const blink::WebAXObject
&) override
;
167 v8::Handle
<v8::Object
> CreateRoot(const blink::WebAXObject
&);
170 typedef v8::PersistentValueVector
<v8::Object
> ElementList
;
171 ElementList elements_
;
174 } // namespace content
176 #endif // CONTENT_SHELL_RENDERER_TEST_RUNNER_WEB_AX_OBJECT_PROXY_H_