Commit 6772afd3 authored by Nektarios Paisios's avatar Nektarios Paisios Committed by Commit Bot

Stops computing an artificial accessible name from inner text on Mac

When an object on Mac is focusable but has no value or name, we compute its accessible description
from its inner text.
Unfortunately, we were adding a space between the concatenation of each piece of text coming from each child object
which creates a mismatch between the text offsets returned by AXPosition and text markers vs. the actual text contents.
If extra spaces are needed, they should be added by Blink, not by the browser.
This patch removes the code that computes the inner text completely since
no other screen reader announces focusable items unless they have an accessible name,
and it is not proper to add an accessible name if there is none.

AX-Relnotes: On Mac and same as on all other platforms, navigating by tab now does not announce
the text contained in a large container such as a table row if that container is focusable.

R=dmazzoni@chromium.org

Change-Id: Iac5f321113595a2372df03bb119ab1c7a6f1bbf4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2308649
Commit-Queue: Nektarios Paisios <nektar@chromium.org>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#794574}
parent 3cea47a9
...@@ -1036,30 +1036,6 @@ bool BrowserAccessibility::HasExplicitlyEmptyName() const { ...@@ -1036,30 +1036,6 @@ bool BrowserAccessibility::HasExplicitlyEmptyName() const {
ax::mojom::NameFrom::kAttributeExplicitlyEmpty; ax::mojom::NameFrom::kAttributeExplicitlyEmpty;
} }
std::string BrowserAccessibility::ComputeAccessibleNameFromDescendants() const {
std::string name;
for (InternalChildIterator it = InternalChildrenBegin();
it != InternalChildrenEnd(); ++it) {
const BrowserAccessibility* child = it.get();
std::string child_name;
if (child->GetStringAttribute(ax::mojom::StringAttribute::kName,
&child_name)) {
if (!name.empty())
name += " ";
name += child_name;
} else if (!child->HasState(ax::mojom::State::kFocusable)) {
child_name = child->ComputeAccessibleNameFromDescendants();
if (!child_name.empty()) {
if (!name.empty())
name += " ";
name += child_name;
}
}
}
return name;
}
std::string BrowserAccessibility::GetLiveRegionText() const { std::string BrowserAccessibility::GetLiveRegionText() const {
if (IsIgnored()) if (IsIgnored())
return ""; return "";
......
...@@ -382,9 +382,6 @@ class CONTENT_EXPORT BrowserAccessibility : public ui::AXPlatformNodeDelegate { ...@@ -382,9 +382,6 @@ class CONTENT_EXPORT BrowserAccessibility : public ui::AXPlatformNodeDelegate {
// Returns true if the accessible name was explicitly set to "" by the author // Returns true if the accessible name was explicitly set to "" by the author
bool HasExplicitlyEmptyName() const; bool HasExplicitlyEmptyName() const;
// TODO(nektar): Remove this method and replace with GetInnerText.
std::string ComputeAccessibleNameFromDescendants() const;
// Get text to announce for a live region change, for ATs that do not // Get text to announce for a live region change, for ATs that do not
// implement this functionality. // implement this functionality.
std::string GetLiveRegionText() const; std::string GetLiveRegionText() const;
......
...@@ -1206,19 +1206,6 @@ id content::AXTextMarkerRangeFrom(id anchor_textmarker, id focus_textmarker) { ...@@ -1206,19 +1206,6 @@ id content::AXTextMarkerRangeFrom(id anchor_textmarker, id focus_textmarker) {
} }
} }
// If it's focusable but didn't have any other name or value, compute a name
// from its descendants. Note that this is a workaround because VoiceOver
// does not always present focus changes if the new focus lacks a name.
base::string16 value = _owner->GetValue();
if (_owner->HasState(ax::mojom::State::kFocusable) &&
!ui::IsControl(_owner->GetRole()) && value.empty() &&
[self internalRole] != ax::mojom::Role::kDateTime &&
[self internalRole] != ax::mojom::Role::kWebArea &&
[self internalRole] != ax::mojom::Role::kRootWebArea) {
return base::SysUTF8ToNSString(
_owner->ComputeAccessibleNameFromDescendants());
}
return @""; return @"";
} }
......
AXWebArea AXWebArea
++AXGroup AXARIAAtomic=0 AXDescription='This test is for aria-atomic="false"' ++AXGroup AXARIAAtomic=0
++++AXStaticText AXARIAAtomic=0 AXValue='This test is for aria-atomic="false"' ++++AXStaticText AXARIAAtomic=0 AXValue='This test is for aria-atomic="false"'
++AXGroup AXARIAAtomic=1 AXDescription='This test is for aria-atomic="true"' ++AXGroup AXARIAAtomic=1
++++AXStaticText AXARIAAtomic=0 AXValue='This test is for aria-atomic="true"' ++++AXStaticText AXARIAAtomic=0 AXValue='This test is for aria-atomic="true"'
++AXGroup AXARIAAtomic=1 AXDescription='This test is for alert.' ++AXGroup AXARIAAtomic=1
++++AXStaticText AXARIAAtomic=0 AXValue='This test is for alert.' ++++AXStaticText AXARIAAtomic=0 AXValue='This test is for alert.'
++AXGroup AXARIAAtomic=1 AXDescription='This test is for status.' ++AXGroup AXARIAAtomic=1
++++AXStaticText AXARIAAtomic=0 AXValue='This test is for status.' ++++AXStaticText AXARIAAtomic=0 AXValue='This test is for status.'
AXWebArea AXRoleDescription='HTML content' AXWebArea AXRoleDescription='HTML content'
++AXGroup AXDescription='First' AXRoleDescription='article' ++AXGroup AXRoleDescription='article'
++++AXStaticText AXRoleDescription='text' AXValue='First' ++++AXStaticText AXRoleDescription='text' AXValue='First'
++AXGroup AXDescription='Second' AXRoleDescription='article' ++AXGroup AXRoleDescription='article'
++++AXStaticText AXRoleDescription='text' AXValue='Second' ++++AXStaticText AXRoleDescription='text' AXValue='Second'
...@@ -24,7 +24,7 @@ AXWebArea AXRoleDescription='HTML content' ...@@ -24,7 +24,7 @@ AXWebArea AXRoleDescription='HTML content'
++++++++++++++++AXGroup AXRoleDescription='group' ++++++++++++++++AXGroup AXRoleDescription='group'
++++++++++++++AXButton AXDescription='Show next month' AXRoleDescription='button' ++++++++++++++AXButton AXDescription='Show next month' AXRoleDescription='button'
++++++++++++++++AXGroup AXRoleDescription='group' ++++++++++++++++AXGroup AXRoleDescription='group'
++++++++++++++AXTable AXDescription='S M T W T F S Sunday, August 31, 2008 Monday, September 1, 2008 Tuesday, September 2, 2008 Wednesday, September 3, 2008 Thursday, September 4, 2008 Friday, September 5, 2008 Saturday, September 6, 2008 Sunday, September 7, 2008 Monday, September 8, 2008 Tuesday, September 9, 2008 Wednesday, September 10, 2008 Thursday, September 11, 2008 Friday, September 12, 2008 Saturday, September 13, 2008 Sunday, September 14, 2008 Monday, September 15, 2008 Tuesday, September 16, 2008 Wednesday, September 17, 2008 Thursday, September 18, 2008 Friday, September 19, 2008 Saturday, September 20, 2008 Sunday, September 21, 2008 Monday, September 22, 2008 Tuesday, September 23, 2008 Wednesday, September 24, 2008 Thursday, September 25, 2008 Friday, September 26, 2008 Saturday, September 27, 2008 Sunday, September 28, 2008 Monday, September 29, 2008 Tuesday, September 30, 2008 Wednesday, October 1, 2008 Thursday, October 2, 2008 Friday, October 3, 2008 Saturday, October 4, 2008 Sunday, October 5, 2008 Monday, October 6, 2008 Tuesday, October 7, 2008 Wednesday, October 8, 2008 Thursday, October 9, 2008 Friday, October 10, 2008 Saturday, October 11, 2008 Today' AXRoleDescription='table' ++++++++++++++AXTable AXRoleDescription='table'
++++++++++++++++AXGroup AXRoleDescription='group' ++++++++++++++++AXGroup AXRoleDescription='group'
++++++++++++++++++AXGroup AXRoleDescription='group' ++++++++++++++++++AXGroup AXRoleDescription='group'
++++++++++++++++++++AXStaticText AXRoleDescription='text' AXValue='S' ++++++++++++++++++++AXStaticText AXRoleDescription='text' AXValue='S'
......
AXWebArea AXTitle='Table example - focusable thead, tbody, tfoot' AXWebArea AXTitle='Table example - focusable thead, tbody, tfoot'
++AXTable ++AXTable
++++AXGroup AXDescription='Sum Subtraction' ++++AXGroup
++++++AXRow AXIndex=0 ++++++AXRow AXIndex=0
++++++++AXCell AXColumnIndexRange={len: 1, loc: 0} AXRowIndexRange={len: 1, loc: 0} ++++++++AXCell AXColumnIndexRange={len: 1, loc: 0} AXRowIndexRange={len: 1, loc: 0}
++++++++++AXStaticText AXValue='Sum' ++++++++++AXStaticText AXValue='Sum'
++++++++AXCell AXColumnIndexRange={len: 1, loc: 1} AXRowIndexRange={len: 1, loc: 0} ++++++++AXCell AXColumnIndexRange={len: 1, loc: 1} AXRowIndexRange={len: 1, loc: 0}
++++++++++AXStaticText AXValue='Subtraction' ++++++++++AXStaticText AXValue='Subtraction'
++++AXGroup AXDescription='10 7 2 4' ++++AXGroup
++++++AXRow AXIndex=1 ++++++AXRow AXIndex=1
++++++++AXCell AXColumnIndexRange={len: 1, loc: 0} AXRowIndexRange={len: 1, loc: 1} ++++++++AXCell AXColumnIndexRange={len: 1, loc: 0} AXRowIndexRange={len: 1, loc: 1}
++++++++++AXStaticText AXValue='10' ++++++++++AXStaticText AXValue='10'
...@@ -17,7 +17,7 @@ AXWebArea AXTitle='Table example - focusable thead, tbody, tfoot' ...@@ -17,7 +17,7 @@ AXWebArea AXTitle='Table example - focusable thead, tbody, tfoot'
++++++++++AXStaticText AXValue='2' ++++++++++AXStaticText AXValue='2'
++++++++AXCell AXColumnIndexRange={len: 1, loc: 1} AXRowIndexRange={len: 1, loc: 2} ++++++++AXCell AXColumnIndexRange={len: 1, loc: 1} AXRowIndexRange={len: 1, loc: 2}
++++++++++AXStaticText AXValue='4' ++++++++++AXStaticText AXValue='4'
++++AXGroup AXDescription='12 3' ++++AXGroup
++++++AXRow AXIndex=3 ++++++AXRow AXIndex=3
++++++++AXCell AXColumnIndexRange={len: 1, loc: 0} AXRowIndexRange={len: 1, loc: 3} ++++++++AXCell AXColumnIndexRange={len: 1, loc: 0} AXRowIndexRange={len: 1, loc: 3}
++++++++++AXStaticText AXValue='12' ++++++++++AXStaticText AXValue='12'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment