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

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

Issue 2931893002: More precise use of multiline state (Closed)
Patch Set: Fix test Created 3 years, 5 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 121
122 if (this == ancestor) 122 if (this == ancestor)
123 return true; 123 return true;
124 124
125 if (PlatformGetParent()) 125 if (PlatformGetParent())
126 return PlatformGetParent()->IsDescendantOf(ancestor); 126 return PlatformGetParent()->IsDescendantOf(ancestor);
127 127
128 return false; 128 return false;
129 } 129 }
130 130
131 bool BrowserAccessibility::IsDocument() const {
dougt 2017/06/30 22:03:30 Please do not add more simple predicates here. In
132 return GetRole() == ui::AX_ROLE_ROOT_WEB_AREA ||
133 GetRole() == ui::AX_ROLE_WEB_AREA;
134 }
135
131 bool BrowserAccessibility::IsTextOnlyObject() const { 136 bool BrowserAccessibility::IsTextOnlyObject() const {
132 return GetRole() == ui::AX_ROLE_STATIC_TEXT || 137 return GetRole() == ui::AX_ROLE_STATIC_TEXT ||
133 GetRole() == ui::AX_ROLE_LINE_BREAK || 138 GetRole() == ui::AX_ROLE_LINE_BREAK ||
134 GetRole() == ui::AX_ROLE_INLINE_TEXT_BOX; 139 GetRole() == ui::AX_ROLE_INLINE_TEXT_BOX;
135 } 140 }
136 141
137 bool BrowserAccessibility::IsLineBreakObject() const { 142 bool BrowserAccessibility::IsLineBreakObject() const {
138 return GetRole() == ui::AX_ROLE_LINE_BREAK || 143 return GetRole() == ui::AX_ROLE_LINE_BREAK ||
139 (IsTextOnlyObject() && PlatformGetParent() && 144 (IsTextOnlyObject() && PlatformGetParent() &&
140 PlatformGetParent()->GetRole() == ui::AX_ROLE_LINE_BREAK); 145 PlatformGetParent()->GetRole() == ui::AX_ROLE_LINE_BREAK);
(...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 if (!GetHtmlAttribute("type", &input_type)) 956 if (!GetHtmlAttribute("type", &input_type))
952 return true; 957 return true;
953 return input_type.empty() || input_type == "email" || 958 return input_type.empty() || input_type == "email" ||
954 input_type == "password" || input_type == "search" || 959 input_type == "password" || input_type == "search" ||
955 input_type == "tel" || input_type == "text" || input_type == "url" || 960 input_type == "tel" || input_type == "text" || input_type == "url" ||
956 input_type == "number"; 961 input_type == "number";
957 } 962 }
958 return html_tag == "textarea"; 963 return html_tag == "textarea";
959 } 964 }
960 965
966 // In general we should use IsEditField() instead if we want to check for
967 // something that has a caret and the user can edit.
968 // TODO(aleventhal) this name is confusing because it returns true for combobox,
969 // and we should take a look at why a combobox is considered a text control. The
970 // ARIA spec says a combobox would contain (but not be) a text field. It looks
971 // like a mistake may have been made in that comboboxes have been considered a
972 // kind of textbox. Find an appropriate name for this function, and consider
973 // returning false for comboboxes it doesn't break existing websites.
961 bool BrowserAccessibility::IsSimpleTextControl() const { 974 bool BrowserAccessibility::IsSimpleTextControl() const {
962 // Time fields, color wells and spinner buttons might also use text fields as 975 // Time fields, color wells and spinner buttons might also use text fields as
963 // constituent parts, but they are not considered text fields as a whole. 976 // constituent parts, but they are not considered text fields as a whole.
964 switch (GetRole()) { 977 switch (GetRole()) {
965 case ui::AX_ROLE_COMBO_BOX: 978 case ui::AX_ROLE_COMBO_BOX:
966 case ui::AX_ROLE_SEARCH_BOX: 979 case ui::AX_ROLE_SEARCH_BOX:
967 return true; 980 return true;
968 case ui::AX_ROLE_TEXT_FIELD: 981 case ui::AX_ROLE_TEXT_FIELD:
969 return !HasState(ui::AX_STATE_RICHLY_EDITABLE); 982 return !HasState(ui::AX_STATE_RICHLY_EDITABLE);
970 default: 983 default:
971 return false; 984 return false;
972 } 985 }
973 } 986 }
974 987
988 bool BrowserAccessibility::IsEditField() const {
dougt 2017/06/30 22:03:30 Same.
989 return GetRole() == ui::AX_ROLE_TEXT_FIELD ||
990 GetRole() == ui::AX_ROLE_SEARCH_BOX;
991 }
992
975 // Indicates if this object is at the root of a rich edit text control. 993 // Indicates if this object is at the root of a rich edit text control.
976 bool BrowserAccessibility::IsRichTextControl() const { 994 bool BrowserAccessibility::IsRichTextControl() const {
977 return HasState(ui::AX_STATE_RICHLY_EDITABLE) && 995 return HasState(ui::AX_STATE_RICHLY_EDITABLE) &&
978 (!PlatformGetParent() || 996 (!PlatformGetParent() ||
979 !PlatformGetParent()->HasState(ui::AX_STATE_RICHLY_EDITABLE)); 997 !PlatformGetParent()->HasState(ui::AX_STATE_RICHLY_EDITABLE));
980 } 998 }
981 999
982 bool BrowserAccessibility::HasExplicitlyEmptyName() const { 1000 bool BrowserAccessibility::HasExplicitlyEmptyName() const {
983 return GetIntAttribute(ui::AX_ATTR_NAME_FROM) == 1001 return GetIntAttribute(ui::AX_ATTR_NAME_FROM) ==
984 ui::AX_NAME_FROM_ATTRIBUTE_EXPLICITLY_EMPTY; 1002 ui::AX_NAME_FROM_ATTRIBUTE_EXPLICITLY_EMPTY;
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
1160 return false; 1178 return false;
1161 } 1179 }
1162 1180
1163 bool BrowserAccessibility::ShouldIgnoreHoveredStateForTesting() { 1181 bool BrowserAccessibility::ShouldIgnoreHoveredStateForTesting() {
1164 BrowserAccessibilityStateImpl* accessibility_state = 1182 BrowserAccessibilityStateImpl* accessibility_state =
1165 BrowserAccessibilityStateImpl::GetInstance(); 1183 BrowserAccessibilityStateImpl::GetInstance();
1166 return accessibility_state->disable_hot_tracking_for_testing(); 1184 return accessibility_state->disable_hot_tracking_for_testing();
1167 } 1185 }
1168 1186
1169 } // namespace content 1187 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698