Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(236)

Side by Side Diff: content/browser/accessibility/browser_accessibility.cc

Issue 1821723002: Exposed the children of elements with role textbox in order to make rich text information available… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Disabled Android test. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | content/browser/accessibility/browser_accessibility_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 if (value.empty() && IsSimpleTextControl()) 454 // Some screen readers like Jaws and older versions of VoiceOver require a
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()))
455 value = GetInnerText(); 458 value = GetInnerText();
456 return value; 459 return value;
457 } 460 }
458 461
459 int BrowserAccessibility::GetWordStartBoundary( 462 int BrowserAccessibility::GetWordStartBoundary(
460 int start, ui::TextBoundaryDirection direction) const { 463 int start, ui::TextBoundaryDirection direction) const {
461 DCHECK_GE(start, -1); 464 DCHECK_GE(start, -1);
462 // Special offset that indicates that a word boundary has not been found. 465 // Special offset that indicates that a word boundary has not been found.
463 int word_start_not_found = static_cast<int>(GetText().size()); 466 int word_start_not_found = static_cast<int>(GetText().size());
464 int word_start = word_start_not_found; 467 int word_start = word_start_not_found;
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
822 return (GetState() >> state_enum) & 1; 825 return (GetState() >> state_enum) & 1;
823 } 826 }
824 827
825 bool BrowserAccessibility::IsCellOrTableHeaderRole() const { 828 bool BrowserAccessibility::IsCellOrTableHeaderRole() const {
826 return (GetRole() == ui::AX_ROLE_CELL || 829 return (GetRole() == ui::AX_ROLE_CELL ||
827 GetRole() == ui::AX_ROLE_COLUMN_HEADER || 830 GetRole() == ui::AX_ROLE_COLUMN_HEADER ||
828 GetRole() == ui::AX_ROLE_ROW_HEADER); 831 GetRole() == ui::AX_ROLE_ROW_HEADER);
829 } 832 }
830 833
831 bool BrowserAccessibility::HasCaret() const { 834 bool BrowserAccessibility::HasCaret() const {
832 if (HasState(ui::AX_STATE_EDITABLE) && 835 if (IsSimpleTextControl() && HasIntAttribute(ui::AX_ATTR_TEXT_SEL_START) &&
833 !HasState(ui::AX_STATE_RICHLY_EDITABLE) &&
834 HasIntAttribute(ui::AX_ATTR_TEXT_SEL_START) &&
835 HasIntAttribute(ui::AX_ATTR_TEXT_SEL_END)) { 836 HasIntAttribute(ui::AX_ATTR_TEXT_SEL_END)) {
836 return true; 837 return true;
837 } 838 }
838 839
839 // The caret is always at the focus of the selection. 840 // The caret is always at the focus of the selection.
840 int32_t focus_id = manager()->GetTreeData().sel_focus_object_id; 841 int32_t focus_id = manager()->GetTreeData().sel_focus_object_id;
841 BrowserAccessibility* focus_object = manager()->GetFromID(focus_id); 842 BrowserAccessibility* focus_object = manager()->GetFromID(focus_id);
842 if (!focus_object) 843 if (!focus_object)
843 return false; 844 return false;
844 845
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
932 return false; 933 return false;
933 } 934 }
934 } 935 }
935 936
936 bool BrowserAccessibility::IsSimpleTextControl() const { 937 bool BrowserAccessibility::IsSimpleTextControl() const {
937 // Time fields, color wells and spinner buttons might also use text fields as 938 // Time fields, color wells and spinner buttons might also use text fields as
938 // constituent parts, but they are not considered text fields as a whole. 939 // constituent parts, but they are not considered text fields as a whole.
939 switch (GetRole()) { 940 switch (GetRole()) {
940 case ui::AX_ROLE_COMBO_BOX: 941 case ui::AX_ROLE_COMBO_BOX:
941 case ui::AX_ROLE_SEARCH_BOX: 942 case ui::AX_ROLE_SEARCH_BOX:
943 return true;
942 case ui::AX_ROLE_TEXT_FIELD: 944 case ui::AX_ROLE_TEXT_FIELD:
943 return true; 945 return !HasState(ui::AX_STATE_RICHLY_EDITABLE);
944 default: 946 default:
945 return false; 947 return false;
946 } 948 }
947 } 949 }
948 950
949 // Indicates if this object is at the root of a rich edit text control. 951 // Indicates if this object is at the root of a rich edit text control.
950 bool BrowserAccessibility::IsRichTextControl() const { 952 bool BrowserAccessibility::IsRichTextControl() const {
951 return HasState(ui::AX_STATE_RICHLY_EDITABLE) && 953 return HasState(ui::AX_STATE_RICHLY_EDITABLE) &&
952 (!GetParent() || !GetParent()->HasState(ui::AX_STATE_RICHLY_EDITABLE)); 954 (!GetParent() || !GetParent()->HasState(ui::AX_STATE_RICHLY_EDITABLE));
953 } 955 }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1044 } 1046 }
1045 need_to_offset_web_area = true; 1047 need_to_offset_web_area = true;
1046 } 1048 }
1047 parent = parent->GetParent(); 1049 parent = parent->GetParent();
1048 } 1050 }
1049 1051
1050 return bounds; 1052 return bounds;
1051 } 1053 }
1052 1054
1053 } // namespace content 1055 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/accessibility/browser_accessibility_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698