Bug 1523931 - Always create accessibles for div elements if they contain a br element, r=Jamie

After the fix for bug 646216, we no longer create divs with no text and only a br element for a line break. This breaks blank lines in contentEditables such as Gmail.

To fix, always create accessibles for divs if such a div contains a br element either as its first or last child.

Differential Revision: https://phabricator.services.mozilla.com/D18074

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Marco Zehe 2019-01-31 06:58:49 +00:00
parent 49da2e4c53
commit 97310d7a60
2 changed files with 26 additions and 2 deletions

View File

@ -98,7 +98,8 @@ MARKUPMAP(
}
// Check to see if first child has an inline frame.
nsIFrame* firstChildFrame = firstChild->GetPrimaryFrame();
if (firstChildFrame && firstChildFrame->IsInlineFrame()) {
if (firstChildFrame && (firstChildFrame->IsInlineFrame() ||
firstChildFrame->IsBrFrame())) {
return new HyperTextAccessibleWrap(aElement, aContext->Document());
}
nsIContent* lastChild = aElement->GetLastChild();
@ -109,7 +110,8 @@ MARKUPMAP(
}
// Check to see if last child has an inline frame.
nsIFrame* lastChildFrame = lastChild->GetPrimaryFrame();
if (lastChildFrame && lastChildFrame->IsInlineFrame()) {
if (lastChildFrame && (lastChildFrame->IsInlineFrame() ||
lastChildFrame->IsBrFrame())) {
return new HyperTextAccessibleWrap(aElement, aContext->Document());
}
}

View File

@ -191,6 +191,25 @@ function doTest() {
};
testAccessibleTree("c10", tree);
// c11: A div must be exposed if it contains a br element.
tree =
{ role: ROLE_SECTION, // outer div
children: [
{ role: ROLE_SECTION, // First line
children: [
{ TEXT_LEAF: [] }, // text
], // end children first line
}, // end first line
{ SECTION: [] }, // second, blank, line
{ role: ROLE_SECTION, // Third line
children: [
{ TEXT_LEAF: [] }, // text
], // end children third line
}, // end third line
], // end children outer div
};
testAccessibleTree("c11", tree);
SimpleTest.finish();
}
@ -231,5 +250,8 @@ addA11yLoadEvent(doTest);
<!-- Both inner divs need to be rendered so there is a break after b. -->
<div id="c10"><div><b>a</b>b</div><div><b>c</b><b>d</b></div></div>
<!-- Div must be rendered if it contains a br -->
<div id="c11"><div>first line.</div><div><br /></div><div>third line</div></div>
</body>
</html>