зеркало из https://github.com/mozilla/gecko-dev.git
Bug 495390 - If a link has a non-breaking space as screen text, try to fall back to other means like @title, marcoz, davidb
This commit is contained in:
Родитель
1f7a6fb844
Коммит
b9a0cd6c6c
|
@ -75,7 +75,8 @@ nsTextEquivUtils::GetNameFromSubtree(nsIAccessible *aAccessible,
|
|||
nsAutoString name;
|
||||
AppendFromAccessibleChildren(aAccessible, &name);
|
||||
name.CompressWhitespace();
|
||||
aName = name;
|
||||
if (!IsWhitespaceString(name))
|
||||
aName = name;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -419,6 +420,27 @@ nsTextEquivUtils::AppendString(nsAString *aString,
|
|||
return PR_TRUE;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsTextEquivUtils::IsWhitespaceString(const nsSubstring& aString)
|
||||
{
|
||||
nsSubstring::const_char_iterator iterBegin, iterEnd;
|
||||
|
||||
aString.BeginReading(iterBegin);
|
||||
aString.EndReading(iterEnd);
|
||||
|
||||
while (iterBegin != iterEnd && IsWhitespace(*iterBegin))
|
||||
++iterBegin;
|
||||
|
||||
return iterBegin == iterEnd;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsTextEquivUtils::IsWhitespace(PRUnichar aChar)
|
||||
{
|
||||
return aChar == ' ' || aChar == '\n' ||
|
||||
aChar == '\r' || aChar == '\t' || aChar == 0xa0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Name rules to role map.
|
||||
|
||||
|
|
|
@ -159,6 +159,18 @@ private:
|
|||
static PRBool AppendString(nsAString *aString,
|
||||
const nsAString& aTextEquivalent);
|
||||
|
||||
/**
|
||||
* Returns true if the given string is empty or contains whitespace symbols
|
||||
* only. In contrast to nsWhitespaceTokenizer class it takes into account
|
||||
* non-breaking space (0xa0).
|
||||
*/
|
||||
static PRBool IsWhitespaceString(const nsSubstring& aString);
|
||||
|
||||
/**
|
||||
* Returns true if the given character is whitespace symbol.
|
||||
*/
|
||||
static PRBool IsWhitespace(PRUnichar aChar);
|
||||
|
||||
/**
|
||||
* Map array from roles to name rules (constants of ETextEquivRule).
|
||||
*/
|
||||
|
|
|
@ -92,6 +92,9 @@
|
|||
// Gets the name from html:input value, ignore @title attribute on input
|
||||
testName("from_input_ignoretitle", "Custom country");
|
||||
|
||||
// Gets the name from @title, ignore whitespace content
|
||||
testName("from_label_ignore_ws_subtree", "about");
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// label element
|
||||
|
||||
|
@ -303,6 +306,9 @@
|
|||
value="Custom country"
|
||||
title="Input your country of origin"/ >
|
||||
|
||||
<!-- no name from subtree because it holds whitespaces only -->
|
||||
<a id="from_label_ignore_ws_subtree" href="about:" title="about"> </a>
|
||||
|
||||
<!-- label element, label contains the button -->
|
||||
<label>text<button id="btn_label_inside">10</button>text</label>
|
||||
<br/>
|
||||
|
|
Загрузка…
Ссылка в новой задаче