| OLD | NEW |
| 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 896 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 907 if (!GetHtmlAttribute("type", &input_type)) | 907 if (!GetHtmlAttribute("type", &input_type)) |
| 908 return true; | 908 return true; |
| 909 return input_type.empty() || input_type == "email" || | 909 return input_type.empty() || input_type == "email" || |
| 910 input_type == "password" || input_type == "search" || | 910 input_type == "password" || input_type == "search" || |
| 911 input_type == "tel" || input_type == "text" || input_type == "url" || | 911 input_type == "tel" || input_type == "text" || input_type == "url" || |
| 912 input_type == "number"; | 912 input_type == "number"; |
| 913 } | 913 } |
| 914 return html_tag == "textarea"; | 914 return html_tag == "textarea"; |
| 915 } | 915 } |
| 916 | 916 |
| 917 // In general we should use IsEditField() instead if we want to check for | 917 // In general we should use ui::IsEditField() instead if we want to check for |
| 918 // something that has a caret and the user can edit. | 918 // something that has a caret and the user can edit. |
| 919 // TODO(aleventhal) this name is confusing because it returns true for combobox, | 919 // TODO(aleventhal) this name is confusing because it returns true for combobox, |
| 920 // and we should take a look at why a combobox is considered a text control. The | 920 // and we should take a look at why a combobox is considered a text control. The |
| 921 // ARIA spec says a combobox would contain (but not be) a text field. It looks | 921 // ARIA spec says a combobox would contain (but not be) a text field. It looks |
| 922 // like a mistake may have been made in that comboboxes have been considered a | 922 // like a mistake may have been made in that comboboxes have been considered a |
| 923 // kind of textbox. Find an appropriate name for this function, and consider | 923 // kind of textbox. Find an appropriate name for this function, and consider |
| 924 // returning false for comboboxes it doesn't break existing websites. | 924 // returning false for comboboxes it doesn't break existing websites. |
| 925 bool BrowserAccessibility::IsSimpleTextControl() const { | 925 bool BrowserAccessibility::IsSimpleTextControl() const { |
| 926 // Time fields, color wells and spinner buttons might also use text fields as | 926 // Time fields, color wells and spinner buttons might also use text fields as |
| 927 // constituent parts, but they are not considered text fields as a whole. | 927 // constituent parts, but they are not considered text fields as a whole. |
| 928 switch (GetRole()) { | 928 switch (GetRole()) { |
| 929 case ui::AX_ROLE_COMBO_BOX: | 929 case ui::AX_ROLE_COMBO_BOX: |
| 930 case ui::AX_ROLE_SEARCH_BOX: | 930 case ui::AX_ROLE_SEARCH_BOX: |
| 931 return true; | 931 return true; |
| 932 case ui::AX_ROLE_TEXT_FIELD: | 932 case ui::AX_ROLE_TEXT_FIELD: |
| 933 return !HasState(ui::AX_STATE_RICHLY_EDITABLE); | 933 return !HasState(ui::AX_STATE_RICHLY_EDITABLE); |
| 934 default: | 934 default: |
| 935 return false; | 935 return false; |
| 936 } | 936 } |
| 937 } | 937 } |
| 938 | 938 |
| 939 bool BrowserAccessibility::IsEditField() const { | |
| 940 return GetRole() == ui::AX_ROLE_TEXT_FIELD || | |
| 941 GetRole() == ui::AX_ROLE_SEARCH_BOX; | |
| 942 } | |
| 943 | |
| 944 // Indicates if this object is at the root of a rich edit text control. | 939 // Indicates if this object is at the root of a rich edit text control. |
| 945 bool BrowserAccessibility::IsRichTextControl() const { | 940 bool BrowserAccessibility::IsRichTextControl() const { |
| 946 return HasState(ui::AX_STATE_RICHLY_EDITABLE) && | 941 return HasState(ui::AX_STATE_RICHLY_EDITABLE) && |
| 947 (!PlatformGetParent() || | 942 (!PlatformGetParent() || |
| 948 !PlatformGetParent()->HasState(ui::AX_STATE_RICHLY_EDITABLE)); | 943 !PlatformGetParent()->HasState(ui::AX_STATE_RICHLY_EDITABLE)); |
| 949 } | 944 } |
| 950 | 945 |
| 951 bool BrowserAccessibility::HasExplicitlyEmptyName() const { | 946 bool BrowserAccessibility::HasExplicitlyEmptyName() const { |
| 952 return GetIntAttribute(ui::AX_ATTR_NAME_FROM) == | 947 return GetIntAttribute(ui::AX_ATTR_NAME_FROM) == |
| 953 ui::AX_NAME_FROM_ATTRIBUTE_EXPLICITLY_EMPTY; | 948 ui::AX_NAME_FROM_ATTRIBUTE_EXPLICITLY_EMPTY; |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1129 return false; | 1124 return false; |
| 1130 } | 1125 } |
| 1131 | 1126 |
| 1132 bool BrowserAccessibility::ShouldIgnoreHoveredStateForTesting() { | 1127 bool BrowserAccessibility::ShouldIgnoreHoveredStateForTesting() { |
| 1133 BrowserAccessibilityStateImpl* accessibility_state = | 1128 BrowserAccessibilityStateImpl* accessibility_state = |
| 1134 BrowserAccessibilityStateImpl::GetInstance(); | 1129 BrowserAccessibilityStateImpl::GetInstance(); |
| 1135 return accessibility_state->disable_hot_tracking_for_testing(); | 1130 return accessibility_state->disable_hot_tracking_for_testing(); |
| 1136 } | 1131 } |
| 1137 | 1132 |
| 1138 } // namespace content | 1133 } // namespace content |
| OLD | NEW |