forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathweb_ax_object_proxy.h
283 lines (246 loc) · 8.57 KB
/
web_ax_object_proxy.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_WEB_TEST_RENDERER_WEB_AX_OBJECT_PROXY_H_
#define CONTENT_WEB_TEST_RENDERER_WEB_AX_OBJECT_PROXY_H_
#include <stdint.h>
#include <string>
#include <vector>
#include "base/memory/raw_ptr.h"
#include "gin/object_template_builder.h"
#include "gin/wrappable.h"
#include "third_party/blink/public/web/web_ax_context.h"
#include "third_party/blink/public/web/web_ax_object.h"
#include "ui/accessibility/ax_event_intent.h"
#include "v8/include/v8.h"
namespace blink {
class WebLocalFrame;
}
namespace content {
class WebAXObjectProxy : public gin::Wrappable<WebAXObjectProxy> {
public:
class Factory {
public:
virtual ~Factory() {}
virtual v8::Local<v8::Object> GetOrCreate(
const blink::WebAXObject& object) = 0;
virtual blink::WebAXContext* GetAXContext() = 0;
};
static gin::WrapperInfo kWrapperInfo;
WebAXObjectProxy(const blink::WebAXObject& object, Factory* factory);
WebAXObjectProxy(const WebAXObjectProxy&) = delete;
WebAXObjectProxy& operator=(const WebAXObjectProxy&) = delete;
~WebAXObjectProxy() override;
// gin::Wrappable:
gin::ObjectTemplateBuilder GetObjectTemplateBuilder(
v8::Isolate* isolate) override;
virtual v8::Local<v8::Object> GetChildAtIndex(unsigned index);
virtual bool IsRoot() const;
bool IsEqualToObject(const blink::WebAXObject& object);
void NotificationReceived(
blink::WebLocalFrame* frame,
const std::string& notification_name,
const std::vector<ui::AXEventIntent>& event_intents);
void Reset();
protected:
const blink::WebAXObject& accessibility_object() const {
return accessibility_object_;
}
Factory* factory() const { return factory_; }
bool IsDetached() const { return !factory_ || !factory_->GetAXContext(); }
private:
friend class WebAXObjectProxyBindings;
// Returns true if successful.
bool UpdateLayout();
ui::AXNodeData GetAXNodeData() const;
// Bound properties.
std::string Role();
std::string StringValue();
std::string Language();
int X();
int Y();
int Width();
int Height();
v8::Local<v8::Value> InPageLinkTarget(v8::Isolate* isolate);
int IntValue();
int MinValue();
int MaxValue();
int StepValue();
std::string ValueDescription();
int ChildrenCount();
// The following selection functions return global information about the
// current selection and can be called on any object in the tree.
bool SelectionIsBackward();
v8::Local<v8::Value> SelectionAnchorObject(v8::Isolate* isolate);
int SelectionAnchorOffset();
std::string SelectionAnchorAffinity();
v8::Local<v8::Value> SelectionFocusObject(v8::Isolate* isolate);
int SelectionFocusOffset();
std::string SelectionFocusAffinity();
// The following selection functions return text offsets calculated starting
// at this object. They only report on a selection that is placed on the
// current object or on any of its descendants.
// For example, they can be used to retrieve the selection in an input or
// a textarea.
int SelectionStart();
int SelectionEnd();
bool IsAtomic();
bool IsAutofillAvailable();
bool IsBusy();
bool IsRequired();
bool IsEditableRoot();
bool IsEditable();
bool IsRichlyEditable();
bool IsFocused();
bool IsFocusable();
bool IsModal();
bool IsSelected();
bool IsSelectable();
bool IsMultiLine();
bool IsMultiSelectable();
bool IsSelectedOptionActive();
bool IsExpanded();
std::string Checked();
bool IsVisible();
// Exposes the visited state of a link.
bool IsVisited();
bool IsOffScreen();
bool IsCollapsed();
bool IsValid();
bool IsReadOnly();
bool IsIgnored();
std::string Restriction();
v8::Local<v8::Object> ActiveDescendant();
unsigned int BackgroundColor();
unsigned int Color();
// For input elements of type color.
unsigned int ColorValue();
std::string FontFamily();
float FontSize();
std::string Autocomplete();
std::string Current();
std::string HasPopup();
std::string Invalid();
std::string KeyShortcuts();
std::string Live();
std::string Orientation();
std::string Relevant();
std::string RoleDescription();
std::string Sort();
std::string Url();
int HierarchicalLevel();
int PosInSet();
int SetSize();
int ClickPointX();
int ClickPointY();
int32_t AriaColumnCount();
uint32_t AriaColumnIndex();
uint32_t AriaColumnSpan();
int32_t AriaRowCount();
uint32_t AriaRowIndex();
uint32_t AriaRowSpan();
int32_t RowCount();
int32_t RowHeadersCount();
int32_t ColumnCount();
int32_t ColumnHeadersCount();
bool IsClickable();
float BoundsX();
float BoundsY();
float BoundsWidth();
float BoundsHeight();
// Bound methods.
v8::Local<v8::Object> AriaActiveDescendantElement();
v8::Local<v8::Object> AriaControlsElementAtIndex(unsigned index);
v8::Local<v8::Object> AriaDetailsElementAtIndex(unsigned index);
v8::Local<v8::Object> AriaErrorMessageElementAtIndex(unsigned index);
v8::Local<v8::Object> AriaFlowToElementAtIndex(unsigned index);
v8::Local<v8::Object> AriaOwnsElementAtIndex(unsigned index);
std::string AllAttributes();
std::string AttributesOfChildren();
std::string BoundsForRange(int start, int end);
v8::Local<v8::Object> ChildAtIndex(int index);
v8::Local<v8::Object> ElementAtPoint(int x, int y);
v8::Local<v8::Object> TableHeader();
v8::Local<v8::Object> RowHeaderAtIndex(unsigned index);
v8::Local<v8::Object> ColumnHeaderAtIndex(unsigned index);
std::string RowIndexRange();
std::string ColumnIndexRange();
v8::Local<v8::Object> CellForColumnAndRow(int column, int row);
void SetSelectedTextRange(int selection_start, int length);
bool SetSelection(v8::Isolate* isolate,
v8::Local<v8::Value> anchor_object,
int anchor_offset,
v8::Local<v8::Value> focus_object,
int focus_offset);
bool IsAttributeSettable(const std::string& attribute);
bool IsPressActionSupported();
bool IsIncrementActionSupported();
bool IsDecrementActionSupported();
bool HasDefaultAction();
v8::Local<v8::Object> ParentElement();
void Increment();
void Decrement();
void ShowMenu();
void Press();
bool SetValue(const std::string& value);
bool IsEqual(v8::Isolate* isolate, v8::Local<v8::Object> proxy);
void SetNotificationListener(v8::Isolate* isolate,
v8::Local<v8::Function> callback);
void UnsetNotificationListener();
void TakeFocus();
void ScrollToMakeVisible();
void ScrollToMakeVisibleWithSubFocus(int x, int y, int width, int height);
void ScrollToGlobalPoint(int x, int y);
void ScrollUp();
void ScrollDown();
int ScrollX();
int ScrollY();
std::string ToString();
int WordStart(int character_index);
int WordEnd(int character_index);
v8::Local<v8::Object> NextOnLine();
v8::Local<v8::Object> PreviousOnLine();
std::string MisspellingAtIndex(int index);
v8::Local<v8::Object> OffsetContainer();
float BoundsInContainerX();
float BoundsInContainerY();
float BoundsInContainerWidth();
float BoundsInContainerHeight();
bool HasNonIdentityTransform();
std::string Name();
std::string NameFrom();
int NameElementCount();
v8::Local<v8::Object> NameElementAtIndex(unsigned index);
std::string Description();
std::string DescriptionFrom();
int MisspellingsCount();
int DescriptionElementCount();
v8::Local<v8::Object> DescriptionElementAtIndex(unsigned index);
std::vector<std::string> GetMisspellings() const;
std::string Placeholder();
blink::WebAXObject accessibility_object_;
raw_ptr<Factory, ExperimentalRenderer> factory_;
v8::Global<v8::Function> notification_callback_;
};
class RootWebAXObjectProxy : public WebAXObjectProxy {
public:
RootWebAXObjectProxy(const blink::WebAXObject&, Factory*);
v8::Local<v8::Object> GetChildAtIndex(unsigned index) override;
bool IsRoot() const override;
};
class WebAXObjectProxyList : public WebAXObjectProxy::Factory {
public:
explicit WebAXObjectProxyList(v8::Isolate* isolate, blink::WebAXContext&);
~WebAXObjectProxyList() override;
void Clear();
void Remove(unsigned axid);
v8::Local<v8::Object> GetOrCreate(const blink::WebAXObject&) override;
blink::WebAXContext* GetAXContext() override;
private:
raw_ptr<v8::Isolate, ExperimentalRenderer> isolate_;
// Maps from AxID to corresponding v8 wrapper object for an AX object..
std::unordered_map<unsigned, v8::Global<v8::Object>> ax_objects_;
const raw_ptr<blink::WebAXContext, ExperimentalRenderer> ax_context_;
};
} // namespace content
#endif // CONTENT_WEB_TEST_RENDERER_WEB_AX_OBJECT_PROXY_H_