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

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

Issue 2893683002: Selection follows focus/activedescendant in single selection containers (Closed)
Patch Set: Last test to fix we hope Created 3 years, 6 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_android.h" 5 #include "content/browser/accessibility/browser_accessibility_android.h"
6 6
7 #include "base/i18n/break_iterator.h" 7 #include "base/i18n/break_iterator.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 if (BrowserAccessibility::PlatformIsLeaf()) 98 if (BrowserAccessibility::PlatformIsLeaf())
99 return true; 99 return true;
100 100
101 // Iframes are always allowed to contain children. 101 // Iframes are always allowed to contain children.
102 if (IsIframe() || 102 if (IsIframe() ||
103 GetRole() == ui::AX_ROLE_ROOT_WEB_AREA || 103 GetRole() == ui::AX_ROLE_ROOT_WEB_AREA ||
104 GetRole() == ui::AX_ROLE_WEB_AREA) { 104 GetRole() == ui::AX_ROLE_WEB_AREA) {
105 return false; 105 return false;
106 } 106 }
107 107
108 // If it has a focusable child, we definitely can't leave out children.
109 if (HasFocusableChild())
110 return false;
111
112 // Date and time controls should drop their children. 108 // Date and time controls should drop their children.
113 switch (GetRole()) { 109 switch (GetRole()) {
114 case ui::AX_ROLE_DATE: 110 case ui::AX_ROLE_DATE:
115 case ui::AX_ROLE_DATE_TIME: 111 case ui::AX_ROLE_DATE_TIME:
116 case ui::AX_ROLE_INPUT_TIME: 112 case ui::AX_ROLE_INPUT_TIME:
117 return true; 113 return true;
118 default: 114 default:
119 break; 115 break;
120 } 116 }
121 117
118 // If it has a focusable child, we definitely can't leave out children.
119 if (HasFocusableNonOptionChild())
120 return false;
121
122 BrowserAccessibilityManagerAndroid* manager_android = 122 BrowserAccessibilityManagerAndroid* manager_android =
123 static_cast<BrowserAccessibilityManagerAndroid*>(manager()); 123 static_cast<BrowserAccessibilityManagerAndroid*>(manager());
124 if (manager_android->prune_tree_for_screen_reader()) { 124 if (manager_android->prune_tree_for_screen_reader()) {
125 // Headings with text can drop their children. 125 // Headings with text can drop their children.
126 base::string16 name = GetText(); 126 base::string16 name = GetText();
127 if (GetRole() == ui::AX_ROLE_HEADING && !name.empty()) 127 if (GetRole() == ui::AX_ROLE_HEADING && !name.empty())
128 return true; 128 return true;
129 129
130 // Focusable nodes with text can drop their children. 130 // Focusable nodes with text can drop their children.
131 if (HasState(ui::AX_STATE_FOCUSABLE) && !name.empty()) 131 if (HasState(ui::AX_STATE_FOCUSABLE) && !name.empty())
(...skipping 1193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1325 return; 1325 return;
1326 while (iter.Advance()) { 1326 while (iter.Advance()) {
1327 if (iter.IsWord()) { 1327 if (iter.IsWord()) {
1328 word_starts->push_back(iter.prev()); 1328 word_starts->push_back(iter.prev());
1329 word_ends->push_back(iter.pos()); 1329 word_ends->push_back(iter.pos());
1330 } 1330 }
1331 } 1331 }
1332 } 1332 }
1333 } 1333 }
1334 1334
1335 bool BrowserAccessibilityAndroid::HasFocusableChild() const { 1335 bool BrowserAccessibilityAndroid::HasFocusableNonOptionChild() const {
1336 // This is called from PlatformIsLeaf, so don't call PlatformChildCount 1336 // This is called from PlatformIsLeaf, so don't call PlatformChildCount
1337 // from within this! 1337 // from within this!
1338 for (uint32_t i = 0; i < InternalChildCount(); i++) { 1338 for (uint32_t i = 0; i < InternalChildCount(); i++) {
1339 BrowserAccessibility* child = InternalGetChild(i); 1339 BrowserAccessibility* child = InternalGetChild(i);
1340 if (child->HasState(ui::AX_STATE_FOCUSABLE)) 1340 if (child->HasState(ui::AX_STATE_FOCUSABLE) &&
1341 child->GetRole() != ui::AX_ROLE_MENU_LIST_OPTION)
1341 return true; 1342 return true;
1342 if (static_cast<BrowserAccessibilityAndroid*>(child)->HasFocusableChild()) 1343 if (static_cast<BrowserAccessibilityAndroid*>(child)
1344 ->HasFocusableNonOptionChild())
1343 return true; 1345 return true;
1344 } 1346 }
1345 return false; 1347 return false;
1346 } 1348 }
1347 1349
1348 bool BrowserAccessibilityAndroid::HasNonEmptyValue() const { 1350 bool BrowserAccessibilityAndroid::HasNonEmptyValue() const {
1349 return IsEditableText() && !GetValue().empty(); 1351 return IsEditableText() && !GetValue().empty();
1350 } 1352 }
1351 1353
1352 bool BrowserAccessibilityAndroid::HasOnlyTextChildren() const { 1354 bool BrowserAccessibilityAndroid::HasOnlyTextChildren() const {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1426 int BrowserAccessibilityAndroid::CountChildrenWithRole(ui::AXRole role) const { 1428 int BrowserAccessibilityAndroid::CountChildrenWithRole(ui::AXRole role) const {
1427 int count = 0; 1429 int count = 0;
1428 for (uint32_t i = 0; i < PlatformChildCount(); i++) { 1430 for (uint32_t i = 0; i < PlatformChildCount(); i++) {
1429 if (PlatformGetChild(i)->GetRole() == role) 1431 if (PlatformGetChild(i)->GetRole() == role)
1430 count++; 1432 count++;
1431 } 1433 }
1432 return count; 1434 return count;
1433 } 1435 }
1434 1436
1435 } // namespace content 1437 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698