OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 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. | |
4 | |
5 #include "base/bind.h" | |
6 #include "base/bind_helpers.h" | |
7 #include "base/logging.h" | |
8 #include "third_party/WebKit/Source/Platform/chromium/public/WebCString.h" | |
9 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" | |
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityObjec
t.h" | |
11 #include "webkit/tools/test_shell/accessibility_ui_element.h" | |
12 | |
13 using WebKit::WebCString; | |
14 using WebKit::WebString; | |
15 using WebKit::WebAccessibilityObject; | |
16 using WebKit::WebAccessibilityRole; | |
17 using webkit_glue::CppArgumentList; | |
18 using webkit_glue::CppVariant; | |
19 | |
20 namespace { | |
21 | |
22 // Map role value to string, matching Safari/Mac platform implementation to | |
23 // avoid rebaselining layout tests. | |
24 static std::string RoleToString(WebAccessibilityRole role) { | |
25 std::string result = "AXRole: AX"; | |
26 switch (role) { | |
27 case WebKit::WebAccessibilityRoleButton: | |
28 return result.append("Button"); | |
29 case WebKit::WebAccessibilityRoleRadioButton: | |
30 return result.append("RadioButton"); | |
31 case WebKit::WebAccessibilityRoleCheckBox: | |
32 return result.append("CheckBox"); | |
33 case WebKit::WebAccessibilityRoleSlider: | |
34 return result.append("Slider"); | |
35 case WebKit::WebAccessibilityRoleTabGroup: | |
36 return result.append("TabGroup"); | |
37 case WebKit::WebAccessibilityRoleTextField: | |
38 return result.append("TextField"); | |
39 case WebKit::WebAccessibilityRoleStaticText: | |
40 return result.append("StaticText"); | |
41 case WebKit::WebAccessibilityRoleTextArea: | |
42 return result.append("TextArea"); | |
43 case WebKit::WebAccessibilityRoleScrollArea: | |
44 return result.append("ScrollArea"); | |
45 case WebKit::WebAccessibilityRolePopUpButton: | |
46 return result.append("PopUpButton"); | |
47 case WebKit::WebAccessibilityRoleMenuButton: | |
48 return result.append("MenuButton"); | |
49 case WebKit::WebAccessibilityRoleTable: | |
50 return result.append("Table"); | |
51 case WebKit::WebAccessibilityRoleApplication: | |
52 return result.append("Application"); | |
53 case WebKit::WebAccessibilityRoleGroup: | |
54 return result.append("Group"); | |
55 case WebKit::WebAccessibilityRoleRadioGroup: | |
56 return result.append("RadioGroup"); | |
57 case WebKit::WebAccessibilityRoleList: | |
58 return result.append("List"); | |
59 case WebKit::WebAccessibilityRoleScrollBar: | |
60 return result.append("ScrollBar"); | |
61 case WebKit::WebAccessibilityRoleValueIndicator: | |
62 return result.append("ValueIndicator"); | |
63 case WebKit::WebAccessibilityRoleImage: | |
64 return result.append("Image"); | |
65 case WebKit::WebAccessibilityRoleMenuBar: | |
66 return result.append("MenuBar"); | |
67 case WebKit::WebAccessibilityRoleMenu: | |
68 return result.append("Menu"); | |
69 case WebKit::WebAccessibilityRoleMenuItem: | |
70 return result.append("MenuItem"); | |
71 case WebKit::WebAccessibilityRoleColumn: | |
72 return result.append("Column"); | |
73 case WebKit::WebAccessibilityRoleRow: | |
74 return result.append("Row"); | |
75 case WebKit::WebAccessibilityRoleToolbar: | |
76 return result.append("Toolbar"); | |
77 case WebKit::WebAccessibilityRoleBusyIndicator: | |
78 return result.append("BusyIndicator"); | |
79 case WebKit::WebAccessibilityRoleProgressIndicator: | |
80 return result.append("ProgressIndicator"); | |
81 case WebKit::WebAccessibilityRoleWindow: | |
82 return result.append("Window"); | |
83 case WebKit::WebAccessibilityRoleDrawer: | |
84 return result.append("Drawer"); | |
85 case WebKit::WebAccessibilityRoleSystemWide: | |
86 return result.append("SystemWide"); | |
87 case WebKit::WebAccessibilityRoleOutline: | |
88 return result.append("Outline"); | |
89 case WebKit::WebAccessibilityRoleIncrementor: | |
90 return result.append("Incrementor"); | |
91 case WebKit::WebAccessibilityRoleBrowser: | |
92 return result.append("Browser"); | |
93 case WebKit::WebAccessibilityRoleComboBox: | |
94 return result.append("ComboBox"); | |
95 case WebKit::WebAccessibilityRoleSplitGroup: | |
96 return result.append("SplitGroup"); | |
97 case WebKit::WebAccessibilityRoleSplitter: | |
98 return result.append("Splitter"); | |
99 case WebKit::WebAccessibilityRoleColorWell: | |
100 return result.append("ColorWell"); | |
101 case WebKit::WebAccessibilityRoleGrowArea: | |
102 return result.append("GrowArea"); | |
103 case WebKit::WebAccessibilityRoleSheet: | |
104 return result.append("Sheet"); | |
105 case WebKit::WebAccessibilityRoleHelpTag: | |
106 return result.append("HelpTag"); | |
107 case WebKit::WebAccessibilityRoleMatte: | |
108 return result.append("Matte"); | |
109 case WebKit::WebAccessibilityRoleRuler: | |
110 return result.append("Ruler"); | |
111 case WebKit::WebAccessibilityRoleRulerMarker: | |
112 return result.append("RulerMarker"); | |
113 case WebKit::WebAccessibilityRoleLink: | |
114 return result.append("Link"); | |
115 case WebKit::WebAccessibilityRoleDisclosureTriangle: | |
116 return result.append("DisclosureTriangle"); | |
117 case WebKit::WebAccessibilityRoleGrid: | |
118 return result.append("Grid"); | |
119 case WebKit::WebAccessibilityRoleCell: | |
120 return result.append("Cell"); | |
121 case WebKit::WebAccessibilityRoleColumnHeader: | |
122 return result.append("ColumnHeader"); | |
123 case WebKit::WebAccessibilityRoleRowHeader: | |
124 return result.append("RowHeader"); | |
125 case WebKit::WebAccessibilityRoleWebCoreLink: | |
126 // Maps to Link role. | |
127 return result.append("Link"); | |
128 case WebKit::WebAccessibilityRoleImageMapLink: | |
129 return result.append("ImageMapLink"); | |
130 case WebKit::WebAccessibilityRoleImageMap: | |
131 return result.append("ImageMap"); | |
132 case WebKit::WebAccessibilityRoleListMarker: | |
133 return result.append("ListMarker"); | |
134 case WebKit::WebAccessibilityRoleWebArea: | |
135 return result.append("WebArea"); | |
136 case WebKit::WebAccessibilityRoleHeading: | |
137 return result.append("Heading"); | |
138 case WebKit::WebAccessibilityRoleListBox: | |
139 return result.append("ListBox"); | |
140 case WebKit::WebAccessibilityRoleListBoxOption: | |
141 return result.append("ListBoxOption"); | |
142 case WebKit::WebAccessibilityRoleTableHeaderContainer: | |
143 return result.append("TableHeaderContainer"); | |
144 //case WebKit::WebAccessibilityRoleDefinitionListTerm: | |
145 // return result.append("DefinitionListTerm"); | |
146 //case WebKit::WebAccessibilityRoleDefinitionListDefinition: | |
147 // return result.append("DefinitionListDefinition"); | |
148 case WebKit::WebAccessibilityRoleAnnotation: | |
149 return result.append("Annotation"); | |
150 case WebKit::WebAccessibilityRoleSliderThumb: | |
151 return result.append("SliderThumb"); | |
152 case WebKit::WebAccessibilityRoleLandmarkApplication: | |
153 return result.append("LandmarkApplication"); | |
154 case WebKit::WebAccessibilityRoleLandmarkBanner: | |
155 return result.append("LandmarkBanner"); | |
156 case WebKit::WebAccessibilityRoleLandmarkComplementary: | |
157 return result.append("LandmarkComplementary"); | |
158 case WebKit::WebAccessibilityRoleLandmarkContentInfo: | |
159 return result.append("LandmarkContentInfo"); | |
160 case WebKit::WebAccessibilityRoleLandmarkMain: | |
161 return result.append("LandmarkMain"); | |
162 case WebKit::WebAccessibilityRoleLandmarkNavigation: | |
163 return result.append("LandmarkNavigation"); | |
164 case WebKit::WebAccessibilityRoleLandmarkSearch: | |
165 return result.append("LandmarkSearch"); | |
166 case WebKit::WebAccessibilityRoleApplicationLog: | |
167 return result.append("ApplicationLog"); | |
168 case WebKit::WebAccessibilityRoleApplicationMarquee: | |
169 return result.append("ApplicationMarquee"); | |
170 case WebKit::WebAccessibilityRoleApplicationStatus: | |
171 return result.append("ApplicationStatus"); | |
172 case WebKit::WebAccessibilityRoleApplicationTimer: | |
173 return result.append("ApplicationTimer"); | |
174 case WebKit::WebAccessibilityRoleDocument: | |
175 return result.append("Document"); | |
176 case WebKit::WebAccessibilityRoleDocumentArticle: | |
177 return result.append("DocumentArticle"); | |
178 case WebKit::WebAccessibilityRoleDocumentNote: | |
179 return result.append("DocumentNote"); | |
180 case WebKit::WebAccessibilityRoleDocumentRegion: | |
181 return result.append("DocumentRegion"); | |
182 case WebKit::WebAccessibilityRoleUserInterfaceTooltip: | |
183 return result.append("UserInterfaceTooltip"); | |
184 default: | |
185 // Also matches WebAccessibilityRoleUnknown. | |
186 return result.append("Unknown"); | |
187 } | |
188 } | |
189 | |
190 std::string GetDescription(const WebAccessibilityObject& object) { | |
191 std::string description = object.accessibilityDescription().utf8(); | |
192 return description.insert(0, "AXDescription: "); | |
193 } | |
194 | |
195 std::string GetRole(const WebAccessibilityObject& object) { | |
196 return RoleToString(object.roleValue()); | |
197 } | |
198 | |
199 std::string GetTitle(const WebAccessibilityObject& object) { | |
200 std::string title = object.title().utf8(); | |
201 return title.insert(0, "AXTitle: "); | |
202 } | |
203 | |
204 std::string GetAttributes(const WebAccessibilityObject& object) { | |
205 // TODO(dglazkov): Concatenate all attributes of the AccessibilityObject. | |
206 std::string attributes(GetTitle(object)); | |
207 attributes.append("\n"); | |
208 attributes.append(GetRole(object)); | |
209 attributes.append("\n"); | |
210 attributes.append(GetDescription(object)); | |
211 return attributes; | |
212 } | |
213 | |
214 | |
215 // Collects attributes into a string, delimited by dashes. Used by all methods | |
216 // that output lists of attributes: AttributesOfLinkedUIElementsCallback, | |
217 // AttributesOfChildrenCallback, etc. | |
218 class AttributesCollector { | |
219 public: | |
220 void CollectAttributes(const WebAccessibilityObject& object) { | |
221 attributes_.append("\n------------\n"); | |
222 attributes_.append(GetAttributes(object)); | |
223 } | |
224 std::string attributes() const { return attributes_; } | |
225 | |
226 private: | |
227 std::string attributes_; | |
228 }; | |
229 | |
230 } // namespace | |
231 | |
232 AccessibilityUIElement::AccessibilityUIElement( | |
233 const WebKit::WebAccessibilityObject& object, | |
234 Factory* factory) | |
235 : accessibility_object_(object), | |
236 factory_(factory) { | |
237 | |
238 DCHECK(factory); | |
239 | |
240 BindCallback("allAttributes", | |
241 base::Bind(&AccessibilityUIElement::AllAttributesCallback, | |
242 base::Unretained(this))); | |
243 BindCallback( | |
244 "attributesOfLinkedUIElements", | |
245 base::Bind(&AccessibilityUIElement::AttributesOfLinkedUIElementsCallback, | |
246 base::Unretained(this))); | |
247 BindCallback( | |
248 "attributesOfDocumentLinks", | |
249 base::Bind(&AccessibilityUIElement::AttributesOfDocumentLinksCallback, | |
250 base::Unretained(this))); | |
251 BindCallback( | |
252 "attributesOfChildren", | |
253 base::Bind(&AccessibilityUIElement::AttributesOfChildrenCallback, | |
254 base::Unretained(this))); | |
255 BindCallback( | |
256 "parameterizedAttributeNames", | |
257 base::Bind(&AccessibilityUIElement::ParametrizedAttributeNamesCallback, | |
258 base::Unretained(this))); | |
259 BindCallback("lineForIndex", | |
260 base::Bind(&AccessibilityUIElement::LineForIndexCallback, | |
261 base::Unretained(this))); | |
262 BindCallback("boundsForRange", | |
263 base::Bind(&AccessibilityUIElement::BoundsForRangeCallback, | |
264 base::Unretained(this))); | |
265 BindCallback("stringForRange", | |
266 base::Bind(&AccessibilityUIElement::StringForRangeCallback, | |
267 base::Unretained(this))); | |
268 BindCallback("childAtIndex", | |
269 base::Bind(&AccessibilityUIElement::ChildAtIndexCallback, | |
270 base::Unretained(this))); | |
271 BindCallback("elementAtPoint", | |
272 base::Bind(&AccessibilityUIElement::ElementAtPointCallback, | |
273 base::Unretained(this))); | |
274 BindCallback( | |
275 "attributesOfColumnHeaders", | |
276 base::Bind(&AccessibilityUIElement::AttributesOfColumnHeadersCallback, | |
277 base::Unretained(this))); | |
278 BindCallback( | |
279 "attributesOfRowHeaders", | |
280 base::Bind(&AccessibilityUIElement::AttributesOfRowHeadersCallback, | |
281 base::Unretained(this))); | |
282 BindCallback("attributesOfColumns", | |
283 base::Bind(&AccessibilityUIElement::AttributesOfColumnsCallback, | |
284 base::Unretained(this))); | |
285 BindCallback("attributesOfRows", | |
286 base::Bind(&AccessibilityUIElement::AttributesOfRowsCallback, | |
287 base::Unretained(this))); | |
288 BindCallback( | |
289 "attributesOfVisibleCells", | |
290 base::Bind(&AccessibilityUIElement::AttributesOfVisibleCellsCallback, | |
291 base::Unretained(this))); | |
292 BindCallback("attributesOfHeader", | |
293 base::Bind(&AccessibilityUIElement::AttributesOfHeaderCallback, | |
294 base::Unretained(this))); | |
295 BindCallback("indexInTable", | |
296 base::Bind(&AccessibilityUIElement::IndexInTableCallback, | |
297 base::Unretained(this))); | |
298 BindCallback("rowIndexRange", | |
299 base::Bind(&AccessibilityUIElement::RowIndexRangeCallback, | |
300 base::Unretained(this))); | |
301 BindCallback("columnIndexRange", | |
302 base::Bind(&AccessibilityUIElement::ColumnIndexRangeCallback, | |
303 base::Unretained(this))); | |
304 BindCallback("cellForColumnAndRow", | |
305 base::Bind(&AccessibilityUIElement::CellForColumnAndRowCallback, | |
306 base::Unretained(this))); | |
307 BindCallback("titleUIElement", | |
308 base::Bind(&AccessibilityUIElement::TitleUIElementCallback, | |
309 base::Unretained(this))); | |
310 BindCallback("setSelectedTextRange", | |
311 base::Bind(&AccessibilityUIElement::SetSelectedTextRangeCallback, | |
312 base::Unretained(this))); | |
313 BindCallback("attributeValue", | |
314 base::Bind(&AccessibilityUIElement::AttributeValueCallback, | |
315 base::Unretained(this))); | |
316 BindCallback("isAttributeSettable", | |
317 base::Bind(&AccessibilityUIElement::IsAttributeSettableCallback, | |
318 base::Unretained(this))); | |
319 BindCallback("isActionSupported", | |
320 base::Bind(&AccessibilityUIElement::IsActionSupportedCallback, | |
321 base::Unretained(this))); | |
322 BindCallback("parentElement", | |
323 base::Bind(&AccessibilityUIElement::ParentElementCallback, | |
324 base::Unretained(this))); | |
325 BindCallback("increment", | |
326 base::Bind(&AccessibilityUIElement::IncrementCallback, | |
327 base::Unretained(this))); | |
328 BindCallback("decrement", | |
329 base::Bind(&AccessibilityUIElement::DecrementCallback, | |
330 base::Unretained(this))); | |
331 | |
332 BindGetterCallback("role", | |
333 base::Bind(&AccessibilityUIElement::RoleGetterCallback, | |
334 base::Unretained(this))); | |
335 BindProperty("subrole", &subrole_); | |
336 BindGetterCallback("title", | |
337 base::Bind(&AccessibilityUIElement::TitleGetterCallback, | |
338 base::Unretained(this))); | |
339 BindGetterCallback( | |
340 "description", | |
341 base::Bind(&AccessibilityUIElement::DescriptionGetterCallback, | |
342 base::Unretained(this))); | |
343 BindProperty("language", &language_); | |
344 BindProperty("x", &x_); | |
345 BindProperty("y", &y_); | |
346 BindProperty("width", &width_); | |
347 BindProperty("height", &height_); | |
348 BindProperty("clickPointX", &click_point_x_); | |
349 BindProperty("clickPointY", &click_point_y_); | |
350 BindProperty("intValue", &int_value_); | |
351 BindProperty("minValue", &min_value_); | |
352 BindProperty("maxValue", &max_value_); | |
353 BindGetterCallback( | |
354 "childrenCount", | |
355 base::Bind(&AccessibilityUIElement::ChildrenCountGetterCallback, | |
356 base::Unretained(this))); | |
357 BindProperty("insertionPointLineNumber", &insertion_point_line_number_); | |
358 BindProperty("selectedTextRange", &selected_text_range); | |
359 BindGetterCallback( | |
360 "isEnabled", | |
361 base::Bind(&AccessibilityUIElement::IsEnabledGetterCallback, | |
362 base::Unretained(this))); | |
363 BindProperty("isRequired", &is_required_); | |
364 BindGetterCallback( | |
365 "isSelected", | |
366 base::Bind(&AccessibilityUIElement::IsSelectedGetterCallback, | |
367 base::Unretained(this))); | |
368 BindProperty("valueDescription", &value_description_); | |
369 | |
370 BindFallbackCallback(base::Bind(&AccessibilityUIElement::FallbackCallback, | |
371 base::Unretained(this))); | |
372 } | |
373 | |
374 AccessibilityUIElement::~AccessibilityUIElement() {} | |
375 | |
376 AccessibilityUIElement* AccessibilityUIElement::GetChildAtIndex( | |
377 unsigned index) { | |
378 return factory_->Create(accessibility_object().childAt(index)); | |
379 } | |
380 | |
381 bool AccessibilityUIElement::IsRoot() const { | |
382 return false; | |
383 } | |
384 | |
385 void AccessibilityUIElement::AllAttributesCallback( | |
386 const CppArgumentList& args, CppVariant* result) { | |
387 result->Set(GetAttributes(accessibility_object())); | |
388 } | |
389 | |
390 void AccessibilityUIElement::AttributesOfLinkedUIElementsCallback( | |
391 const CppArgumentList& args, CppVariant* result) { | |
392 result->SetNull(); | |
393 } | |
394 | |
395 void AccessibilityUIElement::AttributesOfDocumentLinksCallback( | |
396 const CppArgumentList& args, CppVariant* result) { | |
397 result->SetNull(); | |
398 } | |
399 | |
400 void AccessibilityUIElement::AttributesOfChildrenCallback( | |
401 const CppArgumentList& args, CppVariant* result) { | |
402 AttributesCollector collector; | |
403 unsigned size = accessibility_object().childCount(); | |
404 for(unsigned i = 0; i < size; ++i) { | |
405 collector.CollectAttributes(accessibility_object().childAt(i)); | |
406 } | |
407 result->Set(collector.attributes()); | |
408 } | |
409 | |
410 void AccessibilityUIElement::ParametrizedAttributeNamesCallback( | |
411 const CppArgumentList& args, CppVariant* result) { | |
412 result->SetNull(); | |
413 } | |
414 | |
415 void AccessibilityUIElement::LineForIndexCallback( | |
416 const CppArgumentList& args, CppVariant* result) { | |
417 result->SetNull(); | |
418 } | |
419 | |
420 void AccessibilityUIElement::BoundsForRangeCallback( | |
421 const CppArgumentList& args, CppVariant* result) { | |
422 result->SetNull(); | |
423 } | |
424 | |
425 void AccessibilityUIElement::StringForRangeCallback( | |
426 const CppArgumentList& args, CppVariant* result) { | |
427 result->SetNull(); | |
428 } | |
429 | |
430 void AccessibilityUIElement::ChildAtIndexCallback( | |
431 const CppArgumentList& args, CppVariant* result) { | |
432 if (args.empty() || !args[0].isNumber()) { | |
433 result->SetNull(); | |
434 return; | |
435 } | |
436 | |
437 AccessibilityUIElement* child = GetChildAtIndex(args[0].ToInt32()); | |
438 if (!child) { | |
439 result->SetNull(); | |
440 return; | |
441 } | |
442 | |
443 result->Set(*(child->GetAsCppVariant())); | |
444 } | |
445 | |
446 void AccessibilityUIElement::ElementAtPointCallback( | |
447 const CppArgumentList& args, CppVariant* result) { | |
448 result->SetNull(); | |
449 } | |
450 | |
451 void AccessibilityUIElement::AttributesOfColumnHeadersCallback( | |
452 const CppArgumentList& args, CppVariant* result) { | |
453 result->SetNull(); | |
454 } | |
455 | |
456 void AccessibilityUIElement::AttributesOfRowHeadersCallback( | |
457 const CppArgumentList& args, CppVariant* result) { | |
458 result->SetNull(); | |
459 } | |
460 | |
461 void AccessibilityUIElement::AttributesOfColumnsCallback( | |
462 const CppArgumentList& args, CppVariant* result) { | |
463 result->SetNull(); | |
464 } | |
465 | |
466 void AccessibilityUIElement::AttributesOfRowsCallback( | |
467 const CppArgumentList& args, CppVariant* result) { | |
468 result->SetNull(); | |
469 } | |
470 | |
471 void AccessibilityUIElement::AttributesOfVisibleCellsCallback( | |
472 const CppArgumentList& args, CppVariant* result) { | |
473 result->SetNull(); | |
474 } | |
475 | |
476 void AccessibilityUIElement::AttributesOfHeaderCallback( | |
477 const CppArgumentList& args, CppVariant* result) { | |
478 result->SetNull(); | |
479 } | |
480 | |
481 void AccessibilityUIElement::IndexInTableCallback( | |
482 const CppArgumentList& args, CppVariant* result) { | |
483 result->SetNull(); | |
484 } | |
485 | |
486 void AccessibilityUIElement::RowIndexRangeCallback( | |
487 const CppArgumentList& args, CppVariant* result) { | |
488 result->SetNull(); | |
489 } | |
490 | |
491 void AccessibilityUIElement::ColumnIndexRangeCallback( | |
492 const CppArgumentList& args, CppVariant* result) { | |
493 result->SetNull(); | |
494 } | |
495 | |
496 void AccessibilityUIElement::CellForColumnAndRowCallback( | |
497 const CppArgumentList& args, CppVariant* result) { | |
498 result->SetNull(); | |
499 } | |
500 | |
501 void AccessibilityUIElement::TitleUIElementCallback( | |
502 const CppArgumentList& args, CppVariant* result) { | |
503 result->SetNull(); | |
504 } | |
505 | |
506 void AccessibilityUIElement::SetSelectedTextRangeCallback( | |
507 const CppArgumentList& args, CppVariant* result) { | |
508 result->SetNull(); | |
509 } | |
510 | |
511 void AccessibilityUIElement::AttributeValueCallback( | |
512 const CppArgumentList& args, CppVariant* result) { | |
513 result->SetNull(); | |
514 } | |
515 | |
516 void AccessibilityUIElement::IsAttributeSettableCallback( | |
517 const CppArgumentList& args, CppVariant* result) { | |
518 if (args.size() < 1 && !args[0].isString()) { | |
519 result->SetNull(); | |
520 return; | |
521 } | |
522 | |
523 std::string attribute = args[0].ToString(); | |
524 bool settable = false; | |
525 if (attribute == "AXValue") { | |
526 settable = accessibility_object().canSetValueAttribute(); | |
527 } | |
528 result->Set(settable); | |
529 } | |
530 | |
531 void AccessibilityUIElement::IsActionSupportedCallback( | |
532 const CppArgumentList& args, CppVariant* result) { | |
533 // This one may be really hard to implement. | |
534 // Not exposed by AccessibilityObject. | |
535 result->SetNull(); | |
536 } | |
537 | |
538 void AccessibilityUIElement::ParentElementCallback( | |
539 const CppArgumentList& args, CppVariant* result) { | |
540 result->SetNull(); | |
541 } | |
542 | |
543 void AccessibilityUIElement::IncrementCallback( | |
544 const CppArgumentList& args, CppVariant* result) { | |
545 result->SetNull(); | |
546 } | |
547 | |
548 void AccessibilityUIElement::DecrementCallback( | |
549 const CppArgumentList& args, CppVariant* result) { | |
550 result->SetNull(); | |
551 } | |
552 | |
553 void AccessibilityUIElement::FallbackCallback(const CppArgumentList &args, | |
554 CppVariant *result) { | |
555 // TODO(dglazkov): Implement this. | |
556 result->SetNull(); | |
557 } | |
558 | |
559 void AccessibilityUIElement::ChildrenCountGetterCallback(CppVariant* result) { | |
560 int count = 1; // Root object always has only one child, the WebView. | |
561 if (!IsRoot()) | |
562 count = accessibility_object().childCount(); | |
563 result->Set(count); | |
564 } | |
565 | |
566 void AccessibilityUIElement::DescriptionGetterCallback(CppVariant *result) { | |
567 result->Set(GetDescription(accessibility_object())); | |
568 } | |
569 | |
570 void AccessibilityUIElement::IsEnabledGetterCallback(CppVariant* result) { | |
571 result->Set(accessibility_object().isEnabled()); | |
572 } | |
573 | |
574 void AccessibilityUIElement::IsSelectedGetterCallback(CppVariant* result) { | |
575 result->SetNull(); | |
576 } | |
577 | |
578 void AccessibilityUIElement::RoleGetterCallback(CppVariant* result) { | |
579 result->Set(GetRole(accessibility_object())); | |
580 } | |
581 | |
582 void AccessibilityUIElement::TitleGetterCallback(CppVariant* result) { | |
583 result->Set(GetTitle(accessibility_object())); | |
584 } | |
585 | |
586 RootAccessibilityUIElement::RootAccessibilityUIElement( | |
587 const WebKit::WebAccessibilityObject &object, | |
588 Factory *factory) | |
589 : AccessibilityUIElement(object, factory) {} | |
590 | |
591 RootAccessibilityUIElement::~RootAccessibilityUIElement() {} | |
592 | |
593 AccessibilityUIElement* RootAccessibilityUIElement::GetChildAtIndex( | |
594 unsigned index) { | |
595 if (index != 0) | |
596 return NULL; | |
597 | |
598 return factory()->Create(accessibility_object()); | |
599 } | |
600 | |
601 bool RootAccessibilityUIElement::IsRoot() const { | |
602 return true; | |
603 } | |
604 | |
605 AccessibilityUIElementList::AccessibilityUIElementList() {} | |
606 | |
607 AccessibilityUIElementList::~AccessibilityUIElementList() { | |
608 Clear(); | |
609 } | |
610 | |
611 void AccessibilityUIElementList::Clear() { | |
612 for (ElementList::iterator i = elements_.begin(); i != elements_.end(); ++i) | |
613 delete (*i); | |
614 elements_.clear(); | |
615 } | |
616 | |
617 AccessibilityUIElement* AccessibilityUIElementList::Create( | |
618 const WebAccessibilityObject& object) { | |
619 if (object.isNull()) | |
620 return NULL; | |
621 | |
622 AccessibilityUIElement* element = new AccessibilityUIElement(object, this); | |
623 elements_.push_back(element); | |
624 return element; | |
625 } | |
626 | |
627 AccessibilityUIElement* AccessibilityUIElementList::CreateRoot( | |
628 const WebAccessibilityObject& object) { | |
629 AccessibilityUIElement* element = | |
630 new RootAccessibilityUIElement(object, this); | |
631 elements_.push_back(element); | |
632 return element; | |
633 } | |
OLD | NEW |