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_
11 #include "base/basictypes.h"
12 #include "content/shell/renderer/test_runner/unsafe_persistent.h"
13 #include "gin/object_template_builder.h"
14 #include "gin/wrappable.h"
15 #include "third_party/WebKit/public/web/WebAXObject.h"
16 #include "v8/include/v8.h"
24 class WebAXObjectProxy : public gin::Wrappable<WebAXObjectProxy> {
28 virtual ~Factory() { }
29 virtual v8::Handle<v8::Object> GetOrCreate(
30 const blink::WebAXObject& object) = 0;
33 static gin::WrapperInfo kWrapperInfo;
35 WebAXObjectProxy(const blink::WebAXObject& object, Factory* factory);
36 virtual ~WebAXObjectProxy();
39 virtual gin::ObjectTemplateBuilder GetObjectTemplateBuilder(
40 v8::Isolate* isolate) OVERRIDE;
42 virtual v8::Handle<v8::Object> GetChildAtIndex(unsigned index);
43 virtual bool IsRoot() const;
44 bool IsEqualToObject(const blink::WebAXObject& object);
46 void NotificationReceived(blink::WebFrame* frame,
47 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();
72 std::string ValueDescription();
74 int InsertionPointLineNumber();
75 std::string SelectedTextRange();
82 bool IsMultiSelectable();
83 bool IsSelectedOptionActive();
92 std::string Orientation();
96 int32_t ColumnCount();
100 std::string AllAttributes();
101 std::string AttributesOfChildren();
102 int LineForIndex(int index);
103 std::string BoundsForRange(int start, int end);
104 v8::Handle<v8::Object> ChildAtIndex(int index);
105 v8::Handle<v8::Object> ElementAtPoint(int x, int y);
106 v8::Handle<v8::Object> TableHeader();
107 std::string RowIndexRange();
108 std::string ColumnIndexRange();
109 v8::Handle<v8::Object> CellForColumnAndRow(int column, int row);
110 v8::Handle<v8::Object> TitleUIElement();
111 void SetSelectedTextRange(int selection_start, int length);
112 bool IsAttributeSettable(const std::string& attribute);
113 bool IsPressActionSupported();
114 bool IsIncrementActionSupported();
115 bool IsDecrementActionSupported();
116 v8::Handle<v8::Object> ParentElement();
121 bool IsEqual(v8::Handle<v8::Object> proxy);
122 void SetNotificationListener(v8::Handle<v8::Function> callback);
123 void UnsetNotificationListener();
125 void ScrollToMakeVisible();
126 void ScrollToMakeVisibleWithSubFocus(int x, int y, int width, int height);
127 void ScrollToGlobalPoint(int x, int y);
128 int WordStart(int character_index);
129 int WordEnd(int character_index);
131 blink::WebAXObject accessibility_object_;
134 v8::Persistent<v8::Function> notification_callback_;
136 DISALLOW_COPY_AND_ASSIGN(WebAXObjectProxy);
139 class RootWebAXObjectProxy : public WebAXObjectProxy {
141 RootWebAXObjectProxy(const blink::WebAXObject&, Factory*);
143 virtual v8::Handle<v8::Object> GetChildAtIndex(unsigned index) OVERRIDE;
144 virtual bool IsRoot() const OVERRIDE;
148 // Provides simple lifetime management of the WebAXObjectProxy instances: all
149 // WebAXObjectProxys ever created from the controller are stored in a list and
150 // cleared explicitly.
151 class WebAXObjectProxyList : public WebAXObjectProxy::Factory {
153 WebAXObjectProxyList();
154 virtual ~WebAXObjectProxyList();
157 virtual v8::Handle<v8::Object> GetOrCreate(
158 const blink::WebAXObject&) OVERRIDE;
159 v8::Handle<v8::Object> CreateRoot(const blink::WebAXObject&);
162 typedef std::vector<UnsafePersistent<v8::Object> > ElementList;
163 ElementList elements_;
166 } // namespace content
168 #endif // CONTENT_SHELL_RENDERER_TEST_RUNNER_WEB_AX_OBJECT_PROXY_H_