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

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

Issue 2890723003: Slider events with valuetext (Closed)
Patch Set: Fix test Created 3 years, 7 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
« no previous file with comments | « no previous file | content/browser/accessibility/browser_accessibility_cocoa.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 } 259 }
260 260
261 bool BrowserAccessibilityAndroid::IsPassword() const { 261 bool BrowserAccessibilityAndroid::IsPassword() const {
262 return HasState(ui::AX_STATE_PROTECTED); 262 return HasState(ui::AX_STATE_PROTECTED);
263 } 263 }
264 264
265 bool BrowserAccessibilityAndroid::IsRangeType() const { 265 bool BrowserAccessibilityAndroid::IsRangeType() const {
266 return (GetRole() == ui::AX_ROLE_PROGRESS_INDICATOR || 266 return (GetRole() == ui::AX_ROLE_PROGRESS_INDICATOR ||
267 GetRole() == ui::AX_ROLE_METER || 267 GetRole() == ui::AX_ROLE_METER ||
268 GetRole() == ui::AX_ROLE_SCROLL_BAR || 268 GetRole() == ui::AX_ROLE_SCROLL_BAR ||
269 GetRole() == ui::AX_ROLE_SLIDER); 269 GetRole() == ui::AX_ROLE_SLIDER ||
270 (GetRole() == ui::AX_ROLE_SPLITTER && IsFocusable()));
270 } 271 }
271 272
272 bool BrowserAccessibilityAndroid::IsScrollable() const { 273 bool BrowserAccessibilityAndroid::IsScrollable() const {
273 return (HasIntAttribute(ui::AX_ATTR_SCROLL_X_MAX) && 274 return (HasIntAttribute(ui::AX_ATTR_SCROLL_X_MAX) &&
274 GetRole() != ui::AX_ROLE_SCROLL_AREA); 275 GetRole() != ui::AX_ROLE_SCROLL_AREA);
275 } 276 }
276 277
277 bool BrowserAccessibilityAndroid::IsSelected() const { 278 bool BrowserAccessibilityAndroid::IsSelected() const {
278 return HasState(ui::AX_STATE_SELECTED); 279 return HasState(ui::AX_STATE_SELECTED);
279 } 280 }
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 } 847 }
847 848
848 if (message_id != -1) 849 if (message_id != -1)
849 return content_client->GetLocalizedString(message_id); 850 return content_client->GetLocalizedString(message_id);
850 851
851 return base::string16(); 852 return base::string16();
852 } 853 }
853 854
854 int BrowserAccessibilityAndroid::GetItemIndex() const { 855 int BrowserAccessibilityAndroid::GetItemIndex() const {
855 int index = 0; 856 int index = 0;
856 switch (GetRole()) { 857 if (IsRangeType()) {
857 case ui::AX_ROLE_LIST_ITEM: 858 // Return a percentage here for live feedback in an AccessibilityEvent.
858 case ui::AX_ROLE_LIST_BOX_OPTION: 859 // The exact value is returned in RangeCurrentValue.
859 case ui::AX_ROLE_TREE_ITEM: 860 float min = GetFloatAttribute(ui::AX_ATTR_MIN_VALUE_FOR_RANGE);
860 index = GetIntAttribute(ui::AX_ATTR_POS_IN_SET) - 1; 861 float max = GetFloatAttribute(ui::AX_ATTR_MAX_VALUE_FOR_RANGE);
861 break; 862 float value = GetFloatAttribute(ui::AX_ATTR_VALUE_FOR_RANGE);
862 case ui::AX_ROLE_SLIDER: 863 if (max > min && value >= min && value <= max)
863 case ui::AX_ROLE_PROGRESS_INDICATOR: { 864 index = static_cast<int>(((value - min)) * 100 / (max - min));
864 // Return a percentage here for live feedback in an AccessibilityEvent. 865 } else {
865 // The exact value is returned in RangeCurrentValue. 866 switch (GetRole()) {
866 float min = GetFloatAttribute(ui::AX_ATTR_MIN_VALUE_FOR_RANGE); 867 case ui::AX_ROLE_LIST_ITEM:
867 float max = GetFloatAttribute(ui::AX_ATTR_MAX_VALUE_FOR_RANGE); 868 case ui::AX_ROLE_LIST_BOX_OPTION:
868 float value = GetFloatAttribute(ui::AX_ATTR_VALUE_FOR_RANGE); 869 case ui::AX_ROLE_TREE_ITEM:
869 if (max > min && value >= min && value <= max) 870 index = GetIntAttribute(ui::AX_ATTR_POS_IN_SET) - 1;
870 index = static_cast<int>(((value - min)) * 100 / (max - min)); 871 break;
871 break; 872 default:
873 break;
872 } 874 }
873 default:
874 break;
875 } 875 }
876 return index; 876 return index;
877 } 877 }
878 878
879 int BrowserAccessibilityAndroid::GetItemCount() const { 879 int BrowserAccessibilityAndroid::GetItemCount() const {
880 int count = 0; 880 int count = 0;
881 switch (GetRole()) { 881 if (IsRangeType()) {
882 case ui::AX_ROLE_LIST: 882 // An AccessibilityEvent can only return integer information about a
883 case ui::AX_ROLE_LIST_BOX: 883 // seek control, so we return a percentage. The real range is returned
884 case ui::AX_ROLE_DESCRIPTION_LIST: 884 // in RangeMin and RangeMax.
885 count = PlatformChildCount(); 885 count = 100;
886 break; 886 } else {
887 case ui::AX_ROLE_SLIDER: 887 switch (GetRole()) {
888 case ui::AX_ROLE_PROGRESS_INDICATOR: 888 case ui::AX_ROLE_LIST:
889 // An AccessibilityEvent can only return integer information about a 889 case ui::AX_ROLE_LIST_BOX:
890 // seek control, so we return a percentage. The real range is returned 890 case ui::AX_ROLE_DESCRIPTION_LIST:
891 // in RangeMin and RangeMax. 891 count = PlatformChildCount();
892 count = 100; 892 break;
893 break; 893 default:
894 default: 894 break;
895 break; 895 }
896 } 896 }
897 return count; 897 return count;
898 } 898 }
899 899
900 bool BrowserAccessibilityAndroid::CanScrollForward() const { 900 bool BrowserAccessibilityAndroid::CanScrollForward() const {
901 if (IsSlider()) { 901 if (IsSlider()) {
902 float value = GetFloatAttribute(ui::AX_ATTR_VALUE_FOR_RANGE); 902 float value = GetFloatAttribute(ui::AX_ATTR_VALUE_FOR_RANGE);
903 float max = GetFloatAttribute(ui::AX_ATTR_MAX_VALUE_FOR_RANGE); 903 float max = GetFloatAttribute(ui::AX_ATTR_MAX_VALUE_FOR_RANGE);
904 return value < max; 904 return value < max;
905 } else { 905 } else {
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
1426 int BrowserAccessibilityAndroid::CountChildrenWithRole(ui::AXRole role) const { 1426 int BrowserAccessibilityAndroid::CountChildrenWithRole(ui::AXRole role) const {
1427 int count = 0; 1427 int count = 0;
1428 for (uint32_t i = 0; i < PlatformChildCount(); i++) { 1428 for (uint32_t i = 0; i < PlatformChildCount(); i++) {
1429 if (PlatformGetChild(i)->GetRole() == role) 1429 if (PlatformGetChild(i)->GetRole() == role)
1430 count++; 1430 count++;
1431 } 1431 }
1432 return count; 1432 return count;
1433 } 1433 }
1434 1434
1435 } // namespace content 1435 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/accessibility/browser_accessibility_cocoa.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698