From 9d751c3283a4db483c0d151aee9525a4a7c9480e Mon Sep 17 00:00:00 2001 From: Nathan LaPre Date: Tue, 30 Apr 2024 00:35:45 +0000 Subject: [PATCH] Bug 1878356: Remove nbsp trimming from acc names, r=Jamie This revision reverts the changes that trimmed non-breaking spaces from the start and end of accessible names. The web platform group has decided that those tests weren't valid as-is; the correct behavior is not to trim those characters. This revision also removes expected-fail designations from affected tests. Differential Revision: https://phabricator.services.mozilla.com/D208687 --- accessible/base/nsCoreUtils.cpp | 26 ------------------- accessible/base/nsCoreUtils.h | 5 ---- accessible/generic/LocalAccessible.cpp | 1 - .../meta/accname/name/comp_text_node.html.ini | 15 ----------- 4 files changed, 47 deletions(-) delete mode 100644 testing/web-platform/meta/accname/name/comp_text_node.html.ini diff --git a/accessible/base/nsCoreUtils.cpp b/accessible/base/nsCoreUtils.cpp index c5e89258fadb..3e66fa9c2323 100644 --- a/accessible/base/nsCoreUtils.cpp +++ b/accessible/base/nsCoreUtils.cpp @@ -547,32 +547,6 @@ bool nsCoreUtils::IsWhitespaceString(const nsAString& aString) { return iterBegin == iterEnd; } -void nsCoreUtils::TrimNonBreakingSpaces(nsAString& aString) { - if (aString.IsEmpty()) { - return; - } - - // Find the index past the last nbsp prefix character. - constexpr char16_t nbsp{0xA0}; - size_t startIndex = 0; - while (aString.CharAt(startIndex) == nbsp) { - startIndex++; - } - - // Find the index before the first nbsp suffix character. - size_t endIndex = aString.Length() - 1; - while (endIndex > startIndex && aString.CharAt(endIndex) == nbsp) { - endIndex--; - } - if (startIndex > endIndex) { - aString.Truncate(); - return; - } - - // Trim the string down, removing the non-breaking space characters. - aString = Substring(aString, startIndex, endIndex - startIndex + 1); -} - bool nsCoreUtils::AccEventObserversExist() { nsCOMPtr obsService = services::GetObserverService(); NS_ENSURE_TRUE(obsService, false); diff --git a/accessible/base/nsCoreUtils.h b/accessible/base/nsCoreUtils.h index 5e77d6bfe0ef..28ead982af66 100644 --- a/accessible/base/nsCoreUtils.h +++ b/accessible/base/nsCoreUtils.h @@ -307,11 +307,6 @@ class nsCoreUtils { aChar == 0xa0; } - /** - * Remove non-breaking spaces from the beginning and end of the string. - */ - static void TrimNonBreakingSpaces(nsAString& aString); - /* * Return true if there are any observers of accessible events. */ diff --git a/accessible/generic/LocalAccessible.cpp b/accessible/generic/LocalAccessible.cpp index 98ee5d4dd874..b9b4590cf470 100644 --- a/accessible/generic/LocalAccessible.cpp +++ b/accessible/generic/LocalAccessible.cpp @@ -127,7 +127,6 @@ ENameValueFlag LocalAccessible::Name(nsString& aName) const { if (!aName.IsEmpty()) return eNameOK; ENameValueFlag nameFlag = NativeName(aName); - nsCoreUtils::TrimNonBreakingSpaces(aName); if (!aName.IsEmpty()) return nameFlag; // In the end get the name from tooltip. diff --git a/testing/web-platform/meta/accname/name/comp_text_node.html.ini b/testing/web-platform/meta/accname/name/comp_text_node.html.ini deleted file mode 100644 index b92d76a4966a..000000000000 --- a/testing/web-platform/meta/accname/name/comp_text_node.html.ini +++ /dev/null @@ -1,15 +0,0 @@ -[comp_text_node.html] - [span[role=button\] with text node, with leading/trailing non-breaking space] - expected: FAIL - - [div[role=heading\] with text node, with leading/trailing non-breaking space] - expected: FAIL - - [button with text node, with leading/trailing non-breaking space] - expected: FAIL - - [heading with text node, with leading/trailing non-breaking space] - expected: FAIL - - [link with text node, with leading/trailing non-breaking space] - expected: FAIL