Don't preload rarely seen large images
[chromium-blink-merge.git] / components / test_runner / web_ax_object_proxy.h
blob1b8c4690598074ea359c42fa629d417d023fdb08
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_
8 #include <string>
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"
17 namespace blink {
18 class WebFrame;
21 namespace test_runner {
23 class WebAXObjectProxy : public gin::Wrappable<WebAXObjectProxy> {
24 public:
25 class Factory {
26 public:
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;
37 // gin::Wrappable:
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);
47 void Reset();
49 protected:
50 const blink::WebAXObject& accessibility_object() const {
51 return accessibility_object_;
54 Factory* factory() const { return factory_; }
56 private:
57 friend class WebAXObjectProxyBindings;
59 // Bound properties.
60 std::string Role();
61 std::string StringValue();
62 std::string Language();
63 int X();
64 int Y();
65 int Width();
66 int Height();
67 int IntValue();
68 int MinValue();
69 int MaxValue();
70 std::string ValueDescription();
71 int ChildrenCount();
72 int SelectionStart();
73 int SelectionEnd();
74 int SelectionStartLineNumber();
75 int SelectionEndLineNumber();
76 bool IsEnabled();
77 bool IsRequired();
78 bool IsRichlyEditable();
79 bool IsFocused();
80 bool IsFocusable();
81 bool IsSelected();
82 bool IsSelectable();
83 bool IsMultiSelectable();
84 bool IsSelectedOptionActive();
85 bool IsExpanded();
86 bool IsChecked();
87 bool IsVisible();
88 bool IsOffScreen();
89 bool IsCollapsed();
90 bool HasPopup();
91 bool IsValid();
92 bool IsReadOnly();
93 unsigned int BackgroundColor();
94 unsigned int Color();
95 // For input elements of type color.
96 unsigned int ColorValue();
97 float FontSize();
98 std::string Orientation();
99 int PosInSet();
100 int SetSize();
101 int ClickPointX();
102 int ClickPointY();
103 int32_t RowCount();
104 int32_t RowHeadersCount();
105 int32_t ColumnCount();
106 int32_t ColumnHeadersCount();
107 bool IsClickable();
108 bool IsButtonStateMixed();
110 // Bound methods.
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();
132 void Increment();
133 void Decrement();
134 void ShowMenu();
135 void Press();
136 bool IsEqual(v8::Local<v8::Object> proxy);
137 void SetNotificationListener(v8::Local<v8::Function> callback);
138 void UnsetNotificationListener();
139 void TakeFocus();
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
155 std::string Name();
156 std::string NameFrom();
157 int NameElementCount();
158 v8::Local<v8::Object> NameElementAtIndex(unsigned index);
160 blink::WebAXObject accessibility_object_;
161 Factory* factory_;
163 v8::Persistent<v8::Function> notification_callback_;
165 DISALLOW_COPY_AND_ASSIGN(WebAXObjectProxy);
168 class RootWebAXObjectProxy : public WebAXObjectProxy {
169 public:
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 {
181 public:
182 WebAXObjectProxyList();
183 ~WebAXObjectProxyList() override;
185 void Clear();
186 v8::Local<v8::Object> GetOrCreate(const blink::WebAXObject&) override;
188 private:
189 typedef v8::PersistentValueVector<v8::Object> ElementList;
190 ElementList elements_;
193 } // namespace test_runner
195 #endif // COMPONENTS_TEST_RUNNER_WEB_AX_OBJECT_PROXY_H_