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

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: Created 4 years, 9 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
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 if (value.empty() &&
455 (IsSimpleTextControl() ||
456 // Some screen readers like Jaws and older versions of VoiceOver require
dmazzoni 2016/03/21 17:04:02 Nit: put the comment above or below. Comments in t
457 // a
458 // value to be set in text fields with rich content, even though the same
459 // information is available on the children.
460 IsRichTextControl())) {
455 value = GetInnerText(); 461 value = GetInnerText();
462 }
456 return value; 463 return value;
457 } 464 }
458 465
459 int BrowserAccessibility::GetWordStartBoundary( 466 int BrowserAccessibility::GetWordStartBoundary(
460 int start, ui::TextBoundaryDirection direction) const { 467 int start, ui::TextBoundaryDirection direction) const {
461 DCHECK_GE(start, -1); 468 DCHECK_GE(start, -1);
462 // Special offset that indicates that a word boundary has not been found. 469 // Special offset that indicates that a word boundary has not been found.
463 int word_start_not_found = static_cast<int>(GetText().size()); 470 int word_start_not_found = static_cast<int>(GetText().size());
464 int word_start = word_start_not_found; 471 int word_start = word_start_not_found;
465 472
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
822 return (GetState() >> state_enum) & 1; 829 return (GetState() >> state_enum) & 1;
823 } 830 }
824 831
825 bool BrowserAccessibility::IsCellOrTableHeaderRole() const { 832 bool BrowserAccessibility::IsCellOrTableHeaderRole() const {
826 return (GetRole() == ui::AX_ROLE_CELL || 833 return (GetRole() == ui::AX_ROLE_CELL ||
827 GetRole() == ui::AX_ROLE_COLUMN_HEADER || 834 GetRole() == ui::AX_ROLE_COLUMN_HEADER ||
828 GetRole() == ui::AX_ROLE_ROW_HEADER); 835 GetRole() == ui::AX_ROLE_ROW_HEADER);
829 } 836 }
830 837
831 bool BrowserAccessibility::HasCaret() const { 838 bool BrowserAccessibility::HasCaret() const {
832 if (HasState(ui::AX_STATE_EDITABLE) && 839 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)) { 840 HasIntAttribute(ui::AX_ATTR_TEXT_SEL_END)) {
836 return true; 841 return true;
837 } 842 }
838 843
839 // The caret is always at the focus of the selection. 844 // The caret is always at the focus of the selection.
840 int32_t focus_id = manager()->GetTreeData().sel_focus_object_id; 845 int32_t focus_id = manager()->GetTreeData().sel_focus_object_id;
841 BrowserAccessibility* focus_object = manager()->GetFromID(focus_id); 846 BrowserAccessibility* focus_object = manager()->GetFromID(focus_id);
842 if (!focus_object) 847 if (!focus_object)
843 return false; 848 return false;
844 849
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
932 return false; 937 return false;
933 } 938 }
934 } 939 }
935 940
936 bool BrowserAccessibility::IsSimpleTextControl() const { 941 bool BrowserAccessibility::IsSimpleTextControl() const {
937 // Time fields, color wells and spinner buttons might also use text fields as 942 // 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. 943 // constituent parts, but they are not considered text fields as a whole.
939 switch (GetRole()) { 944 switch (GetRole()) {
940 case ui::AX_ROLE_COMBO_BOX: 945 case ui::AX_ROLE_COMBO_BOX:
941 case ui::AX_ROLE_SEARCH_BOX: 946 case ui::AX_ROLE_SEARCH_BOX:
947 return true;
942 case ui::AX_ROLE_TEXT_FIELD: 948 case ui::AX_ROLE_TEXT_FIELD:
943 return true; 949 return !HasState(ui::AX_STATE_RICHLY_EDITABLE);
944 default: 950 default:
945 return false; 951 return false;
946 } 952 }
947 } 953 }
948 954
949 // Indicates if this object is at the root of a rich edit text control. 955 // Indicates if this object is at the root of a rich edit text control.
950 bool BrowserAccessibility::IsRichTextControl() const { 956 bool BrowserAccessibility::IsRichTextControl() const {
951 return HasState(ui::AX_STATE_RICHLY_EDITABLE) && 957 return HasState(ui::AX_STATE_RICHLY_EDITABLE) &&
952 (!GetParent() || !GetParent()->HasState(ui::AX_STATE_RICHLY_EDITABLE)); 958 (!GetParent() || !GetParent()->HasState(ui::AX_STATE_RICHLY_EDITABLE));
953 } 959 }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1044 } 1050 }
1045 need_to_offset_web_area = true; 1051 need_to_offset_web_area = true;
1046 } 1052 }
1047 parent = parent->GetParent(); 1053 parent = parent->GetParent();
1048 } 1054 }
1049 1055
1050 return bounds; 1056 return bounds;
1051 } 1057 }
1052 1058
1053 } // namespace content 1059 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698