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

Side by Side Diff: content/browser/accessibility/browser_accessibility.cc

Issue 2825803002: Expose internal treegrid role, do some cleanup for table/grid/treegrid handling (Closed)
Patch Set: Fix mac tests Created 3 years, 8 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 (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/browser/accessibility/browser_accessibility.h" 5 #include "content/browser/accessibility/browser_accessibility.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <iterator> 10 #include <iterator>
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 return true; 774 return true;
775 775
776 if (base::EqualsASCII(value, "mixed")) 776 if (base::EqualsASCII(value, "mixed"))
777 *is_mixed = true; 777 *is_mixed = true;
778 778
779 return false; // Not set. 779 return false; // Not set.
780 } 780 }
781 781
782 BrowserAccessibility* BrowserAccessibility::GetTable() const { 782 BrowserAccessibility* BrowserAccessibility::GetTable() const {
783 BrowserAccessibility* table = const_cast<BrowserAccessibility*>(this); 783 BrowserAccessibility* table = const_cast<BrowserAccessibility*>(this);
784 while (table && !table->IsTableOrGridOrTreeGridRole()) 784 while (table && !table->IsTableLikeRole())
785 table = table->PlatformGetParent(); 785 table = table->PlatformGetParent();
786 return table; 786 return table;
787 } 787 }
788 788
789 BrowserAccessibility* BrowserAccessibility::GetTableCell(int index) const { 789 BrowserAccessibility* BrowserAccessibility::GetTableCell(int index) const {
790 if (!IsTableOrGridOrTreeGridRole() && !IsCellOrTableHeaderRole()) 790 if (!IsTableLikeRole() && !IsCellOrTableHeaderRole())
791 return nullptr; 791 return nullptr;
792 792
793 BrowserAccessibility* table = GetTable(); 793 BrowserAccessibility* table = GetTable();
794 if (!table) 794 if (!table)
795 return nullptr; 795 return nullptr;
796 const std::vector<int32_t>& unique_cell_ids = 796 const std::vector<int32_t>& unique_cell_ids =
797 table->GetIntListAttribute(ui::AX_ATTR_UNIQUE_CELL_IDS); 797 table->GetIntListAttribute(ui::AX_ATTR_UNIQUE_CELL_IDS);
798 if (index < 0 || index >= static_cast<int>(unique_cell_ids.size())) 798 if (index < 0 || index >= static_cast<int>(unique_cell_ids.size()))
799 return nullptr; 799 return nullptr;
800 return table->manager_->GetFromID(unique_cell_ids[index]); 800 return table->manager_->GetFromID(unique_cell_ids[index]);
801 } 801 }
802 802
803 BrowserAccessibility* BrowserAccessibility::GetTableCell(int row, 803 BrowserAccessibility* BrowserAccessibility::GetTableCell(int row,
804 int column) const { 804 int column) const {
805 if (!IsTableOrGridOrTreeGridRole() && !IsCellOrTableHeaderRole()) 805 if (!IsTableLikeRole() && !IsCellOrTableHeaderRole())
806 return nullptr; 806 return nullptr;
807 if (row < 0 || row >= GetTableRowCount() || column < 0 || 807 if (row < 0 || row >= GetTableRowCount() || column < 0 ||
808 column >= GetTableColumnCount()) { 808 column >= GetTableColumnCount()) {
809 return nullptr; 809 return nullptr;
810 } 810 }
811 811
812 BrowserAccessibility* table = GetTable(); 812 BrowserAccessibility* table = GetTable();
813 if (!table) 813 if (!table)
814 return nullptr; 814 return nullptr;
815 815
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
894 bool BrowserAccessibility::HasState(ui::AXState state_enum) const { 894 bool BrowserAccessibility::HasState(ui::AXState state_enum) const {
895 return (GetState() >> state_enum) & 1; 895 return (GetState() >> state_enum) & 1;
896 } 896 }
897 897
898 bool BrowserAccessibility::IsCellOrTableHeaderRole() const { 898 bool BrowserAccessibility::IsCellOrTableHeaderRole() const {
899 return (GetRole() == ui::AX_ROLE_CELL || 899 return (GetRole() == ui::AX_ROLE_CELL ||
900 GetRole() == ui::AX_ROLE_COLUMN_HEADER || 900 GetRole() == ui::AX_ROLE_COLUMN_HEADER ||
901 GetRole() == ui::AX_ROLE_ROW_HEADER); 901 GetRole() == ui::AX_ROLE_ROW_HEADER);
902 } 902 }
903 903
904 bool BrowserAccessibility::IsTableOrGridOrTreeGridRole() const { 904 bool BrowserAccessibility::IsTableLikeRole() const {
905 return (GetRole() == ui::AX_ROLE_TABLE || 905 return (GetRole() == ui::AX_ROLE_TABLE ||
906 GetRole() == ui::AX_ROLE_GRID || 906 GetRole() == ui::AX_ROLE_GRID ||
907 GetRole() == ui::AX_ROLE_TREE_GRID); 907 GetRole() == ui::AX_ROLE_TREE_GRID);
908 } 908 }
909 909
910 bool BrowserAccessibility::HasCaret() const { 910 bool BrowserAccessibility::HasCaret() const {
911 if (IsSimpleTextControl() && HasIntAttribute(ui::AX_ATTR_TEXT_SEL_START) && 911 if (IsSimpleTextControl() && HasIntAttribute(ui::AX_ATTR_TEXT_SEL_START) &&
912 HasIntAttribute(ui::AX_ATTR_TEXT_SEL_END)) { 912 HasIntAttribute(ui::AX_ATTR_TEXT_SEL_END)) {
913 return true; 913 return true;
914 } 914 }
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
1189 return gfx::kNullAcceleratedWidget; 1189 return gfx::kNullAcceleratedWidget;
1190 } 1190 }
1191 1191
1192 bool BrowserAccessibility::AccessibilityPerformAction( 1192 bool BrowserAccessibility::AccessibilityPerformAction(
1193 const ui::AXActionData& data) { 1193 const ui::AXActionData& data) {
1194 NOTREACHED(); 1194 NOTREACHED();
1195 return false; 1195 return false;
1196 } 1196 }
1197 1197
1198 } // namespace content 1198 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/accessibility/browser_accessibility.h ('k') | content/browser/accessibility/browser_accessibility_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698