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 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 // These roles don't have readonly set, but they're not editable text. | 595 // These roles don't have readonly set, but they're not editable text. |
596 if (role_ == ui::AX_ROLE_SCROLL_AREA || | 596 if (role_ == ui::AX_ROLE_SCROLL_AREA || |
597 role_ == ui::AX_ROLE_COLUMN || | 597 role_ == ui::AX_ROLE_COLUMN || |
598 role_ == ui::AX_ROLE_TABLE_HEADER_CONTAINER) { | 598 role_ == ui::AX_ROLE_TABLE_HEADER_CONTAINER) { |
599 return false; | 599 return false; |
600 } | 600 } |
601 | 601 |
602 // Note: WebAXStateReadonly being false means it's either a text control, | 602 // Note: WebAXStateReadonly being false means it's either a text control, |
603 // or contenteditable. We also check for editable text roles to cover | 603 // or contenteditable. We also check for editable text roles to cover |
604 // another element that has role=textbox set on it. | 604 // another element that has role=textbox set on it. |
605 return (!HasState(ui::AX_STATE_READONLY) || | 605 return (!HasState(ui::AX_STATE_READ_ONLY) || |
606 role_ == ui::AX_ROLE_TEXT_FIELD || | 606 role_ == ui::AX_ROLE_TEXT_FIELD || |
607 role_ == ui::AX_ROLE_TEXT_AREA); | 607 role_ == ui::AX_ROLE_TEXT_AREA); |
608 } | 608 } |
609 | 609 |
610 std::string BrowserAccessibility::GetTextRecursive() const { | 610 std::string BrowserAccessibility::GetTextRecursive() const { |
611 if (!name_.empty()) { | 611 if (!name_.empty()) { |
612 return name_; | 612 return name_; |
613 } | 613 } |
614 | 614 |
615 std::string result; | 615 std::string result; |
616 for (uint32 i = 0; i < PlatformChildCount(); ++i) | 616 for (uint32 i = 0; i < PlatformChildCount(); ++i) |
617 result += PlatformGetChild(i)->GetTextRecursive(); | 617 result += PlatformGetChild(i)->GetTextRecursive(); |
618 return result; | 618 return result; |
619 } | 619 } |
620 | 620 |
621 int BrowserAccessibility::GetStaticTextLenRecursive() const { | 621 int BrowserAccessibility::GetStaticTextLenRecursive() const { |
622 if (role_ == blink::WebAXRoleStaticText) | 622 if (role_ == blink::WebAXRoleStaticText) |
623 return static_cast<int>(GetStringAttribute(ui::AX_ATTR_VALUE).size()); | 623 return static_cast<int>(GetStringAttribute(ui::AX_ATTR_VALUE).size()); |
624 | 624 |
625 int len = 0; | 625 int len = 0; |
626 for (size_t i = 0; i < children_.size(); ++i) | 626 for (size_t i = 0; i < children_.size(); ++i) |
627 len += children_[i]->GetStaticTextLenRecursive(); | 627 len += children_[i]->GetStaticTextLenRecursive(); |
628 return len; | 628 return len; |
629 } | 629 } |
630 | 630 |
631 } // namespace content | 631 } // namespace content |
OLD | NEW |