Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1064)

Side by Side Diff: content/renderer/accessibility/accessibility_node_serializer.cc

Issue 175613002: Include relationship ARIA objects in serialized accessibility tree (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Revert spurious changes Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/accessibility/accessibility_node_serializer.h" 5 #include "content/renderer/accessibility/accessibility_node_serializer.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 if (src.helpText().length()) 151 if (src.helpText().length())
152 dst->AddStringAttribute(ui::AX_ATTR_HELP, UTF16ToUTF8(src.helpText())); 152 dst->AddStringAttribute(ui::AX_ATTR_HELP, UTF16ToUTF8(src.helpText()));
153 if (src.keyboardShortcut().length()) { 153 if (src.keyboardShortcut().length()) {
154 dst->AddStringAttribute(ui::AX_ATTR_SHORTCUT, 154 dst->AddStringAttribute(ui::AX_ATTR_SHORTCUT,
155 UTF16ToUTF8(src.keyboardShortcut())); 155 UTF16ToUTF8(src.keyboardShortcut()));
156 } 156 }
157 if (!src.titleUIElement().isDetached()) { 157 if (!src.titleUIElement().isDetached()) {
158 dst->AddIntAttribute(ui::AX_ATTR_TITLE_UI_ELEMENT, 158 dst->AddIntAttribute(ui::AX_ATTR_TITLE_UI_ELEMENT,
159 src.titleUIElement().axID()); 159 src.titleUIElement().axID());
160 } 160 }
161 if (!src.activeDescendant().isDetached()) {
162 dst->AddIntAttribute(ui::AX_ATTR_ACTIVEDESCENDANT_ID,
163 src.activeDescendant().axID());
164 }
165
161 if (!src.url().isEmpty()) 166 if (!src.url().isEmpty())
162 dst->AddStringAttribute(ui::AX_ATTR_URL, src.url().spec()); 167 dst->AddStringAttribute(ui::AX_ATTR_URL, src.url().spec());
163 168
164 if (dst->role == ui::AX_ROLE_HEADING) 169 if (dst->role == ui::AX_ROLE_HEADING)
165 dst->AddIntAttribute(ui::AX_ATTR_HIERARCHICAL_LEVEL, src.headingLevel()); 170 dst->AddIntAttribute(ui::AX_ATTR_HIERARCHICAL_LEVEL, src.headingLevel());
166 else if ((dst->role == ui::AX_ROLE_TREE_ITEM || 171 else if ((dst->role == ui::AX_ROLE_TREE_ITEM ||
167 dst->role == ui::AX_ROLE_ROW) && 172 dst->role == ui::AX_ROLE_ROW) &&
168 src.hierarchicalLevel() > 0) { 173 src.hierarchicalLevel() > 0) {
169 dst->AddIntAttribute(ui::AX_ATTR_HIERARCHICAL_LEVEL, 174 dst->AddIntAttribute(ui::AX_ATTR_HIERARCHICAL_LEVEL,
170 src.hierarchicalLevel()); 175 src.hierarchicalLevel());
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 } 407 }
403 408
404 dst->AddStringAttribute(ui::AX_ATTR_NAME, name); 409 dst->AddStringAttribute(ui::AX_ATTR_NAME, name);
405 410
406 // Add the ids of *indirect* children - those who are children of this node, 411 // Add the ids of *indirect* children - those who are children of this node,
407 // but whose parent is *not* this node. One example is a table 412 // but whose parent is *not* this node. One example is a table
408 // cell, which is a child of both a row and a column. Because the cell's 413 // cell, which is a child of both a row and a column. Because the cell's
409 // parent is the row, the row adds it as a child, and the column adds it 414 // parent is the row, the row adds it as a child, and the column adds it
410 // as an indirect child. 415 // as an indirect child.
411 int child_count = src.childCount(); 416 int child_count = src.childCount();
417 std::vector<int32> indirect_child_ids;
412 for (int i = 0; i < child_count; ++i) { 418 for (int i = 0; i < child_count; ++i) {
413 WebAXObject child = src.childAt(i); 419 WebAXObject child = src.childAt(i);
414 std::vector<int32> indirect_child_ids;
415 if (!is_iframe && !child.isDetached() && !IsParentUnignoredOf(src, child)) 420 if (!is_iframe && !child.isDetached() && !IsParentUnignoredOf(src, child))
416 indirect_child_ids.push_back(child.axID()); 421 indirect_child_ids.push_back(child.axID());
417 if (indirect_child_ids.size() > 0) { 422 }
418 dst->AddIntListAttribute( 423 if (indirect_child_ids.size() > 0) {
419 ui::AX_ATTR_INDIRECT_CHILD_IDS, indirect_child_ids); 424 dst->AddIntListAttribute(ui::AX_ATTR_INDIRECT_CHILD_IDS,
420 } 425 indirect_child_ids);
426 }
427
428 WebVector<WebAXObject> controls;
429 if (src.controls(controls)) {
430 std::vector<int32> controls_ids;
431 for(size_t i = 0; i < controls.size(); i++)
432 controls_ids.push_back(controls[i].axID());
433 if (controls_ids.size() > 0)
434 dst->AddIntListAttribute(ui::AX_ATTR_CONTROLS_IDS, controls_ids);
435 }
436
437 WebVector<WebAXObject> describedby;
438 if (src.describedby(describedby)) {
439 std::vector<int32> describedby_ids;
440 for(size_t i = 0; i < describedby.size(); i++)
dmazzoni 2014/03/11 23:37:52 Maybe a helper function here too - that goes from
aboxhall 2014/03/12 17:50:47 Done.
441 describedby_ids.push_back(describedby[i].axID());
442 if (describedby_ids.size() > 0)
443 dst->AddIntListAttribute(ui::AX_ATTR_DESCRIBEDBY_IDS, describedby_ids);
444 }
445
446 WebVector<WebAXObject> flowTo;
447 if (src.flowTo(flowTo)) {
448 std::vector<int32> flowTo_ids;
449 for(size_t i = 0; i < flowTo.size(); i++)
450 flowTo_ids.push_back(flowTo[i].axID());
451 if (flowTo_ids.size() > 0)
452 dst->AddIntListAttribute(ui::AX_ATTR_FLOWTO_IDS, flowTo_ids);
453 }
454
455 WebVector<WebAXObject> labelledby;
456 if (src.labelledby(labelledby)) {
457 std::vector<int32> labelledby_ids;
458 for(size_t i = 0; i < labelledby.size(); i++)
459 labelledby_ids.push_back(labelledby[i].axID());
460 if (labelledby_ids.size() > 0)
461 dst->AddIntListAttribute(ui::AX_ATTR_LABELLEDBY_IDS, labelledby_ids);
462 }
463
464 WebVector<WebAXObject> owns;
465 if (src.owns(owns)) {
466 std::vector<int32> owns_ids;
467 for(size_t i = 0; i < owns.size(); i++)
468 owns_ids.push_back(owns[i].axID());
469 if (owns_ids.size() > 0)
470 dst->AddIntListAttribute(ui::AX_ATTR_OWNS_IDS, owns_ids);
421 } 471 }
422 } 472 }
423 473
424 bool ShouldIncludeChildNode( 474 bool ShouldIncludeChildNode(
425 const WebAXObject& parent, 475 const WebAXObject& parent,
426 const WebAXObject& child) { 476 const WebAXObject& child) {
427 // The child may be invalid due to issues in webkit accessibility code. 477 // The child may be invalid due to issues in webkit accessibility code.
428 // Don't add children that are invalid thus preventing a crash. 478 // Don't add children that are invalid thus preventing a crash.
429 // https://bugs.webkit.org/show_bug.cgi?id=44149 479 // https://bugs.webkit.org/show_bug.cgi?id=44149
430 // TODO(ctguil): We may want to remove this check as webkit stabilizes. 480 // TODO(ctguil): We may want to remove this check as webkit stabilizes.
431 if (child.isDetached()) 481 if (child.isDetached())
432 return false; 482 return false;
433 483
434 // Skip children whose parent isn't this - see indirect_child_ids, above. 484 // Skip children whose parent isn't this - see indirect_child_ids, above.
435 // As an exception, include children of an iframe element. 485 // As an exception, include children of an iframe element.
436 bool is_iframe = false; 486 bool is_iframe = false;
437 WebNode node = parent.node(); 487 WebNode node = parent.node();
438 if (!node.isNull() && node.isElementNode()) { 488 if (!node.isNull() && node.isElementNode()) {
439 WebElement element = node.to<WebElement>(); 489 WebElement element = node.to<WebElement>();
440 is_iframe = (element.tagName() == base::ASCIIToUTF16("IFRAME")); 490 is_iframe = (element.tagName() == base::ASCIIToUTF16("IFRAME"));
441 } 491 }
442 492
443 return (is_iframe || IsParentUnignoredOf(parent, child)); 493 return (is_iframe || IsParentUnignoredOf(parent, child));
444 } 494 }
445 495
446 } // namespace content 496 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698