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

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

Issue 2539503003: ARIA 1.1: implementation for aria-col-* and aria-row-*. (Closed)
Patch Set: Fix bad rebase Created 3 years, 11 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
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <set> 9 #include <set>
10 10
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 case ui::AX_ROLE_MAIN: 93 case ui::AX_ROLE_MAIN:
94 return "main"; 94 return "main";
95 case ui::AX_ROLE_NAVIGATION: 95 case ui::AX_ROLE_NAVIGATION:
96 return "navigation"; 96 return "navigation";
97 case ui::AX_ROLE_RADIO_BUTTON: 97 case ui::AX_ROLE_RADIO_BUTTON:
98 return "radio"; 98 return "radio";
99 case ui::AX_ROLE_REGION: 99 case ui::AX_ROLE_REGION:
100 return "region"; 100 return "region";
101 case ui::AX_ROLE_SLIDER: 101 case ui::AX_ROLE_SLIDER:
102 return "slider"; 102 return "slider";
103 case ui::AX_ROLE_TIME:
104 return "time";
103 default: 105 default:
104 break; 106 break;
105 } 107 }
106 108
107 return std::string(); 109 return std::string();
108 } 110 }
109 111
110 void AddIntListAttributeFromWebObjects(ui::AXIntListAttribute attr, 112 void AddIntListAttributeFromWebObjects(ui::AXIntListAttribute attr,
111 WebVector<WebAXObject> objects, 113 WebVector<WebAXObject> objects,
112 AXContentNodeData* dst) { 114 AXContentNodeData* dst) {
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 unique_cell_ids.push_back(cell_id); 604 unique_cell_ids.push_back(cell_id);
603 } 605 }
604 } 606 }
605 cell_ids.push_back(cell_id); 607 cell_ids.push_back(cell_id);
606 } 608 }
607 dst->AddIntListAttribute(ui::AX_ATTR_CELL_IDS, cell_ids); 609 dst->AddIntListAttribute(ui::AX_ATTR_CELL_IDS, cell_ids);
608 dst->AddIntListAttribute(ui::AX_ATTR_UNIQUE_CELL_IDS, unique_cell_ids); 610 dst->AddIntListAttribute(ui::AX_ATTR_UNIQUE_CELL_IDS, unique_cell_ids);
609 } 611 }
610 } 612 }
611 613
614 if (dst->role == ui::AX_ROLE_TABLE ||
615 dst->role == ui::AX_ROLE_GRID ||
616 dst->role == ui::AX_ROLE_TREE_GRID) {
617 int aria_colcount = src.ariaColumnCount();
618 if (aria_colcount)
619 dst->AddIntAttribute(ui::AX_ATTR_ARIA_COL_COUNT, aria_colcount);
620
621 int aria_rowcount = src.ariaRowCount();
622 if (aria_rowcount)
623 dst->AddIntAttribute(ui::AX_ATTR_ARIA_ROW_COUNT, aria_rowcount);
624 }
625
612 if (dst->role == ui::AX_ROLE_ROW) { 626 if (dst->role == ui::AX_ROLE_ROW) {
613 dst->AddIntAttribute(ui::AX_ATTR_TABLE_ROW_INDEX, src.rowIndex()); 627 dst->AddIntAttribute(ui::AX_ATTR_TABLE_ROW_INDEX, src.rowIndex());
614 WebAXObject header = src.rowHeader(); 628 WebAXObject header = src.rowHeader();
615 if (!header.isDetached()) 629 if (!header.isDetached())
616 dst->AddIntAttribute(ui::AX_ATTR_TABLE_ROW_HEADER_ID, header.axID()); 630 dst->AddIntAttribute(ui::AX_ATTR_TABLE_ROW_HEADER_ID, header.axID());
617 } 631 }
618 632
619 if (dst->role == ui::AX_ROLE_COLUMN) { 633 if (dst->role == ui::AX_ROLE_COLUMN) {
620 dst->AddIntAttribute(ui::AX_ATTR_TABLE_COLUMN_INDEX, src.columnIndex()); 634 dst->AddIntAttribute(ui::AX_ATTR_TABLE_COLUMN_INDEX, src.columnIndex());
621 WebAXObject header = src.columnHeader(); 635 WebAXObject header = src.columnHeader();
622 if (!header.isDetached()) 636 if (!header.isDetached())
623 dst->AddIntAttribute(ui::AX_ATTR_TABLE_COLUMN_HEADER_ID, header.axID()); 637 dst->AddIntAttribute(ui::AX_ATTR_TABLE_COLUMN_HEADER_ID, header.axID());
624 } 638 }
625 639
626 if (dst->role == ui::AX_ROLE_CELL || 640 if (dst->role == ui::AX_ROLE_CELL ||
627 dst->role == ui::AX_ROLE_ROW_HEADER || 641 dst->role == ui::AX_ROLE_ROW_HEADER ||
628 dst->role == ui::AX_ROLE_COLUMN_HEADER) { 642 dst->role == ui::AX_ROLE_COLUMN_HEADER ||
629 dst->AddIntAttribute(ui::AX_ATTR_TABLE_CELL_COLUMN_INDEX, 643 dst->role == ui::AX_ROLE_ROW) {
630 src.cellColumnIndex()); 644 if (dst->role != ui::AX_ROLE_ROW) {
631 dst->AddIntAttribute(ui::AX_ATTR_TABLE_CELL_COLUMN_SPAN, 645 dst->AddIntAttribute(ui::AX_ATTR_TABLE_CELL_COLUMN_INDEX,
632 src.cellColumnSpan()); 646 src.cellColumnIndex());
633 dst->AddIntAttribute(ui::AX_ATTR_TABLE_CELL_ROW_INDEX, 647 dst->AddIntAttribute(ui::AX_ATTR_TABLE_CELL_COLUMN_SPAN,
634 src.cellRowIndex()); 648 src.cellColumnSpan());
635 dst->AddIntAttribute(ui::AX_ATTR_TABLE_CELL_ROW_SPAN, src.cellRowSpan()); 649 dst->AddIntAttribute(ui::AX_ATTR_TABLE_CELL_ROW_INDEX,
650 src.cellRowIndex());
651 dst->AddIntAttribute(ui::AX_ATTR_TABLE_CELL_ROW_SPAN,src.cellRowSpan());
652
653 int aria_colindex = src.ariaColumnIndex();
654 if (aria_colindex)
655 dst->AddIntAttribute(ui::AX_ATTR_ARIA_COL_INDEX, aria_colindex);
656 }
657
658 int aria_rowindex = src.ariaRowIndex();
659 if (aria_rowindex)
660 dst->AddIntAttribute(ui::AX_ATTR_ARIA_ROW_INDEX, aria_rowindex);
636 } 661 }
637 662
638 if ((dst->role == ui::AX_ROLE_ROW_HEADER || 663 if ((dst->role == ui::AX_ROLE_ROW_HEADER ||
639 dst->role == ui::AX_ROLE_COLUMN_HEADER) && src.sortDirection()) { 664 dst->role == ui::AX_ROLE_COLUMN_HEADER) && src.sortDirection()) {
640 dst->AddIntAttribute(ui::AX_ATTR_SORT_DIRECTION, 665 dst->AddIntAttribute(ui::AX_ATTR_SORT_DIRECTION,
641 AXSortDirectionFromBlink(src.sortDirection())); 666 AXSortDirectionFromBlink(src.sortDirection()));
642 } 667 }
643 } 668 }
644 669
645 // The majority of the rest of this code computes attributes needed for 670 // The majority of the rest of this code computes attributes needed for
646 // all modes, not just for screen readers. 671 // all modes, not just for screen readers.
647 672
648 WebNode node = src.node(); 673 WebNode node = src.node();
649 bool is_iframe = false; 674 bool is_iframe = false;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 712
688 // ARIA role. 713 // ARIA role.
689 if (element.hasAttribute("role")) { 714 if (element.hasAttribute("role")) {
690 dst->AddStringAttribute( 715 dst->AddStringAttribute(
691 ui::AX_ATTR_ROLE, 716 ui::AX_ATTR_ROLE,
692 element.getAttribute("role").utf8()); 717 element.getAttribute("role").utf8());
693 } else { 718 } else {
694 std::string role = GetEquivalentAriaRoleString(dst->role); 719 std::string role = GetEquivalentAriaRoleString(dst->role);
695 if (!role.empty()) 720 if (!role.empty())
696 dst->AddStringAttribute(ui::AX_ATTR_ROLE, role); 721 dst->AddStringAttribute(ui::AX_ATTR_ROLE, role);
697 else if (dst->role == ui::AX_ROLE_TIME)
698 dst->AddStringAttribute(ui::AX_ATTR_ROLE, "time");
699 } 722 }
700 723
701 // Browser plugin (used in a <webview>). 724 // Browser plugin (used in a <webview>).
702 BrowserPlugin* browser_plugin = BrowserPlugin::GetFromNode(element); 725 BrowserPlugin* browser_plugin = BrowserPlugin::GetFromNode(element);
703 if (browser_plugin) { 726 if (browser_plugin) {
704 dst->AddContentIntAttribute( 727 dst->AddContentIntAttribute(
705 AX_CONTENT_ATTR_CHILD_BROWSER_PLUGIN_INSTANCE_ID, 728 AX_CONTENT_ATTR_CHILD_BROWSER_PLUGIN_INSTANCE_ID,
706 browser_plugin->browser_plugin_instance_id()); 729 browser_plugin->browser_plugin_instance_id());
707 } 730 }
708 731
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 return WebAXObject(); 796 return WebAXObject();
774 797
775 WebDocument document = render_frame_->GetWebFrame()->document(); 798 WebDocument document = render_frame_->GetWebFrame()->document();
776 if (!document.isNull()) 799 if (!document.isNull())
777 return document.accessibilityObject(); 800 return document.accessibilityObject();
778 801
779 return WebAXObject(); 802 return WebAXObject();
780 } 803 }
781 804
782 } // namespace content 805 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698