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

Don't ClearDistribution() until we update it.

With FlatTreeStyleRecalc we expect to traverse up the current flat tree
ancestor chain even when the distribution is marked dirty. Otherwise,
we will not be able to reach the style dirty nodes marked when we have
a dirty distribution.

Bug: 1023178
Change-Id: I2b80ad252bc17bb223a3caa9336526c9e2fb6387
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1911208Reviewed-by: default avatarMason Freed <masonfreed@chromium.org>
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#714855}
parent 780bbd1b
...@@ -527,4 +527,43 @@ TEST_F(NodeTest, UpdateChildDirtyAfterSlottingDirtyNode) { ...@@ -527,4 +527,43 @@ TEST_F(NodeTest, UpdateChildDirtyAfterSlottingDirtyNode) {
EXPECT_TRUE(span->NeedsStyleRecalc()); EXPECT_TRUE(span->NeedsStyleRecalc());
} }
TEST_F(NodeTest, ChildDirtyNeedsV0Distribution) {
ScopedFlatTreeStyleRecalcForTest scope(true);
SetBodyContent("<div id=host><span></span> </div>");
ShadowRoot* shadow_root = CreateShadowRootForElementWithIDAndSetInnerHTML(
GetDocument(), "host", "<content />");
UpdateAllLifecyclePhasesForTest();
#if DCHECK_IS_ON()
GetDocument().SetAllowDirtyShadowV0Traversal(true);
#endif
auto* host = GetDocument().getElementById("host");
auto* span = To<Element>(host->firstChild());
auto* content = shadow_root->firstChild();
host->lastChild()->remove();
EXPECT_FALSE(GetDocument().documentElement()->ChildNeedsStyleRecalc());
EXPECT_TRUE(GetDocument().documentElement()->ChildNeedsDistributionRecalc());
EXPECT_EQ(content, host->firstChild()->GetStyleRecalcParent());
EXPECT_FALSE(content->ChildNeedsStyleRecalc());
// Make the span style dirty.
span->setAttribute("style", "color:green");
// Check that the flat tree ancestor chain is child-dirty while the
// shadow distribution is still dirty.
EXPECT_TRUE(GetDocument().documentElement()->ChildNeedsStyleRecalc());
EXPECT_TRUE(GetDocument().body()->ChildNeedsStyleRecalc());
EXPECT_TRUE(host->ChildNeedsStyleRecalc());
EXPECT_TRUE(content->ChildNeedsStyleRecalc());
EXPECT_TRUE(GetDocument().documentElement()->ChildNeedsDistributionRecalc());
#if DCHECK_IS_ON()
GetDocument().SetAllowDirtyShadowV0Traversal(false);
#endif
}
} // namespace blink } // namespace blink
...@@ -248,8 +248,6 @@ void ShadowRoot::SetNeedsDistributionRecalc() { ...@@ -248,8 +248,6 @@ void ShadowRoot::SetNeedsDistributionRecalc() {
return; return;
needs_distribution_recalc_ = true; needs_distribution_recalc_ = true;
host().MarkAncestorsWithChildNeedsDistributionRecalc(); host().MarkAncestorsWithChildNeedsDistributionRecalc();
if (!IsV1())
V0().ClearDistribution();
} }
void ShadowRoot::Trace(Visitor* visitor) { void ShadowRoot::Trace(Visitor* visitor) {
......
...@@ -168,6 +168,8 @@ const DestinationInsertionPoints* ShadowRootV0::DestinationInsertionPointsFor( ...@@ -168,6 +168,8 @@ const DestinationInsertionPoints* ShadowRootV0::DestinationInsertionPointsFor(
} }
void ShadowRootV0::Distribute() { void ShadowRootV0::Distribute() {
ClearDistribution();
DistributionPool pool(GetShadowRoot().host()); DistributionPool pool(GetShadowRoot().host());
HTMLShadowElement* shadow_insertion_point = nullptr; HTMLShadowElement* shadow_insertion_point = nullptr;
......
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