<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[208616] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/208616">208616</a></dd>
<dt>Author</dt> <dd>antti@apple.com</dd>
<dt>Date</dt> <dd>2016-11-11 15:08:34 -0800 (Fri, 11 Nov 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>Updating class name doesn't update the slotted content's style
https://bugs.webkit.org/show_bug.cgi?id=164577
<rdar://problem/29205873>
Reviewed by Ryosuke Niwa.
Source/WebCore:
Test: fast/shadow-dom/css-scoping-slotted-invalidation.html
Teach style invalidation code for attribute/class/id mutations about slotted rules.
* dom/ShadowRoot.cpp:
(WebCore::assignedShadowRootsIfSlotted):
Helper to find all assigned shadow roots (there may be more than one if slots are assigned to slots).
* dom/ShadowRoot.h:
* style/AttributeChangeInvalidation.cpp:
(WebCore::Style::mayBeAffectedByAttributeChange):
(WebCore::Style::mayBeAffectedByHostRules):
(WebCore::Style::mayBeAffectedBySlottedRules):
(WebCore::Style::AttributeChangeInvalidation::invalidateStyle):
(WebCore::Style::mayBeAffectedByHostStyle): Deleted.
* style/ClassChangeInvalidation.cpp:
(WebCore::Style::mayBeAffectedByHostRules):
(WebCore::Style::mayBeAffectedBySlottedRules):
(WebCore::Style::ClassChangeInvalidation::invalidateStyle):
(WebCore::Style::mayBeAffectedByHostStyle): Deleted.
* style/ClassChangeInvalidation.h:
* style/IdChangeInvalidation.cpp:
(WebCore::Style::mayBeAffectedByHostRules):
(WebCore::Style::mayBeAffectedBySlottedRules):
(WebCore::Style::IdChangeInvalidation::invalidateStyle):
(WebCore::Style::mayBeAffectedByHostStyle): Deleted.
* style/StyleSharingResolver.cpp:
(WebCore::Style::SharingResolver::canShareStyleWithElement):
Fix a bug in style sharing where we were checking wrong element for host rules.
Tested by the included test too (the last empty div).
LayoutTests:
* fast/shadow-dom/css-scoping-slotted-invalidation-expected.html: Added.
* fast/shadow-dom/css-scoping-slotted-invalidation.html: Added.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoredomShadowRootcpp">trunk/Source/WebCore/dom/ShadowRoot.cpp</a></li>
<li><a href="#trunkSourceWebCoredomShadowRooth">trunk/Source/WebCore/dom/ShadowRoot.h</a></li>
<li><a href="#trunkSourceWebCorestyleAttributeChangeInvalidationcpp">trunk/Source/WebCore/style/AttributeChangeInvalidation.cpp</a></li>
<li><a href="#trunkSourceWebCorestyleClassChangeInvalidationcpp">trunk/Source/WebCore/style/ClassChangeInvalidation.cpp</a></li>
<li><a href="#trunkSourceWebCorestyleClassChangeInvalidationh">trunk/Source/WebCore/style/ClassChangeInvalidation.h</a></li>
<li><a href="#trunkSourceWebCorestyleIdChangeInvalidationcpp">trunk/Source/WebCore/style/IdChangeInvalidation.cpp</a></li>
<li><a href="#trunkSourceWebCorestyleStyleSharingResolvercpp">trunk/Source/WebCore/style/StyleSharingResolver.cpp</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastshadowdomcssscopingslottedinvalidationexpectedhtml">trunk/LayoutTests/fast/shadow-dom/css-scoping-slotted-invalidation-expected.html</a></li>
<li><a href="#trunkLayoutTestsfastshadowdomcssscopingslottedinvalidationhtml">trunk/LayoutTests/fast/shadow-dom/css-scoping-slotted-invalidation.html</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (208615 => 208616)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-11-11 23:04:55 UTC (rev 208615)
+++ trunk/LayoutTests/ChangeLog        2016-11-11 23:08:34 UTC (rev 208616)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2016-11-11 Antti Koivisto <antti@apple.com>
+
+ Updating class name doesn't update the slotted content's style
+ https://bugs.webkit.org/show_bug.cgi?id=164577
+ <rdar://problem/29205873>
+
+ Reviewed by Ryosuke Niwa.
+
+ * fast/shadow-dom/css-scoping-slotted-invalidation-expected.html: Added.
+ * fast/shadow-dom/css-scoping-slotted-invalidation.html: Added.
+
</ins><span class="cx"> 2016-11-11 Chris Dumez <cdumez@apple.com>
</span><span class="cx">
</span><span class="cx"> WorkerGlobalScope's indexedDB property should be on the prototype, not the instance
</span></span></pre></div>
<a id="trunkLayoutTestsfastshadowdomcssscopingslottedinvalidationexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/shadow-dom/css-scoping-slotted-invalidation-expected.html (0 => 208616)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/shadow-dom/css-scoping-slotted-invalidation-expected.html         (rev 0)
+++ trunk/LayoutTests/fast/shadow-dom/css-scoping-slotted-invalidation-expected.html        2016-11-11 23:08:34 UTC (rev 208616)
</span><span class="lines">@@ -0,0 +1,7 @@
</span><ins>+<!DOCTYPE html>
+<html>
+ <body>
+ <p>Test passes if you see a single 100px by 100px green box below.</p>
+ <div style="width: 100px; height: 100px; background: green;"></div>
+ </body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsfastshadowdomcssscopingslottedinvalidationhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/shadow-dom/css-scoping-slotted-invalidation.html (0 => 208616)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/shadow-dom/css-scoping-slotted-invalidation.html         (rev 0)
+++ trunk/LayoutTests/fast/shadow-dom/css-scoping-slotted-invalidation.html        2016-11-11 23:08:34 UTC (rev 208616)
</span><span class="lines">@@ -0,0 +1,89 @@
</span><ins>+<!DOCTYPE html>
+<body>
+<p>Test passes if you see a single 100px by 100px green box below.</p>
+<div id="t1">
+ <span>FAIL</span>
+</div>
+<div id="t2">
+ <span slot="second-slot">FAIL</span>
+</div>
+<div id="t3">
+ <span>FAIL</span>
+</div>
+<div id="t4">
+ <span>FAIL</span>
+</div>
+<div id="t5">
+ <span selected>FAIL</span>
+</div>
+<div>
+</div>
+<script>
+
+function attachShadow(host, selector)
+{
+ const shadow = host.attachShadow({mode: 'closed'});
+ shadow.innerHTML = `
+ <style>
+ :host {
+ width: 100px;
+ height: 20px;
+ background: green;
+ color: red;
+ }
+ ${selector} {
+ color: green;
+ }
+ </style>
+ <slot></slot>
+ <slot name="second-slot"></slot>`;
+ return shadow;
+}
+
+{
+ const host = document.querySelector('#t1');
+ attachShadow(host, '::slotted(.selected)');
+ const span = host.querySelector('span');
+ getComputedStyle(span).backgroundColor;
+ span.className = 'selected';
+}
+
+{
+ const host = document.querySelector('#t2');
+ attachShadow(host, '[name=second-slot]::slotted(#selected)');
+ const span = host.querySelector('span');
+ getComputedStyle(span).backgroundColor
+ span.id = 'selected';
+}
+
+{
+ const host = document.querySelector('#t3');
+ attachShadow(host, '::slotted([selected])');
+ const span = host.querySelector('span');
+ getComputedStyle(span).backgroundColor;
+ span.setAttribute('selected', 'selected');
+}
+
+{
+ const host = document.querySelector('#t4');
+ const shadow = host.attachShadow({mode: 'closed'});
+ shadow.innerHTML = `<div><slot></slot></div>`;
+ const deepHost = shadow.querySelector('div');
+ attachShadow(deepHost, '::slotted(.selected)');
+ const span = host.querySelector('span');
+ getComputedStyle(span).backgroundColor;
+ span.className = 'selected';
+}
+
+{
+ const host = document.querySelector('#t5');
+ const shadow = host.attachShadow({mode: 'closed'});
+ shadow.innerHTML = `<div><slot slot="second-slot"></slot></div>`;
+ const deepHost = shadow.querySelector('div');
+ attachShadow(deepHost, '[name=second-slot]::slotted(:not([selected]))');
+ const span = host.querySelector('span');
+ getComputedStyle(span).backgroundColor;
+ span.removeAttribute('selected');
+}
+
+</script>
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (208615 => 208616)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-11-11 23:04:55 UTC (rev 208615)
+++ trunk/Source/WebCore/ChangeLog        2016-11-11 23:08:34 UTC (rev 208616)
</span><span class="lines">@@ -1,3 +1,44 @@
</span><ins>+2016-11-11 Antti Koivisto <antti@apple.com>
+
+ Updating class name doesn't update the slotted content's style
+ https://bugs.webkit.org/show_bug.cgi?id=164577
+ <rdar://problem/29205873>
+
+ Reviewed by Ryosuke Niwa.
+
+ Test: fast/shadow-dom/css-scoping-slotted-invalidation.html
+
+ Teach style invalidation code for attribute/class/id mutations about slotted rules.
+
+ * dom/ShadowRoot.cpp:
+ (WebCore::assignedShadowRootsIfSlotted):
+
+ Helper to find all assigned shadow roots (there may be more than one if slots are assigned to slots).
+
+ * dom/ShadowRoot.h:
+ * style/AttributeChangeInvalidation.cpp:
+ (WebCore::Style::mayBeAffectedByAttributeChange):
+ (WebCore::Style::mayBeAffectedByHostRules):
+ (WebCore::Style::mayBeAffectedBySlottedRules):
+ (WebCore::Style::AttributeChangeInvalidation::invalidateStyle):
+ (WebCore::Style::mayBeAffectedByHostStyle): Deleted.
+ * style/ClassChangeInvalidation.cpp:
+ (WebCore::Style::mayBeAffectedByHostRules):
+ (WebCore::Style::mayBeAffectedBySlottedRules):
+ (WebCore::Style::ClassChangeInvalidation::invalidateStyle):
+ (WebCore::Style::mayBeAffectedByHostStyle): Deleted.
+ * style/ClassChangeInvalidation.h:
+ * style/IdChangeInvalidation.cpp:
+ (WebCore::Style::mayBeAffectedByHostRules):
+ (WebCore::Style::mayBeAffectedBySlottedRules):
+ (WebCore::Style::IdChangeInvalidation::invalidateStyle):
+ (WebCore::Style::mayBeAffectedByHostStyle): Deleted.
+ * style/StyleSharingResolver.cpp:
+ (WebCore::Style::SharingResolver::canShareStyleWithElement):
+
+ Fix a bug in style sharing where we were checking wrong element for host rules.
+ Tested by the included test too (the last empty div).
+
</ins><span class="cx"> 2016-11-11 Dave Hyatt <hyatt@apple.com>
</span><span class="cx">
</span><span class="cx"> [CSS Parser] Support the spring animation timing function
</span></span></pre></div>
<a id="trunkSourceWebCoredomShadowRootcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/ShadowRoot.cpp (208615 => 208616)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/ShadowRoot.cpp        2016-11-11 23:04:55 UTC (rev 208615)
+++ trunk/Source/WebCore/dom/ShadowRoot.cpp        2016-11-11 23:08:34 UTC (rev 208616)
</span><span class="lines">@@ -31,6 +31,7 @@
</span><span class="cx"> #include "CSSStyleSheet.h"
</span><span class="cx"> #include "ElementTraversal.h"
</span><span class="cx"> #include "ExceptionCode.h"
</span><ins>+#include "HTMLSlotElement.h"
</ins><span class="cx"> #include "RenderElement.h"
</span><span class="cx"> #include "RuntimeEnabledFeatures.h"
</span><span class="cx"> #include "SlotAssignment.h"
</span><span class="lines">@@ -183,5 +184,14 @@
</span><span class="cx"> return m_slotAssignment->assignedNodesForSlot(slot, *this);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+Vector<ShadowRoot*> assignedShadowRootsIfSlotted(const Node& node)
+{
+ Vector<ShadowRoot*> result;
+ for (auto* slot = node.assignedSlot(); slot; slot = slot->assignedSlot()) {
+ ASSERT(slot->containingShadowRoot());
+ result.append(slot->containingShadowRoot());
+ }
+ return result;
+}
</ins><span class="cx">
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoredomShadowRooth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/ShadowRoot.h (208615 => 208616)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/ShadowRoot.h        2016-11-11 23:04:55 UTC (rev 208615)
+++ trunk/Source/WebCore/dom/ShadowRoot.h        2016-11-11 23:08:34 UTC (rev 208616)
</span><span class="lines">@@ -133,6 +133,8 @@
</span><span class="cx"> return node.parentNode() && node.parentNode()->isShadowRoot();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+Vector<ShadowRoot*> assignedShadowRootsIfSlotted(const Node&);
+
</ins><span class="cx"> } // namespace WebCore
</span><span class="cx">
</span><span class="cx"> SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ShadowRoot)
</span></span></pre></div>
<a id="trunkSourceWebCorestyleAttributeChangeInvalidationcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/style/AttributeChangeInvalidation.cpp (208615 => 208616)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/style/AttributeChangeInvalidation.cpp        2016-11-11 23:04:55 UTC (rev 208615)
+++ trunk/Source/WebCore/style/AttributeChangeInvalidation.cpp        2016-11-11 23:08:34 UTC (rev 208616)
</span><span class="lines">@@ -36,16 +36,36 @@
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> namespace Style {
</span><span class="cx">
</span><del>-static bool mayBeAffectedByHostStyle(ShadowRoot& shadowRoot, bool isHTML, const QualifiedName& attributeName)
</del><ins>+static bool mayBeAffectedByAttributeChange(DocumentRuleSets& ruleSets, bool isHTML, const QualifiedName& attributeName)
</ins><span class="cx"> {
</span><del>- auto& shadowRuleSets = shadowRoot.styleScope().resolver().ruleSets();
</del><ins>+ auto& nameSet = isHTML ? ruleSets.features().attributeCanonicalLocalNamesInRules : ruleSets.features().attributeLocalNamesInRules;
+ return nameSet.contains(attributeName.localName().impl());
+}
+
+static bool mayBeAffectedByHostRules(const Element& element, const QualifiedName& attributeName)
+{
+ auto* shadowRoot = element.shadowRoot();
+ if (!shadowRoot)
+ return false;
+ auto& shadowRuleSets = shadowRoot->styleScope().resolver().ruleSets();
</ins><span class="cx"> if (shadowRuleSets.authorStyle().hostPseudoClassRules().isEmpty())
</span><span class="cx"> return false;
</span><span class="cx">
</span><del>- auto& nameSet = isHTML ? shadowRuleSets.features().attributeCanonicalLocalNamesInRules : shadowRuleSets.features().attributeLocalNamesInRules;
- return nameSet.contains(attributeName.localName().impl());
</del><ins>+ return mayBeAffectedByAttributeChange(shadowRuleSets, element.isHTMLElement(), attributeName);
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+static bool mayBeAffectedBySlottedRules(const Element& element, const QualifiedName& attributeName)
+{
+ for (auto* shadowRoot : assignedShadowRootsIfSlotted(element)) {
+ auto& ruleSets = shadowRoot->styleScope().resolver().ruleSets();
+ if (ruleSets.authorStyle().slottedPseudoElementRules().isEmpty())
+ continue;
+ if (mayBeAffectedByAttributeChange(ruleSets, element.isHTMLElement(), attributeName))
+ return true;
+ }
+ return false;
+}
+
</ins><span class="cx"> void AttributeChangeInvalidation::invalidateStyle(const QualifiedName& attributeName, const AtomicString& oldValue, const AtomicString& newValue)
</span><span class="cx"> {
</span><span class="cx"> if (newValue == oldValue)
</span><span class="lines">@@ -54,13 +74,10 @@
</span><span class="cx"> auto& ruleSets = m_element.styleResolver().ruleSets();
</span><span class="cx"> bool isHTML = m_element.isHTMLElement();
</span><span class="cx">
</span><del>- auto& nameSet = isHTML ? ruleSets.features().attributeCanonicalLocalNamesInRules : ruleSets.features().attributeLocalNamesInRules;
- bool mayAffectStyle = nameSet.contains(attributeName.localName().impl());
</del><ins>+ bool mayAffectStyle = mayBeAffectedByAttributeChange(ruleSets, isHTML, attributeName)
+ || mayBeAffectedByHostRules(m_element, attributeName)
+ || mayBeAffectedBySlottedRules(m_element, attributeName);
</ins><span class="cx">
</span><del>- auto* shadowRoot = m_element.shadowRoot();
- if (!mayAffectStyle && shadowRoot && mayBeAffectedByHostStyle(*shadowRoot, isHTML, attributeName))
- mayAffectStyle = true;
-
</del><span class="cx"> if (!mayAffectStyle)
</span><span class="cx"> return;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorestyleClassChangeInvalidationcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/style/ClassChangeInvalidation.cpp (208615 => 208616)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/style/ClassChangeInvalidation.cpp        2016-11-11 23:04:55 UTC (rev 208615)
+++ trunk/Source/WebCore/style/ClassChangeInvalidation.cpp        2016-11-11 23:08:34 UTC (rev 208616)
</span><span class="lines">@@ -86,14 +86,28 @@
</span><span class="cx"> return changedClasses;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static bool mayBeAffectedByHostStyle(ShadowRoot& shadowRoot, AtomicStringImpl* changedClass)
</del><ins>+static bool mayBeAffectedByHostRules(ShadowRoot* shadowRoot, AtomicStringImpl* changedClass)
</ins><span class="cx"> {
</span><del>- auto& shadowRuleSets = shadowRoot.styleScope().resolver().ruleSets();
</del><ins>+ if (!shadowRoot)
+ return false;
+ auto& shadowRuleSets = shadowRoot->styleScope().resolver().ruleSets();
</ins><span class="cx"> if (shadowRuleSets.authorStyle().hostPseudoClassRules().isEmpty())
</span><span class="cx"> return false;
</span><span class="cx"> return shadowRuleSets.features().classesInRules.contains(changedClass);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+static bool mayBeAffectedBySlottedRules(const Vector<ShadowRoot*>& assignedShadowRoots, AtomicStringImpl* changedClass)
+{
+ for (auto& assignedShadowRoot : assignedShadowRoots) {
+ auto& ruleSets = assignedShadowRoot->styleScope().resolver().ruleSets();
+ if (ruleSets.authorStyle().slottedPseudoElementRules().isEmpty())
+ continue;
+ if (ruleSets.features().classesInRules.contains(changedClass))
+ return true;
+ }
+ return false;
+}
+
</ins><span class="cx"> void ClassChangeInvalidation::invalidateStyle(const SpaceSplitString& oldClasses, const SpaceSplitString& newClasses)
</span><span class="cx"> {
</span><span class="cx"> auto changedClasses = computeClassChange(oldClasses, newClasses);
</span><span class="lines">@@ -100,14 +114,13 @@
</span><span class="cx">
</span><span class="cx"> auto& ruleSets = m_element.styleResolver().ruleSets();
</span><span class="cx"> auto* shadowRoot = m_element.shadowRoot();
</span><ins>+ auto assignedShadowRoots = assignedShadowRootsIfSlotted(m_element);
</ins><span class="cx">
</span><span class="cx"> ClassChangeVector changedClassesAffectingStyle;
</span><span class="cx"> for (auto* changedClass : changedClasses) {
</span><del>- bool mayAffectStyle = ruleSets.features().classesInRules.contains(changedClass);
-
- if (!mayAffectStyle && shadowRoot && mayBeAffectedByHostStyle(*shadowRoot, changedClass))
- mayAffectStyle = true;
-
</del><ins>+ bool mayAffectStyle = ruleSets.features().classesInRules.contains(changedClass)
+ || mayBeAffectedByHostRules(shadowRoot, changedClass)
+ || mayBeAffectedBySlottedRules(assignedShadowRoots, changedClass);
</ins><span class="cx"> if (mayAffectStyle)
</span><span class="cx"> changedClassesAffectingStyle.append(changedClass);
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebCorestyleClassChangeInvalidationh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/style/ClassChangeInvalidation.h (208615 => 208616)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/style/ClassChangeInvalidation.h        2016-11-11 23:04:55 UTC (rev 208615)
+++ trunk/Source/WebCore/style/ClassChangeInvalidation.h        2016-11-11 23:08:34 UTC (rev 208616)
</span><span class="lines">@@ -69,7 +69,7 @@
</span><span class="cx"> return;
</span><span class="cx"> invalidateDescendantStyle();
</span><span class="cx"> }
</span><del>-
</del><ins>+
</ins><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorestyleIdChangeInvalidationcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/style/IdChangeInvalidation.cpp (208615 => 208616)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/style/IdChangeInvalidation.cpp        2016-11-11 23:04:55 UTC (rev 208615)
+++ trunk/Source/WebCore/style/IdChangeInvalidation.cpp        2016-11-11 23:08:34 UTC (rev 208616)
</span><span class="lines">@@ -35,15 +35,29 @@
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> namespace Style {
</span><span class="cx">
</span><del>-static bool mayBeAffectedByHostStyle(ShadowRoot& shadowRoot, const AtomicString& changedId)
</del><ins>+static bool mayBeAffectedByHostRules(const Element& element, const AtomicString& changedId)
</ins><span class="cx"> {
</span><del>- auto& shadowRuleSets = shadowRoot.styleScope().resolver().ruleSets();
</del><ins>+ auto* shadowRoot = element.shadowRoot();
+ if (!shadowRoot)
+ return false;
+ auto& shadowRuleSets = shadowRoot->styleScope().resolver().ruleSets();
</ins><span class="cx"> if (shadowRuleSets.authorStyle().hostPseudoClassRules().isEmpty())
</span><span class="cx"> return false;
</span><del>-
</del><span class="cx"> return shadowRuleSets.features().idsInRules.contains(changedId.impl());
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+static bool mayBeAffectedBySlottedRules(const Element& element, const AtomicString& changedId)
+{
+ for (auto* shadowRoot : assignedShadowRootsIfSlotted(element)) {
+ auto& ruleSets = shadowRoot->styleScope().resolver().ruleSets();
+ if (ruleSets.authorStyle().slottedPseudoElementRules().isEmpty())
+ continue;
+ if (ruleSets.features().idsInRules.contains(changedId.impl()))
+ return true;
+ }
+ return false;
+}
+
</ins><span class="cx"> void IdChangeInvalidation::invalidateStyle(const AtomicString& changedId)
</span><span class="cx"> {
</span><span class="cx"> if (changedId.isEmpty())
</span><span class="lines">@@ -51,12 +65,10 @@
</span><span class="cx">
</span><span class="cx"> auto& ruleSets = m_element.styleResolver().ruleSets();
</span><span class="cx">
</span><del>- bool mayAffectStyle = ruleSets.features().idsInRules.contains(changedId.impl());
</del><ins>+ bool mayAffectStyle = ruleSets.features().idsInRules.contains(changedId.impl())
+ || mayBeAffectedByHostRules(m_element, changedId)
+ || mayBeAffectedBySlottedRules(m_element, changedId);
</ins><span class="cx">
</span><del>- auto* shadowRoot = m_element.shadowRoot();
- if (!mayAffectStyle && shadowRoot && mayBeAffectedByHostStyle(*shadowRoot, changedId))
- mayAffectStyle = true;
-
</del><span class="cx"> if (!mayAffectStyle)
</span><span class="cx"> return;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorestyleStyleSharingResolvercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/style/StyleSharingResolver.cpp (208615 => 208616)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/style/StyleSharingResolver.cpp        2016-11-11 23:04:55 UTC (rev 208615)
+++ trunk/Source/WebCore/style/StyleSharingResolver.cpp        2016-11-11 23:08:34 UTC (rev 208616)
</span><span class="lines">@@ -288,7 +288,7 @@
</span><span class="cx"> if (candidateElement.matchesDefaultPseudoClass() != element.matchesDefaultPseudoClass())
</span><span class="cx"> return false;
</span><span class="cx">
</span><del>- if (element.shadowRoot() && !element.shadowRoot()->styleScope().resolver().ruleSets().authorStyle().hostPseudoClassRules().isEmpty())
</del><ins>+ if (candidateElement.shadowRoot() && !candidateElement.shadowRoot()->styleScope().resolver().ruleSets().authorStyle().hostPseudoClassRules().isEmpty())
</ins><span class="cx"> return false;
</span><span class="cx">
</span><span class="cx"> #if ENABLE(FULLSCREEN_API)
</span></span></pre>
</div>
</div>
</body>
</html>