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 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 | 444 |
445 // Adjust the bounds by the top left corner of the containing view's bounds | 445 // Adjust the bounds by the top left corner of the containing view's bounds |
446 // in screen coordinates. | 446 // in screen coordinates. |
447 bounds.Offset(manager_->GetViewBounds().OffsetFromOrigin()); | 447 bounds.Offset(manager_->GetViewBounds().OffsetFromOrigin()); |
448 | 448 |
449 return bounds; | 449 return bounds; |
450 } | 450 } |
451 | 451 |
452 base::string16 BrowserAccessibility::GetValue() const { | 452 base::string16 BrowserAccessibility::GetValue() const { |
453 base::string16 value = GetString16Attribute(ui::AX_ATTR_VALUE); | 453 base::string16 value = GetString16Attribute(ui::AX_ATTR_VALUE); |
454 // Some screen readers like Jaws and older versions of VoiceOver require a | 454 if (value.empty() && IsSimpleTextControl()) |
455 // value to be set in text fields with rich content, even though the same | |
456 // information is available on the children. | |
457 if (value.empty() && (IsSimpleTextControl() || IsRichTextControl())) | |
458 value = GetInnerText(); | 455 value = GetInnerText(); |
459 return value; | 456 return value; |
460 } | 457 } |
461 | 458 |
462 int BrowserAccessibility::GetWordStartBoundary( | 459 int BrowserAccessibility::GetWordStartBoundary( |
463 int start, ui::TextBoundaryDirection direction) const { | 460 int start, ui::TextBoundaryDirection direction) const { |
464 DCHECK_GE(start, -1); | 461 DCHECK_GE(start, -1); |
465 // Special offset that indicates that a word boundary has not been found. | 462 // Special offset that indicates that a word boundary has not been found. |
466 int word_start_not_found = static_cast<int>(GetText().size()); | 463 int word_start_not_found = static_cast<int>(GetText().size()); |
467 int word_start = word_start_not_found; | 464 int word_start = word_start_not_found; |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
825 return (GetState() >> state_enum) & 1; | 822 return (GetState() >> state_enum) & 1; |
826 } | 823 } |
827 | 824 |
828 bool BrowserAccessibility::IsCellOrTableHeaderRole() const { | 825 bool BrowserAccessibility::IsCellOrTableHeaderRole() const { |
829 return (GetRole() == ui::AX_ROLE_CELL || | 826 return (GetRole() == ui::AX_ROLE_CELL || |
830 GetRole() == ui::AX_ROLE_COLUMN_HEADER || | 827 GetRole() == ui::AX_ROLE_COLUMN_HEADER || |
831 GetRole() == ui::AX_ROLE_ROW_HEADER); | 828 GetRole() == ui::AX_ROLE_ROW_HEADER); |
832 } | 829 } |
833 | 830 |
834 bool BrowserAccessibility::HasCaret() const { | 831 bool BrowserAccessibility::HasCaret() const { |
835 if (IsSimpleTextControl() && HasIntAttribute(ui::AX_ATTR_TEXT_SEL_START) && | 832 if (HasState(ui::AX_STATE_EDITABLE) && |
| 833 !HasState(ui::AX_STATE_RICHLY_EDITABLE) && |
| 834 HasIntAttribute(ui::AX_ATTR_TEXT_SEL_START) && |
836 HasIntAttribute(ui::AX_ATTR_TEXT_SEL_END)) { | 835 HasIntAttribute(ui::AX_ATTR_TEXT_SEL_END)) { |
837 return true; | 836 return true; |
838 } | 837 } |
839 | 838 |
840 // The caret is always at the focus of the selection. | 839 // The caret is always at the focus of the selection. |
841 int32_t focus_id = manager()->GetTreeData().sel_focus_object_id; | 840 int32_t focus_id = manager()->GetTreeData().sel_focus_object_id; |
842 BrowserAccessibility* focus_object = manager()->GetFromID(focus_id); | 841 BrowserAccessibility* focus_object = manager()->GetFromID(focus_id); |
843 if (!focus_object) | 842 if (!focus_object) |
844 return false; | 843 return false; |
845 | 844 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
933 return false; | 932 return false; |
934 } | 933 } |
935 } | 934 } |
936 | 935 |
937 bool BrowserAccessibility::IsSimpleTextControl() const { | 936 bool BrowserAccessibility::IsSimpleTextControl() const { |
938 // Time fields, color wells and spinner buttons might also use text fields as | 937 // Time fields, color wells and spinner buttons might also use text fields as |
939 // constituent parts, but they are not considered text fields as a whole. | 938 // constituent parts, but they are not considered text fields as a whole. |
940 switch (GetRole()) { | 939 switch (GetRole()) { |
941 case ui::AX_ROLE_COMBO_BOX: | 940 case ui::AX_ROLE_COMBO_BOX: |
942 case ui::AX_ROLE_SEARCH_BOX: | 941 case ui::AX_ROLE_SEARCH_BOX: |
| 942 case ui::AX_ROLE_TEXT_FIELD: |
943 return true; | 943 return true; |
944 case ui::AX_ROLE_TEXT_FIELD: | |
945 return !HasState(ui::AX_STATE_RICHLY_EDITABLE); | |
946 default: | 944 default: |
947 return false; | 945 return false; |
948 } | 946 } |
949 } | 947 } |
950 | 948 |
951 // Indicates if this object is at the root of a rich edit text control. | 949 // Indicates if this object is at the root of a rich edit text control. |
952 bool BrowserAccessibility::IsRichTextControl() const { | 950 bool BrowserAccessibility::IsRichTextControl() const { |
953 return HasState(ui::AX_STATE_RICHLY_EDITABLE) && | 951 return HasState(ui::AX_STATE_RICHLY_EDITABLE) && |
954 (!GetParent() || !GetParent()->HasState(ui::AX_STATE_RICHLY_EDITABLE)); | 952 (!GetParent() || !GetParent()->HasState(ui::AX_STATE_RICHLY_EDITABLE)); |
955 } | 953 } |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1046 } | 1044 } |
1047 need_to_offset_web_area = true; | 1045 need_to_offset_web_area = true; |
1048 } | 1046 } |
1049 parent = parent->GetParent(); | 1047 parent = parent->GetParent(); |
1050 } | 1048 } |
1051 | 1049 |
1052 return bounds; | 1050 return bounds; |
1053 } | 1051 } |
1054 | 1052 |
1055 } // namespace content | 1053 } // namespace content |
OLD | NEW |