Commit d7c08c78 authored by Rune Lillesveen's avatar Rune Lillesveen Committed by Commit Bot

Missing check for GetForceReattachLayoutTree().

The style recalc root may be marked GetForceReattachLayoutTree() without
being marked for NeedsStyleRecalc(). Without that check, the
StyleRecalcRoot code was confused to believe we removed the recalc root
from the flat tree when it wasn't.

Bug: 1031934, 1031521
Change-Id: I1a5be72b44932d31adc7a59da06941ab975206a0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1958126
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Reviewed-by: default avatarAnders Hartvoll Ruud <andruud@chromium.org>
Cr-Commit-Position: refs/heads/master@{#723293}
parent b558cdc3
...@@ -2539,4 +2539,27 @@ TEST_F(StyleEngineTest, RecalcEnsuredStyleOutsideFlatTreeV0) { ...@@ -2539,4 +2539,27 @@ TEST_F(StyleEngineTest, RecalcEnsuredStyleOutsideFlatTreeV0) {
EXPECT_FALSE(GetDocument().body()->ChildNeedsStyleRecalc()); EXPECT_FALSE(GetDocument().body()->ChildNeedsStyleRecalc());
} }
TEST_F(StyleEngineTest, ForceReattachRecalcRootAttachShadow) {
ScopedFlatTreeStyleRecalcForTest scope(true);
GetDocument().body()->SetInnerHTMLFromString(R"HTML(
<div id="reattach"></div><div id="host"><span></span></div>
)HTML");
auto* reattach = GetDocument().getElementById("reattach");
auto* host = GetDocument().getElementById("host");
UpdateAllLifecyclePhases();
reattach->SetForceReattachLayoutTree();
EXPECT_FALSE(reattach->NeedsStyleRecalc());
EXPECT_EQ(reattach, GetStyleRecalcRoot());
// Attaching the shadow root will call RemovedFromFlatTree() on the span child
// of the host and mark the host for style recalc . Make sure the recalc root
// is correctly updated.
host->AttachShadowRootInternal(ShadowRootType::kOpen);
EXPECT_EQ(GetDocument().body(), GetStyleRecalcRoot());
}
} // namespace blink } // namespace blink
...@@ -131,6 +131,7 @@ void StyleRecalcRoot::RemovedFromFlatTree(const Node& node) { ...@@ -131,6 +131,7 @@ void StyleRecalcRoot::RemovedFromFlatTree(const Node& node) {
// make sure we don't have a recalc root outside the flat tree, which is not // make sure we don't have a recalc root outside the flat tree, which is not
// allowed with FlatTreeStyleRecalc enabled. // allowed with FlatTreeStyleRecalc enabled.
if (GetRootNode()->NeedsStyleRecalc() || if (GetRootNode()->NeedsStyleRecalc() ||
GetRootNode()->GetForceReattachLayoutTree() ||
GetRootNode()->ChildNeedsStyleRecalc()) { GetRootNode()->ChildNeedsStyleRecalc()) {
return; return;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment