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 | 10 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 } | 63 } |
64 | 64 |
65 bool BrowserAccessibility::PlatformIsLeaf() const { | 65 bool BrowserAccessibility::PlatformIsLeaf() const { |
66 if (InternalChildCount() == 0) | 66 if (InternalChildCount() == 0) |
67 return true; | 67 return true; |
68 | 68 |
69 // These types of objects may have children that we use as internal | 69 // These types of objects may have children that we use as internal |
70 // implementation details, but we want to expose them as leaves to platform | 70 // implementation details, but we want to expose them as leaves to platform |
71 // accessibility APIs because screen readers might be confused if they find | 71 // accessibility APIs because screen readers might be confused if they find |
72 // any children. | 72 // any children. |
73 if (IsSimpleTextControl() || IsTextOnlyObject()) | 73 // Note that if a combo box, search box or text field are not native, they |
| 74 // might present a menu of choices using aria-owns which should not be hidden |
| 75 // from tree. |
| 76 if (IsNativeTextControl() || IsTextOnlyObject()) |
74 return true; | 77 return true; |
75 | 78 |
76 // Roles whose children are only presentational according to the ARIA and | 79 // Roles whose children are only presentational according to the ARIA and |
77 // HTML5 Specs should be hidden from screen readers. | 80 // HTML5 Specs should be hidden from screen readers. |
78 // (Note that whilst ARIA buttons can have only presentational children, HTML5 | 81 // (Note that whilst ARIA buttons can have only presentational children, HTML5 |
79 // buttons are allowed to have content.) | 82 // buttons are allowed to have content.) |
80 switch (GetRole()) { | 83 switch (GetRole()) { |
81 case ui::AX_ROLE_IMAGE: | 84 case ui::AX_ROLE_IMAGE: |
82 case ui::AX_ROLE_MATH: | 85 case ui::AX_ROLE_MATH: |
83 case ui::AX_ROLE_METER: | 86 case ui::AX_ROLE_METER: |
(...skipping 973 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1057 case ui::AX_ROLE_MENU_ITEM_CHECK_BOX: | 1060 case ui::AX_ROLE_MENU_ITEM_CHECK_BOX: |
1058 case ui::AX_ROLE_MENU_ITEM_RADIO: | 1061 case ui::AX_ROLE_MENU_ITEM_RADIO: |
1059 case ui::AX_ROLE_MENU_LIST_OPTION: | 1062 case ui::AX_ROLE_MENU_LIST_OPTION: |
1060 case ui::AX_ROLE_MENU_LIST_POPUP: | 1063 case ui::AX_ROLE_MENU_LIST_POPUP: |
1061 return true; | 1064 return true; |
1062 default: | 1065 default: |
1063 return false; | 1066 return false; |
1064 } | 1067 } |
1065 } | 1068 } |
1066 | 1069 |
| 1070 bool BrowserAccessibility::IsNativeTextControl() const { |
| 1071 const std::string& html_tag = GetStringAttribute(ui::AX_ATTR_HTML_TAG); |
| 1072 if (html_tag == "input") { |
| 1073 std::string input_type; |
| 1074 if (!GetHtmlAttribute("type", &input_type)) |
| 1075 return true; |
| 1076 return input_type.empty() || input_type == "email" || |
| 1077 input_type == "password" || input_type == "search" || |
| 1078 input_type == "tel" || input_type == "text" || input_type == "url" || |
| 1079 input_type == "number"; |
| 1080 } |
| 1081 return html_tag == "textarea"; |
| 1082 } |
| 1083 |
1067 bool BrowserAccessibility::IsSimpleTextControl() const { | 1084 bool BrowserAccessibility::IsSimpleTextControl() const { |
1068 // Time fields, color wells and spinner buttons might also use text fields as | 1085 // Time fields, color wells and spinner buttons might also use text fields as |
1069 // constituent parts, but they are not considered text fields as a whole. | 1086 // constituent parts, but they are not considered text fields as a whole. |
1070 switch (GetRole()) { | 1087 switch (GetRole()) { |
1071 case ui::AX_ROLE_COMBO_BOX: | 1088 case ui::AX_ROLE_COMBO_BOX: |
1072 case ui::AX_ROLE_SEARCH_BOX: | 1089 case ui::AX_ROLE_SEARCH_BOX: |
1073 return true; | 1090 return true; |
1074 case ui::AX_ROLE_TEXT_FIELD: | 1091 case ui::AX_ROLE_TEXT_FIELD: |
1075 return !HasState(ui::AX_STATE_RICHLY_EDITABLE); | 1092 return !HasState(ui::AX_STATE_RICHLY_EDITABLE); |
1076 default: | 1093 default: |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1186 break; | 1203 break; |
1187 | 1204 |
1188 manager = root->GetParent()->manager(); | 1205 manager = root->GetParent()->manager(); |
1189 root = manager->GetRoot(); | 1206 root = manager->GetRoot(); |
1190 } | 1207 } |
1191 | 1208 |
1192 return bounds; | 1209 return bounds; |
1193 } | 1210 } |
1194 | 1211 |
1195 } // namespace content | 1212 } // namespace content |
OLD | NEW |