| 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 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 727 ui::AXIntListAttribute attribute) const { | 727 ui::AXIntListAttribute attribute) const { |
| 728 return GetData().GetIntListAttribute(attribute); | 728 return GetData().GetIntListAttribute(attribute); |
| 729 } | 729 } |
| 730 | 730 |
| 731 bool BrowserAccessibility::GetIntListAttribute( | 731 bool BrowserAccessibility::GetIntListAttribute( |
| 732 ui::AXIntListAttribute attribute, | 732 ui::AXIntListAttribute attribute, |
| 733 std::vector<int32_t>* value) const { | 733 std::vector<int32_t>* value) const { |
| 734 return GetData().GetIntListAttribute(attribute, value); | 734 return GetData().GetIntListAttribute(attribute, value); |
| 735 } | 735 } |
| 736 | 736 |
| 737 bool BrowserAccessibility::GetHtmlAttribute( | |
| 738 const char* html_attr, std::string* value) const { | |
| 739 return GetData().GetHtmlAttribute(html_attr, value); | |
| 740 } | |
| 741 | |
| 742 bool BrowserAccessibility::GetHtmlAttribute( | |
| 743 const char* html_attr, base::string16* value) const { | |
| 744 return GetData().GetHtmlAttribute(html_attr, value); | |
| 745 } | |
| 746 | |
| 747 bool BrowserAccessibility::GetAriaTristate( | |
| 748 const char* html_attr, | |
| 749 bool* is_defined, | |
| 750 bool* is_mixed) const { | |
| 751 *is_defined = false; | |
| 752 *is_mixed = false; | |
| 753 | |
| 754 base::string16 value; | |
| 755 if (!GetHtmlAttribute(html_attr, &value) || | |
| 756 value.empty() || | |
| 757 base::EqualsASCII(value, "undefined")) { | |
| 758 return false; // Not set (and *is_defined is also false) | |
| 759 } | |
| 760 | |
| 761 *is_defined = true; | |
| 762 | |
| 763 if (base::EqualsASCII(value, "true")) | |
| 764 return true; | |
| 765 | |
| 766 if (base::EqualsASCII(value, "mixed")) | |
| 767 *is_mixed = true; | |
| 768 | |
| 769 return false; // Not set. | |
| 770 } | |
| 771 | |
| 772 BrowserAccessibility* BrowserAccessibility::GetTable() const { | 737 BrowserAccessibility* BrowserAccessibility::GetTable() const { |
| 773 BrowserAccessibility* table = const_cast<BrowserAccessibility*>(this); | 738 BrowserAccessibility* table = const_cast<BrowserAccessibility*>(this); |
| 774 while (table && !table->IsTableLikeRole()) | 739 while (table && !table->IsTableLikeRole()) |
| 775 table = table->PlatformGetParent(); | 740 table = table->PlatformGetParent(); |
| 776 return table; | 741 return table; |
| 777 } | 742 } |
| 778 | 743 |
| 779 BrowserAccessibility* BrowserAccessibility::GetTableCell(int index) const { | 744 BrowserAccessibility* BrowserAccessibility::GetTableCell(int index) const { |
| 780 if (!IsTableLikeRole() && !IsCellOrTableHeaderRole()) | 745 if (!IsTableLikeRole() && !IsCellOrTableHeaderRole()) |
| 781 return nullptr; | 746 return nullptr; |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 977 case ui::AX_ROLE_MENU_LIST_OPTION: | 942 case ui::AX_ROLE_MENU_LIST_OPTION: |
| 978 case ui::AX_ROLE_MENU_LIST_POPUP: | 943 case ui::AX_ROLE_MENU_LIST_POPUP: |
| 979 return true; | 944 return true; |
| 980 default: | 945 default: |
| 981 return false; | 946 return false; |
| 982 } | 947 } |
| 983 } | 948 } |
| 984 | 949 |
| 985 bool BrowserAccessibility::IsNativeTextControl() const { | 950 bool BrowserAccessibility::IsNativeTextControl() const { |
| 986 const std::string& html_tag = GetStringAttribute(ui::AX_ATTR_HTML_TAG); | 951 const std::string& html_tag = GetStringAttribute(ui::AX_ATTR_HTML_TAG); |
| 987 if (html_tag == "input") { | 952 if (html_tag == "input") |
| 988 std::string input_type; | 953 return HasState(ui::AX_STATE_EDITABLE); |
| 989 if (!GetHtmlAttribute("type", &input_type)) | |
| 990 return true; | |
| 991 return input_type.empty() || input_type == "email" || | |
| 992 input_type == "password" || input_type == "search" || | |
| 993 input_type == "tel" || input_type == "text" || input_type == "url" || | |
| 994 input_type == "number"; | |
| 995 } | |
| 996 return html_tag == "textarea"; | 954 return html_tag == "textarea"; |
| 997 } | 955 } |
| 998 | 956 |
| 999 bool BrowserAccessibility::IsSimpleTextControl() const { | 957 bool BrowserAccessibility::IsSimpleTextControl() const { |
| 1000 // Time fields, color wells and spinner buttons might also use text fields as | 958 // Time fields, color wells and spinner buttons might also use text fields as |
| 1001 // constituent parts, but they are not considered text fields as a whole. | 959 // constituent parts, but they are not considered text fields as a whole. |
| 1002 switch (GetRole()) { | 960 switch (GetRole()) { |
| 1003 case ui::AX_ROLE_COMBO_BOX: | 961 case ui::AX_ROLE_COMBO_BOX: |
| 1004 case ui::AX_ROLE_SEARCH_BOX: | 962 case ui::AX_ROLE_SEARCH_BOX: |
| 1005 return true; | 963 return true; |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1215 const ui::AXActionData& data) { | 1173 const ui::AXActionData& data) { |
| 1216 if (data.action == ui::AX_ACTION_DO_DEFAULT) { | 1174 if (data.action == ui::AX_ACTION_DO_DEFAULT) { |
| 1217 manager_->DoDefaultAction(*this); | 1175 manager_->DoDefaultAction(*this); |
| 1218 return true; | 1176 return true; |
| 1219 } | 1177 } |
| 1220 | 1178 |
| 1221 return false; | 1179 return false; |
| 1222 } | 1180 } |
| 1223 | 1181 |
| 1224 } // namespace content | 1182 } // namespace content |
| OLD | NEW |