Bug 1630819 - Remove the logic to reframe root unconditionally when reframing body. r=emilio

For whatever reasons, we pass body element into
`RecreateFramesForContent`, the root element won't be reframed down in
the `ContentRemoved` path, but in `ContentRangeInserted()` path while
checking `WipeContainingBlock`. And in bug 1593752, we already have the
logic to reframe root element only when html and body's writing-modes
are different, so we won't over-eagerly reframe the root element.

Differential Revision: https://phabricator.services.mozilla.com/D71606
This commit is contained in:
Ting-Yu Lin 2020-04-20 18:03:14 +00:00
parent 1ddbdbc6f0
commit ecf2e451c6
3 changed files with 49 additions and 11 deletions

View File

@ -8245,17 +8245,6 @@ bool nsCSSFrameConstructor::MaybeRecreateContainerForFrameRemoval(
"placeholder for primary frame has previous continuations?");
nsIFrame* parent = inFlowFrame->GetParent();
if (aFrame->GetContent() == mDocument->GetBodyElement()) {
// If the frame of the canonical body element is removed (either because of
// removing of the element, or removing for frame construction like
// writing-mode changed), we need to reframe the root element so that the
// root element's frames has the correct writing-mode propagated from body
// element. (See nsCSSFrameConstructor::ConstructDocElementFrame.)
TRACE("Root");
RecreateFramesForContent(mDocument->GetRootElement(), InsertionKind::Async);
return true;
}
if (inFlowFrame->HasAnyStateBits(NS_FRAME_HAS_MULTI_COLUMN_ANCESTOR)) {
nsIFrame* grandparent = parent->GetParent();
MOZ_ASSERT(grandparent);

View File

@ -154,6 +154,7 @@ skip-if = true # Bug 688128
[test_frame_reconstruction_for_svg_transforms.html]
[test_frame_reconstruction_scroll_restore.html]
[test_frame_reconstruction_body_writing_mode.html]
[test_frame_reconstruction_body_table.html]
[test_getBoxQuads_convertPointRectQuad.html]
support-files =
file_getBoxQuads_convertPointRectQuad_frame1.html

View File

@ -0,0 +1,48 @@
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<title>
Test for Bug 1630819: Test we don't reframe the html element when
inserting a block element into a display:table body element.
</title>
<link rel="author" title="Ting-Yu Lin" href="mailto:tlin@mozilla.com">
<link rel="author" title="Mozilla" href="http://www.mozilla.org/">
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script>
SimpleTest.waitForExplicitFinish();
const utils = SpecialPowers.getDOMWindowUtils(window);
function runTest() {
document.documentElement.offsetTop;
const frameCountBeforeReframe = utils.framesConstructed;
// We expect to construct one newly appended block, and reconstruct the
// display:table <body>, which consists of 8 frames including TableWrapper,
// Table, TableRowGroup, TableRow, TableColGroup, TableCol, TableCell, and
// TableCell's inner block.
const expectedFrameConstructionCount = 1 + 8;
let div = document.createElement("div");
document.body.appendChild(div);
document.documentElement.offsetTop;
is(utils.framesConstructed - frameCountBeforeReframe,
expectedFrameConstructionCount,
"We shouldn't reframe <html> when appending a <div> into a display:table <body>!");
SimpleTest.finish();
}
</script>
<style>
body {
display: table;
}
</style>
<body onload="runTest();"></body>
</html>