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 #include "content/renderer/accessibility/blink_ax_tree_source.h"
9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/string_util.h"
11 #include "base/strings/utf_string_conversions.h"
12 #include "content/renderer/accessibility/blink_ax_enum_conversion.h"
13 #include "content/renderer/browser_plugin/browser_plugin.h"
14 #include "content/renderer/render_frame_impl.h"
15 #include "content/renderer/render_frame_proxy.h"
16 #include "content/renderer/render_view_impl.h"
17 #include "third_party/WebKit/public/platform/WebRect.h"
18 #include "third_party/WebKit/public/platform/WebSize.h"
19 #include "third_party/WebKit/public/platform/WebString.h"
20 #include "third_party/WebKit/public/platform/WebVector.h"
21 #include "third_party/WebKit/public/web/WebAXEnums.h"
22 #include "third_party/WebKit/public/web/WebAXObject.h"
23 #include "third_party/WebKit/public/web/WebDocument.h"
24 #include "third_party/WebKit/public/web/WebDocumentType.h"
25 #include "third_party/WebKit/public/web/WebElement.h"
26 #include "third_party/WebKit/public/web/WebFormControlElement.h"
27 #include "third_party/WebKit/public/web/WebFrame.h"
28 #include "third_party/WebKit/public/web/WebLocalFrame.h"
29 #include "third_party/WebKit/public/web/WebNode.h"
30 #include "third_party/WebKit/public/web/WebPlugin.h"
31 #include "third_party/WebKit/public/web/WebPluginContainer.h"
32 #include "third_party/WebKit/public/web/WebView.h"
34 using base::ASCIIToUTF16
;
35 using base::UTF16ToUTF8
;
36 using blink::WebAXObject
;
37 using blink::WebDocument
;
38 using blink::WebDocumentType
;
39 using blink::WebElement
;
40 using blink::WebLocalFrame
;
42 using blink::WebPlugin
;
43 using blink::WebPluginContainer
;
44 using blink::WebVector
;
51 // Returns true if |ancestor| is the first unignored parent of |child|,
52 // which means that when walking up the parent chain from |child|,
53 // |ancestor| is the *first* ancestor that isn't marked as
54 // accessibilityIsIgnored().
55 bool IsParentUnignoredOf(WebAXObject ancestor
,
57 WebAXObject parent
= child
.parentObject();
58 while (!parent
.isDetached() && parent
.accessibilityIsIgnored())
59 parent
= parent
.parentObject();
60 return parent
.equals(ancestor
);
63 std::string
GetEquivalentAriaRoleString(const ui::AXRole role
) {
65 case ui::AX_ROLE_ARTICLE
:
67 case ui::AX_ROLE_BANNER
:
69 case ui::AX_ROLE_BUTTON
:
71 case ui::AX_ROLE_COMPLEMENTARY
:
72 return "complementary";
73 case ui::AX_ROLE_FIGURE
:
75 case ui::AX_ROLE_FOOTER
:
77 case ui::AX_ROLE_HEADING
:
79 case ui::AX_ROLE_IMAGE
:
81 case ui::AX_ROLE_MAIN
:
83 case ui::AX_ROLE_NAVIGATION
:
85 case ui::AX_ROLE_RADIO_BUTTON
:
87 case ui::AX_ROLE_REGION
:
89 case ui::AX_ROLE_SLIDER
:
98 void AddIntListAttributeFromWebObjects(ui::AXIntListAttribute attr
,
99 WebVector
<WebAXObject
> objects
,
100 ui::AXNodeData
* dst
) {
101 std::vector
<int32
> ids
;
102 for(size_t i
= 0; i
< objects
.size(); i
++)
103 ids
.push_back(objects
[i
].axID());
105 dst
->AddIntListAttribute(attr
, ids
);
108 } // Anonymous namespace
110 BlinkAXTreeSource::BlinkAXTreeSource(RenderFrameImpl
* render_frame
)
111 : render_frame_(render_frame
),
112 node_to_frame_routing_id_map_(NULL
),
113 node_to_browser_plugin_instance_id_map_(NULL
),
114 accessibility_focus_id_(-1) {
117 BlinkAXTreeSource::~BlinkAXTreeSource() {
120 bool BlinkAXTreeSource::IsInTree(blink::WebAXObject node
) const {
121 const blink::WebAXObject
& root
= GetRoot();
122 while (IsValid(node
)) {
123 if (node
.equals(root
))
125 node
= GetParent(node
);
130 void BlinkAXTreeSource::CollectChildFrameIdMapping(
131 std::map
<int32
, int>* node_to_frame_routing_id_map
,
132 std::map
<int32
, int>* node_to_browser_plugin_instance_id_map
) {
133 node_to_frame_routing_id_map_
= node_to_frame_routing_id_map
;
134 node_to_browser_plugin_instance_id_map_
=
135 node_to_browser_plugin_instance_id_map
;
138 blink::WebAXObject
BlinkAXTreeSource::GetRoot() const {
139 return GetMainDocument().accessibilityObject();
142 blink::WebAXObject
BlinkAXTreeSource::GetFromId(int32 id
) const {
143 return GetMainDocument().accessibilityObjectFromID(id
);
146 int32
BlinkAXTreeSource::GetId(blink::WebAXObject node
) const {
150 void BlinkAXTreeSource::GetChildren(
151 blink::WebAXObject parent
,
152 std::vector
<blink::WebAXObject
>* out_children
) const {
153 if (parent
.role() == blink::WebAXRoleStaticText
) {
154 blink::WebAXObject ancestor
= parent
;
155 while (!ancestor
.isDetached()) {
156 if (ancestor
.axID() == accessibility_focus_id_
) {
157 parent
.loadInlineTextBoxes();
160 ancestor
= ancestor
.parentObject();
164 bool is_iframe
= false;
165 WebNode node
= parent
.node();
166 if (!node
.isNull() && node
.isElementNode()) {
167 WebElement element
= node
.to
<WebElement
>();
168 is_iframe
= (element
.tagName() == ASCIIToUTF16("IFRAME"));
171 for (unsigned i
= 0; i
< parent
.childCount(); i
++) {
172 blink::WebAXObject child
= parent
.childAt(i
);
174 // The child may be invalid due to issues in blink accessibility code.
175 if (child
.isDetached())
178 // Skip children whose parent isn't |parent|.
179 // As an exception, include children of an iframe element.
180 if (!is_iframe
&& !IsParentUnignoredOf(parent
, child
))
183 out_children
->push_back(child
);
187 blink::WebAXObject
BlinkAXTreeSource::GetParent(
188 blink::WebAXObject node
) const {
189 // Blink returns ignored objects when walking up the parent chain,
190 // we have to skip those here. Also, stop when we get to the root
192 blink::WebAXObject root
= GetRoot();
194 if (node
.equals(root
))
195 return blink::WebAXObject();
196 node
= node
.parentObject();
197 } while (!node
.isDetached() && node
.accessibilityIsIgnored());
202 bool BlinkAXTreeSource::IsValid(blink::WebAXObject node
) const {
203 return !node
.isDetached(); // This also checks if it's null.
206 bool BlinkAXTreeSource::IsEqual(blink::WebAXObject node1
,
207 blink::WebAXObject node2
) const {
208 return node1
.equals(node2
);
211 blink::WebAXObject
BlinkAXTreeSource::GetNull() const {
212 return blink::WebAXObject();
215 void BlinkAXTreeSource::SerializeNode(blink::WebAXObject src
,
216 ui::AXNodeData
* dst
) const {
217 dst
->role
= AXRoleFromBlink(src
.role());
218 dst
->state
= AXStateFromBlink(src
);
219 dst
->location
= src
.boundingBoxRect();
220 dst
->id
= src
.axID();
221 std::string name
= UTF16ToUTF8(src
.title());
224 if (src
.valueDescription().length()) {
225 dst
->AddStringAttribute(ui::AX_ATTR_VALUE
,
226 UTF16ToUTF8(src
.valueDescription()));
228 dst
->AddStringAttribute(ui::AX_ATTR_VALUE
, UTF16ToUTF8(src
.stringValue()));
231 if (dst
->role
== ui::AX_ROLE_COLOR_WELL
) {
233 src
.colorValue(r
, g
, b
);
234 dst
->AddIntAttribute(ui::AX_ATTR_COLOR_VALUE_RED
, r
);
235 dst
->AddIntAttribute(ui::AX_ATTR_COLOR_VALUE_GREEN
, g
);
236 dst
->AddIntAttribute(ui::AX_ATTR_COLOR_VALUE_BLUE
, b
);
239 if (dst
->role
== ui::AX_ROLE_INLINE_TEXT_BOX
) {
240 dst
->AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION
,
241 AXTextDirectionFromBlink(src
.textDirection()));
243 WebVector
<int> src_character_offsets
;
244 src
.characterOffsets(src_character_offsets
);
245 std::vector
<int32
> character_offsets
;
246 character_offsets
.reserve(src_character_offsets
.size());
247 for (size_t i
= 0; i
< src_character_offsets
.size(); ++i
)
248 character_offsets
.push_back(src_character_offsets
[i
]);
249 dst
->AddIntListAttribute(ui::AX_ATTR_CHARACTER_OFFSETS
, character_offsets
);
251 WebVector
<int> src_word_starts
;
252 WebVector
<int> src_word_ends
;
253 src
.wordBoundaries(src_word_starts
, src_word_ends
);
254 std::vector
<int32
> word_starts
;
255 std::vector
<int32
> word_ends
;
256 word_starts
.reserve(src_word_starts
.size());
257 word_ends
.reserve(src_word_starts
.size());
258 for (size_t i
= 0; i
< src_word_starts
.size(); ++i
) {
259 word_starts
.push_back(src_word_starts
[i
]);
260 word_ends
.push_back(src_word_ends
[i
]);
262 dst
->AddIntListAttribute(ui::AX_ATTR_WORD_STARTS
, word_starts
);
263 dst
->AddIntListAttribute(ui::AX_ATTR_WORD_ENDS
, word_ends
);
266 if (src
.accessKey().length()) {
267 dst
->AddStringAttribute(ui::AX_ATTR_ACCESS_KEY
,
268 UTF16ToUTF8(src
.accessKey()));
270 if (src
.actionVerb().length())
271 dst
->AddStringAttribute(ui::AX_ATTR_ACTION
, UTF16ToUTF8(src
.actionVerb()));
272 if (src
.ariaAutoComplete().length())
273 dst
->AddStringAttribute(ui::AX_ATTR_AUTO_COMPLETE
,
274 UTF16ToUTF8(src
.ariaAutoComplete()));
275 if (src
.isAriaReadOnly())
276 dst
->AddBoolAttribute(ui::AX_ATTR_ARIA_READONLY
, true);
277 if (src
.isButtonStateMixed())
278 dst
->AddBoolAttribute(ui::AX_ATTR_BUTTON_MIXED
, true);
279 if (src
.canSetValueAttribute())
280 dst
->AddBoolAttribute(ui::AX_ATTR_CAN_SET_VALUE
, true);
281 if (src
.accessibilityDescription().length()) {
282 dst
->AddStringAttribute(ui::AX_ATTR_DESCRIPTION
,
283 UTF16ToUTF8(src
.accessibilityDescription()));
285 if (src
.hasComputedStyle()) {
286 dst
->AddStringAttribute(ui::AX_ATTR_DISPLAY
,
287 UTF16ToUTF8(src
.computedStyleDisplay()));
289 if (src
.helpText().length())
290 dst
->AddStringAttribute(ui::AX_ATTR_HELP
, UTF16ToUTF8(src
.helpText()));
291 if (src
.keyboardShortcut().length()) {
292 dst
->AddStringAttribute(ui::AX_ATTR_SHORTCUT
,
293 UTF16ToUTF8(src
.keyboardShortcut()));
295 if (!src
.titleUIElement().isDetached()) {
296 dst
->AddIntAttribute(ui::AX_ATTR_TITLE_UI_ELEMENT
,
297 src
.titleUIElement().axID());
299 if (!src
.ariaActiveDescendant().isDetached()) {
300 dst
->AddIntAttribute(ui::AX_ATTR_ACTIVEDESCENDANT_ID
,
301 src
.ariaActiveDescendant().axID());
304 if (!src
.url().isEmpty())
305 dst
->AddStringAttribute(ui::AX_ATTR_URL
, src
.url().spec());
307 if (dst
->role
== ui::AX_ROLE_HEADING
)
308 dst
->AddIntAttribute(ui::AX_ATTR_HIERARCHICAL_LEVEL
, src
.headingLevel());
309 else if ((dst
->role
== ui::AX_ROLE_TREE_ITEM
||
310 dst
->role
== ui::AX_ROLE_ROW
) &&
311 src
.hierarchicalLevel() > 0) {
312 dst
->AddIntAttribute(ui::AX_ATTR_HIERARCHICAL_LEVEL
,
313 src
.hierarchicalLevel());
316 // Treat the active list box item as focused.
317 if (dst
->role
== ui::AX_ROLE_LIST_BOX_OPTION
&&
318 src
.isSelectedOptionActive()) {
319 dst
->state
|= (1 << ui::AX_STATE_FOCUSED
);
322 if (src
.canvasHasFallbackContent())
323 dst
->AddBoolAttribute(ui::AX_ATTR_CANVAS_HAS_FALLBACK
, true);
325 WebNode node
= src
.node();
326 bool is_iframe
= false;
328 if (!node
.isNull() && node
.isElementNode()) {
329 WebElement element
= node
.to
<WebElement
>();
330 is_iframe
= (element
.tagName() == ASCIIToUTF16("IFRAME"));
332 // TODO(ctguil): The tagName in WebKit is lower cased but
333 // HTMLElement::nodeName calls localNameUpper. Consider adding
334 // a WebElement method that returns the original lower cased tagName.
335 dst
->AddStringAttribute(
336 ui::AX_ATTR_HTML_TAG
,
337 base::StringToLowerASCII(UTF16ToUTF8(element
.tagName())));
338 for (unsigned i
= 0; i
< element
.attributeCount(); ++i
) {
339 std::string name
= base::StringToLowerASCII(UTF16ToUTF8(
340 element
.attributeLocalName(i
)));
341 std::string value
= UTF16ToUTF8(element
.attributeValue(i
));
342 dst
->html_attributes
.push_back(std::make_pair(name
, value
));
345 if (dst
->role
== ui::AX_ROLE_TEXT_AREA
||
346 dst
->role
== ui::AX_ROLE_TEXT_FIELD
) {
347 dst
->AddIntAttribute(ui::AX_ATTR_TEXT_SEL_START
, src
.selectionStart());
348 dst
->AddIntAttribute(ui::AX_ATTR_TEXT_SEL_END
, src
.selectionEnd());
350 WebVector
<int> src_line_breaks
;
351 src
.lineBreaks(src_line_breaks
);
352 if (src_line_breaks
.size() > 0) {
353 std::vector
<int32
> line_breaks
;
354 line_breaks
.reserve(src_line_breaks
.size());
355 for (size_t i
= 0; i
< src_line_breaks
.size(); ++i
)
356 line_breaks
.push_back(src_line_breaks
[i
]);
357 dst
->AddIntListAttribute(ui::AX_ATTR_LINE_BREAKS
, line_breaks
);
360 if (dst
->role
== ui::AX_ROLE_TEXT_FIELD
&&
361 src
.textInputType().length()) {
362 dst
->AddStringAttribute(ui::AX_ATTR_TEXT_INPUT_TYPE
,
363 UTF16ToUTF8(src
.textInputType()));
368 if (element
.hasAttribute("role")) {
369 dst
->AddStringAttribute(ui::AX_ATTR_ROLE
,
370 UTF16ToUTF8(element
.getAttribute("role")));
372 std::string role
= GetEquivalentAriaRoleString(dst
->role
);
374 dst
->AddStringAttribute(ui::AX_ATTR_ROLE
, role
);
377 // Browser plugin (used in a <webview>).
378 if (node_to_browser_plugin_instance_id_map_
) {
379 BrowserPlugin
* browser_plugin
= BrowserPlugin::GetFromNode(element
);
380 if (browser_plugin
) {
381 (*node_to_browser_plugin_instance_id_map_
)[dst
->id
] =
382 browser_plugin
->browser_plugin_instance_id();
383 dst
->AddBoolAttribute(ui::AX_ATTR_IS_AX_TREE_HOST
, true);
388 if (src
.isInLiveRegion()) {
389 dst
->AddBoolAttribute(ui::AX_ATTR_LIVE_ATOMIC
, src
.liveRegionAtomic());
390 dst
->AddBoolAttribute(ui::AX_ATTR_LIVE_BUSY
, src
.liveRegionBusy());
391 if (src
.liveRegionBusy())
392 dst
->state
|= (1 << ui::AX_STATE_BUSY
);
393 if (!src
.liveRegionStatus().isEmpty()) {
394 dst
->AddStringAttribute(ui::AX_ATTR_LIVE_STATUS
,
395 UTF16ToUTF8(src
.liveRegionStatus()));
397 dst
->AddStringAttribute(ui::AX_ATTR_LIVE_RELEVANT
,
398 UTF16ToUTF8(src
.liveRegionRelevant()));
399 dst
->AddBoolAttribute(ui::AX_ATTR_CONTAINER_LIVE_ATOMIC
,
400 src
.containerLiveRegionAtomic());
401 dst
->AddBoolAttribute(ui::AX_ATTR_CONTAINER_LIVE_BUSY
,
402 src
.containerLiveRegionBusy());
403 dst
->AddStringAttribute(ui::AX_ATTR_CONTAINER_LIVE_STATUS
,
404 UTF16ToUTF8(src
.containerLiveRegionStatus()));
405 dst
->AddStringAttribute(ui::AX_ATTR_CONTAINER_LIVE_RELEVANT
,
406 UTF16ToUTF8(src
.containerLiveRegionRelevant()));
409 if (dst
->role
== ui::AX_ROLE_PROGRESS_INDICATOR
||
410 dst
->role
== ui::AX_ROLE_SCROLL_BAR
||
411 dst
->role
== ui::AX_ROLE_SLIDER
||
412 dst
->role
== ui::AX_ROLE_SPIN_BUTTON
) {
413 dst
->AddFloatAttribute(ui::AX_ATTR_VALUE_FOR_RANGE
, src
.valueForRange());
414 dst
->AddFloatAttribute(ui::AX_ATTR_MAX_VALUE_FOR_RANGE
,
415 src
.maxValueForRange());
416 dst
->AddFloatAttribute(ui::AX_ATTR_MIN_VALUE_FOR_RANGE
,
417 src
.minValueForRange());
420 if (dst
->role
== ui::AX_ROLE_DOCUMENT
||
421 dst
->role
== ui::AX_ROLE_WEB_AREA
) {
422 dst
->AddStringAttribute(ui::AX_ATTR_HTML_TAG
, "#document");
423 const WebDocument
& document
= src
.document();
425 name
= UTF16ToUTF8(document
.title());
426 dst
->AddStringAttribute(ui::AX_ATTR_DOC_TITLE
,
427 UTF16ToUTF8(document
.title()));
428 dst
->AddStringAttribute(ui::AX_ATTR_DOC_URL
, document
.url().spec());
429 dst
->AddStringAttribute(
430 ui::AX_ATTR_DOC_MIMETYPE
,
431 document
.isXHTMLDocument() ? "text/xhtml" : "text/html");
432 dst
->AddBoolAttribute(ui::AX_ATTR_DOC_LOADED
, src
.isLoaded());
433 dst
->AddFloatAttribute(ui::AX_ATTR_DOC_LOADING_PROGRESS
,
434 src
.estimatedLoadingProgress());
436 const WebDocumentType
& doctype
= document
.doctype();
437 if (!doctype
.isNull()) {
438 dst
->AddStringAttribute(ui::AX_ATTR_DOC_DOCTYPE
,
439 UTF16ToUTF8(doctype
.name()));
442 const gfx::Size
& scroll_offset
= document
.scrollOffset();
443 dst
->AddIntAttribute(ui::AX_ATTR_SCROLL_X
, scroll_offset
.width());
444 dst
->AddIntAttribute(ui::AX_ATTR_SCROLL_Y
, scroll_offset
.height());
446 const gfx::Size
& min_offset
= document
.minimumScrollOffset();
447 dst
->AddIntAttribute(ui::AX_ATTR_SCROLL_X_MIN
, min_offset
.width());
448 dst
->AddIntAttribute(ui::AX_ATTR_SCROLL_Y_MIN
, min_offset
.height());
450 const gfx::Size
& max_offset
= document
.maximumScrollOffset();
451 dst
->AddIntAttribute(ui::AX_ATTR_SCROLL_X_MAX
, max_offset
.width());
452 dst
->AddIntAttribute(ui::AX_ATTR_SCROLL_Y_MAX
, max_offset
.height());
454 if (node_to_frame_routing_id_map_
&& !src
.equals(GetRoot())) {
455 WebLocalFrame
* frame
= document
.frame();
456 RenderFrameImpl
* render_frame
= RenderFrameImpl::FromWebFrame(frame
);
458 (*node_to_frame_routing_id_map_
)[dst
->id
] =
459 render_frame
->GetRoutingID();
460 dst
->AddBoolAttribute(ui::AX_ATTR_IS_AX_TREE_HOST
, true);
462 RenderFrameProxy
* render_frame_proxy
=
463 RenderFrameProxy::FromWebFrame(frame
);
464 if (render_frame_proxy
) {
465 (*node_to_frame_routing_id_map_
)[dst
->id
] =
466 render_frame_proxy
->routing_id();
467 dst
->AddBoolAttribute(ui::AX_ATTR_IS_AX_TREE_HOST
, true);
473 if (dst
->role
== ui::AX_ROLE_TABLE
) {
474 int column_count
= src
.columnCount();
475 int row_count
= src
.rowCount();
476 if (column_count
> 0 && row_count
> 0) {
477 std::set
<int32
> unique_cell_id_set
;
478 std::vector
<int32
> cell_ids
;
479 std::vector
<int32
> unique_cell_ids
;
480 dst
->AddIntAttribute(ui::AX_ATTR_TABLE_COLUMN_COUNT
, column_count
);
481 dst
->AddIntAttribute(ui::AX_ATTR_TABLE_ROW_COUNT
, row_count
);
482 WebAXObject header
= src
.headerContainerObject();
483 if (!header
.isDetached())
484 dst
->AddIntAttribute(ui::AX_ATTR_TABLE_HEADER_ID
, header
.axID());
485 for (int i
= 0; i
< column_count
* row_count
; ++i
) {
486 WebAXObject cell
= src
.cellForColumnAndRow(
487 i
% column_count
, i
/ column_count
);
489 if (!cell
.isDetached()) {
490 cell_id
= cell
.axID();
491 if (unique_cell_id_set
.find(cell_id
) == unique_cell_id_set
.end()) {
492 unique_cell_id_set
.insert(cell_id
);
493 unique_cell_ids
.push_back(cell_id
);
496 cell_ids
.push_back(cell_id
);
498 dst
->AddIntListAttribute(ui::AX_ATTR_CELL_IDS
, cell_ids
);
499 dst
->AddIntListAttribute(ui::AX_ATTR_UNIQUE_CELL_IDS
, unique_cell_ids
);
503 if (dst
->role
== ui::AX_ROLE_ROW
) {
504 dst
->AddIntAttribute(ui::AX_ATTR_TABLE_ROW_INDEX
, src
.rowIndex());
505 WebAXObject header
= src
.rowHeader();
506 if (!header
.isDetached())
507 dst
->AddIntAttribute(ui::AX_ATTR_TABLE_ROW_HEADER_ID
, header
.axID());
510 if (dst
->role
== ui::AX_ROLE_COLUMN
) {
511 dst
->AddIntAttribute(ui::AX_ATTR_TABLE_COLUMN_INDEX
, src
.columnIndex());
512 WebAXObject header
= src
.columnHeader();
513 if (!header
.isDetached())
514 dst
->AddIntAttribute(ui::AX_ATTR_TABLE_COLUMN_HEADER_ID
, header
.axID());
517 if (dst
->role
== ui::AX_ROLE_CELL
||
518 dst
->role
== ui::AX_ROLE_ROW_HEADER
||
519 dst
->role
== ui::AX_ROLE_COLUMN_HEADER
) {
520 dst
->AddIntAttribute(ui::AX_ATTR_TABLE_CELL_COLUMN_INDEX
,
521 src
.cellColumnIndex());
522 dst
->AddIntAttribute(ui::AX_ATTR_TABLE_CELL_COLUMN_SPAN
,
523 src
.cellColumnSpan());
524 dst
->AddIntAttribute(ui::AX_ATTR_TABLE_CELL_ROW_INDEX
, src
.cellRowIndex());
525 dst
->AddIntAttribute(ui::AX_ATTR_TABLE_CELL_ROW_SPAN
, src
.cellRowSpan());
528 dst
->AddStringAttribute(ui::AX_ATTR_NAME
, name
);
530 // Add the ids of *indirect* children - those who are children of this node,
531 // but whose parent is *not* this node. One example is a table
532 // cell, which is a child of both a row and a column. Because the cell's
533 // parent is the row, the row adds it as a child, and the column adds it
534 // as an indirect child.
535 int child_count
= src
.childCount();
536 for (int i
= 0; i
< child_count
; ++i
) {
537 WebAXObject child
= src
.childAt(i
);
538 std::vector
<int32
> indirect_child_ids
;
539 if (!is_iframe
&& !child
.isDetached() && !IsParentUnignoredOf(src
, child
))
540 indirect_child_ids
.push_back(child
.axID());
541 if (indirect_child_ids
.size() > 0) {
542 dst
->AddIntListAttribute(
543 ui::AX_ATTR_INDIRECT_CHILD_IDS
, indirect_child_ids
);
547 WebVector
<WebAXObject
> controls
;
548 if (src
.ariaControls(controls
))
549 AddIntListAttributeFromWebObjects(ui::AX_ATTR_CONTROLS_IDS
, controls
, dst
);
551 WebVector
<WebAXObject
> describedby
;
552 if (src
.ariaDescribedby(describedby
)) {
553 AddIntListAttributeFromWebObjects(
554 ui::AX_ATTR_DESCRIBEDBY_IDS
, describedby
, dst
);
557 WebVector
<WebAXObject
> flowTo
;
558 if (src
.ariaFlowTo(flowTo
))
559 AddIntListAttributeFromWebObjects(ui::AX_ATTR_FLOWTO_IDS
, flowTo
, dst
);
561 WebVector
<WebAXObject
> labelledby
;
562 if (src
.ariaLabelledby(labelledby
)) {
563 AddIntListAttributeFromWebObjects(
564 ui::AX_ATTR_LABELLEDBY_IDS
, labelledby
, dst
);
567 WebVector
<WebAXObject
> owns
;
568 if (src
.ariaOwns(owns
))
569 AddIntListAttributeFromWebObjects(ui::AX_ATTR_OWNS_IDS
, owns
, dst
);
572 blink::WebDocument
BlinkAXTreeSource::GetMainDocument() const {
573 if (render_frame_
&& render_frame_
->GetWebFrame())
574 return render_frame_
->GetWebFrame()->document();
575 return WebDocument();
578 } // namespace content