зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 60cf5a19aa68 (bug 1550644
) for causing bc failures on browser_autocomplete_a11y_label.js.
This commit is contained in:
Родитель
3c144d6712
Коммит
a019566c16
|
@ -105,6 +105,26 @@ nsresult nsTextEquivUtils::AppendTextEquivFromContent(
|
|||
nsresult nsTextEquivUtils::AppendTextEquivFromTextContent(nsIContent* aContent,
|
||||
nsAString* aString) {
|
||||
if (aContent->IsText()) {
|
||||
bool isHTMLBlock = false;
|
||||
|
||||
nsIContent* parentContent = aContent->GetFlattenedTreeParent();
|
||||
if (parentContent) {
|
||||
nsIFrame* frame = parentContent->GetPrimaryFrame();
|
||||
if (frame) {
|
||||
// If this text is inside a block level frame (as opposed to span
|
||||
// level), we need to add spaces around that block's text, so we don't
|
||||
// get words jammed together in final name.
|
||||
const nsStyleDisplay* display = frame->StyleDisplay();
|
||||
if (display->IsBlockOutsideStyle() ||
|
||||
display->mDisplay == StyleDisplay::TableCell) {
|
||||
isHTMLBlock = true;
|
||||
if (!aString->IsEmpty()) {
|
||||
aString->Append(char16_t(' '));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (aContent->TextLength() > 0) {
|
||||
nsIFrame* frame = aContent->GetPrimaryFrame();
|
||||
if (frame) {
|
||||
|
@ -116,6 +136,9 @@ nsresult nsTextEquivUtils::AppendTextEquivFromTextContent(nsIContent* aContent,
|
|||
// If aContent is an object that is display: none, we have no a frame.
|
||||
aContent->GetAsText()->AppendTextTo(*aString);
|
||||
}
|
||||
if (isHTMLBlock && !aString->IsEmpty()) {
|
||||
aString->Append(char16_t(' '));
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -161,27 +184,10 @@ nsresult nsTextEquivUtils::AppendFromAccessibleChildren(
|
|||
nsresult nsTextEquivUtils::AppendFromAccessible(Accessible* aAccessible,
|
||||
nsAString* aString) {
|
||||
// XXX: is it necessary to care the accessible is not a document?
|
||||
bool isHTMLBlock = false;
|
||||
if (aAccessible->IsLocal() && aAccessible->AsLocal()->IsContent()) {
|
||||
nsIContent* content = aAccessible->AsLocal()->GetContent();
|
||||
nsresult rv = AppendTextEquivFromTextContent(content, aString);
|
||||
nsresult rv = AppendTextEquivFromTextContent(
|
||||
aAccessible->AsLocal()->GetContent(), aString);
|
||||
if (rv != NS_OK_NO_NAME_CLAUSE_HANDLED) return rv;
|
||||
if (!content->IsText()) {
|
||||
nsIFrame* frame = content->GetPrimaryFrame();
|
||||
if (frame) {
|
||||
// If this is a block level frame (as opposed to span level), we need to
|
||||
// add spaces around that block's text, so we don't get words jammed
|
||||
// together in final name.
|
||||
const nsStyleDisplay* display = frame->StyleDisplay();
|
||||
if (display->IsBlockOutsideStyle() ||
|
||||
display->mDisplay == StyleDisplay::TableCell) {
|
||||
isHTMLBlock = true;
|
||||
if (!aString->IsEmpty()) {
|
||||
aString->Append(char16_t(' '));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool isEmptyTextEquiv = true;
|
||||
|
@ -214,15 +220,9 @@ nsresult nsTextEquivUtils::AppendFromAccessible(Accessible* aAccessible,
|
|||
// Implementation of h. step
|
||||
if (isEmptyTextEquiv && !text.IsEmpty()) {
|
||||
AppendString(aString, text);
|
||||
if (isHTMLBlock) {
|
||||
aString->Append(char16_t(' '));
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (!isEmptyTextEquiv && isHTMLBlock) {
|
||||
aString->Append(char16_t(' '));
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
|
|
@ -58,9 +58,10 @@
|
|||
// spaces)
|
||||
testName("btn_labelledby_mixed_block", "text more text");
|
||||
|
||||
// Gets the name from text nodes contained by html:td. The text nodes
|
||||
// should not be divided by spaces.
|
||||
testName("btn_labelledby_mixed_table", "textTEXTtext");
|
||||
// Gets the name from text nodes contained by html:td (every text node
|
||||
// value in the name should be devided by spaces).
|
||||
// XXX: this case is rather a feature than strong wanted behaviour.
|
||||
testName("btn_labelledby_mixed_table", "text space text");
|
||||
|
||||
// Gets the name from image accessible.
|
||||
testName("btn_labelledby_mixed_img", "text image");
|
||||
|
@ -250,17 +251,6 @@
|
|||
// Name from subtree of grouping labelled by an ancestor.
|
||||
testName("grouping_labelledby_ancestor", "label");
|
||||
|
||||
// Name from subtree of a container containing text nodes and inline
|
||||
// elements. There should be no spaces because everyhing is inline.
|
||||
testName("container_text_inline", "abc");
|
||||
// Name from subtree of a container containing text nodes and block
|
||||
// elements. There should be a space on both sides of the block.
|
||||
testName("container_text_block", "a b c");
|
||||
// Name from subtree of a container containing text nodes and empty
|
||||
// block elements. There should be space on either side of the blocks, but
|
||||
// not a double space.
|
||||
testName("container_text_emptyblock", "a b");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
|
@ -397,7 +387,7 @@
|
|||
|
||||
<!-- the name from subtree, mixed content, table structure -->
|
||||
<table><tr>
|
||||
<td id="labelledby_mixed_table">text<span>TEXT</span>text</td>
|
||||
<td id="labelledby_mixed_table">text<span>space</span>text</td>
|
||||
</tr></table>
|
||||
<button id="btn_labelledby_mixed_table"
|
||||
aria-labelledby="labelledby_mixed_table">5</button>
|
||||
|
@ -721,12 +711,5 @@
|
|||
This content should not be included in the grouping's label.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Text nodes and inline elements. -->
|
||||
<div id="container_text_inline" role="option">a<strong>b</strong>c</div>
|
||||
<!-- Text nodes and block elements. -->
|
||||
<div id="container_text_block" role="option">a<p>b</p>c</div>
|
||||
<!-- Text nodes and empty block elements. -->
|
||||
<div id="container_text_emptyblock" role="option">a<p></p><p></p>b</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Загрузка…
Ссылка в новой задаче