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

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

Issue 1182783008: Add an option to not prune the Android AX tree, to preserve more style info. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@style_info_sgurun
Patch Set: Un-disable tests Created 5 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_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 } 74 }
75 75
76 // If it has a focusable child, we definitely can't leave out children. 76 // If it has a focusable child, we definitely can't leave out children.
77 if (HasFocusableChild()) 77 if (HasFocusableChild())
78 return false; 78 return false;
79 79
80 // Date and time controls should drop their children. 80 // Date and time controls should drop their children.
81 if (GetRole() == ui::AX_ROLE_DATE || GetRole() == ui::AX_ROLE_INPUT_TIME) 81 if (GetRole() == ui::AX_ROLE_DATE || GetRole() == ui::AX_ROLE_INPUT_TIME)
82 return true; 82 return true;
83 83
84 // Headings with text can drop their children. 84 BrowserAccessibilityManagerAndroid* manager_android =
85 base::string16 name = GetText(); 85 static_cast<BrowserAccessibilityManagerAndroid*>(manager());
86 if (GetRole() == ui::AX_ROLE_HEADING && !name.empty()) 86 if (manager_android->prune_tree_for_screen_reader()) {
87 return true; 87 // Headings with text can drop their children.
88 base::string16 name = GetText();
89 if (GetRole() == ui::AX_ROLE_HEADING && !name.empty())
90 return true;
88 91
89 // Focusable nodes with text can drop their children. 92 // Focusable nodes with text can drop their children.
90 if (HasState(ui::AX_STATE_FOCUSABLE) && !name.empty()) 93 if (HasState(ui::AX_STATE_FOCUSABLE) && !name.empty())
91 return true; 94 return true;
92 95
93 // Nodes with only static text as children can drop their children. 96 // Nodes with only static text as children can drop their children.
94 if (HasOnlyStaticTextChildren()) 97 if (HasOnlyStaticTextChildren())
95 return true; 98 return true;
99 }
96 100
97 return BrowserAccessibility::PlatformIsLeaf(); 101 return BrowserAccessibility::PlatformIsLeaf();
98 } 102 }
99 103
100 bool BrowserAccessibilityAndroid::CanScrollForward() const { 104 bool BrowserAccessibilityAndroid::CanScrollForward() const {
101 if (!IsSlider()) 105 if (!IsSlider())
102 return false; 106 return false;
103 107
104 float value = GetFloatAttribute(ui::AX_ATTR_VALUE_FOR_RANGE); 108 float value = GetFloatAttribute(ui::AX_ATTR_VALUE_FOR_RANGE);
105 float max = GetFloatAttribute(ui::AX_ATTR_MAX_VALUE_FOR_RANGE); 109 float max = GetFloatAttribute(ui::AX_ATTR_MAX_VALUE_FOR_RANGE);
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after
876 int BrowserAccessibilityAndroid::CountChildrenWithRole(ui::AXRole role) const { 880 int BrowserAccessibilityAndroid::CountChildrenWithRole(ui::AXRole role) const {
877 int count = 0; 881 int count = 0;
878 for (uint32 i = 0; i < PlatformChildCount(); i++) { 882 for (uint32 i = 0; i < PlatformChildCount(); i++) {
879 if (PlatformGetChild(i)->GetRole() == role) 883 if (PlatformGetChild(i)->GetRole() == role)
880 count++; 884 count++;
881 } 885 }
882 return count; 886 return count;
883 } 887 }
884 888
885 } // namespace content 889 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698