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

Don't style recalc shadow root descendants if not necessary.

Sibling invalidation sets may be (re-)scheduled on shadow roots on dom
changes. If the removed node was the one that needed style invalidation,
we may end up with a style-dirty shadow root with no style-dirty
children. There is a DCHECK in RecalcDescendantStyles which triggers if
we call it unnecessarily. We called it unconditionally in ShadowRoot.

Discovered while minimizing the fuzzer case for the mentioned Bug.

Bug: 798918
Change-Id: I4f59b1a77af6a89ed304abd88d7f8cca84775127
Reviewed-on: https://chromium-review.googlesource.com/850395Reviewed-by: default avatarEric Willigers <ericwilligers@chromium.org>
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#526995}
parent 5f145943
<!DOCTYPE html>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<style>
.a + .b { color: pink }
</style>
<div id="host"></div>
<script>
test(() => {
var root = host.createShadowRoot();
root.innerHTML = "<span></span><span></span>";
var span = root.firstChild;
document.documentElement.offsetTop;
span.setAttribute("class", "a");
span.remove();
}, `Scheduling a sibling invalidation set on shadow root before remove()
should not cause a DCHECK failure`);
</script>
...@@ -168,7 +168,8 @@ void ShadowRoot::RecalcStyle(StyleRecalcChange change) { ...@@ -168,7 +168,8 @@ void ShadowRoot::RecalcStyle(StyleRecalcChange change) {
// There's no style to update so just calling recalcStyle means we're updated. // There's no style to update so just calling recalcStyle means we're updated.
ClearNeedsStyleRecalc(); ClearNeedsStyleRecalc();
RecalcDescendantStyles(change); if (change >= kUpdatePseudoElements || ChildNeedsStyleRecalc())
RecalcDescendantStyles(change);
ClearChildNeedsStyleRecalc(); ClearChildNeedsStyleRecalc();
} }
......
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