Commit dfe6cf58 authored by rune's avatar rune Committed by Commit bot

Use LocalStyleChange for insertion point inheritance propagation.

For shadow dom v0, we used a SubtreeStyleChange for propagating
inherited style changes through insertion points to distributed nodes.
LocalStyleChange should suffice. We already use LocalStyleChange in the
HTMLSlotElement case.

We still need to use SubtreeStyleChange where we have a
SubtreeStyleChange/Force from further up the tree like:

<host>
  <:shadow-root>
    <style>.a::content * { background: green }</style>
    <div id="a">
      <content></content>
    </div>
  </:shadow-root>
  <div>Green when #a gets class a.</div>
</host>

R=kochi@chromium.org
BUG=638869

Review-Url: https://codereview.chromium.org/2258793003
Cr-Commit-Position: refs/heads/master@{#414386}
parent beb3a83f
<!DOCTYPE html>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<style>
#stopInherit { color: green }
</style>
<div id="host">
<div id="stopInherit">
<span></span>
<span></span>
<span></span>
<span></span>
<span></span>
</div>
</div>
<script>
test(() => {
var root = host.createShadowRoot();
root.innerHTML = '<div id="shadowDiv"><content></content></div>';
host.offsetTop;
root.querySelector("#shadowDiv").style.color = "red";
assert_true(!!window.internals, "This test only works with --expose-internals-for-testing.");
assert_equals(internals.updateStyleAndReturnAffectedElementCount(), 2, "Inheritance propagation should stop at #stopInherit element.");
}, "Inheritance propagation should not cause full subtree recalcs in flat-tree.");
</script>
......@@ -122,10 +122,17 @@ void InsertionPoint::detachLayoutTree(const AttachContext& context)
void InsertionPoint::willRecalcStyle(StyleRecalcChange change)
{
if (change < IndependentInherit && getStyleChangeType() < SubtreeStyleChange)
StyleChangeType styleChangeType = NoStyleChange;
if (change > Inherit || getStyleChangeType() > LocalStyleChange)
styleChangeType = SubtreeStyleChange;
else if (change > NoInherit)
styleChangeType = LocalStyleChange;
else
return;
for (size_t i = 0; i < m_distributedNodes.size(); ++i)
m_distributedNodes.at(i)->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::create(StyleChangeReason::PropagateInheritChangeToDistributedNodes));
m_distributedNodes.at(i)->setNeedsStyleRecalc(styleChangeType, StyleChangeReasonForTracing::create(StyleChangeReason::PropagateInheritChangeToDistributedNodes));
}
bool InsertionPoint::canBeActive() const
......
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