Commit d72327f2 authored by rune@opera.com's avatar rune@opera.com

Corrected insertion point style recalc.

When crossing an insertion point boundary from style recalc, we mark the
distributed nodes for subtree style recalc. The reason is that the
distributed nodes will have their style recalculated in the context of
where they are distributed from. In the case below, changing class=a on
content will affect the style of class=b. The invalidation starts on
class=a and will not reach class=b in the invalidation traversal.

The bug was that InsertionPoint::willRecalcStyle had an early return
if the parent style change was at least an Inherit, but that is not the
case if the class change does not affect anything at, or above, the
insertion point, like in the case below.

<div>
  <:shadow-root>
    <style>.a::content .b { ... }</style>
    <content class="a"></content>
  </:shadow-root>
  <div class="b"></div>
</div>

R=esprehn@chromium.org,chrishtr@chromium.org
BUG=423293

Review URL: https://codereview.chromium.org/637273003

git-svn-id: svn://svn.chromium.org/blink/trunk@183844 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 88584cdf
<!DOCTYPE html>
<style>
.square { width: 100px; height: 100px; background-color: green; }
</style>
<p>You should see two green squares below.</p>
<div class="square"></div>
<br>
<div class="square"></div>
<!DOCTYPE html>
<style>
.square { width: 100px; height: 100px; }
</style>
<p>You should see two green squares below.</p>
<div id="host1">
<div class="square"></div>
</div>
<br>
<div id="host2">
<div class="square"></div>
</div>
<script>
host1.createShadowRoot().innerHTML = "<style>.c::content .square { background-color: green }</style><content></content>";
host2.createShadowRoot().innerHTML = "<style>.c::content * { background-color: green }</style><content></content>";
document.body.offsetTop; // Force style recalc.
host1.shadowRoot.querySelector("content").className = "c";
host2.shadowRoot.querySelector("content").className = "c";
</script>
......@@ -120,7 +120,7 @@ void InsertionPoint::detach(const AttachContext& context)
void InsertionPoint::willRecalcStyle(StyleRecalcChange change)
{
if (change < Inherit)
if (change < Inherit && styleChangeType() < SubtreeStyleChange)
return;
for (size_t i = 0; i < m_distribution.size(); ++i)
m_distribution.at(i)->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::create(StyleChangeReason::PropagateInheritChangeToDistributedNodes));
......
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