<!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>[206880] 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/206880">206880</a></dd>
<dt>Author</dt> <dd>antti@apple.com</dd>
<dt>Date</dt> <dd>2016-10-06 13:53:08 -0700 (Thu, 06 Oct 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Mutating styleSheet in shadow tree doesn't update the style
https://bugs.webkit.org/show_bug.cgi?id=162744
&lt;rdar://problem/28550588&gt;

Reviewed by Ryosuke Niwa.

Source/WebCore:

We weren't always invalidating the right AuthorStyleSheets (to be renamed) instance
for the scope after mutations.

Test: fast/shadow-dom/mutating-stylesheet-in-shadow-tree.html

* css/CSSStyleSheet.cpp:
(WebCore::CSSStyleSheet::didMutateRules):
(WebCore::CSSStyleSheet::didMutate):
(WebCore::CSSStyleSheet::clearOwnerNode):
(WebCore::CSSStyleSheet::rootStyleSheet):
(WebCore::CSSStyleSheet::ownerDocument):
(WebCore::CSSStyleSheet::styleSheetScope):

    Invalidate the right scope after stylesheet mutations.

* css/CSSStyleSheet.h:
* dom/AuthorStyleSheets.cpp:
(WebCore::AuthorStyleSheets::styleResolver):
(WebCore::AuthorStyleSheets::styleResolverIfExists):

    Take care to update the right style resolver.

(WebCore::AuthorStyleSheets::forNode):
(WebCore::AuthorStyleSheets::removeStyleSheetCandidateNode):

    Start the update timer so clients don't need to request update separately.

(WebCore::AuthorStyleSheets::analyzeStyleSheetChange):
(WebCore::AuthorStyleSheets::updateActiveStyleSheets):
(WebCore::AuthorStyleSheets::updateStyleResolver):
* dom/AuthorStyleSheets.h:
* dom/InlineStyleSheetOwner.cpp:
(WebCore::InlineStyleSheetOwner::insertedIntoDocument):

    Save the scope we were inserted into so removals can be done reliably.

(WebCore::InlineStyleSheetOwner::removedFromDocument):

    Use and clear the saved scope.
    Remove didChangeCandidatesForActiveSet() as it is now done by removeStyleSheetCandidateNode() call.

(WebCore::InlineStyleSheetOwner::clearDocumentData):
(WebCore::InlineStyleSheetOwner::createSheet):
(WebCore::InlineStyleSheetOwner::sheetLoaded):
(WebCore::InlineStyleSheetOwner::startLoadingDynamicSheet):
(WebCore::authorStyleSheetsForElement): Deleted.
* dom/InlineStyleSheetOwner.h:
(WebCore::InlineStyleSheetOwner::styleSheetScope):
* dom/ShadowRoot.cpp:
(WebCore::ShadowRoot::styleResolverIfExists):
* dom/ShadowRoot.h:
* html/HTMLLinkElement.cpp:
(WebCore::HTMLLinkElement::removedFrom):

    Remove didChangeCandidatesForActiveSet() as it is now done by removeStyleSheetCandidateNode() call.

* html/HTMLStyleElement.cpp:
(WebCore::HTMLStyleElement::~HTMLStyleElement):
(WebCore::HTMLStyleElement::parseAttribute):

    Fix a bug where we wouldn't create stylesheet if a style element was activated by removing a media attribute.

(WebCore::HTMLStyleElement::insertedInto):
(WebCore::HTMLStyleElement::removedFrom):
* page/DOMWindow.cpp:
(WebCore::DOMWindow::getMatchedCSSRules):
* svg/SVGStyleElement.cpp:
(WebCore::SVGStyleElement::~SVGStyleElement):
(WebCore::SVGStyleElement::insertedInto):
(WebCore::SVGStyleElement::removedFrom):

LayoutTests:

* fast/shadow-dom/mutating-stylesheet-in-shadow-tree-expected.html: Added.
* fast/shadow-dom/mutating-stylesheet-in-shadow-tree.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="#trunkSourceWebCorecssCSSStyleSheetcpp">trunk/Source/WebCore/css/CSSStyleSheet.cpp</a></li>
<li><a href="#trunkSourceWebCorecssCSSStyleSheeth">trunk/Source/WebCore/css/CSSStyleSheet.h</a></li>
<li><a href="#trunkSourceWebCoredomAuthorStyleSheetscpp">trunk/Source/WebCore/dom/AuthorStyleSheets.cpp</a></li>
<li><a href="#trunkSourceWebCoredomAuthorStyleSheetsh">trunk/Source/WebCore/dom/AuthorStyleSheets.h</a></li>
<li><a href="#trunkSourceWebCoredomInlineStyleSheetOwnercpp">trunk/Source/WebCore/dom/InlineStyleSheetOwner.cpp</a></li>
<li><a href="#trunkSourceWebCoredomInlineStyleSheetOwnerh">trunk/Source/WebCore/dom/InlineStyleSheetOwner.h</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="#trunkSourceWebCorehtmlHTMLLinkElementcpp">trunk/Source/WebCore/html/HTMLLinkElement.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLStyleElementcpp">trunk/Source/WebCore/html/HTMLStyleElement.cpp</a></li>
<li><a href="#trunkSourceWebCorepageDOMWindowcpp">trunk/Source/WebCore/page/DOMWindow.cpp</a></li>
<li><a href="#trunkSourceWebCoresvgSVGStyleElementcpp">trunk/Source/WebCore/svg/SVGStyleElement.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastshadowdommutatingstylesheetinshadowtreeexpectedhtml">trunk/LayoutTests/fast/shadow-dom/mutating-stylesheet-in-shadow-tree-expected.html</a></li>
<li><a href="#trunkLayoutTestsfastshadowdommutatingstylesheetinshadowtreehtml">trunk/LayoutTests/fast/shadow-dom/mutating-stylesheet-in-shadow-tree.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (206879 => 206880)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-10-06 20:47:44 UTC (rev 206879)
+++ trunk/LayoutTests/ChangeLog        2016-10-06 20:53:08 UTC (rev 206880)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2016-10-06  Antti Koivisto  &lt;antti@apple.com&gt;
+
+        Mutating styleSheet in shadow tree doesn't update the style
+        https://bugs.webkit.org/show_bug.cgi?id=162744
+        &lt;rdar://problem/28550588&gt;
+
+        Reviewed by Ryosuke Niwa.
+
+        * fast/shadow-dom/mutating-stylesheet-in-shadow-tree-expected.html: Added.
+        * fast/shadow-dom/mutating-stylesheet-in-shadow-tree.html: Added.
+
</ins><span class="cx"> 2016-10-06  Adam Bergkvist  &lt;adam.bergkvist@ericsson.com&gt;
</span><span class="cx"> 
</span><span class="cx">         WebRTC: Add support for the iceconnectionstatechange event in MediaEndpointPeerConnection
</span></span></pre></div>
<a id="trunkLayoutTestsfastshadowdommutatingstylesheetinshadowtreeexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/shadow-dom/mutating-stylesheet-in-shadow-tree-expected.html (0 => 206880)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/shadow-dom/mutating-stylesheet-in-shadow-tree-expected.html                                (rev 0)
+++ trunk/LayoutTests/fast/shadow-dom/mutating-stylesheet-in-shadow-tree-expected.html        2016-10-06 20:53:08 UTC (rev 206880)
</span><span class="lines">@@ -0,0 +1,7 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;body&gt;
+    &lt;p&gt;Test passes if you see a single 100px by 100px green box below.&lt;/p&gt;
+    &lt;div style=&quot;width: 100px; height: 100px; background: green;&quot;&gt;&lt;/div&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastshadowdommutatingstylesheetinshadowtreehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/shadow-dom/mutating-stylesheet-in-shadow-tree.html (0 => 206880)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/shadow-dom/mutating-stylesheet-in-shadow-tree.html                                (rev 0)
+++ trunk/LayoutTests/fast/shadow-dom/mutating-stylesheet-in-shadow-tree.html        2016-10-06 20:53:08 UTC (rev 206880)
</span><span class="lines">@@ -0,0 +1,57 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;body&gt;
+&lt;p&gt;Test passes if you see a single 100px by 100px green box below.&lt;/p&gt;
+&lt;style&gt;
+
+div {
+    width: 100px;
+    height: 25px;
+    background: red;
+}
+
+&lt;/style&gt;
+&lt;script&gt;
+
+function appendShadowHost(container, template, callback) {
+    var host = document.createElement('div');
+    container.appendChild(host);
+    var shadow = host.attachShadow({mode: 'closed'});
+    shadow.innerHTML = template;
+    callback(shadow);
+    return host;
+}
+
+appendShadowHost(document.body, `
+    &lt;style&gt;&lt;/style&gt;
+    &lt;div&gt;FAIL&lt;/div&gt;
+`, function (shadow) {
+    var style = shadow.querySelector('style');
+    style.sheet.insertRule('div { width: 100%; height: 100%; background: green; color: green; }', 0);    
+});
+appendShadowHost(document.body, `
+    &lt;style media=&quot;aural&quot;&gt; div { width: 100%; height: 100%; color: green; background: green; } &lt;/style&gt;
+    &lt;div&gt;FAIL&lt;/div&gt;
+`, function (shadow) {
+    var style = shadow.querySelector('style');
+    style.removeAttribute('media');
+});
+appendShadowHost(document.body, `
+    &lt;style&gt; div { width: 100%; height: 100%; color: green; background: green; } &lt;/style&gt;
+    &lt;style&gt; div { color: black; background: red; } &lt;/style&gt;
+    &lt;div&gt;FAIL&lt;/div&gt;
+`, function (shadow) {
+    var style = shadow.querySelectorAll('style')[1];
+    style.disabled = true;
+});
+appendShadowHost(document.body, `
+    &lt;style&gt; div { width: 100%; height: 100%; color: green; background: green; } &lt;/style&gt;
+    &lt;style&gt; div { color: black; background: red; } &lt;/style&gt;
+    &lt;div&gt;FAIL&lt;/div&gt;
+`, function (shadow) {
+    shadow.querySelectorAll('style')[1].remove();
+});
+
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (206879 => 206880)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-10-06 20:47:44 UTC (rev 206879)
+++ trunk/Source/WebCore/ChangeLog        2016-10-06 20:53:08 UTC (rev 206880)
</span><span class="lines">@@ -1,3 +1,82 @@
</span><ins>+2016-10-06  Antti Koivisto  &lt;antti@apple.com&gt;
+
+        Mutating styleSheet in shadow tree doesn't update the style
+        https://bugs.webkit.org/show_bug.cgi?id=162744
+        &lt;rdar://problem/28550588&gt;
+
+        Reviewed by Ryosuke Niwa.
+
+        We weren't always invalidating the right AuthorStyleSheets (to be renamed) instance
+        for the scope after mutations.
+
+        Test: fast/shadow-dom/mutating-stylesheet-in-shadow-tree.html
+
+        * css/CSSStyleSheet.cpp:
+        (WebCore::CSSStyleSheet::didMutateRules):
+        (WebCore::CSSStyleSheet::didMutate):
+        (WebCore::CSSStyleSheet::clearOwnerNode):
+        (WebCore::CSSStyleSheet::rootStyleSheet):
+        (WebCore::CSSStyleSheet::ownerDocument):
+        (WebCore::CSSStyleSheet::styleSheetScope):
+
+            Invalidate the right scope after stylesheet mutations.
+
+        * css/CSSStyleSheet.h:
+        * dom/AuthorStyleSheets.cpp:
+        (WebCore::AuthorStyleSheets::styleResolver):
+        (WebCore::AuthorStyleSheets::styleResolverIfExists):
+
+            Take care to update the right style resolver.
+
+        (WebCore::AuthorStyleSheets::forNode):
+        (WebCore::AuthorStyleSheets::removeStyleSheetCandidateNode):
+
+            Start the update timer so clients don't need to request update separately.
+
+        (WebCore::AuthorStyleSheets::analyzeStyleSheetChange):
+        (WebCore::AuthorStyleSheets::updateActiveStyleSheets):
+        (WebCore::AuthorStyleSheets::updateStyleResolver):
+        * dom/AuthorStyleSheets.h:
+        * dom/InlineStyleSheetOwner.cpp:
+        (WebCore::InlineStyleSheetOwner::insertedIntoDocument):
+
+            Save the scope we were inserted into so removals can be done reliably.
+
+        (WebCore::InlineStyleSheetOwner::removedFromDocument):
+
+            Use and clear the saved scope.
+            Remove didChangeCandidatesForActiveSet() as it is now done by removeStyleSheetCandidateNode() call.
+
+        (WebCore::InlineStyleSheetOwner::clearDocumentData):
+        (WebCore::InlineStyleSheetOwner::createSheet):
+        (WebCore::InlineStyleSheetOwner::sheetLoaded):
+        (WebCore::InlineStyleSheetOwner::startLoadingDynamicSheet):
+        (WebCore::authorStyleSheetsForElement): Deleted.
+        * dom/InlineStyleSheetOwner.h:
+        (WebCore::InlineStyleSheetOwner::styleSheetScope):
+        * dom/ShadowRoot.cpp:
+        (WebCore::ShadowRoot::styleResolverIfExists):
+        * dom/ShadowRoot.h:
+        * html/HTMLLinkElement.cpp:
+        (WebCore::HTMLLinkElement::removedFrom):
+
+            Remove didChangeCandidatesForActiveSet() as it is now done by removeStyleSheetCandidateNode() call.
+
+        * html/HTMLStyleElement.cpp:
+        (WebCore::HTMLStyleElement::~HTMLStyleElement):
+        (WebCore::HTMLStyleElement::parseAttribute):
+
+            Fix a bug where we wouldn't create stylesheet if a style element was activated by removing a media attribute.
+
+        (WebCore::HTMLStyleElement::insertedInto):
+        (WebCore::HTMLStyleElement::removedFrom):
+        * page/DOMWindow.cpp:
+        (WebCore::DOMWindow::getMatchedCSSRules):
+        * svg/SVGStyleElement.cpp:
+        (WebCore::SVGStyleElement::~SVGStyleElement):
+        (WebCore::SVGStyleElement::insertedInto):
+        (WebCore::SVGStyleElement::removedFrom):
+
</ins><span class="cx"> 2016-10-06  Alex Christensen  &lt;achristensen@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Skip tabs and newlines between end of query and beginning of fragment in non-UTF-8-encoded URLs
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSStyleSheetcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSStyleSheet.cpp (206879 => 206880)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSStyleSheet.cpp        2016-10-06 20:47:44 UTC (rev 206879)
+++ trunk/Source/WebCore/css/CSSStyleSheet.cpp        2016-10-06 20:53:08 UTC (rev 206880)
</span><span class="lines">@@ -41,6 +41,7 @@
</span><span class="cx"> #include &quot;SVGNames.h&quot;
</span><span class="cx"> #include &quot;SVGStyleElement.h&quot;
</span><span class="cx"> #include &quot;SecurityOrigin.h&quot;
</span><ins>+#include &quot;ShadowRoot.h&quot;
</ins><span class="cx"> #include &quot;StyleResolver.h&quot;
</span><span class="cx"> #include &quot;StyleRule.h&quot;
</span><span class="cx"> #include &quot;StyleSheetContents.h&quot;
</span><span class="lines">@@ -169,21 +170,21 @@
</span><span class="cx">     ASSERT(m_contents-&gt;isMutable());
</span><span class="cx">     ASSERT(m_contents-&gt;hasOneClient());
</span><span class="cx"> 
</span><del>-    Document* owner = ownerDocument();
-    if (!owner)
</del><ins>+    auto* scope = styleSheetScope();
+    if (!scope)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    if (mutationType == RuleInsertion &amp;&amp; !contentsWereClonedForMutation &amp;&amp; !owner-&gt;authorStyleSheets().activeStyleSheetsContains(this)) {
</del><ins>+    if (mutationType == RuleInsertion &amp;&amp; !contentsWereClonedForMutation &amp;&amp; !scope-&gt;activeStyleSheetsContains(this)) {
</ins><span class="cx">         if (insertedKeyframesRule) {
</span><del>-            if (StyleResolver* resolver = owner-&gt;styleResolverIfExists())
</del><ins>+            if (auto* resolver = scope-&gt;styleResolverIfExists())
</ins><span class="cx">                 resolver-&gt;addKeyframeStyle(*insertedKeyframesRule);
</span><span class="cx">             return;
</span><span class="cx">         }
</span><del>-        owner-&gt;authorStyleSheets().scheduleActiveSetUpdate();
</del><ins>+        scope-&gt;scheduleActiveSetUpdate();
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    owner-&gt;authorStyleSheets().didChangeContentsOrInterpretation();
</del><ins>+    scope-&gt;didChangeContentsOrInterpretation();
</ins><span class="cx"> 
</span><span class="cx">     m_mutatedRules = true;
</span><span class="cx"> }
</span><span class="lines">@@ -190,19 +191,15 @@
</span><span class="cx"> 
</span><span class="cx"> void CSSStyleSheet::didMutate()
</span><span class="cx"> {
</span><del>-    Document* owner = ownerDocument();
-    if (!owner)
</del><ins>+    auto* scope = styleSheetScope();
+    if (!scope)
</ins><span class="cx">         return;
</span><del>-    owner-&gt;authorStyleSheets().didChangeContentsOrInterpretation();
</del><ins>+    scope-&gt;didChangeContentsOrInterpretation();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void CSSStyleSheet::clearOwnerNode()
</span><span class="cx"> {
</span><del>-    Document* owner = ownerDocument();
-    m_ownerNode = 0;
-    if (!owner)
-        return;
-    owner-&gt;authorStyleSheets().didChangeCandidatesForActiveSet();
</del><ins>+    m_ownerNode = nullptr;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void CSSStyleSheet::reattachChildRuleCSSOMWrappers()
</span><span class="lines">@@ -399,14 +396,33 @@
</span><span class="cx">     return m_ownerRule ? m_ownerRule-&gt;parentStyleSheet() : nullptr;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-Document* CSSStyleSheet::ownerDocument() const
</del><ins>+CSSStyleSheet&amp; CSSStyleSheet::rootStyleSheet()
</ins><span class="cx"> {
</span><del>-    const CSSStyleSheet* root = this;
</del><ins>+    auto* root = this;
</ins><span class="cx">     while (root-&gt;parentStyleSheet())
</span><span class="cx">         root = root-&gt;parentStyleSheet();
</span><del>-    return root-&gt;ownerNode() ? &amp;root-&gt;ownerNode()-&gt;document() : nullptr;
</del><ins>+    return *root;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+const CSSStyleSheet&amp; CSSStyleSheet::rootStyleSheet() const
+{
+    return const_cast&lt;CSSStyleSheet&amp;&gt;(*this).rootStyleSheet();
+}
+
+Document* CSSStyleSheet::ownerDocument() const
+{
+    auto&amp; root = rootStyleSheet();
+    return root.ownerNode() ? &amp;root.ownerNode()-&gt;document() : nullptr;
+}
+
+AuthorStyleSheets* CSSStyleSheet::styleSheetScope()
+{
+    auto* ownerNode = rootStyleSheet().ownerNode();
+    if (!ownerNode)
+        return nullptr;
+    return &amp;AuthorStyleSheets::forNode(*ownerNode);
+}
+
</ins><span class="cx"> void CSSStyleSheet::clearChildRuleCSSOMWrappers()
</span><span class="cx"> {
</span><span class="cx">     m_childRuleCSSOMWrappers.clear();
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSStyleSheeth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSStyleSheet.h (206879 => 206880)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSStyleSheet.h        2016-10-06 20:47:44 UTC (rev 206879)
+++ trunk/Source/WebCore/css/CSSStyleSheet.h        2016-10-06 20:53:08 UTC (rev 206880)
</span><span class="lines">@@ -31,6 +31,7 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><ins>+class AuthorStyleSheets;
</ins><span class="cx"> class CSSCharsetRule;
</span><span class="cx"> class CSSImportRule;
</span><span class="cx"> class CSSParser;
</span><span class="lines">@@ -82,7 +83,12 @@
</span><span class="cx">     bool isLoading() const final;
</span><span class="cx">     
</span><span class="cx">     void clearOwnerRule() { m_ownerRule = 0; }
</span><ins>+
</ins><span class="cx">     Document* ownerDocument() const;
</span><ins>+    CSSStyleSheet&amp; rootStyleSheet();
+    const CSSStyleSheet&amp; rootStyleSheet() const;
+    AuthorStyleSheets* styleSheetScope();
+
</ins><span class="cx">     MediaQuerySet* mediaQueries() const { return m_mediaQueries.get(); }
</span><span class="cx">     void setMediaQueries(Ref&lt;MediaQuerySet&gt;&amp;&amp;);
</span><span class="cx">     void setTitle(const String&amp; title) { m_title = title; }
</span></span></pre></div>
<a id="trunkSourceWebCoredomAuthorStyleSheetscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/AuthorStyleSheets.cpp (206879 => 206880)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/AuthorStyleSheets.cpp        2016-10-06 20:47:44 UTC (rev 206879)
+++ trunk/Source/WebCore/dom/AuthorStyleSheets.cpp        2016-10-06 20:53:08 UTC (rev 206880)
</span><span class="lines">@@ -69,6 +69,31 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+StyleResolver&amp; AuthorStyleSheets::styleResolver()
+{
+    if (m_shadowRoot)
+        return m_shadowRoot-&gt;styleResolver();
+
+    return m_document.ensureStyleResolver();
+}
+
+StyleResolver* AuthorStyleSheets::styleResolverIfExists()
+{
+    if (m_shadowRoot)
+        return m_shadowRoot-&gt;styleResolverIfExists();
+
+    return m_document.styleResolverIfExists();
+}
+
+AuthorStyleSheets&amp; AuthorStyleSheets::forNode(Node&amp; node)
+{
+    ASSERT(node.inDocument());
+    auto* shadowRoot = node.containingShadowRoot();
+    if (shadowRoot)
+        return shadowRoot-&gt;authorStyleSheets();
+    return node.document().authorStyleSheets();
+}
+
</ins><span class="cx"> // This method is called whenever a top-level stylesheet has finished loading.
</span><span class="cx"> void AuthorStyleSheets::removePendingSheet(RemovePendingSheetNotificationType notification)
</span><span class="cx"> {
</span><span class="lines">@@ -133,7 +158,8 @@
</span><span class="cx"> 
</span><span class="cx"> void AuthorStyleSheets::removeStyleSheetCandidateNode(Node&amp; node)
</span><span class="cx"> {
</span><del>-    m_styleSheetCandidateNodes.remove(&amp;node);
</del><ins>+    if (m_styleSheetCandidateNodes.remove(&amp;node))
+        scheduleActiveSetUpdate();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void AuthorStyleSheets::collectActiveStyleSheets(Vector&lt;RefPtr&lt;StyleSheet&gt;&gt;&amp; sheets)
</span><span class="lines">@@ -220,10 +246,10 @@
</span><span class="cx">     
</span><span class="cx">     unsigned newStylesheetCount = newStylesheets.size();
</span><span class="cx"> 
</span><del>-    if (!m_document.styleResolverIfExists())
</del><ins>+    if (!styleResolverIfExists())
</ins><span class="cx">         return Reconstruct;
</span><span class="cx"> 
</span><del>-    StyleResolver&amp; styleResolver = *m_document.styleResolverIfExists();
</del><ins>+    StyleResolver&amp; styleResolver = *styleResolverIfExists();
</ins><span class="cx"> 
</span><span class="cx">     // Find out which stylesheets are new.
</span><span class="cx">     unsigned oldStylesheetCount = m_activeStyleSheets.size();
</span><span class="lines">@@ -306,6 +332,10 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    // FIXME: Support optimized invalidation in shadow trees.
+    if (m_shadowRoot)
+        updateType = UpdateType::ContentsOrInterpretation;
+
</ins><span class="cx">     m_didUpdateActiveStyleSheets = true;
</span><span class="cx"> 
</span><span class="cx">     Vector&lt;RefPtr&lt;StyleSheet&gt;&gt; activeStyleSheets;
</span><span class="lines">@@ -352,8 +382,7 @@
</span><span class="cx">             m_document.clearStyleResolver();
</span><span class="cx">         return;
</span><span class="cx">     }
</span><del>-    auto&amp; styleResolver = m_document.ensureStyleResolver();
-    auto&amp; userAgentShadowTreeStyleResolver = m_document.userAgentShadowTreeStyleResolver();
</del><ins>+    auto&amp; styleResolver = this-&gt;styleResolver();
</ins><span class="cx"> 
</span><span class="cx">     if (updateType == Reset) {
</span><span class="cx">         styleResolver.ruleSets().resetAuthorStyle();
</span><span class="lines">@@ -366,10 +395,13 @@
</span><span class="cx">         styleResolver.appendAuthorStyleSheets(newStyleSheets);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    userAgentShadowTreeStyleResolver.ruleSets().resetAuthorStyle();
-    auto&amp; authorRuleSet = styleResolver.ruleSets().authorStyle();
-    if (authorRuleSet.hasShadowPseudoElementRules())
-        userAgentShadowTreeStyleResolver.ruleSets().authorStyle().copyShadowPseudoElementRulesFrom(authorRuleSet);
</del><ins>+    if (!m_shadowRoot) {
+        auto&amp; userAgentShadowTreeStyleResolver = m_document.userAgentShadowTreeStyleResolver();
+        userAgentShadowTreeStyleResolver.ruleSets().resetAuthorStyle();
+        auto&amp; authorRuleSet = styleResolver.ruleSets().authorStyle();
+        if (authorRuleSet.hasShadowPseudoElementRules())
+            userAgentShadowTreeStyleResolver.ruleSets().authorStyle().copyShadowPseudoElementRulesFrom(authorRuleSet);
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> const Vector&lt;RefPtr&lt;CSSStyleSheet&gt;&gt; AuthorStyleSheets::activeStyleSheetsForInspector() const
</span><span class="lines">@@ -422,6 +454,11 @@
</span><span class="cx"> 
</span><span class="cx"> void AuthorStyleSheets::scheduleActiveSetUpdate()
</span><span class="cx"> {
</span><ins>+    if (m_shadowRoot) {
+        // FIXME: We need to flush updates recursively to support asynchronous updates in shadow trees.
+        didChangeCandidatesForActiveSet();
+        return;
+    }
</ins><span class="cx">     if (m_pendingUpdateTimer.isActive())
</span><span class="cx">         return;
</span><span class="cx">     if (!m_pendingUpdateType)
</span></span></pre></div>
<a id="trunkSourceWebCoredomAuthorStyleSheetsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/AuthorStyleSheets.h (206879 => 206880)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/AuthorStyleSheets.h        2016-10-06 20:47:44 UTC (rev 206879)
+++ trunk/Source/WebCore/dom/AuthorStyleSheets.h        2016-10-06 20:53:08 UTC (rev 206880)
</span><span class="lines">@@ -42,6 +42,7 @@
</span><span class="cx"> class CSSStyleSheet;
</span><span class="cx"> class Document;
</span><span class="cx"> class Node;
</span><ins>+class StyleResolver;
</ins><span class="cx"> class StyleSheet;
</span><span class="cx"> class StyleSheetContents;
</span><span class="cx"> class StyleSheetList;
</span><span class="lines">@@ -87,6 +88,11 @@
</span><span class="cx">     bool hasPendingUpdate() const { return !!m_pendingUpdateType; }
</span><span class="cx">     void flushPendingUpdate();
</span><span class="cx"> 
</span><ins>+    StyleResolver&amp; styleResolver();
+    StyleResolver* styleResolverIfExists();
+
+    static AuthorStyleSheets&amp; forNode(Node&amp;);
+
</ins><span class="cx"> private:
</span><span class="cx">     enum class UpdateType { ActiveSet, ContentsOrInterpretation };
</span><span class="cx">     void updateActiveStyleSheets(UpdateType);
</span></span></pre></div>
<a id="trunkSourceWebCoredomInlineStyleSheetOwnercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/InlineStyleSheetOwner.cpp (206879 => 206880)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/InlineStyleSheetOwner.cpp        2016-10-06 20:47:44 UTC (rev 206879)
+++ trunk/Source/WebCore/dom/InlineStyleSheetOwner.cpp        2016-10-06 20:53:08 UTC (rev 206880)
</span><span class="lines">@@ -49,41 +49,35 @@
</span><span class="cx">         clearSheet();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static AuthorStyleSheets&amp; authorStyleSheetsForElement(Element&amp; element)
</del><ins>+void InlineStyleSheetOwner::insertedIntoDocument(Element&amp; element)
</ins><span class="cx"> {
</span><del>-    auto* shadowRoot = element.containingShadowRoot();
-    return shadowRoot ? shadowRoot-&gt;authorStyleSheets() : element.document().authorStyleSheets();
-}
</del><ins>+    m_styleSheetScope = &amp;AuthorStyleSheets::forNode(element);
+    m_styleSheetScope-&gt;addStyleSheetCandidateNode(element, m_isParsingChildren);
</ins><span class="cx"> 
</span><del>-void InlineStyleSheetOwner::insertedIntoDocument(Document&amp;, Element&amp; element)
-{
-    authorStyleSheetsForElement(element).addStyleSheetCandidateNode(element, m_isParsingChildren);
-
</del><span class="cx">     if (m_isParsingChildren)
</span><span class="cx">         return;
</span><span class="cx">     createSheetFromTextContents(element);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void InlineStyleSheetOwner::removedFromDocument(Document&amp; document, Element&amp; element)
</del><ins>+void InlineStyleSheetOwner::removedFromDocument(Element&amp; element)
</ins><span class="cx"> {
</span><del>-    authorStyleSheetsForElement(element).removeStyleSheetCandidateNode(element);
-
</del><ins>+    if (m_styleSheetScope) {
+        m_styleSheetScope-&gt;removeStyleSheetCandidateNode(element);
+        m_styleSheetScope = nullptr;
+    }
</ins><span class="cx">     if (m_sheet)
</span><span class="cx">         clearSheet();
</span><del>-
-    // If we're in document teardown, then we don't need to do any notification of our sheet's removal.
-    if (document.hasLivingRenderTree())
-        document.authorStyleSheets().didChangeContentsOrInterpretation();
</del><span class="cx"> }
</span><span class="cx"> 
</span><del>-void InlineStyleSheetOwner::clearDocumentData(Document&amp;, Element&amp; element)
</del><ins>+void InlineStyleSheetOwner::clearDocumentData(Element&amp; element)
</ins><span class="cx"> {
</span><span class="cx">     if (m_sheet)
</span><span class="cx">         m_sheet-&gt;clearOwnerNode();
</span><span class="cx"> 
</span><del>-    if (!element.inDocument())
-        return;
-    authorStyleSheetsForElement(element).removeStyleSheetCandidateNode(element);
</del><ins>+    if (m_styleSheetScope) {
+        m_styleSheetScope-&gt;removeStyleSheetCandidateNode(element);
+        m_styleSheetScope = nullptr;
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void InlineStyleSheetOwner::childrenChanged(Element&amp; element)
</span><span class="lines">@@ -130,8 +124,8 @@
</span><span class="cx">     ASSERT(element.inDocument());
</span><span class="cx">     Document&amp; document = element.document();
</span><span class="cx">     if (m_sheet) {
</span><del>-        if (m_sheet-&gt;isLoading())
-            document.authorStyleSheets().removePendingSheet();
</del><ins>+        if (m_sheet-&gt;isLoading() &amp;&amp; m_styleSheetScope)
+            m_styleSheetScope-&gt;removePendingSheet();
</ins><span class="cx">         clearSheet();
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -155,7 +149,8 @@
</span><span class="cx">     if (!screenEval.evaluate(*mediaQueries) &amp;&amp; !printEval.evaluate(*mediaQueries))
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    authorStyleSheetsForElement(element).addPendingSheet();
</del><ins>+    if (m_styleSheetScope)
+        m_styleSheetScope-&gt;addPendingSheet();
</ins><span class="cx"> 
</span><span class="cx">     m_loading = true;
</span><span class="cx"> 
</span><span class="lines">@@ -177,18 +172,21 @@
</span><span class="cx">     return m_sheet &amp;&amp; m_sheet-&gt;isLoading();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool InlineStyleSheetOwner::sheetLoaded(Element&amp; element)
</del><ins>+bool InlineStyleSheetOwner::sheetLoaded(Element&amp;)
</ins><span class="cx"> {
</span><span class="cx">     if (isLoading())
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><del>-    authorStyleSheetsForElement(element).removePendingSheet();
</del><ins>+    if (m_styleSheetScope)
+        m_styleSheetScope-&gt;removePendingSheet();
+
</ins><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void InlineStyleSheetOwner::startLoadingDynamicSheet(Element&amp; element)
</del><ins>+void InlineStyleSheetOwner::startLoadingDynamicSheet(Element&amp;)
</ins><span class="cx"> {
</span><del>-    authorStyleSheetsForElement(element).addPendingSheet();
</del><ins>+    if (m_styleSheetScope)
+        m_styleSheetScope-&gt;addPendingSheet();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoredomInlineStyleSheetOwnerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/InlineStyleSheetOwner.h (206879 => 206880)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/InlineStyleSheetOwner.h        2016-10-06 20:47:44 UTC (rev 206879)
+++ trunk/Source/WebCore/dom/InlineStyleSheetOwner.h        2016-10-06 20:53:08 UTC (rev 206880)
</span><span class="lines">@@ -44,12 +44,14 @@
</span><span class="cx">     bool sheetLoaded(Element&amp;);
</span><span class="cx">     void startLoadingDynamicSheet(Element&amp;);
</span><span class="cx"> 
</span><del>-    void insertedIntoDocument(Document&amp;, Element&amp;);
-    void removedFromDocument(Document&amp;, Element&amp;);
-    void clearDocumentData(Document&amp;, Element&amp;);
</del><ins>+    void insertedIntoDocument(Element&amp;);
+    void removedFromDocument(Element&amp;);
+    void clearDocumentData(Element&amp;);
</ins><span class="cx">     void childrenChanged(Element&amp;);
</span><span class="cx">     void finishParsingChildren(Element&amp;);
</span><span class="cx"> 
</span><ins>+    AuthorStyleSheets* styleSheetScope() { return m_styleSheetScope; }
+
</ins><span class="cx"> private:
</span><span class="cx">     void createSheet(Element&amp;, const String&amp; text);
</span><span class="cx">     void createSheetFromTextContents(Element&amp;);
</span><span class="lines">@@ -61,6 +63,7 @@
</span><span class="cx">     AtomicString m_contentType;
</span><span class="cx">     AtomicString m_media;
</span><span class="cx">     RefPtr&lt;CSSStyleSheet&gt; m_sheet;
</span><ins>+    AuthorStyleSheets* m_styleSheetScope { nullptr };
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoredomShadowRootcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/ShadowRoot.cpp (206879 => 206880)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/ShadowRoot.cpp        2016-10-06 20:47:44 UTC (rev 206879)
+++ trunk/Source/WebCore/dom/ShadowRoot.cpp        2016-10-06 20:53:08 UTC (rev 206880)
</span><span class="lines">@@ -94,6 +94,14 @@
</span><span class="cx">     return *m_styleResolver;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+StyleResolver* ShadowRoot::styleResolverIfExists()
+{
+    if (m_type == Mode::UserAgent)
+        return &amp;document().userAgentShadowTreeStyleResolver();
+
+    return m_styleResolver.get();
+}
+
</ins><span class="cx"> void ShadowRoot::resetStyleResolver()
</span><span class="cx"> {
</span><span class="cx">     m_styleResolver = nullptr;
</span></span></pre></div>
<a id="trunkSourceWebCoredomShadowRooth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/ShadowRoot.h (206879 => 206880)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/ShadowRoot.h        2016-10-06 20:47:44 UTC (rev 206879)
+++ trunk/Source/WebCore/dom/ShadowRoot.h        2016-10-06 20:53:08 UTC (rev 206880)
</span><span class="lines">@@ -63,8 +63,9 @@
</span><span class="cx">     using TreeScope::rootNode;
</span><span class="cx"> 
</span><span class="cx">     StyleResolver&amp; styleResolver();
</span><ins>+    StyleResolver* styleResolverIfExists();
</ins><span class="cx">     AuthorStyleSheets&amp; authorStyleSheets();
</span><del>-    
</del><ins>+
</ins><span class="cx">     void updateStyle();
</span><span class="cx">     void resetStyleResolver();
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLLinkElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLLinkElement.cpp (206879 => 206880)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLLinkElement.cpp        2016-10-06 20:47:44 UTC (rev 206879)
+++ trunk/Source/WebCore/html/HTMLLinkElement.cpp        2016-10-06 20:53:08 UTC (rev 206880)
</span><span class="lines">@@ -328,9 +328,6 @@
</span><span class="cx"> 
</span><span class="cx">     if (styleSheetIsLoading())
</span><span class="cx">         removePendingSheet(RemovePendingSheetNotifyLater);
</span><del>-
-    if (document().hasLivingRenderTree())
-        document().authorStyleSheets().didChangeCandidatesForActiveSet();
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void HTMLLinkElement::finishParsingChildren()
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLStyleElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLStyleElement.cpp (206879 => 206880)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLStyleElement.cpp        2016-10-06 20:47:44 UTC (rev 206879)
+++ trunk/Source/WebCore/html/HTMLStyleElement.cpp        2016-10-06 20:53:08 UTC (rev 206880)
</span><span class="lines">@@ -58,9 +58,7 @@
</span><span class="cx"> 
</span><span class="cx"> HTMLStyleElement::~HTMLStyleElement()
</span><span class="cx"> {
</span><del>-    // During tear-down, willRemove isn't called, so m_scopedStyleRegistrationState may still be RegisteredAsScoped or RegisteredInShadowRoot here.
-    // Therefore we can't ASSERT(m_scopedStyleRegistrationState == NotRegistered).
-    m_styleSheetOwner.clearDocumentData(document(), *this);
</del><ins>+    m_styleSheetOwner.clearDocumentData(*this);
</ins><span class="cx"> 
</span><span class="cx">     styleLoadEventSender().cancelEvent(*this);
</span><span class="cx"> }
</span><span class="lines">@@ -78,9 +76,10 @@
</span><span class="cx">         m_styleSheetOwner.setMedia(value);
</span><span class="cx">         if (sheet()) {
</span><span class="cx">             sheet()-&gt;setMediaQueries(MediaQuerySet::createAllowingDescriptionSyntax(value));
</span><del>-            if (inDocument() &amp;&amp; document().hasLivingRenderTree())
-                document().authorStyleSheets().didChangeContentsOrInterpretation();
-        }
</del><ins>+            if (auto* scope = m_styleSheetOwner.styleSheetScope())
+                scope-&gt;didChangeContentsOrInterpretation();
+        } else
+            m_styleSheetOwner.childrenChanged(*this);
</ins><span class="cx">     } else if (name == typeAttr)
</span><span class="cx">         m_styleSheetOwner.setContentType(value);
</span><span class="cx">     else
</span><span class="lines">@@ -97,7 +96,7 @@
</span><span class="cx"> {
</span><span class="cx">     HTMLElement::insertedInto(insertionPoint);
</span><span class="cx">     if (insertionPoint.inDocument())
</span><del>-        m_styleSheetOwner.insertedIntoDocument(document(), *this);
</del><ins>+        m_styleSheetOwner.insertedIntoDocument(*this);
</ins><span class="cx"> 
</span><span class="cx">     return InsertionDone;
</span><span class="cx"> }
</span><span class="lines">@@ -107,7 +106,7 @@
</span><span class="cx">     HTMLElement::removedFrom(insertionPoint);
</span><span class="cx"> 
</span><span class="cx">     if (insertionPoint.inDocument())
</span><del>-        m_styleSheetOwner.removedFromDocument(document(), *this);
</del><ins>+        m_styleSheetOwner.removedFromDocument(*this);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void HTMLStyleElement::childrenChanged(const ChildChange&amp; change)
</span></span></pre></div>
<a id="trunkSourceWebCorepageDOMWindowcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/DOMWindow.cpp (206879 => 206880)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/DOMWindow.cpp        2016-10-06 20:47:44 UTC (rev 206879)
+++ trunk/Source/WebCore/page/DOMWindow.cpp        2016-10-06 20:53:08 UTC (rev 206880)
</span><span class="lines">@@ -27,6 +27,7 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;DOMWindow.h&quot;
</span><span class="cx"> 
</span><ins>+#include &quot;AuthorStyleSheets.h&quot;
</ins><span class="cx"> #include &quot;BackForwardController.h&quot;
</span><span class="cx"> #include &quot;BarProp.h&quot;
</span><span class="cx"> #include &quot;BeforeUnloadEvent.h&quot;
</span><span class="lines">@@ -1431,6 +1432,8 @@
</span><span class="cx">     if (pseudoType == CSSSelector::PseudoElementUnknown &amp;&amp; !pseudoElement.isEmpty())
</span><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><ins>+    m_frame-&gt;document()-&gt;authorStyleSheets().flushPendingUpdate();
+
</ins><span class="cx">     unsigned rulesToInclude = StyleResolver::AuthorCSSRules;
</span><span class="cx">     if (!authorOnly)
</span><span class="cx">         rulesToInclude |= StyleResolver::UAAndUserCSSRules;
</span></span></pre></div>
<a id="trunkSourceWebCoresvgSVGStyleElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/svg/SVGStyleElement.cpp (206879 => 206880)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/svg/SVGStyleElement.cpp        2016-10-06 20:47:44 UTC (rev 206879)
+++ trunk/Source/WebCore/svg/SVGStyleElement.cpp        2016-10-06 20:53:08 UTC (rev 206880)
</span><span class="lines">@@ -41,7 +41,7 @@
</span><span class="cx"> 
</span><span class="cx"> SVGStyleElement::~SVGStyleElement()
</span><span class="cx"> {
</span><del>-    m_styleSheetOwner.clearDocumentData(document(), *this);
</del><ins>+    m_styleSheetOwner.clearDocumentData(*this);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> Ref&lt;SVGStyleElement&gt; SVGStyleElement::create(const QualifiedName&amp; tagName, Document&amp; document, bool createdByParser)
</span><span class="lines">@@ -123,7 +123,7 @@
</span><span class="cx"> {
</span><span class="cx">     SVGElement::insertedInto(rootParent);
</span><span class="cx">     if (rootParent.inDocument())
</span><del>-        m_styleSheetOwner.insertedIntoDocument(document(), *this);
</del><ins>+        m_styleSheetOwner.insertedIntoDocument(*this);
</ins><span class="cx">     return InsertionDone;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -131,7 +131,7 @@
</span><span class="cx"> {
</span><span class="cx">     SVGElement::removedFrom(rootParent);
</span><span class="cx">     if (rootParent.inDocument())
</span><del>-        m_styleSheetOwner.removedFromDocument(document(), *this);
</del><ins>+        m_styleSheetOwner.removedFromDocument(*this);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void SVGStyleElement::childrenChanged(const ChildChange&amp; change)
</span></span></pre>
</div>
</div>

</body>
</html>