<!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>[206951] trunk/Source/WebCore</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/206951">206951</a></dd>
<dt>Author</dt> <dd>antti@apple.com</dd>
<dt>Date</dt> <dd>2016-10-08 01:42:03 -0700 (Sat, 08 Oct 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Move StyleResolver ownership from Document/ShadowRoot to Style::Scope
https://bugs.webkit.org/show_bug.cgi?id=163148

Reviewed by Andreas Kling.

Reduce duplication between Document and ShadowRoot.

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::ComputedStyleExtractor::propertyValue):
* css/CSSStyleSheet.cpp:
(WebCore::CSSStyleSheet::didMutateRules):
* css/ElementRuleCollector.cpp:
(WebCore::ElementRuleCollector::matchHostPseudoClassRules):
(WebCore::ElementRuleCollector::matchSlottedPseudoElementRules):
* css/MediaQueryMatcher.cpp:
(WebCore::MediaQueryMatcher::documentElementUserAgentStyle):
* css/StyleMedia.cpp:
(WebCore::StyleMedia::matchMedium):
* css/parser/SizesAttributeParser.cpp:
(WebCore::SizesAttributeParser::mediaConditionMatches):
* dom/Document.cpp:
(WebCore::Document::~Document):
(WebCore::Document::childrenChanged):
(WebCore::Document::isPageBoxVisible):
(WebCore::Document::pageSizeAndMarginsInPixels):
(WebCore::Document::userAgentShadowTreeStyleResolver):
(WebCore::Document::fontsNeedUpdate):
(WebCore::Document::didClearStyleResolver):
(WebCore::Document::updateViewportUnitsOnResize):
(WebCore::Document::createStyleResolver): Deleted.
(WebCore::Document::clearStyleResolver): Deleted.
* dom/Document.h:
(WebCore::Document::styleResolverIfExists): Deleted.
(WebCore::Document::ensureStyleResolver): Deleted.
* dom/Element.cpp:
(WebCore::Element::styleResolver):
* dom/ShadowRoot.cpp:
(WebCore::ShadowRoot::styleResolver): Deleted.
(WebCore::ShadowRoot::styleResolverIfExists): Deleted.
(WebCore::ShadowRoot::resetStyleResolver): Deleted.
* dom/ShadowRoot.h:
* page/DOMWindow.cpp:
(WebCore::DOMWindow::getMatchedCSSRules):
* page/FrameView.cpp:
(WebCore::FrameView::layout):
* page/Page.cpp:
(WebCore::Page::updateStyleForAllPagesAfterGlobalChangeInEnvironment):
* page/PrintContext.cpp:
(WebCore::PrintContext::pageProperty):
* platform/MemoryPressureHandler.cpp:
(WebCore::MemoryPressureHandler::releaseCriticalMemory):
* style/AttributeChangeInvalidation.cpp:
(WebCore::Style::mayBeAffectedByHostStyle):
* style/ClassChangeInvalidation.cpp:
(WebCore::Style::mayBeAffectedByHostStyle):
* style/IdChangeInvalidation.cpp:
(WebCore::Style::mayBeAffectedByHostStyle):
* style/StyleScope.cpp:
(WebCore::Style::Scope::resolver):
(WebCore::Style::Scope::resolverIfExists):
(WebCore::Style::Scope::clearResolver):
(WebCore::Style::Scope::analyzeStyleSheetChange):
(WebCore::Style::Scope::updateActiveStyleSheets):
(WebCore::Style::Scope::updateStyleResolver):
(WebCore::Style::Scope::styleResolver): Deleted.
(WebCore::Style::Scope::styleResolverIfExists): Deleted.
* style/StyleScope.h:
* style/StyleSharingResolver.cpp:
(WebCore::Style::SharingResolver::resolve):
(WebCore::Style::SharingResolver::canShareStyleWithElement):
* style/StyleTreeResolver.cpp:
(WebCore::Style::TreeResolver::Scope::Scope):
(WebCore::Style::TreeResolver::resolve):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorecssCSSComputedStyleDeclarationcpp">trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp</a></li>
<li><a href="#trunkSourceWebCorecssCSSStyleSheetcpp">trunk/Source/WebCore/css/CSSStyleSheet.cpp</a></li>
<li><a href="#trunkSourceWebCorecssElementRuleCollectorcpp">trunk/Source/WebCore/css/ElementRuleCollector.cpp</a></li>
<li><a href="#trunkSourceWebCorecssMediaQueryMatchercpp">trunk/Source/WebCore/css/MediaQueryMatcher.cpp</a></li>
<li><a href="#trunkSourceWebCorecssStyleMediacpp">trunk/Source/WebCore/css/StyleMedia.cpp</a></li>
<li><a href="#trunkSourceWebCorecssparserSizesAttributeParsercpp">trunk/Source/WebCore/css/parser/SizesAttributeParser.cpp</a></li>
<li><a href="#trunkSourceWebCoredomDocumentcpp">trunk/Source/WebCore/dom/Document.cpp</a></li>
<li><a href="#trunkSourceWebCoredomDocumenth">trunk/Source/WebCore/dom/Document.h</a></li>
<li><a href="#trunkSourceWebCoredomElementcpp">trunk/Source/WebCore/dom/Element.cpp</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="#trunkSourceWebCorepageDOMWindowcpp">trunk/Source/WebCore/page/DOMWindow.cpp</a></li>
<li><a href="#trunkSourceWebCorepageFrameViewcpp">trunk/Source/WebCore/page/FrameView.cpp</a></li>
<li><a href="#trunkSourceWebCorepagePagecpp">trunk/Source/WebCore/page/Page.cpp</a></li>
<li><a href="#trunkSourceWebCorepagePrintContextcpp">trunk/Source/WebCore/page/PrintContext.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformMemoryPressureHandlercpp">trunk/Source/WebCore/platform/MemoryPressureHandler.cpp</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="#trunkSourceWebCorestyleIdChangeInvalidationcpp">trunk/Source/WebCore/style/IdChangeInvalidation.cpp</a></li>
<li><a href="#trunkSourceWebCorestyleStyleScopecpp">trunk/Source/WebCore/style/StyleScope.cpp</a></li>
<li><a href="#trunkSourceWebCorestyleStyleScopeh">trunk/Source/WebCore/style/StyleScope.h</a></li>
<li><a href="#trunkSourceWebCorestyleStyleSharingResolvercpp">trunk/Source/WebCore/style/StyleSharingResolver.cpp</a></li>
<li><a href="#trunkSourceWebCorestyleStyleTreeResolvercpp">trunk/Source/WebCore/style/StyleTreeResolver.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (206950 => 206951)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-10-08 08:31:00 UTC (rev 206950)
+++ trunk/Source/WebCore/ChangeLog        2016-10-08 08:42:03 UTC (rev 206951)
</span><span class="lines">@@ -1,3 +1,79 @@
</span><ins>+2016-10-08  Antti Koivisto  &lt;antti@apple.com&gt;
+
+        Move StyleResolver ownership from Document/ShadowRoot to Style::Scope
+        https://bugs.webkit.org/show_bug.cgi?id=163148
+
+        Reviewed by Andreas Kling.
+
+        Reduce duplication between Document and ShadowRoot.
+
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::ComputedStyleExtractor::propertyValue):
+        * css/CSSStyleSheet.cpp:
+        (WebCore::CSSStyleSheet::didMutateRules):
+        * css/ElementRuleCollector.cpp:
+        (WebCore::ElementRuleCollector::matchHostPseudoClassRules):
+        (WebCore::ElementRuleCollector::matchSlottedPseudoElementRules):
+        * css/MediaQueryMatcher.cpp:
+        (WebCore::MediaQueryMatcher::documentElementUserAgentStyle):
+        * css/StyleMedia.cpp:
+        (WebCore::StyleMedia::matchMedium):
+        * css/parser/SizesAttributeParser.cpp:
+        (WebCore::SizesAttributeParser::mediaConditionMatches):
+        * dom/Document.cpp:
+        (WebCore::Document::~Document):
+        (WebCore::Document::childrenChanged):
+        (WebCore::Document::isPageBoxVisible):
+        (WebCore::Document::pageSizeAndMarginsInPixels):
+        (WebCore::Document::userAgentShadowTreeStyleResolver):
+        (WebCore::Document::fontsNeedUpdate):
+        (WebCore::Document::didClearStyleResolver):
+        (WebCore::Document::updateViewportUnitsOnResize):
+        (WebCore::Document::createStyleResolver): Deleted.
+        (WebCore::Document::clearStyleResolver): Deleted.
+        * dom/Document.h:
+        (WebCore::Document::styleResolverIfExists): Deleted.
+        (WebCore::Document::ensureStyleResolver): Deleted.
+        * dom/Element.cpp:
+        (WebCore::Element::styleResolver):
+        * dom/ShadowRoot.cpp:
+        (WebCore::ShadowRoot::styleResolver): Deleted.
+        (WebCore::ShadowRoot::styleResolverIfExists): Deleted.
+        (WebCore::ShadowRoot::resetStyleResolver): Deleted.
+        * dom/ShadowRoot.h:
+        * page/DOMWindow.cpp:
+        (WebCore::DOMWindow::getMatchedCSSRules):
+        * page/FrameView.cpp:
+        (WebCore::FrameView::layout):
+        * page/Page.cpp:
+        (WebCore::Page::updateStyleForAllPagesAfterGlobalChangeInEnvironment):
+        * page/PrintContext.cpp:
+        (WebCore::PrintContext::pageProperty):
+        * platform/MemoryPressureHandler.cpp:
+        (WebCore::MemoryPressureHandler::releaseCriticalMemory):
+        * style/AttributeChangeInvalidation.cpp:
+        (WebCore::Style::mayBeAffectedByHostStyle):
+        * style/ClassChangeInvalidation.cpp:
+        (WebCore::Style::mayBeAffectedByHostStyle):
+        * style/IdChangeInvalidation.cpp:
+        (WebCore::Style::mayBeAffectedByHostStyle):
+        * style/StyleScope.cpp:
+        (WebCore::Style::Scope::resolver):
+        (WebCore::Style::Scope::resolverIfExists):
+        (WebCore::Style::Scope::clearResolver):
+        (WebCore::Style::Scope::analyzeStyleSheetChange):
+        (WebCore::Style::Scope::updateActiveStyleSheets):
+        (WebCore::Style::Scope::updateStyleResolver):
+        (WebCore::Style::Scope::styleResolver): Deleted.
+        (WebCore::Style::Scope::styleResolverIfExists): Deleted.
+        * style/StyleScope.h:
+        * style/StyleSharingResolver.cpp:
+        (WebCore::Style::SharingResolver::resolve):
+        (WebCore::Style::SharingResolver::canShareStyleWithElement):
+        * style/StyleTreeResolver.cpp:
+        (WebCore::Style::TreeResolver::Scope::Scope):
+        (WebCore::Style::TreeResolver::resolve):
+
</ins><span class="cx"> 2016-10-07  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         window.navigator.language incorrectly returns all lowercase string
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSComputedStyleDeclarationcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (206950 => 206951)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp        2016-10-08 08:31:00 UTC (rev 206950)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp        2016-10-08 08:42:03 UTC (rev 206951)
</span><span class="lines">@@ -70,6 +70,7 @@
</span><span class="cx"> #include &quot;StylePropertyShorthand.h&quot;
</span><span class="cx"> #include &quot;StylePropertyShorthandFunctions.h&quot;
</span><span class="cx"> #include &quot;StyleResolver.h&quot;
</span><ins>+#include &quot;StyleScope.h&quot;
</ins><span class="cx"> #include &quot;WebKitCSSFilterValue.h&quot;
</span><span class="cx"> #include &quot;WebKitCSSTransformValue.h&quot;
</span><span class="cx"> #include &quot;WebKitFontFamilyNames.h&quot;
</span><span class="lines">@@ -2494,7 +2495,7 @@
</span><span class="cx">         // FIXME: Some of these cases could be narrowed down or optimized better.
</span><span class="cx">         forceFullLayout = isLayoutDependent(propertyID, style, renderer)
</span><span class="cx">             || styledNode-&gt;isInShadowTree()
</span><del>-            || (document.styleResolverIfExists() &amp;&amp; document.styleResolverIfExists()-&gt;hasViewportDependentMediaQueries() &amp;&amp; document.ownerElement());
</del><ins>+            || (document.styleScope().resolverIfExists() &amp;&amp; document.styleScope().resolverIfExists()-&gt;hasViewportDependentMediaQueries() &amp;&amp; document.ownerElement());
</ins><span class="cx"> 
</span><span class="cx">         if (forceFullLayout) {
</span><span class="cx">             document.updateLayoutIgnorePendingStylesheets();
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSStyleSheetcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSStyleSheet.cpp (206950 => 206951)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSStyleSheet.cpp        2016-10-08 08:31:00 UTC (rev 206950)
+++ trunk/Source/WebCore/css/CSSStyleSheet.cpp        2016-10-08 08:42:03 UTC (rev 206951)
</span><span class="lines">@@ -177,7 +177,7 @@
</span><span class="cx"> 
</span><span class="cx">     if (mutationType == RuleInsertion &amp;&amp; !contentsWereClonedForMutation &amp;&amp; !scope-&gt;activeStyleSheetsContains(this)) {
</span><span class="cx">         if (insertedKeyframesRule) {
</span><del>-            if (auto* resolver = scope-&gt;styleResolverIfExists())
</del><ins>+            if (auto* resolver = scope-&gt;resolverIfExists())
</ins><span class="cx">                 resolver-&gt;addKeyframeStyle(*insertedKeyframesRule);
</span><span class="cx">             return;
</span><span class="cx">         }
</span></span></pre></div>
<a id="trunkSourceWebCorecssElementRuleCollectorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/ElementRuleCollector.cpp (206950 => 206951)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/ElementRuleCollector.cpp        2016-10-08 08:31:00 UTC (rev 206950)
+++ trunk/Source/WebCore/css/ElementRuleCollector.cpp        2016-10-08 08:42:03 UTC (rev 206951)
</span><span class="lines">@@ -45,6 +45,7 @@
</span><span class="cx"> #include &quot;SelectorFilter.h&quot;
</span><span class="cx"> #include &quot;ShadowRoot.h&quot;
</span><span class="cx"> #include &quot;StyleProperties.h&quot;
</span><ins>+#include &quot;StyleScope.h&quot;
</ins><span class="cx"> #include &quot;StyledElement.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &lt;wtf/TemporaryChange.h&gt;
</span><span class="lines">@@ -234,7 +235,7 @@
</span><span class="cx"> 
</span><span class="cx">     matchRequest.treeContextOrdinal++;
</span><span class="cx"> 
</span><del>-    auto&amp; shadowAuthorStyle = m_element.shadowRoot()-&gt;styleResolver().ruleSets().authorStyle();
</del><ins>+    auto&amp; shadowAuthorStyle = m_element.shadowRoot()-&gt;styleScope().resolver().ruleSets().authorStyle();
</ins><span class="cx">     auto&amp; shadowHostRules = shadowAuthorStyle.hostPseudoClassRules();
</span><span class="cx">     if (shadowHostRules.isEmpty())
</span><span class="cx">         return;
</span><span class="lines">@@ -265,11 +266,11 @@
</span><span class="cx"> 
</span><span class="cx">         // In nested case the slot may itself be assigned to a slot. Collect ::slotted rules from all the nested trees.
</span><span class="cx">         maybeSlotted = slot;
</span><del>-        if (!hostShadowRoot-&gt;styleResolver().ruleSets().isAuthorStyleDefined())
</del><ins>+        if (!hostShadowRoot-&gt;styleScope().resolver().ruleSets().isAuthorStyleDefined())
</ins><span class="cx">             continue;
</span><span class="cx">         // Find out if there are any ::slotted rules in the shadow tree matching the current slot.
</span><span class="cx">         // FIXME: This is really part of the slot style and could be cached when resolving it.
</span><del>-        ElementRuleCollector collector(*slot, hostShadowRoot-&gt;styleResolver().ruleSets().authorStyle(), nullptr);
</del><ins>+        ElementRuleCollector collector(*slot, hostShadowRoot-&gt;styleScope().resolver().ruleSets().authorStyle(), nullptr);
</ins><span class="cx">         auto slottedPseudoElementRules = collector.collectSlottedPseudoElementRulesForSlot(matchRequest.includeEmptyRules);
</span><span class="cx">         if (!slottedPseudoElementRules)
</span><span class="cx">             continue;
</span></span></pre></div>
<a id="trunkSourceWebCorecssMediaQueryMatchercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/MediaQueryMatcher.cpp (206950 => 206951)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/MediaQueryMatcher.cpp        2016-10-08 08:31:00 UTC (rev 206950)
+++ trunk/Source/WebCore/css/MediaQueryMatcher.cpp        2016-10-08 08:42:03 UTC (rev 206951)
</span><span class="lines">@@ -30,6 +30,7 @@
</span><span class="cx"> #include &quot;NodeRenderStyle.h&quot;
</span><span class="cx"> #include &quot;RenderElement.h&quot;
</span><span class="cx"> #include &quot;StyleResolver.h&quot;
</span><ins>+#include &quot;StyleScope.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="lines">@@ -65,7 +66,7 @@
</span><span class="cx">     if (!documentElement)
</span><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><del>-    return m_document-&gt;ensureStyleResolver().styleForElement(*documentElement, m_document-&gt;renderStyle(), MatchOnlyUserAgentRules).renderStyle;
</del><ins>+    return m_document-&gt;styleScope().resolver().styleForElement(*documentElement, m_document-&gt;renderStyle(), MatchOnlyUserAgentRules).renderStyle;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool MediaQueryMatcher::evaluate(const MediaQuerySet&amp; media)
</span></span></pre></div>
<a id="trunkSourceWebCorecssStyleMediacpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/StyleMedia.cpp (206950 => 206951)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/StyleMedia.cpp        2016-10-08 08:31:00 UTC (rev 206950)
+++ trunk/Source/WebCore/css/StyleMedia.cpp        2016-10-08 08:42:03 UTC (rev 206951)
</span><span class="lines">@@ -34,6 +34,7 @@
</span><span class="cx"> #include &quot;NodeRenderStyle.h&quot;
</span><span class="cx"> #include &quot;RenderElement.h&quot;
</span><span class="cx"> #include &quot;StyleResolver.h&quot;
</span><ins>+#include &quot;StyleScope.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="lines">@@ -62,7 +63,7 @@
</span><span class="cx">     if (!documentElement)
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><del>-    auto rootStyle = document-&gt;ensureStyleResolver().styleForElement(*documentElement, document-&gt;renderStyle(), MatchOnlyUserAgentRules).renderStyle;
</del><ins>+    auto rootStyle = document-&gt;styleScope().resolver().styleForElement(*documentElement, document-&gt;renderStyle(), MatchOnlyUserAgentRules).renderStyle;
</ins><span class="cx"> 
</span><span class="cx">     auto media = MediaQuerySet::create();
</span><span class="cx">     if (!media-&gt;parse(query))
</span></span></pre></div>
<a id="trunkSourceWebCorecssparserSizesAttributeParsercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/parser/SizesAttributeParser.cpp (206950 => 206951)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/parser/SizesAttributeParser.cpp        2016-10-08 08:31:00 UTC (rev 206950)
+++ trunk/Source/WebCore/css/parser/SizesAttributeParser.cpp        2016-10-08 08:42:03 UTC (rev 206951)
</span><span class="lines">@@ -36,6 +36,7 @@
</span><span class="cx"> #include &quot;MediaQueryEvaluator.h&quot;
</span><span class="cx"> #include &quot;RenderView.h&quot;
</span><span class="cx"> #include &quot;SizesCalcParser.h&quot;
</span><ins>+#include &quot;StyleScope.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="lines">@@ -110,7 +111,7 @@
</span><span class="cx">     if (!renderer)
</span><span class="cx">         return false;
</span><span class="cx">     auto&amp; style = renderer-&gt;style();
</span><del>-    return MediaQueryEvaluator { &quot;screen&quot;, m_document, &amp;style }.evaluate(mediaCondition, m_document.styleResolverIfExists());
</del><ins>+    return MediaQueryEvaluator { &quot;screen&quot;, m_document, &amp;style }.evaluate(mediaCondition, const_cast&lt;Style::Scope&amp;&gt;(m_document.styleScope()).resolverIfExists());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool SizesAttributeParser::parse(CSSParserTokenRange range)
</span></span></pre></div>
<a id="trunkSourceWebCoredomDocumentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Document.cpp (206950 => 206951)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Document.cpp        2016-10-08 08:31:00 UTC (rev 206950)
+++ trunk/Source/WebCore/dom/Document.cpp        2016-10-08 08:42:03 UTC (rev 206951)
</span><span class="lines">@@ -631,7 +631,7 @@
</span><span class="cx"> 
</span><span class="cx">     extensionStyleSheets().detachFromDocument();
</span><span class="cx"> 
</span><del>-    clearStyleResolver(); // We need to destroy CSSFontSelector before destroying m_cachedResourceLoader.
</del><ins>+    styleScope().clearResolver(); // We need to destroy CSSFontSelector before destroying m_cachedResourceLoader.
</ins><span class="cx">     m_fontSelector-&gt;clearDocument();
</span><span class="cx">     m_fontSelector-&gt;unregisterForInvalidationCallbacks(*this);
</span><span class="cx"> 
</span><span class="lines">@@ -863,7 +863,7 @@
</span><span class="cx">         return;
</span><span class="cx">     m_documentElement = newDocumentElement;
</span><span class="cx">     // The root style used for media query matching depends on the document element.
</span><del>-    clearStyleResolver();
</del><ins>+    styleScope().clearResolver();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(CUSTOM_ELEMENTS)
</span><span class="lines">@@ -2097,13 +2097,13 @@
</span><span class="cx"> 
</span><span class="cx"> bool Document::isPageBoxVisible(int pageIndex)
</span><span class="cx"> {
</span><del>-    std::unique_ptr&lt;RenderStyle&gt; pageStyle(ensureStyleResolver().styleForPage(pageIndex));
</del><ins>+    std::unique_ptr&lt;RenderStyle&gt; pageStyle(styleScope().resolver().styleForPage(pageIndex));
</ins><span class="cx">     return pageStyle-&gt;visibility() != HIDDEN; // display property doesn't apply to @page.
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void Document::pageSizeAndMarginsInPixels(int pageIndex, IntSize&amp; pageSize, int&amp; marginTop, int&amp; marginRight, int&amp; marginBottom, int&amp; marginLeft)
</span><span class="cx"> {
</span><del>-    std::unique_ptr&lt;RenderStyle&gt; style = ensureStyleResolver().styleForPage(pageIndex);
</del><ins>+    std::unique_ptr&lt;RenderStyle&gt; style = styleScope().resolver().styleForPage(pageIndex);
</ins><span class="cx"> 
</span><span class="cx">     int width = pageSize.width();
</span><span class="cx">     int height = pageSize.height();
</span><span class="lines">@@ -2139,12 +2139,6 @@
</span><span class="cx">     marginLeft = style-&gt;marginLeft().isAuto() ? marginLeft : intValueForLength(style-&gt;marginLeft(), width);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Document::createStyleResolver()
-{
-    m_styleResolver = std::make_unique&lt;StyleResolver&gt;(*this);
-    m_styleResolver-&gt;appendAuthorStyleSheets(styleScope().activeStyleSheets());
-}
-
</del><span class="cx"> StyleResolver&amp; Document::userAgentShadowTreeStyleResolver()
</span><span class="cx"> {
</span><span class="cx">     if (!m_userAgentShadowTreeStyleResolver) {
</span><span class="lines">@@ -2151,7 +2145,7 @@
</span><span class="cx">         m_userAgentShadowTreeStyleResolver = std::make_unique&lt;StyleResolver&gt;(*this);
</span><span class="cx"> 
</span><span class="cx">         // FIXME: Filter out shadow pseudo elements we don't want to expose to authors.
</span><del>-        auto&amp; documentAuthorStyle = ensureStyleResolver().ruleSets().authorStyle();
</del><ins>+        auto&amp; documentAuthorStyle = styleScope().resolver().ruleSets().authorStyle();
</ins><span class="cx">         if (documentAuthorStyle.hasShadowPseudoElementRules())
</span><span class="cx">             m_userAgentShadowTreeStyleResolver-&gt;ruleSets().authorStyle().copyShadowPseudoElementRulesFrom(documentAuthorStyle);
</span><span class="cx">     }
</span><span class="lines">@@ -2161,16 +2155,15 @@
</span><span class="cx"> 
</span><span class="cx"> void Document::fontsNeedUpdate(FontSelector&amp;)
</span><span class="cx"> {
</span><del>-    if (m_styleResolver)
-        m_styleResolver-&gt;invalidateMatchedPropertiesCache();
</del><ins>+    if (auto* resolver = styleScope().resolverIfExists())
+        resolver-&gt;invalidateMatchedPropertiesCache();
</ins><span class="cx">     if (pageCacheState() != NotInPageCache || !renderView())
</span><span class="cx">         return;
</span><span class="cx">     scheduleForcedStyleRecalc();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Document::clearStyleResolver()
</del><ins>+void Document::didClearStyleResolver()
</ins><span class="cx"> {
</span><del>-    m_styleResolver = nullptr;
</del><span class="cx">     m_userAgentShadowTreeStyleResolver = nullptr;
</span><span class="cx"> 
</span><span class="cx">     m_fontSelector-&gt;buildStarted();
</span><span class="lines">@@ -3491,7 +3484,7 @@
</span><span class="cx">     if (!hasStyleWithViewportUnits())
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    ensureStyleResolver().clearCachedPropertiesAffectedByViewportUnits();
</del><ins>+    styleScope().resolver().clearCachedPropertiesAffectedByViewportUnits();
</ins><span class="cx"> 
</span><span class="cx">     // FIXME: Ideally, we should save the list of elements that have viewport units and only iterate over those.
</span><span class="cx">     for (Element* element = ElementTraversal::firstWithin(rootNode()); element; element = ElementTraversal::nextIncludingPseudo(*element)) {
</span></span></pre></div>
<a id="trunkSourceWebCoredomDocumenth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Document.h (206950 => 206951)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Document.h        2016-10-08 08:31:00 UTC (rev 206950)
+++ trunk/Source/WebCore/dom/Document.h        2016-10-08 08:42:03 UTC (rev 206951)
</span><span class="lines">@@ -487,16 +487,8 @@
</span><span class="cx"> 
</span><span class="cx">     bool isSrcdocDocument() const { return m_isSrcdocDocument; }
</span><span class="cx"> 
</span><del>-    StyleResolver* styleResolverIfExists() const { return m_styleResolver.get(); }
-
</del><span class="cx">     bool sawElementsInKnownNamespaces() const { return m_sawElementsInKnownNamespaces; }
</span><span class="cx"> 
</span><del>-    StyleResolver&amp; ensureStyleResolver()
-    { 
-        if (!m_styleResolver)
-            createStyleResolver();
-        return *m_styleResolver;
-    }
</del><span class="cx">     StyleResolver&amp; userAgentShadowTreeStyleResolver();
</span><span class="cx"> 
</span><span class="cx">     CSSFontSelector&amp; fontSelector() { return m_fontSelector; }
</span><span class="lines">@@ -1230,7 +1222,7 @@
</span><span class="cx"> 
</span><span class="cx">     void didRemoveAllPendingStylesheet();
</span><span class="cx">     void setNeedsNotifyRemoveAllPendingStylesheet() { m_needsNotifyRemoveAllPendingStylesheet = true; }
</span><del>-    void clearStyleResolver();
</del><ins>+    void didClearStyleResolver();
</ins><span class="cx"> 
</span><span class="cx">     bool inStyleRecalc() const { return m_inStyleRecalc; }
</span><span class="cx">     bool inRenderTreeUpdate() const { return m_inRenderTreeUpdate; }
</span><span class="lines">@@ -1352,8 +1344,6 @@
</span><span class="cx"> 
</span><span class="cx">     void buildAccessKeyMap(TreeScope* root);
</span><span class="cx"> 
</span><del>-    void createStyleResolver();
-
</del><span class="cx">     void loadEventDelayTimerFired();
</span><span class="cx"> 
</span><span class="cx">     void pendingTasksTimerFired();
</span><span class="lines">@@ -1397,7 +1387,6 @@
</span><span class="cx"> 
</span><span class="cx">     unsigned m_referencingNodeCount;
</span><span class="cx"> 
</span><del>-    std::unique_ptr&lt;StyleResolver&gt; m_styleResolver;
</del><span class="cx">     std::unique_ptr&lt;StyleResolver&gt; m_userAgentShadowTreeStyleResolver;
</span><span class="cx">     bool m_hasNodesWithPlaceholderStyle;
</span><span class="cx">     bool m_needsNotifyRemoveAllPendingStylesheet;
</span></span></pre></div>
<a id="trunkSourceWebCoredomElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Element.cpp (206950 => 206951)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Element.cpp        2016-10-08 08:31:00 UTC (rev 206950)
+++ trunk/Source/WebCore/dom/Element.cpp        2016-10-08 08:42:03 UTC (rev 206951)
</span><span class="lines">@@ -97,6 +97,7 @@
</span><span class="cx"> #include &quot;SlotAssignment.h&quot;
</span><span class="cx"> #include &quot;StyleProperties.h&quot;
</span><span class="cx"> #include &quot;StyleResolver.h&quot;
</span><ins>+#include &quot;StyleScope.h&quot;
</ins><span class="cx"> #include &quot;StyleTreeResolver.h&quot;
</span><span class="cx"> #include &quot;TextIterator.h&quot;
</span><span class="cx"> #include &quot;VoidCallback.h&quot;
</span><span class="lines">@@ -1429,9 +1430,9 @@
</span><span class="cx"> StyleResolver&amp; Element::styleResolver()
</span><span class="cx"> {
</span><span class="cx">     if (auto* shadowRoot = containingShadowRoot())
</span><del>-        return shadowRoot-&gt;styleResolver();
</del><ins>+        return shadowRoot-&gt;styleScope().resolver();
</ins><span class="cx"> 
</span><del>-    return document().ensureStyleResolver();
</del><ins>+    return document().styleScope().resolver();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> ElementStyle Element::resolveStyle(const RenderStyle* parentStyle)
</span></span></pre></div>
<a id="trunkSourceWebCoredomShadowRootcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/ShadowRoot.cpp (206950 => 206951)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/ShadowRoot.cpp        2016-10-08 08:31:00 UTC (rev 206950)
+++ trunk/Source/WebCore/dom/ShadowRoot.cpp        2016-10-08 08:42:03 UTC (rev 206951)
</span><span class="lines">@@ -41,7 +41,6 @@
</span><span class="cx"> 
</span><span class="cx"> struct SameSizeAsShadowRoot : public DocumentFragment, public TreeScope {
</span><span class="cx">     unsigned countersAndFlags[1];
</span><del>-    void* styleResolver;
</del><span class="cx">     void* styleScope;
</span><span class="cx">     void* host;
</span><span class="cx">     void* slotAssignment;
</span><span class="lines">@@ -80,33 +79,6 @@
</span><span class="cx">     removeDetachedChildren();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-StyleResolver&amp; ShadowRoot::styleResolver()
-{
-    if (m_type == Mode::UserAgent)
-        return document().userAgentShadowTreeStyleResolver();
-
-    if (!m_styleResolver) {
-        // FIXME: We could share style resolver with shadow roots that have identical style.
-        m_styleResolver = std::make_unique&lt;StyleResolver&gt;(document());
-        if (m_styleScope)
-            m_styleResolver-&gt;appendAuthorStyleSheets(m_styleScope-&gt;activeStyleSheets());
-    }
-    return *m_styleResolver;
-}
-
-StyleResolver* ShadowRoot::styleResolverIfExists()
-{
-    if (m_type == Mode::UserAgent)
-        return &amp;document().userAgentShadowTreeStyleResolver();
-
-    return m_styleResolver.get();
-}
-
-void ShadowRoot::resetStyleResolver()
-{
-    m_styleResolver = nullptr;
-}
-
</del><span class="cx"> Style::Scope&amp; ShadowRoot::styleScope()
</span><span class="cx"> {
</span><span class="cx">     if (!m_styleScope)
</span><span class="lines">@@ -114,14 +86,6 @@
</span><span class="cx">     return *m_styleScope;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void ShadowRoot::updateStyle()
-{
-    if (!m_styleScope)
-        return;
-    // FIXME: Make optimized updated work.
-    m_styleScope-&gt;didChangeContentsOrInterpretation();
-}
-
</del><span class="cx"> String ShadowRoot::innerHTML() const
</span><span class="cx"> {
</span><span class="cx">     return createMarkup(*this, ChildrenOnly);
</span></span></pre></div>
<a id="trunkSourceWebCoredomShadowRooth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/ShadowRoot.h (206950 => 206951)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/ShadowRoot.h        2016-10-08 08:31:00 UTC (rev 206950)
+++ trunk/Source/WebCore/dom/ShadowRoot.h        2016-10-08 08:42:03 UTC (rev 206951)
</span><span class="lines">@@ -61,13 +61,8 @@
</span><span class="cx"> 
</span><span class="cx">     using TreeScope::rootNode;
</span><span class="cx"> 
</span><del>-    StyleResolver&amp; styleResolver();
-    StyleResolver* styleResolverIfExists();
</del><span class="cx">     Style::Scope&amp; styleScope();
</span><span class="cx"> 
</span><del>-    void updateStyle();
-    void resetStyleResolver();
-
</del><span class="cx">     bool resetStyleInheritance() const { return m_resetStyleInheritance; }
</span><span class="cx">     void setResetStyleInheritance(bool);
</span><span class="cx"> 
</span><span class="lines">@@ -114,7 +109,6 @@
</span><span class="cx"> 
</span><span class="cx">     Element* m_host { nullptr };
</span><span class="cx"> 
</span><del>-    std::unique_ptr&lt;StyleResolver&gt; m_styleResolver;
</del><span class="cx">     std::unique_ptr&lt;Style::Scope&gt; m_styleScope;
</span><span class="cx"> 
</span><span class="cx">     std::unique_ptr&lt;SlotAssignment&gt; m_slotAssignment;
</span></span></pre></div>
<a id="trunkSourceWebCorepageDOMWindowcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/DOMWindow.cpp (206950 => 206951)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/DOMWindow.cpp        2016-10-08 08:31:00 UTC (rev 206950)
+++ trunk/Source/WebCore/page/DOMWindow.cpp        2016-10-08 08:42:03 UTC (rev 206951)
</span><span class="lines">@@ -1442,7 +1442,7 @@
</span><span class="cx"> 
</span><span class="cx">     PseudoId pseudoId = CSSSelector::pseudoId(pseudoType);
</span><span class="cx"> 
</span><del>-    auto matchedRules = m_frame-&gt;document()-&gt;ensureStyleResolver().pseudoStyleRulesForElement(element, pseudoId, rulesToInclude);
</del><ins>+    auto matchedRules = m_frame-&gt;document()-&gt;styleScope().resolver().pseudoStyleRulesForElement(element, pseudoId, rulesToInclude);
</ins><span class="cx">     if (matchedRules.isEmpty())
</span><span class="cx">         return nullptr;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorepageFrameViewcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/FrameView.cpp (206950 => 206951)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/FrameView.cpp        2016-10-08 08:31:00 UTC (rev 206950)
+++ trunk/Source/WebCore/page/FrameView.cpp        2016-10-08 08:42:03 UTC (rev 206951)
</span><span class="lines">@@ -1332,7 +1332,7 @@
</span><span class="cx">         m_layoutPhase = InPreLayoutStyleUpdate;
</span><span class="cx"> 
</span><span class="cx">         // Viewport-dependent media queries may cause us to need completely different style information.
</span><del>-        StyleResolver* styleResolver = document.styleResolverIfExists();
</del><ins>+        auto* styleResolver = document.styleScope().resolverIfExists();
</ins><span class="cx">         if (!styleResolver || styleResolver-&gt;hasMediaQueriesAffectedByViewportChange()) {
</span><span class="cx">             LOG(Layout, &quot;  hasMediaQueriesAffectedByViewportChange, enqueueing style recalc&quot;);
</span><span class="cx">             document.styleScope().didChangeContentsOrInterpretation();
</span></span></pre></div>
<a id="trunkSourceWebCorepagePagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/Page.cpp (206950 => 206951)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/Page.cpp        2016-10-08 08:31:00 UTC (rev 206950)
+++ trunk/Source/WebCore/page/Page.cpp        2016-10-08 08:42:03 UTC (rev 206951)
</span><span class="lines">@@ -491,7 +491,7 @@
</span><span class="cx">             // the properties cache.
</span><span class="cx">             if (!frame-&gt;document())
</span><span class="cx">                 continue;
</span><del>-            if (StyleResolver* styleResolver = frame-&gt;document()-&gt;styleResolverIfExists())
</del><ins>+            if (StyleResolver* styleResolver = frame-&gt;document()-&gt;styleScope().resolverIfExists())
</ins><span class="cx">                 styleResolver-&gt;invalidateMatchedPropertiesCache();
</span><span class="cx">             frame-&gt;document()-&gt;scheduleForcedStyleRecalc();
</span><span class="cx">         }
</span></span></pre></div>
<a id="trunkSourceWebCorepagePrintContextcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/PrintContext.cpp (206950 => 206951)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/PrintContext.cpp        2016-10-08 08:31:00 UTC (rev 206950)
+++ trunk/Source/WebCore/page/PrintContext.cpp        2016-10-08 08:42:03 UTC (rev 206951)
</span><span class="lines">@@ -27,6 +27,7 @@
</span><span class="cx"> #include &quot;RenderView.h&quot;
</span><span class="cx"> #include &quot;StyleInheritedData.h&quot;
</span><span class="cx"> #include &quot;StyleResolver.h&quot;
</span><ins>+#include &quot;StyleScope.h&quot;
</ins><span class="cx"> #include &lt;wtf/text/WTFString.h&gt;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -251,7 +252,7 @@
</span><span class="cx">     PrintContext printContext(frame);
</span><span class="cx">     printContext.begin(800); // Any width is OK here.
</span><span class="cx">     document-&gt;updateLayout();
</span><del>-    std::unique_ptr&lt;RenderStyle&gt; style = document-&gt;ensureStyleResolver().styleForPage(pageNumber);
</del><ins>+    std::unique_ptr&lt;RenderStyle&gt; style = document-&gt;styleScope().resolver().styleForPage(pageNumber);
</ins><span class="cx"> 
</span><span class="cx">     // Implement formatters for properties we care about.
</span><span class="cx">     if (!strcmp(propertyName, &quot;margin-left&quot;)) {
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformMemoryPressureHandlercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/MemoryPressureHandler.cpp (206950 => 206951)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/MemoryPressureHandler.cpp        2016-10-08 08:31:00 UTC (rev 206950)
+++ trunk/Source/WebCore/platform/MemoryPressureHandler.cpp        2016-10-08 08:42:03 UTC (rev 206951)
</span><span class="lines">@@ -39,6 +39,7 @@
</span><span class="cx"> #include &quot;Page.h&quot;
</span><span class="cx"> #include &quot;PageCache.h&quot;
</span><span class="cx"> #include &quot;ScrollingThread.h&quot;
</span><ins>+#include &quot;StyleScope.h&quot;
</ins><span class="cx"> #include &quot;StyledElement.h&quot;
</span><span class="cx"> #include &quot;WorkerThread.h&quot;
</span><span class="cx"> #include &lt;JavaScriptCore/IncrementalSweeper.h&gt;
</span><span class="lines">@@ -128,7 +129,7 @@
</span><span class="cx">         Vector&lt;RefPtr&lt;Document&gt;&gt; documents;
</span><span class="cx">         copyToVector(Document::allDocuments(), documents);
</span><span class="cx">         for (auto&amp; document : documents)
</span><del>-            document-&gt;clearStyleResolver();
</del><ins>+            document-&gt;styleScope().clearResolver();
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     {
</span></span></pre></div>
<a id="trunkSourceWebCorestyleAttributeChangeInvalidationcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/style/AttributeChangeInvalidation.cpp (206950 => 206951)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/style/AttributeChangeInvalidation.cpp        2016-10-08 08:31:00 UTC (rev 206950)
+++ trunk/Source/WebCore/style/AttributeChangeInvalidation.cpp        2016-10-08 08:42:03 UTC (rev 206951)
</span><span class="lines">@@ -31,6 +31,7 @@
</span><span class="cx"> #include &quot;ShadowRoot.h&quot;
</span><span class="cx"> #include &quot;StyleInvalidationAnalysis.h&quot;
</span><span class="cx"> #include &quot;StyleResolver.h&quot;
</span><ins>+#include &quot;StyleScope.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> namespace Style {
</span><span class="lines">@@ -37,7 +38,7 @@
</span><span class="cx"> 
</span><span class="cx"> static bool mayBeAffectedByHostStyle(ShadowRoot&amp; shadowRoot, bool isHTML, const QualifiedName&amp; attributeName)
</span><span class="cx"> {
</span><del>-    auto&amp; shadowRuleSets = shadowRoot.styleResolver().ruleSets();
</del><ins>+    auto&amp; 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></span></pre></div>
<a id="trunkSourceWebCorestyleClassChangeInvalidationcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/style/ClassChangeInvalidation.cpp (206950 => 206951)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/style/ClassChangeInvalidation.cpp        2016-10-08 08:31:00 UTC (rev 206950)
+++ trunk/Source/WebCore/style/ClassChangeInvalidation.cpp        2016-10-08 08:42:03 UTC (rev 206951)
</span><span class="lines">@@ -32,6 +32,7 @@
</span><span class="cx"> #include &quot;SpaceSplitString.h&quot;
</span><span class="cx"> #include &quot;StyleInvalidationAnalysis.h&quot;
</span><span class="cx"> #include &quot;StyleResolver.h&quot;
</span><ins>+#include &quot;StyleScope.h&quot;
</ins><span class="cx"> #include &lt;wtf/BitVector.h&gt;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -87,7 +88,7 @@
</span><span class="cx"> 
</span><span class="cx"> static bool mayBeAffectedByHostStyle(ShadowRoot&amp; shadowRoot, AtomicStringImpl* changedClass)
</span><span class="cx"> {
</span><del>-    auto&amp; shadowRuleSets = shadowRoot.styleResolver().ruleSets();
</del><ins>+    auto&amp; 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></pre></div>
<a id="trunkSourceWebCorestyleIdChangeInvalidationcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/style/IdChangeInvalidation.cpp (206950 => 206951)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/style/IdChangeInvalidation.cpp        2016-10-08 08:31:00 UTC (rev 206950)
+++ trunk/Source/WebCore/style/IdChangeInvalidation.cpp        2016-10-08 08:42:03 UTC (rev 206951)
</span><span class="lines">@@ -30,6 +30,7 @@
</span><span class="cx"> #include &quot;ElementChildIterator.h&quot;
</span><span class="cx"> #include &quot;ShadowRoot.h&quot;
</span><span class="cx"> #include &quot;StyleResolver.h&quot;
</span><ins>+#include &quot;StyleScope.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> namespace Style {
</span><span class="lines">@@ -36,7 +37,7 @@
</span><span class="cx"> 
</span><span class="cx"> static bool mayBeAffectedByHostStyle(ShadowRoot&amp; shadowRoot, const AtomicString&amp; changedId)
</span><span class="cx"> {
</span><del>-    auto&amp; shadowRuleSets = shadowRoot.styleResolver().ruleSets();
</del><ins>+    auto&amp; 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></span></pre></div>
<a id="trunkSourceWebCorestyleStyleScopecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/style/StyleScope.cpp (206950 => 206951)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/style/StyleScope.cpp        2016-10-08 08:31:00 UTC (rev 206950)
+++ trunk/Source/WebCore/style/StyleScope.cpp        2016-10-08 08:42:03 UTC (rev 206951)
</span><span class="lines">@@ -71,22 +71,34 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-StyleResolver&amp; Scope::styleResolver()
</del><ins>+StyleResolver&amp; Scope::resolver()
</ins><span class="cx"> {
</span><del>-    if (m_shadowRoot)
-        return m_shadowRoot-&gt;styleResolver();
</del><ins>+    if (m_shadowRoot &amp;&amp; m_shadowRoot-&gt;mode() == ShadowRoot::Mode::UserAgent)
+        return m_document.userAgentShadowTreeStyleResolver();
</ins><span class="cx"> 
</span><del>-    return m_document.ensureStyleResolver();
</del><ins>+    if (!m_resolver) {
+        m_resolver = std::make_unique&lt;StyleResolver&gt;(m_document);
+        m_resolver-&gt;appendAuthorStyleSheets(m_activeStyleSheets);
+    }
+    return *m_resolver;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-StyleResolver* Scope::styleResolverIfExists()
</del><ins>+StyleResolver* Scope::resolverIfExists()
</ins><span class="cx"> {
</span><del>-    if (m_shadowRoot)
-        return m_shadowRoot-&gt;styleResolverIfExists();
</del><ins>+    if (m_shadowRoot &amp;&amp; m_shadowRoot-&gt;mode() == ShadowRoot::Mode::UserAgent)
+        return &amp;m_document.userAgentShadowTreeStyleResolver();
</ins><span class="cx"> 
</span><del>-    return m_document.styleResolverIfExists();
</del><ins>+    return m_resolver.get();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void Scope::clearResolver()
+{
+    m_resolver = nullptr;
+
+    if (!m_shadowRoot)
+        m_document.didClearStyleResolver();
+}
+
</ins><span class="cx"> Scope&amp; Scope::forNode(Node&amp; node)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(node.inDocument());
</span><span class="lines">@@ -118,7 +130,8 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (m_shadowRoot) {
</span><del>-        m_shadowRoot-&gt;updateStyle();
</del><ins>+        // FIXME: Make optimized updates work.
+        didChangeContentsOrInterpretation();
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -248,10 +261,10 @@
</span><span class="cx">     
</span><span class="cx">     unsigned newStylesheetCount = newStylesheets.size();
</span><span class="cx"> 
</span><del>-    if (!styleResolverIfExists())
</del><ins>+    if (!resolverIfExists())
</ins><span class="cx">         return Reconstruct;
</span><span class="cx"> 
</span><del>-    StyleResolver&amp; styleResolver = *styleResolverIfExists();
</del><ins>+    auto&amp; styleResolver = *resolverIfExists();
</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">@@ -323,7 +336,7 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (!m_document.hasLivingRenderTree()) {
</span><del>-        m_document.clearStyleResolver();
</del><ins>+        clearResolver();
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -330,7 +343,7 @@
</span><span class="cx">     // Don't bother updating, since we haven't loaded all our style info yet
</span><span class="cx">     // and haven't calculated the style resolver for the first time.
</span><span class="cx">     if (!m_shadowRoot &amp;&amp; !m_didUpdateActiveStyleSheets &amp;&amp; m_pendingStyleSheetCount) {
</span><del>-        m_document.clearStyleResolver();
</del><ins>+        clearResolver();
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -378,13 +391,10 @@
</span><span class="cx"> void Scope::updateStyleResolver(Vector&lt;RefPtr&lt;CSSStyleSheet&gt;&gt;&amp; activeStyleSheets, StyleResolverUpdateType updateType)
</span><span class="cx"> {
</span><span class="cx">     if (updateType == Reconstruct) {
</span><del>-        if (m_shadowRoot)
-            m_shadowRoot-&gt;resetStyleResolver();
-        else
-            m_document.clearStyleResolver();
</del><ins>+        clearResolver();
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><del>-    auto&amp; styleResolver = this-&gt;styleResolver();
</del><ins>+    auto&amp; styleResolver = resolver();
</ins><span class="cx"> 
</span><span class="cx">     if (updateType == Reset) {
</span><span class="cx">         styleResolver.ruleSets().resetAuthorStyle();
</span></span></pre></div>
<a id="trunkSourceWebCorestyleStyleScopeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/style/StyleScope.h (206950 => 206951)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/style/StyleScope.h        2016-10-08 08:31:00 UTC (rev 206950)
+++ trunk/Source/WebCore/style/StyleScope.h        2016-10-08 08:42:03 UTC (rev 206951)
</span><span class="lines">@@ -89,8 +89,9 @@
</span><span class="cx">     bool hasPendingUpdate() const { return !!m_pendingUpdateType; }
</span><span class="cx">     void flushPendingUpdate();
</span><span class="cx"> 
</span><del>-    StyleResolver&amp; styleResolver();
-    StyleResolver* styleResolverIfExists();
</del><ins>+    StyleResolver&amp; resolver();
+    StyleResolver* resolverIfExists();
+    void clearResolver();
</ins><span class="cx"> 
</span><span class="cx">     static Scope&amp; forNode(Node&amp;);
</span><span class="cx"> 
</span><span class="lines">@@ -114,6 +115,8 @@
</span><span class="cx">     Document&amp; m_document;
</span><span class="cx">     ShadowRoot* m_shadowRoot { nullptr };
</span><span class="cx"> 
</span><ins>+    std::unique_ptr&lt;StyleResolver&gt; m_resolver;
+
</ins><span class="cx">     Vector&lt;RefPtr&lt;StyleSheet&gt;&gt; m_styleSheetsForStyleSheetList;
</span><span class="cx">     Vector&lt;RefPtr&lt;CSSStyleSheet&gt;&gt; m_activeStyleSheets;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorestyleStyleSharingResolvercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/style/StyleSharingResolver.cpp (206950 => 206951)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/style/StyleSharingResolver.cpp        2016-10-08 08:31:00 UTC (rev 206950)
+++ trunk/Source/WebCore/style/StyleSharingResolver.cpp        2016-10-08 08:42:03 UTC (rev 206951)
</span><span class="lines">@@ -34,6 +34,7 @@
</span><span class="cx"> #include &quot;RenderStyle.h&quot;
</span><span class="cx"> #include &quot;SVGElement.h&quot;
</span><span class="cx"> #include &quot;ShadowRoot.h&quot;
</span><ins>+#include &quot;StyleScope.h&quot;
</ins><span class="cx"> #include &quot;StyleUpdate.h&quot;
</span><span class="cx"> #include &quot;StyledElement.h&quot;
</span><span class="cx"> #include &quot;VisitedLinkState.h&quot;
</span><span class="lines">@@ -97,7 +98,7 @@
</span><span class="cx">         return nullptr;
</span><span class="cx">     if (elementHasDirectionAuto(element))
</span><span class="cx">         return nullptr;
</span><del>-    if (element.shadowRoot() &amp;&amp; !element.shadowRoot()-&gt;styleResolver().ruleSets().authorStyle().hostPseudoClassRules().isEmpty())
</del><ins>+    if (element.shadowRoot() &amp;&amp; !element.shadowRoot()-&gt;styleScope().resolver().ruleSets().authorStyle().hostPseudoClassRules().isEmpty())
</ins><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><span class="cx">     Context context {
</span><span class="lines">@@ -287,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() &amp;&amp; !element.shadowRoot()-&gt;styleResolver().ruleSets().authorStyle().hostPseudoClassRules().isEmpty())
</del><ins>+    if (element.shadowRoot() &amp;&amp; !element.shadowRoot()-&gt;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>
<a id="trunkSourceWebCorestyleStyleTreeResolvercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/style/StyleTreeResolver.cpp (206950 => 206951)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/style/StyleTreeResolver.cpp        2016-10-08 08:31:00 UTC (rev 206950)
+++ trunk/Source/WebCore/style/StyleTreeResolver.cpp        2016-10-08 08:42:03 UTC (rev 206951)
</span><span class="lines">@@ -83,13 +83,13 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> TreeResolver::Scope::Scope(Document&amp; document)
</span><del>-    : styleResolver(document.ensureStyleResolver())
</del><ins>+    : styleResolver(document.styleScope().resolver())
</ins><span class="cx">     , sharingResolver(document, styleResolver.ruleSets(), selectorFilter)
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> TreeResolver::Scope::Scope(ShadowRoot&amp; shadowRoot, Scope&amp; enclosingScope)
</span><del>-    : styleResolver(shadowRoot.styleResolver())
</del><ins>+    : styleResolver(shadowRoot.styleScope().resolver())
</ins><span class="cx">     , sharingResolver(shadowRoot.documentScope(), styleResolver.ruleSets(), selectorFilter)
</span><span class="cx">     , shadowRoot(&amp;shadowRoot)
</span><span class="cx">     , enclosingScope(&amp;enclosingScope)
</span><span class="lines">@@ -440,7 +440,7 @@
</span><span class="cx"> 
</span><span class="cx">     Element* documentElement = m_document.documentElement();
</span><span class="cx">     if (!documentElement) {
</span><del>-        m_document.ensureStyleResolver();
</del><ins>+        m_document.styleScope().resolver();
</ins><span class="cx">         return nullptr;
</span><span class="cx">     }
</span><span class="cx">     if (change != Force &amp;&amp; !documentElement-&gt;childNeedsStyleRecalc() &amp;&amp; !documentElement-&gt;needsStyleRecalc())
</span></span></pre>
</div>
</div>

</body>
</html>