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

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

Issue 2931893002: More precise use of multiline state (Closed)
Patch Set: Fix typo 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 120
121 if (this == ancestor) 121 if (this == ancestor)
122 return true; 122 return true;
123 123
124 if (PlatformGetParent()) 124 if (PlatformGetParent())
125 return PlatformGetParent()->IsDescendantOf(ancestor); 125 return PlatformGetParent()->IsDescendantOf(ancestor);
126 126
127 return false; 127 return false;
128 } 128 }
129 129
130 bool BrowserAccessibility::IsDocument() const {
131 return GetRole() == ui::AX_ROLE_ROOT_WEB_AREA ||
132 GetRole() == ui::AX_ROLE_WEB_AREA;
133 }
dougt 2017/06/27 17:23:38 Note in CL 2962453002, I started moving this kind
134
130 bool BrowserAccessibility::IsTextOnlyObject() const { 135 bool BrowserAccessibility::IsTextOnlyObject() const {
131 return GetRole() == ui::AX_ROLE_STATIC_TEXT || 136 return GetRole() == ui::AX_ROLE_STATIC_TEXT ||
132 GetRole() == ui::AX_ROLE_LINE_BREAK || 137 GetRole() == ui::AX_ROLE_LINE_BREAK ||
133 GetRole() == ui::AX_ROLE_INLINE_TEXT_BOX; 138 GetRole() == ui::AX_ROLE_INLINE_TEXT_BOX;
134 } 139 }
135 140
136 bool BrowserAccessibility::IsLineBreakObject() const { 141 bool BrowserAccessibility::IsLineBreakObject() const {
137 return GetRole() == ui::AX_ROLE_LINE_BREAK || 142 return GetRole() == ui::AX_ROLE_LINE_BREAK ||
138 (IsTextOnlyObject() && PlatformGetParent() && 143 (IsTextOnlyObject() && PlatformGetParent() &&
139 PlatformGetParent()->GetRole() == ui::AX_ROLE_LINE_BREAK); 144 PlatformGetParent()->GetRole() == ui::AX_ROLE_LINE_BREAK);
(...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after
960 if (!GetHtmlAttribute("type", &input_type)) 965 if (!GetHtmlAttribute("type", &input_type))
961 return true; 966 return true;
962 return input_type.empty() || input_type == "email" || 967 return input_type.empty() || input_type == "email" ||
963 input_type == "password" || input_type == "search" || 968 input_type == "password" || input_type == "search" ||
964 input_type == "tel" || input_type == "text" || input_type == "url" || 969 input_type == "tel" || input_type == "text" || input_type == "url" ||
965 input_type == "number"; 970 input_type == "number";
966 } 971 }
967 return html_tag == "textarea"; 972 return html_tag == "textarea";
968 } 973 }
969 974
975 // In general we should use IsEditBox() instead if we want to check for
976 // something that has a caret and the user can edit.
977 // TODO(aleventhal) this name is confusing because it returns true for combobox,
978 // and we should take a look at why a combobox is considered a text control. The
979 // ARIA spec says a combobox would contain (but not be) a text field. It looks
980 // like a mistake may have been made in that comboboxes have been considered a
981 // kind of textbox. Find an appropriate name for this function, and consider
982 // returning false for comboboxes it doesn't break existing websites.
970 bool BrowserAccessibility::IsSimpleTextControl() const { 983 bool BrowserAccessibility::IsSimpleTextControl() const {
971 // Time fields, color wells and spinner buttons might also use text fields as 984 // Time fields, color wells and spinner buttons might also use text fields as
972 // constituent parts, but they are not considered text fields as a whole. 985 // constituent parts, but they are not considered text fields as a whole.
973 switch (GetRole()) { 986 switch (GetRole()) {
974 case ui::AX_ROLE_COMBO_BOX: 987 case ui::AX_ROLE_COMBO_BOX:
975 case ui::AX_ROLE_SEARCH_BOX: 988 case ui::AX_ROLE_SEARCH_BOX:
976 return true; 989 return true;
977 case ui::AX_ROLE_TEXT_FIELD: 990 case ui::AX_ROLE_TEXT_FIELD:
978 return !HasState(ui::AX_STATE_RICHLY_EDITABLE); 991 return !HasState(ui::AX_STATE_RICHLY_EDITABLE);
979 default: 992 default:
980 return false; 993 return false;
981 } 994 }
982 } 995 }
983 996
997 bool BrowserAccessibility::IsEditBox() const {
dougt 2017/06/27 17:23:38 Same.
998 return GetRole() == ui::AX_ROLE_TEXT_FIELD ||
999 GetRole() == ui::AX_ROLE_SEARCH_BOX;
1000 }
1001
984 // Indicates if this object is at the root of a rich edit text control. 1002 // Indicates if this object is at the root of a rich edit text control.
985 bool BrowserAccessibility::IsRichTextControl() const { 1003 bool BrowserAccessibility::IsRichTextControl() const {
986 return HasState(ui::AX_STATE_RICHLY_EDITABLE) && 1004 return HasState(ui::AX_STATE_RICHLY_EDITABLE) &&
987 (!PlatformGetParent() || 1005 (!PlatformGetParent() ||
988 !PlatformGetParent()->HasState(ui::AX_STATE_RICHLY_EDITABLE)); 1006 !PlatformGetParent()->HasState(ui::AX_STATE_RICHLY_EDITABLE));
989 } 1007 }
990 1008
991 bool BrowserAccessibility::HasExplicitlyEmptyName() const { 1009 bool BrowserAccessibility::HasExplicitlyEmptyName() const {
992 return GetIntAttribute(ui::AX_ATTR_NAME_FROM) == 1010 return GetIntAttribute(ui::AX_ATTR_NAME_FROM) ==
993 ui::AX_NAME_FROM_ATTRIBUTE_EXPLICITLY_EMPTY; 1011 ui::AX_NAME_FROM_ATTRIBUTE_EXPLICITLY_EMPTY;
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
1163 1181
1164 if (data.action == ui::AX_ACTION_FOCUS) { 1182 if (data.action == ui::AX_ACTION_FOCUS) {
1165 manager_->SetFocus(*this); 1183 manager_->SetFocus(*this);
1166 return true; 1184 return true;
1167 } 1185 }
1168 1186
1169 return false; 1187 return false;
1170 } 1188 }
1171 1189
1172 } // namespace content 1190 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698