| 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 "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 } | 671 } |
| 672 | 672 |
| 673 // Note: WebAXStateReadonly being false means it's either a text control, | 673 // Note: WebAXStateReadonly being false means it's either a text control, |
| 674 // or contenteditable. We also check for editable text roles to cover | 674 // or contenteditable. We also check for editable text roles to cover |
| 675 // another element that has role=textbox set on it. | 675 // another element that has role=textbox set on it. |
| 676 return (!HasState(ui::AX_STATE_READ_ONLY) || | 676 return (!HasState(ui::AX_STATE_READ_ONLY) || |
| 677 GetRole() == ui::AX_ROLE_TEXT_FIELD || | 677 GetRole() == ui::AX_ROLE_TEXT_FIELD || |
| 678 GetRole() == ui::AX_ROLE_TEXT_AREA); | 678 GetRole() == ui::AX_ROLE_TEXT_AREA); |
| 679 } | 679 } |
| 680 | 680 |
| 681 bool BrowserAccessibility::IsWebAreaForPresentationalIframe() const { |
| 682 if (GetRole() != ui::AX_ROLE_WEB_AREA && |
| 683 GetRole() != ui::AX_ROLE_ROOT_WEB_AREA) { |
| 684 return false; |
| 685 } |
| 686 |
| 687 BrowserAccessibility* parent = GetParent(); |
| 688 if (!parent) |
| 689 return false; |
| 690 |
| 691 BrowserAccessibility* grandparent = parent->GetParent(); |
| 692 if (!grandparent) |
| 693 return false; |
| 694 |
| 695 return grandparent->GetRole() == ui::AX_ROLE_IFRAME_PRESENTATIONAL; |
| 696 } |
| 697 |
| 681 std::string BrowserAccessibility::GetTextRecursive() const { | 698 std::string BrowserAccessibility::GetTextRecursive() const { |
| 682 if (!name_.empty()) { | 699 if (!name_.empty()) { |
| 683 return name_; | 700 return name_; |
| 684 } | 701 } |
| 685 | 702 |
| 686 std::string result; | 703 std::string result; |
| 687 for (uint32 i = 0; i < PlatformChildCount(); ++i) | 704 for (uint32 i = 0; i < PlatformChildCount(); ++i) |
| 688 result += PlatformGetChild(i)->GetTextRecursive(); | 705 result += PlatformGetChild(i)->GetTextRecursive(); |
| 689 return result; | 706 return result; |
| 690 } | 707 } |
| 691 | 708 |
| 692 int BrowserAccessibility::GetStaticTextLenRecursive() const { | 709 int BrowserAccessibility::GetStaticTextLenRecursive() const { |
| 693 if (GetRole() == ui::AX_ROLE_STATIC_TEXT) | 710 if (GetRole() == ui::AX_ROLE_STATIC_TEXT) |
| 694 return static_cast<int>(GetStringAttribute(ui::AX_ATTR_VALUE).size()); | 711 return static_cast<int>(GetStringAttribute(ui::AX_ATTR_VALUE).size()); |
| 695 | 712 |
| 696 int len = 0; | 713 int len = 0; |
| 697 for (size_t i = 0; i < InternalChildCount(); ++i) | 714 for (size_t i = 0; i < InternalChildCount(); ++i) |
| 698 len += InternalGetChild(i)->GetStaticTextLenRecursive(); | 715 len += InternalGetChild(i)->GetStaticTextLenRecursive(); |
| 699 return len; | 716 return len; |
| 700 } | 717 } |
| 701 | 718 |
| 702 } // namespace content | 719 } // namespace content |
| OLD | NEW |