Commit 5def8fbb authored by Rune Lillesveen's avatar Rune Lillesveen Committed by Commit Bot

Missing null check for GetComputedStyle().

Made chrome://tracing crash on closing <dialog> element with
FlatTreeStyleRecalc enabled.

Bug: 972752
Change-Id: Ie152f10d2972a873fb7f1cc00cff745719d90faf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1905710Reviewed-by: default avatarMorten Stenshorne <mstensho@chromium.org>
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#713809}
parent 6f64c64a
......@@ -1314,9 +1314,11 @@ void Node::MarkAncestorsWithChildNeedsStyleRecalc() {
ContainerNode* style_parent = ancestor;
while (style_parent && !style_parent->CanParticipateInFlatTree())
style_parent = style_parent->GetStyleRecalcParent();
if (style_parent &&
style_parent->GetComputedStyle()->IsEnsuredOutsideFlatTree()) {
return;
if (style_parent) {
if (const auto* parent_style = style_parent->GetComputedStyle()) {
if (parent_style->IsEnsuredOutsideFlatTree())
return;
}
}
}
}
......
......@@ -503,4 +503,28 @@ TEST_F(NodeTest, UpdateChildDirtyAfterSlotRemoval) {
EXPECT_TRUE(GetDocument().GetStyleEngine().NeedsStyleRecalc());
}
TEST_F(NodeTest, UpdateChildDirtyAfterSlottingDirtyNode) {
ScopedFlatTreeStyleRecalcForTest scope(true);
SetBodyContent("<div id=host><span></span></div>");
auto* host = GetDocument().getElementById("host");
auto* span = To<Element>(host->firstChild());
// Make sure the span is style dirty.
span->setAttribute("style", "color:green");
ShadowRoot& shadow_root =
host->AttachShadowRootInternal(ShadowRootType::kOpen);
shadow_root.SetInnerHTMLFromString("<div><slot></slot></div>");
GetDocument().GetSlotAssignmentEngine().RecalcSlotAssignments();
// Make sure shadow tree div and slot are marked with ChildNeedsStyleRecalc
// when the dirty span is slotted in.
EXPECT_TRUE(shadow_root.firstChild()->ChildNeedsStyleRecalc());
EXPECT_TRUE(shadow_root.firstChild()->firstChild()->ChildNeedsStyleRecalc());
EXPECT_TRUE(span->NeedsStyleRecalc());
}
} // namespace blink
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