зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1878356: Trim non-breaking spaces from acc name prefixes, suffixes, r=Jamie
This revision modifies LocalAccessible::Name such that the function trims non-breaking spaces from the beginning and end of accessible names. We already compress all ASCII whitespace and trim it from the prefixes and suffixes of accessible names - this change just extends that trimming to non-breaking spaces for the exterior ends of the name string only. This revision implements a new function, TrimNonBreakingSpaces, which does the trimming. Finally, this revision removes five expected failures from the web platform tests. Differential Revision: https://phabricator.services.mozilla.com/D203993
This commit is contained in:
Родитель
77bd48c64e
Коммит
10c7a982bd
|
@ -546,6 +546,32 @@ 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<nsIObserverService> obsService = services::GetObserverService();
|
||||
NS_ENSURE_TRUE(obsService, false);
|
||||
|
|
|
@ -305,6 +305,11 @@ 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.
|
||||
*/
|
||||
|
|
|
@ -127,6 +127,7 @@ 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.
|
||||
|
|
|
@ -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
|
Загрузка…
Ссылка в новой задаче