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 virtual ~WebAXObjectProxy();
38 virtual 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
);
49 const blink::WebAXObject
& accessibility_object() const {
50 return accessibility_object_
;
53 Factory
* factory() const { return factory_
; }
56 friend class WebAXObjectProxyBindings
;
61 std::string
Description();
62 std::string
HelpText();
63 std::string
StringValue();
71 std::string
ValueDescription();
73 int InsertionPointLineNumber();
74 std::string
SelectedTextRange();
81 bool IsMultiSelectable();
82 bool IsSelectedOptionActive();
91 std::string
Orientation();
95 int32_t ColumnCount();
99 std::string
AllAttributes();
100 std::string
AttributesOfChildren();
101 int LineForIndex(int index
);
102 std::string
BoundsForRange(int start
, int end
);
103 v8::Handle
<v8::Object
> ChildAtIndex(int index
);
104 v8::Handle
<v8::Object
> ElementAtPoint(int x
, int y
);
105 v8::Handle
<v8::Object
> TableHeader();
106 std::string
RowIndexRange();
107 std::string
ColumnIndexRange();
108 v8::Handle
<v8::Object
> CellForColumnAndRow(int column
, int row
);
109 v8::Handle
<v8::Object
> TitleUIElement();
110 void SetSelectedTextRange(int selection_start
, int length
);
111 bool IsAttributeSettable(const std::string
& attribute
);
112 bool IsPressActionSupported();
113 bool IsIncrementActionSupported();
114 bool IsDecrementActionSupported();
115 v8::Handle
<v8::Object
> ParentElement();
120 bool IsEqual(v8::Handle
<v8::Object
> proxy
);
121 void SetNotificationListener(v8::Handle
<v8::Function
> callback
);
122 void UnsetNotificationListener();
124 void ScrollToMakeVisible();
125 void ScrollToMakeVisibleWithSubFocus(int x
, int y
, int width
, int height
);
126 void ScrollToGlobalPoint(int x
, int y
);
127 int WordStart(int character_index
);
128 int WordEnd(int character_index
);
130 blink::WebAXObject accessibility_object_
;
133 v8::Persistent
<v8::Function
> notification_callback_
;
135 DISALLOW_COPY_AND_ASSIGN(WebAXObjectProxy
);
138 class RootWebAXObjectProxy
: public WebAXObjectProxy
{
140 RootWebAXObjectProxy(const blink::WebAXObject
&, Factory
*);
142 virtual v8::Handle
<v8::Object
> GetChildAtIndex(unsigned index
) OVERRIDE
;
143 virtual bool IsRoot() const OVERRIDE
;
147 // Provides simple lifetime management of the WebAXObjectProxy instances: all
148 // WebAXObjectProxys ever created from the controller are stored in a list and
149 // cleared explicitly.
150 class WebAXObjectProxyList
: public WebAXObjectProxy::Factory
{
152 WebAXObjectProxyList();
153 virtual ~WebAXObjectProxyList();
156 virtual v8::Handle
<v8::Object
> GetOrCreate(
157 const blink::WebAXObject
&) OVERRIDE
;
158 v8::Handle
<v8::Object
> CreateRoot(const blink::WebAXObject
&);
161 typedef v8::PersistentValueVector
<v8::Object
> ElementList
;
162 ElementList elements_
;
165 } // namespace content
167 #endif // CONTENT_SHELL_RENDERER_TEST_RUNNER_WEB_AX_OBJECT_PROXY_H_