| OLD | NEW |
| 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 case ui::AX_ROLE_MAIN: | 92 case ui::AX_ROLE_MAIN: |
| 93 return "main"; | 93 return "main"; |
| 94 case ui::AX_ROLE_NAVIGATION: | 94 case ui::AX_ROLE_NAVIGATION: |
| 95 return "navigation"; | 95 return "navigation"; |
| 96 case ui::AX_ROLE_RADIO_BUTTON: | 96 case ui::AX_ROLE_RADIO_BUTTON: |
| 97 return "radio"; | 97 return "radio"; |
| 98 case ui::AX_ROLE_REGION: | 98 case ui::AX_ROLE_REGION: |
| 99 return "region"; | 99 return "region"; |
| 100 case ui::AX_ROLE_SLIDER: | 100 case ui::AX_ROLE_SLIDER: |
| 101 return "slider"; | 101 return "slider"; |
| 102 case ui::AX_ROLE_TIME: |
| 103 return "time"; |
| 102 default: | 104 default: |
| 103 break; | 105 break; |
| 104 } | 106 } |
| 105 | 107 |
| 106 return std::string(); | 108 return std::string(); |
| 107 } | 109 } |
| 108 | 110 |
| 109 void AddIntListAttributeFromWebObjects(ui::AXIntListAttribute attr, | 111 void AddIntListAttributeFromWebObjects(ui::AXIntListAttribute attr, |
| 110 WebVector<WebAXObject> objects, | 112 WebVector<WebAXObject> objects, |
| 111 AXContentNodeData* dst) { | 113 AXContentNodeData* dst) { |
| (...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 | 565 |
| 564 // ARIA role. | 566 // ARIA role. |
| 565 if (element.hasAttribute("role")) { | 567 if (element.hasAttribute("role")) { |
| 566 dst->AddStringAttribute( | 568 dst->AddStringAttribute( |
| 567 ui::AX_ATTR_ROLE, | 569 ui::AX_ATTR_ROLE, |
| 568 element.getAttribute("role").utf8()); | 570 element.getAttribute("role").utf8()); |
| 569 } else { | 571 } else { |
| 570 std::string role = GetEquivalentAriaRoleString(dst->role); | 572 std::string role = GetEquivalentAriaRoleString(dst->role); |
| 571 if (!role.empty()) | 573 if (!role.empty()) |
| 572 dst->AddStringAttribute(ui::AX_ATTR_ROLE, role); | 574 dst->AddStringAttribute(ui::AX_ATTR_ROLE, role); |
| 573 else if (dst->role == ui::AX_ROLE_TIME) | |
| 574 dst->AddStringAttribute(ui::AX_ATTR_ROLE, "time"); | |
| 575 } | 575 } |
| 576 | 576 |
| 577 // Browser plugin (used in a <webview>). | 577 // Browser plugin (used in a <webview>). |
| 578 BrowserPlugin* browser_plugin = BrowserPlugin::GetFromNode(element); | 578 BrowserPlugin* browser_plugin = BrowserPlugin::GetFromNode(element); |
| 579 if (browser_plugin) { | 579 if (browser_plugin) { |
| 580 dst->AddContentIntAttribute( | 580 dst->AddContentIntAttribute( |
| 581 AX_CONTENT_ATTR_CHILD_BROWSER_PLUGIN_INSTANCE_ID, | 581 AX_CONTENT_ATTR_CHILD_BROWSER_PLUGIN_INSTANCE_ID, |
| 582 browser_plugin->browser_plugin_instance_id()); | 582 browser_plugin->browser_plugin_instance_id()); |
| 583 } | 583 } |
| 584 | 584 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 unique_cell_ids.push_back(cell_id); | 660 unique_cell_ids.push_back(cell_id); |
| 661 } | 661 } |
| 662 } | 662 } |
| 663 cell_ids.push_back(cell_id); | 663 cell_ids.push_back(cell_id); |
| 664 } | 664 } |
| 665 dst->AddIntListAttribute(ui::AX_ATTR_CELL_IDS, cell_ids); | 665 dst->AddIntListAttribute(ui::AX_ATTR_CELL_IDS, cell_ids); |
| 666 dst->AddIntListAttribute(ui::AX_ATTR_UNIQUE_CELL_IDS, unique_cell_ids); | 666 dst->AddIntListAttribute(ui::AX_ATTR_UNIQUE_CELL_IDS, unique_cell_ids); |
| 667 } | 667 } |
| 668 } | 668 } |
| 669 | 669 |
| 670 if (dst->role == ui::AX_ROLE_TABLE || |
| 671 dst->role == ui::AX_ROLE_GRID || |
| 672 dst->role == ui::AX_ROLE_TREE_GRID) { |
| 673 int aria_colcount = src.ariaColumnCount(); |
| 674 if (aria_colcount) |
| 675 dst->AddIntAttribute(ui::AX_ATTR_ARIA_COL_COUNT, aria_colcount); |
| 676 |
| 677 int aria_rowcount = src.ariaRowCount(); |
| 678 if (aria_rowcount) |
| 679 dst->AddIntAttribute(ui::AX_ATTR_ARIA_ROW_COUNT, aria_rowcount); |
| 680 } |
| 681 |
| 670 if (dst->role == ui::AX_ROLE_ROW) { | 682 if (dst->role == ui::AX_ROLE_ROW) { |
| 671 dst->AddIntAttribute(ui::AX_ATTR_TABLE_ROW_INDEX, src.rowIndex()); | 683 dst->AddIntAttribute(ui::AX_ATTR_TABLE_ROW_INDEX, src.rowIndex()); |
| 672 WebAXObject header = src.rowHeader(); | 684 WebAXObject header = src.rowHeader(); |
| 673 if (!header.isDetached()) | 685 if (!header.isDetached()) |
| 674 dst->AddIntAttribute(ui::AX_ATTR_TABLE_ROW_HEADER_ID, header.axID()); | 686 dst->AddIntAttribute(ui::AX_ATTR_TABLE_ROW_HEADER_ID, header.axID()); |
| 675 } | 687 } |
| 676 | 688 |
| 677 if (dst->role == ui::AX_ROLE_COLUMN) { | 689 if (dst->role == ui::AX_ROLE_COLUMN) { |
| 678 dst->AddIntAttribute(ui::AX_ATTR_TABLE_COLUMN_INDEX, src.columnIndex()); | 690 dst->AddIntAttribute(ui::AX_ATTR_TABLE_COLUMN_INDEX, src.columnIndex()); |
| 679 WebAXObject header = src.columnHeader(); | 691 WebAXObject header = src.columnHeader(); |
| 680 if (!header.isDetached()) | 692 if (!header.isDetached()) |
| 681 dst->AddIntAttribute(ui::AX_ATTR_TABLE_COLUMN_HEADER_ID, header.axID()); | 693 dst->AddIntAttribute(ui::AX_ATTR_TABLE_COLUMN_HEADER_ID, header.axID()); |
| 682 } | 694 } |
| 683 | 695 |
| 684 if (dst->role == ui::AX_ROLE_CELL || | 696 if (dst->role == ui::AX_ROLE_CELL || |
| 685 dst->role == ui::AX_ROLE_ROW_HEADER || | 697 dst->role == ui::AX_ROLE_ROW_HEADER || |
| 686 dst->role == ui::AX_ROLE_COLUMN_HEADER) { | 698 dst->role == ui::AX_ROLE_COLUMN_HEADER || |
| 687 dst->AddIntAttribute(ui::AX_ATTR_TABLE_CELL_COLUMN_INDEX, | 699 dst->role == ui::AX_ROLE_ROW) { |
| 688 src.cellColumnIndex()); | 700 if (dst->role != ui::AX_ROLE_ROW) { |
| 689 dst->AddIntAttribute(ui::AX_ATTR_TABLE_CELL_COLUMN_SPAN, | 701 dst->AddIntAttribute(ui::AX_ATTR_TABLE_CELL_COLUMN_INDEX, |
| 690 src.cellColumnSpan()); | 702 src.cellColumnIndex()); |
| 691 dst->AddIntAttribute(ui::AX_ATTR_TABLE_CELL_ROW_INDEX, src.cellRowIndex()); | 703 dst->AddIntAttribute(ui::AX_ATTR_TABLE_CELL_COLUMN_SPAN, |
| 692 dst->AddIntAttribute(ui::AX_ATTR_TABLE_CELL_ROW_SPAN, src.cellRowSpan()); | 704 src.cellColumnSpan()); |
| 705 dst->AddIntAttribute(ui::AX_ATTR_TABLE_CELL_ROW_INDEX, |
| 706 src.cellRowIndex()); |
| 707 dst->AddIntAttribute(ui::AX_ATTR_TABLE_CELL_ROW_SPAN,src.cellRowSpan()); |
| 708 |
| 709 int aria_colindex = src.ariaColumnIndex(); |
| 710 if (aria_colindex) |
| 711 dst->AddIntAttribute(ui::AX_ATTR_ARIA_COL_INDEX, aria_colindex); |
| 712 } |
| 713 |
| 714 int aria_rowindex = src.ariaRowIndex(); |
| 715 if (aria_rowindex) |
| 716 dst->AddIntAttribute(ui::AX_ATTR_ARIA_ROW_INDEX, aria_rowindex); |
| 693 } | 717 } |
| 694 | 718 |
| 695 if ((dst->role == ui::AX_ROLE_ROW_HEADER || | 719 if ((dst->role == ui::AX_ROLE_ROW_HEADER || |
| 696 dst->role == ui::AX_ROLE_COLUMN_HEADER) && src.sortDirection()) { | 720 dst->role == ui::AX_ROLE_COLUMN_HEADER) && src.sortDirection()) { |
| 697 dst->AddIntAttribute(ui::AX_ATTR_SORT_DIRECTION, | 721 dst->AddIntAttribute(ui::AX_ATTR_SORT_DIRECTION, |
| 698 AXSortDirectionFromBlink(src.sortDirection())); | 722 AXSortDirectionFromBlink(src.sortDirection())); |
| 699 } | 723 } |
| 700 | 724 |
| 701 // Add the ids of *indirect* children - those who are children of this node, | 725 // Add the ids of *indirect* children - those who are children of this node, |
| 702 // but whose parent is *not* this node. One example is a table | 726 // but whose parent is *not* this node. One example is a table |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 return WebAXObject(); | 780 return WebAXObject(); |
| 757 | 781 |
| 758 WebDocument document = render_frame_->GetWebFrame()->document(); | 782 WebDocument document = render_frame_->GetWebFrame()->document(); |
| 759 if (!document.isNull()) | 783 if (!document.isNull()) |
| 760 return document.accessibilityObject(); | 784 return document.accessibilityObject(); |
| 761 | 785 |
| 762 return WebAXObject(); | 786 return WebAXObject(); |
| 763 } | 787 } |
| 764 | 788 |
| 765 } // namespace content | 789 } // namespace content |
| OLD | NEW |