Bug 1734582: Don't assert for a null frame in TextLeafPoint::FindPrev/NextLineStartSameLocalAcc. r=morgan
This can happen for display: contents. In that case, there are no lines in the Accessible anyway, so returning an invalid TextLeafPoint (as we already did) is the correct thing to do. Differential Revision: https://phabricator.services.mozilla.com/D128319
This commit is contained in:
@@ -415,7 +415,8 @@ TextLeafPoint TextLeafPoint::FindPrevLineStartSameLocalAcc(
|
||||
}
|
||||
nsIFrame* frame = acc->GetFrame();
|
||||
if (!frame) {
|
||||
MOZ_ASSERT_UNREACHABLE("No frame");
|
||||
// This can happen if this is an empty element with display: contents. In
|
||||
// that case, this Accessible contains no lines.
|
||||
return TextLeafPoint();
|
||||
}
|
||||
if (!frame->IsTextFrame()) {
|
||||
@@ -461,7 +462,8 @@ TextLeafPoint TextLeafPoint::FindNextLineStartSameLocalAcc(
|
||||
}
|
||||
nsIFrame* frame = acc->GetFrame();
|
||||
if (!frame) {
|
||||
MOZ_ASSERT_UNREACHABLE("No frame");
|
||||
// This can happen if this is an empty element with display: contents. In
|
||||
// that case, this Accessible contains no lines.
|
||||
return TextLeafPoint();
|
||||
}
|
||||
if (!frame->IsTextFrame()) {
|
||||
|
||||
@@ -11,16 +11,25 @@
|
||||
src="../text.js"></script>
|
||||
<script type="application/javascript">
|
||||
function doTest() {
|
||||
const isCacheEnabled = Services.prefs.getBoolPref(
|
||||
"accessibility.cache.enabled",
|
||||
false
|
||||
);
|
||||
// Flag to pass to testTextAtOffset for tests fixed by TextLeafPoint.
|
||||
// if TextLeafPoint is enabled, those tests should pass. If not, they
|
||||
// should be expected failures.
|
||||
const okIfCache = isCacheEnabled ? kOk : kTodo;
|
||||
|
||||
testTextAtOffset("line_test_1", BOUNDARY_LINE_START,
|
||||
[[0, 6, "Line 1 ", 0, 7],
|
||||
// See the todo test below.
|
||||
// See the okIfCache test below.
|
||||
// [7, 7, kEmbedChar, 7, 8],
|
||||
[8, 15, "Line 3 ", 8, 15]]);
|
||||
testTextAtOffset(/* aOffset */ 7, BOUNDARY_LINE_START,
|
||||
kEmbedChar, /* aStartOffset */ 7, /* aEndOffset */ 8,
|
||||
"line_test_1",
|
||||
/* returned text */ kTodo,
|
||||
/* returned start offset */ kOk, /* returned end offset */ kTodo);
|
||||
/* returned text */ okIfCache,
|
||||
/* returned start offset */ kOk, /* returned end offset */ okIfCache);
|
||||
|
||||
// ////////////////////////////////////////////////////////////////////////
|
||||
// __h__e__l__l__o__ __m__y__ __f__r__i__e__n__d__
|
||||
@@ -226,6 +235,19 @@
|
||||
[21, 27, "Line 4\n", 21, 28],
|
||||
[28, 28, "", 28, 28] ]);
|
||||
|
||||
// A line with an empty display: contents leaf in the middle.
|
||||
testTextAtOffset([ "displayContents" ], BOUNDARY_LINE_START,
|
||||
// See the okIfCache test below.
|
||||
// [ [0, 3, `a${kEmbedChar}b`, 0, 3] ]);
|
||||
[ [0, 0, `a${kEmbedChar}b`, 0, 3],
|
||||
[2, 3, `a${kEmbedChar}b`, 0, 3] ]);
|
||||
testTextAtOffset(/* aOffset */ 1, BOUNDARY_LINE_START,
|
||||
`a${kEmbedChar}b`, /* aStartOffset */ 0, /* aEndOffset */ 3,
|
||||
"displayContents",
|
||||
/* returned text */ okIfCache,
|
||||
/* returned start offset */ okIfCache,
|
||||
/* returned end offset */ okIfCache);
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
@@ -343,5 +365,6 @@ two words
|
||||
</span>
|
||||
<span>Line 4<br/>
|
||||
</span></div><!-- OK to indent again -->
|
||||
<div id="displayContents">a<ul style="display: contents;"><li style="display: contents;"></li></ul>b</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user