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

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

Issue 1547643002: ARIA 1.1: implementation for aria-col-* and aria-row-*. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adds MODULES_EXPORT Created 5 years 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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/blink_ax_tree_source.h" 5 #include "content/renderer/accessibility/blink_ax_tree_source.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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 case ui::AX_ROLE_MAIN: 82 case ui::AX_ROLE_MAIN:
83 return "main"; 83 return "main";
84 case ui::AX_ROLE_NAVIGATION: 84 case ui::AX_ROLE_NAVIGATION:
85 return "navigation"; 85 return "navigation";
86 case ui::AX_ROLE_RADIO_BUTTON: 86 case ui::AX_ROLE_RADIO_BUTTON:
87 return "radio"; 87 return "radio";
88 case ui::AX_ROLE_REGION: 88 case ui::AX_ROLE_REGION:
89 return "region"; 89 return "region";
90 case ui::AX_ROLE_SLIDER: 90 case ui::AX_ROLE_SLIDER:
91 return "slider"; 91 return "slider";
92 case ui::AX_ROLE_TIME:
93 return "time";
92 default: 94 default:
93 break; 95 break;
94 } 96 }
95 97
96 return std::string(); 98 return std::string();
97 } 99 }
98 100
99 void AddIntListAttributeFromWebObjects(ui::AXIntListAttribute attr, 101 void AddIntListAttributeFromWebObjects(ui::AXIntListAttribute attr,
100 WebVector<WebAXObject> objects, 102 WebVector<WebAXObject> objects,
101 AXContentNodeData* dst) { 103 AXContentNodeData* dst) {
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 448
447 // ARIA role. 449 // ARIA role.
448 if (element.hasAttribute("role")) { 450 if (element.hasAttribute("role")) {
449 dst->AddStringAttribute( 451 dst->AddStringAttribute(
450 ui::AX_ATTR_ROLE, 452 ui::AX_ATTR_ROLE,
451 element.getAttribute("role").utf8()); 453 element.getAttribute("role").utf8());
452 } else { 454 } else {
453 std::string role = GetEquivalentAriaRoleString(dst->role); 455 std::string role = GetEquivalentAriaRoleString(dst->role);
454 if (!role.empty()) 456 if (!role.empty())
455 dst->AddStringAttribute(ui::AX_ATTR_ROLE, role); 457 dst->AddStringAttribute(ui::AX_ATTR_ROLE, role);
456 else if (dst->role == ui::AX_ROLE_TIME)
457 dst->AddStringAttribute(ui::AX_ATTR_ROLE, "time");
458 } 458 }
459 459
460 // Browser plugin (used in a <webview>). 460 // Browser plugin (used in a <webview>).
461 BrowserPlugin* browser_plugin = BrowserPlugin::GetFromNode(element); 461 BrowserPlugin* browser_plugin = BrowserPlugin::GetFromNode(element);
462 if (browser_plugin) { 462 if (browser_plugin) {
463 dst->AddContentIntAttribute( 463 dst->AddContentIntAttribute(
464 AX_CONTENT_ATTR_CHILD_BROWSER_PLUGIN_INSTANCE_ID, 464 AX_CONTENT_ATTR_CHILD_BROWSER_PLUGIN_INSTANCE_ID,
465 browser_plugin->browser_plugin_instance_id()); 465 browser_plugin->browser_plugin_instance_id());
466 } 466 }
467 467
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 unique_cell_ids.push_back(cell_id); 543 unique_cell_ids.push_back(cell_id);
544 } 544 }
545 } 545 }
546 cell_ids.push_back(cell_id); 546 cell_ids.push_back(cell_id);
547 } 547 }
548 dst->AddIntListAttribute(ui::AX_ATTR_CELL_IDS, cell_ids); 548 dst->AddIntListAttribute(ui::AX_ATTR_CELL_IDS, cell_ids);
549 dst->AddIntListAttribute(ui::AX_ATTR_UNIQUE_CELL_IDS, unique_cell_ids); 549 dst->AddIntListAttribute(ui::AX_ATTR_UNIQUE_CELL_IDS, unique_cell_ids);
550 } 550 }
551 } 551 }
552 552
553 if (dst->role == ui::AX_ROLE_TABLE ||
554 dst->role == ui::AX_ROLE_GRID ||
555 dst->role == ui::AX_ROLE_TREE_GRID) {
556 int aria_colcount = src.ariaColumnCount();
557 if (aria_colcount)
558 dst->AddIntAttribute(ui::AX_ATTR_ARIA_COL_COUNT, aria_colcount);
559
560 int aria_rowcount = src.ariaRowCount();
561 if (aria_rowcount)
562 dst->AddIntAttribute(ui::AX_ATTR_ARIA_ROW_COUNT, aria_rowcount);
563 }
564
553 if (dst->role == ui::AX_ROLE_ROW) { 565 if (dst->role == ui::AX_ROLE_ROW) {
554 dst->AddIntAttribute(ui::AX_ATTR_TABLE_ROW_INDEX, src.rowIndex()); 566 dst->AddIntAttribute(ui::AX_ATTR_TABLE_ROW_INDEX, src.rowIndex());
555 WebAXObject header = src.rowHeader(); 567 WebAXObject header = src.rowHeader();
556 if (!header.isDetached()) 568 if (!header.isDetached())
557 dst->AddIntAttribute(ui::AX_ATTR_TABLE_ROW_HEADER_ID, header.axID()); 569 dst->AddIntAttribute(ui::AX_ATTR_TABLE_ROW_HEADER_ID, header.axID());
558 } 570 }
559 571
560 if (dst->role == ui::AX_ROLE_COLUMN) { 572 if (dst->role == ui::AX_ROLE_COLUMN) {
561 dst->AddIntAttribute(ui::AX_ATTR_TABLE_COLUMN_INDEX, src.columnIndex()); 573 dst->AddIntAttribute(ui::AX_ATTR_TABLE_COLUMN_INDEX, src.columnIndex());
562 WebAXObject header = src.columnHeader(); 574 WebAXObject header = src.columnHeader();
563 if (!header.isDetached()) 575 if (!header.isDetached())
564 dst->AddIntAttribute(ui::AX_ATTR_TABLE_COLUMN_HEADER_ID, header.axID()); 576 dst->AddIntAttribute(ui::AX_ATTR_TABLE_COLUMN_HEADER_ID, header.axID());
565 } 577 }
566 578
567 if (dst->role == ui::AX_ROLE_CELL || 579 if (dst->role == ui::AX_ROLE_CELL ||
568 dst->role == ui::AX_ROLE_ROW_HEADER || 580 dst->role == ui::AX_ROLE_ROW_HEADER ||
569 dst->role == ui::AX_ROLE_COLUMN_HEADER) { 581 dst->role == ui::AX_ROLE_COLUMN_HEADER ||
570 dst->AddIntAttribute(ui::AX_ATTR_TABLE_CELL_COLUMN_INDEX, 582 dst->role == ui::AX_ROLE_ROW) {
571 src.cellColumnIndex()); 583 if (dst->role != ui::AX_ROLE_ROW) {
572 dst->AddIntAttribute(ui::AX_ATTR_TABLE_CELL_COLUMN_SPAN, 584 dst->AddIntAttribute(ui::AX_ATTR_TABLE_CELL_COLUMN_INDEX,
573 src.cellColumnSpan()); 585 src.cellColumnIndex());
574 dst->AddIntAttribute(ui::AX_ATTR_TABLE_CELL_ROW_INDEX, src.cellRowIndex()); 586 dst->AddIntAttribute(ui::AX_ATTR_TABLE_CELL_COLUMN_SPAN,
575 dst->AddIntAttribute(ui::AX_ATTR_TABLE_CELL_ROW_SPAN, src.cellRowSpan()); 587 src.cellColumnSpan());
588 dst->AddIntAttribute(ui::AX_ATTR_TABLE_CELL_ROW_INDEX,
589 src.cellRowIndex());
590 dst->AddIntAttribute(ui::AX_ATTR_TABLE_CELL_ROW_SPAN,src.cellRowSpan());
591
592 int aria_colindex = src.ariaColumnIndex();
593 if (aria_colindex)
594 dst->AddIntAttribute(ui::AX_ATTR_ARIA_COL_INDEX, aria_colindex);
595 }
596
597 int aria_rowindex = src.ariaRowIndex();
598 if (aria_rowindex)
599 dst->AddIntAttribute(ui::AX_ATTR_ARIA_ROW_INDEX, aria_rowindex);
576 } 600 }
577 601
578 if ((dst->role == ui::AX_ROLE_ROW_HEADER || 602 if ((dst->role == ui::AX_ROLE_ROW_HEADER ||
579 dst->role == ui::AX_ROLE_COLUMN_HEADER) && src.sortDirection()) { 603 dst->role == ui::AX_ROLE_COLUMN_HEADER) && src.sortDirection()) {
580 dst->AddIntAttribute(ui::AX_ATTR_SORT_DIRECTION, 604 dst->AddIntAttribute(ui::AX_ATTR_SORT_DIRECTION,
581 AXSortDirectionFromBlink(src.sortDirection())); 605 AXSortDirectionFromBlink(src.sortDirection()));
582 } 606 }
583 607
584 // Add the ids of *indirect* children - those who are children of this node, 608 // Add the ids of *indirect* children - those who are children of this node,
585 // but whose parent is *not* this node. One example is a table 609 // but whose parent is *not* this node. One example is a table
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 } 645 }
622 } 646 }
623 647
624 blink::WebDocument BlinkAXTreeSource::GetMainDocument() const { 648 blink::WebDocument BlinkAXTreeSource::GetMainDocument() const {
625 if (render_frame_ && render_frame_->GetWebFrame()) 649 if (render_frame_ && render_frame_->GetWebFrame())
626 return render_frame_->GetWebFrame()->document(); 650 return render_frame_->GetWebFrame()->document();
627 return WebDocument(); 651 return WebDocument();
628 } 652 }
629 653
630 } // namespace content 654 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698