<!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>[206917] trunk/Source</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/206917">206917</a></dd>
<dt>Author</dt> <dd>antti@apple.com</dd>
<dt>Date</dt> <dd>2016-10-07 09:55:11 -0700 (Fri, 07 Oct 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Rename AuthorStyleSheets to Style::Scope
https://bugs.webkit.org/show_bug.cgi?id=163108

Reviewed by Andreas Kling.

It represents the style scope in DOM.
Also move the file under style/.

* CMakeLists.txt:
* WebCore.xcodeproj/project.pbxproj:
* css/CSSStyleSheet.cpp:
(WebCore::CSSStyleSheet::styleSheetScope):
* css/CSSStyleSheet.h:
* css/InspectorCSSOMWrappers.cpp:
(WebCore::InspectorCSSOMWrappers::getWrapperForRuleInSheets):
* css/InspectorCSSOMWrappers.h:
* css/StyleSheetList.cpp:
(WebCore::StyleSheetList::styleSheets):
(WebCore::StyleSheetList::detachFromDocument):
* dom/AuthorStyleSheets.cpp: Removed.
* dom/AuthorStyleSheets.h: Removed.
* dom/Document.cpp:
(WebCore::Document::Document):
(WebCore::Document::setContentLanguage):
(WebCore::Document::recalcStyle):
(WebCore::Document::needsStyleRecalc):
(WebCore::Document::updateStyleIfNeeded):
(WebCore::Document::updateLayoutIgnorePendingStylesheets):
(WebCore::Document::createStyleResolver):
(WebCore::Document::didRemoveAllPendingStylesheet):
(WebCore::Document::usesStyleBasedEditability):
(WebCore::Document::processHttpEquiv):
(WebCore::Document::preferredStylesheetSet):
(WebCore::Document::selectedStylesheetSet):
(WebCore::Document::setSelectedStylesheetSet):
(WebCore::Document::haveStylesheetsLoaded):
* dom/Document.h:
(WebCore::Document::styleScope):
(WebCore::Document::authorStyleSheets): Deleted.
* dom/ExtensionStyleSheets.cpp:
(WebCore::ExtensionStyleSheets::clearPageUserSheet):
(WebCore::ExtensionStyleSheets::updatePageUserSheet):
(WebCore::ExtensionStyleSheets::invalidateInjectedStyleSheetCache):
(WebCore::ExtensionStyleSheets::addUserStyleSheet):
(WebCore::ExtensionStyleSheets::addAuthorStyleSheetForTesting):
(WebCore::ExtensionStyleSheets::styleResolverChangedTimerFired):
* dom/InlineStyleSheetOwner.cpp:
(WebCore::InlineStyleSheetOwner::insertedIntoDocument):
(WebCore::InlineStyleSheetOwner::removedFromDocument):
(WebCore::InlineStyleSheetOwner::clearDocumentData):
(WebCore::InlineStyleSheetOwner::createSheet):
(WebCore::InlineStyleSheetOwner::sheetLoaded):
(WebCore::InlineStyleSheetOwner::startLoadingDynamicSheet):
* dom/InlineStyleSheetOwner.h:
(WebCore::InlineStyleSheetOwner::styleScope):
(WebCore::InlineStyleSheetOwner::styleSheetScope): Deleted.
* dom/ProcessingInstruction.cpp:
(WebCore::ProcessingInstruction::~ProcessingInstruction):
(WebCore::ProcessingInstruction::checkStyleSheet):
(WebCore::ProcessingInstruction::sheetLoaded):
(WebCore::ProcessingInstruction::insertedInto):
(WebCore::ProcessingInstruction::removedFrom):
* dom/ShadowRoot.cpp:
(WebCore::ShadowRoot::styleResolver):
(WebCore::ShadowRoot::styleScope):
(WebCore::ShadowRoot::updateStyle):
(WebCore::ShadowRoot::authorStyleSheets): Deleted.
* dom/ShadowRoot.h:
* html/HTMLLinkElement.cpp:
(WebCore::HTMLLinkElement::~HTMLLinkElement):
(WebCore::HTMLLinkElement::setDisabledState):
(WebCore::HTMLLinkElement::parseAttribute):
(WebCore::HTMLLinkElement::process):
(WebCore::HTMLLinkElement::insertedInto):
(WebCore::HTMLLinkElement::removedFrom):
(WebCore::HTMLLinkElement::addPendingSheet):
(WebCore::HTMLLinkElement::removePendingSheet):
* html/HTMLStyleElement.cpp:
* inspector/InspectorCSSAgent.cpp:
(WebCore::InspectorCSSAgent::collectAllDocumentStyleSheets):
(WebCore::InspectorCSSAgent::forcePseudoState):
(WebCore::InspectorCSSAgent::buildObjectForRule):
(WebCore::InspectorCSSAgent::resetPseudoStates):
* inspector/InspectorPageAgent.cpp:
(WebCore::InspectorPageAgent::setEmulatedMedia):
* page/DOMWindow.cpp:
(WebCore::DOMWindow::getMatchedCSSRules):
* page/Frame.cpp:
(WebCore::Frame::setPrinting):
* page/FrameView.cpp:
(WebCore::FrameView::layout):
(WebCore::FrameView::setPagination):
(WebCore::FrameView::setViewportSizeForCSSViewportUnits):
* page/Page.cpp:
(WebCore::Page::setViewMode):
(WebCore::Page::setNeedsRecalcStyleInAllFrames):
(WebCore::Page::invalidateInjectedStyleSheetCacheInAllFrames):
* style/StyleScope.cpp: Copied from dom/AuthorStyleSheets.cpp.
(WebCore::Style::Scope::Scope):
(WebCore::Style::Scope::styleResolver):
(WebCore::Style::Scope::styleResolverIfExists):
(WebCore::Style::Scope::forNode):
(WebCore::Style::Scope::removePendingSheet):
(WebCore::Style::Scope::addStyleSheetCandidateNode):
(WebCore::Style::Scope::removeStyleSheetCandidateNode):
(WebCore::Style::Scope::collectActiveStyleSheets):
(WebCore::Style::Scope::analyzeStyleSheetChange):
(WebCore::Style::Scope::updateActiveStyleSheets):
(WebCore::Style::Scope::updateStyleResolver):
(WebCore::Style::Scope::activeStyleSheetsForInspector):
(WebCore::Style::Scope::activeStyleSheetsContains):
(WebCore::Style::Scope::flushPendingUpdate):
(WebCore::Style::Scope::clearPendingUpdate):
(WebCore::Style::Scope::scheduleActiveSetUpdate):
(WebCore::Style::Scope::didChangeCandidatesForActiveSet):
(WebCore::Style::Scope::didChangeContentsOrInterpretation):
(WebCore::Style::Scope::pendingUpdateTimerFired):
(WebCore::AuthorStyleSheets::AuthorStyleSheets): Deleted.
(WebCore::AuthorStyleSheets::styleResolver): Deleted.
(WebCore::AuthorStyleSheets::styleResolverIfExists): Deleted.
(WebCore::AuthorStyleSheets::forNode): Deleted.
(WebCore::AuthorStyleSheets::removePendingSheet): Deleted.
(WebCore::AuthorStyleSheets::addStyleSheetCandidateNode): Deleted.
(WebCore::AuthorStyleSheets::removeStyleSheetCandidateNode): Deleted.
(WebCore::AuthorStyleSheets::collectActiveStyleSheets): Deleted.
(WebCore::AuthorStyleSheets::analyzeStyleSheetChange): Deleted.
(WebCore::AuthorStyleSheets::updateActiveStyleSheets): Deleted.
(WebCore::AuthorStyleSheets::updateStyleResolver): Deleted.
(WebCore::AuthorStyleSheets::activeStyleSheetsForInspector): Deleted.
(WebCore::AuthorStyleSheets::activeStyleSheetsContains): Deleted.
(WebCore::AuthorStyleSheets::flushPendingUpdate): Deleted.
(WebCore::AuthorStyleSheets::clearPendingUpdate): Deleted.
(WebCore::AuthorStyleSheets::scheduleActiveSetUpdate): Deleted.
(WebCore::AuthorStyleSheets::didChangeCandidatesForActiveSet): Deleted.
(WebCore::AuthorStyleSheets::didChangeContentsOrInterpretation): Deleted.
(WebCore::AuthorStyleSheets::pendingUpdateTimerFired): Deleted.
* style/StyleScope.h: Copied from dom/AuthorStyleSheets.h.
* style/StyleTreeResolver.cpp:
* svg/SVGFontFaceElement.cpp:
(WebCore::SVGFontFaceElement::rebuildFontFace):
(WebCore::SVGFontFaceElement::removedFrom):
* xml/XMLTreeViewer.cpp:
(WebCore::XMLTreeViewer::transformDocumentToTreeView):
* xml/parser/XMLDocumentParser.cpp:
(WebCore::XMLDocumentParser::end):
* xml/parser/XMLDocumentParserLibxml2.cpp:
(WebCore::XMLDocumentParser::doEnd):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreCMakeListstxt">trunk/Source/WebCore/CMakeLists.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</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="#trunkSourceWebCorecssInspectorCSSOMWrapperscpp">trunk/Source/WebCore/css/InspectorCSSOMWrappers.cpp</a></li>
<li><a href="#trunkSourceWebCorecssInspectorCSSOMWrappersh">trunk/Source/WebCore/css/InspectorCSSOMWrappers.h</a></li>
<li><a href="#trunkSourceWebCorecssStyleSheetListcpp">trunk/Source/WebCore/css/StyleSheetList.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="#trunkSourceWebCoredomExtensionStyleSheetscpp">trunk/Source/WebCore/dom/ExtensionStyleSheets.cpp</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="#trunkSourceWebCoredomProcessingInstructioncpp">trunk/Source/WebCore/dom/ProcessingInstruction.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="#trunkSourceWebCorehtmlHTMLLinkElementcpp">trunk/Source/WebCore/html/HTMLLinkElement.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLStyleElementcpp">trunk/Source/WebCore/html/HTMLStyleElement.cpp</a></li>
<li><a href="#trunkSourceWebCoreinspectorInspectorCSSAgentcpp">trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp</a></li>
<li><a href="#trunkSourceWebCoreinspectorInspectorPageAgentcpp">trunk/Source/WebCore/inspector/InspectorPageAgent.cpp</a></li>
<li><a href="#trunkSourceWebCorepageDOMWindowcpp">trunk/Source/WebCore/page/DOMWindow.cpp</a></li>
<li><a href="#trunkSourceWebCorepageFramecpp">trunk/Source/WebCore/page/Frame.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="#trunkSourceWebCorestyleStyleTreeResolvercpp">trunk/Source/WebCore/style/StyleTreeResolver.cpp</a></li>
<li><a href="#trunkSourceWebCoresvgSVGFontFaceElementcpp">trunk/Source/WebCore/svg/SVGFontFaceElement.cpp</a></li>
<li><a href="#trunkSourceWebCorexmlXMLTreeViewercpp">trunk/Source/WebCore/xml/XMLTreeViewer.cpp</a></li>
<li><a href="#trunkSourceWebCorexmlparserXMLDocumentParsercpp">trunk/Source/WebCore/xml/parser/XMLDocumentParser.cpp</a></li>
<li><a href="#trunkSourceWebCorexmlparserXMLDocumentParserLibxml2cpp">trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp</a></li>
<li><a href="#trunkSourceWebKitmacWebViewWebHTMLViewmm">trunk/Source/WebKit/mac/WebView/WebHTMLView.mm</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCorestyleStyleScopecpp">trunk/Source/WebCore/style/StyleScope.cpp</a></li>
<li><a href="#trunkSourceWebCorestyleStyleScopeh">trunk/Source/WebCore/style/StyleScope.h</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoredomAuthorStyleSheetscpp">trunk/Source/WebCore/dom/AuthorStyleSheets.cpp</a></li>
<li><a href="#trunkSourceWebCoredomAuthorStyleSheetsh">trunk/Source/WebCore/dom/AuthorStyleSheets.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/CMakeLists.txt (206916 => 206917)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/CMakeLists.txt        2016-10-07 16:41:48 UTC (rev 206916)
+++ trunk/Source/WebCore/CMakeLists.txt        2016-10-07 16:55:11 UTC (rev 206917)
</span><span class="lines">@@ -1384,7 +1384,6 @@
</span><span class="cx">     dom/ActiveDOMObject.cpp
</span><span class="cx">     dom/AnimationEvent.cpp
</span><span class="cx">     dom/Attr.cpp
</span><del>-    dom/AuthorStyleSheets.cpp
</del><span class="cx">     dom/BeforeTextInsertedEvent.cpp
</span><span class="cx">     dom/BeforeUnloadEvent.cpp
</span><span class="cx">     dom/CDATASection.cpp
</span><span class="lines">@@ -2650,6 +2649,7 @@
</span><span class="cx">     style/StylePendingResources.cpp
</span><span class="cx">     style/StyleRelations.cpp
</span><span class="cx">     style/StyleResolveForDocument.cpp
</span><ins>+    style/StyleScope.cpp
</ins><span class="cx">     style/StyleSharingResolver.cpp
</span><span class="cx">     style/StyleTreeResolver.cpp
</span><span class="cx">     style/StyleUpdate.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (206916 => 206917)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-10-07 16:41:48 UTC (rev 206916)
+++ trunk/Source/WebCore/ChangeLog        2016-10-07 16:55:11 UTC (rev 206917)
</span><span class="lines">@@ -1,3 +1,153 @@
</span><ins>+2016-10-07  Antti Koivisto  &lt;antti@apple.com&gt;
+
+        Rename AuthorStyleSheets to Style::Scope
+        https://bugs.webkit.org/show_bug.cgi?id=163108
+
+        Reviewed by Andreas Kling.
+
+        It represents the style scope in DOM.
+        Also move the file under style/.
+
+        * CMakeLists.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * css/CSSStyleSheet.cpp:
+        (WebCore::CSSStyleSheet::styleSheetScope):
+        * css/CSSStyleSheet.h:
+        * css/InspectorCSSOMWrappers.cpp:
+        (WebCore::InspectorCSSOMWrappers::getWrapperForRuleInSheets):
+        * css/InspectorCSSOMWrappers.h:
+        * css/StyleSheetList.cpp:
+        (WebCore::StyleSheetList::styleSheets):
+        (WebCore::StyleSheetList::detachFromDocument):
+        * dom/AuthorStyleSheets.cpp: Removed.
+        * dom/AuthorStyleSheets.h: Removed.
+        * dom/Document.cpp:
+        (WebCore::Document::Document):
+        (WebCore::Document::setContentLanguage):
+        (WebCore::Document::recalcStyle):
+        (WebCore::Document::needsStyleRecalc):
+        (WebCore::Document::updateStyleIfNeeded):
+        (WebCore::Document::updateLayoutIgnorePendingStylesheets):
+        (WebCore::Document::createStyleResolver):
+        (WebCore::Document::didRemoveAllPendingStylesheet):
+        (WebCore::Document::usesStyleBasedEditability):
+        (WebCore::Document::processHttpEquiv):
+        (WebCore::Document::preferredStylesheetSet):
+        (WebCore::Document::selectedStylesheetSet):
+        (WebCore::Document::setSelectedStylesheetSet):
+        (WebCore::Document::haveStylesheetsLoaded):
+        * dom/Document.h:
+        (WebCore::Document::styleScope):
+        (WebCore::Document::authorStyleSheets): Deleted.
+        * dom/ExtensionStyleSheets.cpp:
+        (WebCore::ExtensionStyleSheets::clearPageUserSheet):
+        (WebCore::ExtensionStyleSheets::updatePageUserSheet):
+        (WebCore::ExtensionStyleSheets::invalidateInjectedStyleSheetCache):
+        (WebCore::ExtensionStyleSheets::addUserStyleSheet):
+        (WebCore::ExtensionStyleSheets::addAuthorStyleSheetForTesting):
+        (WebCore::ExtensionStyleSheets::styleResolverChangedTimerFired):
+        * dom/InlineStyleSheetOwner.cpp:
+        (WebCore::InlineStyleSheetOwner::insertedIntoDocument):
+        (WebCore::InlineStyleSheetOwner::removedFromDocument):
+        (WebCore::InlineStyleSheetOwner::clearDocumentData):
+        (WebCore::InlineStyleSheetOwner::createSheet):
+        (WebCore::InlineStyleSheetOwner::sheetLoaded):
+        (WebCore::InlineStyleSheetOwner::startLoadingDynamicSheet):
+        * dom/InlineStyleSheetOwner.h:
+        (WebCore::InlineStyleSheetOwner::styleScope):
+        (WebCore::InlineStyleSheetOwner::styleSheetScope): Deleted.
+        * dom/ProcessingInstruction.cpp:
+        (WebCore::ProcessingInstruction::~ProcessingInstruction):
+        (WebCore::ProcessingInstruction::checkStyleSheet):
+        (WebCore::ProcessingInstruction::sheetLoaded):
+        (WebCore::ProcessingInstruction::insertedInto):
+        (WebCore::ProcessingInstruction::removedFrom):
+        * dom/ShadowRoot.cpp:
+        (WebCore::ShadowRoot::styleResolver):
+        (WebCore::ShadowRoot::styleScope):
+        (WebCore::ShadowRoot::updateStyle):
+        (WebCore::ShadowRoot::authorStyleSheets): Deleted.
+        * dom/ShadowRoot.h:
+        * html/HTMLLinkElement.cpp:
+        (WebCore::HTMLLinkElement::~HTMLLinkElement):
+        (WebCore::HTMLLinkElement::setDisabledState):
+        (WebCore::HTMLLinkElement::parseAttribute):
+        (WebCore::HTMLLinkElement::process):
+        (WebCore::HTMLLinkElement::insertedInto):
+        (WebCore::HTMLLinkElement::removedFrom):
+        (WebCore::HTMLLinkElement::addPendingSheet):
+        (WebCore::HTMLLinkElement::removePendingSheet):
+        * html/HTMLStyleElement.cpp:
+        * inspector/InspectorCSSAgent.cpp:
+        (WebCore::InspectorCSSAgent::collectAllDocumentStyleSheets):
+        (WebCore::InspectorCSSAgent::forcePseudoState):
+        (WebCore::InspectorCSSAgent::buildObjectForRule):
+        (WebCore::InspectorCSSAgent::resetPseudoStates):
+        * inspector/InspectorPageAgent.cpp:
+        (WebCore::InspectorPageAgent::setEmulatedMedia):
+        * page/DOMWindow.cpp:
+        (WebCore::DOMWindow::getMatchedCSSRules):
+        * page/Frame.cpp:
+        (WebCore::Frame::setPrinting):
+        * page/FrameView.cpp:
+        (WebCore::FrameView::layout):
+        (WebCore::FrameView::setPagination):
+        (WebCore::FrameView::setViewportSizeForCSSViewportUnits):
+        * page/Page.cpp:
+        (WebCore::Page::setViewMode):
+        (WebCore::Page::setNeedsRecalcStyleInAllFrames):
+        (WebCore::Page::invalidateInjectedStyleSheetCacheInAllFrames):
+        * style/StyleScope.cpp: Copied from dom/AuthorStyleSheets.cpp.
+        (WebCore::Style::Scope::Scope):
+        (WebCore::Style::Scope::styleResolver):
+        (WebCore::Style::Scope::styleResolverIfExists):
+        (WebCore::Style::Scope::forNode):
+        (WebCore::Style::Scope::removePendingSheet):
+        (WebCore::Style::Scope::addStyleSheetCandidateNode):
+        (WebCore::Style::Scope::removeStyleSheetCandidateNode):
+        (WebCore::Style::Scope::collectActiveStyleSheets):
+        (WebCore::Style::Scope::analyzeStyleSheetChange):
+        (WebCore::Style::Scope::updateActiveStyleSheets):
+        (WebCore::Style::Scope::updateStyleResolver):
+        (WebCore::Style::Scope::activeStyleSheetsForInspector):
+        (WebCore::Style::Scope::activeStyleSheetsContains):
+        (WebCore::Style::Scope::flushPendingUpdate):
+        (WebCore::Style::Scope::clearPendingUpdate):
+        (WebCore::Style::Scope::scheduleActiveSetUpdate):
+        (WebCore::Style::Scope::didChangeCandidatesForActiveSet):
+        (WebCore::Style::Scope::didChangeContentsOrInterpretation):
+        (WebCore::Style::Scope::pendingUpdateTimerFired):
+        (WebCore::AuthorStyleSheets::AuthorStyleSheets): Deleted.
+        (WebCore::AuthorStyleSheets::styleResolver): Deleted.
+        (WebCore::AuthorStyleSheets::styleResolverIfExists): Deleted.
+        (WebCore::AuthorStyleSheets::forNode): Deleted.
+        (WebCore::AuthorStyleSheets::removePendingSheet): Deleted.
+        (WebCore::AuthorStyleSheets::addStyleSheetCandidateNode): Deleted.
+        (WebCore::AuthorStyleSheets::removeStyleSheetCandidateNode): Deleted.
+        (WebCore::AuthorStyleSheets::collectActiveStyleSheets): Deleted.
+        (WebCore::AuthorStyleSheets::analyzeStyleSheetChange): Deleted.
+        (WebCore::AuthorStyleSheets::updateActiveStyleSheets): Deleted.
+        (WebCore::AuthorStyleSheets::updateStyleResolver): Deleted.
+        (WebCore::AuthorStyleSheets::activeStyleSheetsForInspector): Deleted.
+        (WebCore::AuthorStyleSheets::activeStyleSheetsContains): Deleted.
+        (WebCore::AuthorStyleSheets::flushPendingUpdate): Deleted.
+        (WebCore::AuthorStyleSheets::clearPendingUpdate): Deleted.
+        (WebCore::AuthorStyleSheets::scheduleActiveSetUpdate): Deleted.
+        (WebCore::AuthorStyleSheets::didChangeCandidatesForActiveSet): Deleted.
+        (WebCore::AuthorStyleSheets::didChangeContentsOrInterpretation): Deleted.
+        (WebCore::AuthorStyleSheets::pendingUpdateTimerFired): Deleted.
+        * style/StyleScope.h: Copied from dom/AuthorStyleSheets.h.
+        * style/StyleTreeResolver.cpp:
+        * svg/SVGFontFaceElement.cpp:
+        (WebCore::SVGFontFaceElement::rebuildFontFace):
+        (WebCore::SVGFontFaceElement::removedFrom):
+        * xml/XMLTreeViewer.cpp:
+        (WebCore::XMLTreeViewer::transformDocumentToTreeView):
+        * xml/parser/XMLDocumentParser.cpp:
+        (WebCore::XMLDocumentParser::end):
+        * xml/parser/XMLDocumentParserLibxml2.cpp:
+        (WebCore::XMLDocumentParser::doEnd):
+
</ins><span class="cx"> 2016-10-07  Zalan Bujtas  &lt;zalan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         https://vuldb.com/?cvssv3.2012 takes long time to load.
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (206916 => 206917)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-10-07 16:41:48 UTC (rev 206916)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-10-07 16:55:11 UTC (rev 206917)
</span><span class="lines">@@ -6212,8 +6212,8 @@
</span><span class="cx">                 E461802B1C8A06D90026C02C /* RenderTreeUpdater.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E461802A1C8A06D90026C02C /* RenderTreeUpdater.cpp */; };
</span><span class="cx">                 E461802D1C8DD2900026C02C /* StyleRelations.h in Headers */ = {isa = PBXBuildFile; fileRef = E461802C1C8DD2900026C02C /* StyleRelations.h */; };
</span><span class="cx">                 E461802F1C8DD4D20026C02C /* StyleRelations.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E461802E1C8DD4D20026C02C /* StyleRelations.cpp */; };
</span><del>-                E461D65D1BB0C7F000CB5645 /* AuthorStyleSheets.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E461D65C1BB0C7F000CB5645 /* AuthorStyleSheets.cpp */; };
-                E461D65F1BB0C80D00CB5645 /* AuthorStyleSheets.h in Headers */ = {isa = PBXBuildFile; fileRef = E461D65E1BB0C80D00CB5645 /* AuthorStyleSheets.h */; settings = {ATTRIBUTES = (Private, ); }; };
</del><ins>+                E461D65D1BB0C7F000CB5645 /* StyleScope.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E461D65C1BB0C7F000CB5645 /* StyleScope.cpp */; };
+                E461D65F1BB0C80D00CB5645 /* StyleScope.h in Headers */ = {isa = PBXBuildFile; fileRef = E461D65E1BB0C80D00CB5645 /* StyleScope.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">                 E462A4A1113E71BE004A4220 /* IntPointHash.h in Headers */ = {isa = PBXBuildFile; fileRef = E462A4A0113E71BE004A4220 /* IntPointHash.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 E46A2B1C17CA65B9000DBCD8 /* TypedElementDescendantIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = E46A2B1B17CA65B9000DBCD8 /* TypedElementDescendantIterator.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 E46A2B1E17CA76B1000DBCD8 /* ElementChildIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = E46A2B1D17CA76B1000DBCD8 /* ElementChildIterator.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -13828,8 +13828,8 @@
</span><span class="cx">                 E461802A1C8A06D90026C02C /* RenderTreeUpdater.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderTreeUpdater.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 E461802C1C8DD2900026C02C /* StyleRelations.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleRelations.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 E461802E1C8DD4D20026C02C /* StyleRelations.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StyleRelations.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><del>-                E461D65C1BB0C7F000CB5645 /* AuthorStyleSheets.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AuthorStyleSheets.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
-                E461D65E1BB0C80D00CB5645 /* AuthorStyleSheets.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AuthorStyleSheets.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</del><ins>+                E461D65C1BB0C7F000CB5645 /* StyleScope.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StyleScope.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                E461D65E1BB0C80D00CB5645 /* StyleScope.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleScope.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 E462A4A0113E71BE004A4220 /* IntPointHash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IntPointHash.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 E46A2B1B17CA65B9000DBCD8 /* TypedElementDescendantIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TypedElementDescendantIterator.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 E46A2B1D17CA76B1000DBCD8 /* ElementChildIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ElementChildIterator.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -22326,6 +22326,8 @@
</span><span class="cx">                                 E461802C1C8DD2900026C02C /* StyleRelations.h */,
</span><span class="cx">                                 E4D58EB217B4DBDC00CBDCA8 /* StyleResolveForDocument.cpp */,
</span><span class="cx">                                 E4D58EB317B4DBDC00CBDCA8 /* StyleResolveForDocument.h */,
</span><ins>+                                E461D65C1BB0C7F000CB5645 /* StyleScope.cpp */,
+                                E461D65E1BB0C80D00CB5645 /* StyleScope.h */,
</ins><span class="cx">                                 E47A3AC21C5EABBE00CCBFA7 /* StyleSharingResolver.cpp */,
</span><span class="cx">                                 E47A3AC41C5EAC7900CCBFA7 /* StyleSharingResolver.h */,
</span><span class="cx">                                 E4DEAA1517A93DC3000E0430 /* StyleTreeResolver.cpp */,
</span><span class="lines">@@ -22962,8 +22964,6 @@
</span><span class="cx">                                 A8C4A7FB09D563270003AC8D /* Attr.h */,
</span><span class="cx">                                 93EEC1E509C2877700C515D1 /* Attr.idl */,
</span><span class="cx">                                 A8C4A7F909D563270003AC8D /* Attribute.h */,
</span><del>-                                E461D65C1BB0C7F000CB5645 /* AuthorStyleSheets.cpp */,
-                                E461D65E1BB0C80D00CB5645 /* AuthorStyleSheets.h */,
</del><span class="cx">                                 760847CD19A6A27700428CCC /* AutocompleteErrorEvent.h */,
</span><span class="cx">                                 760847CF19A6A28600428CCC /* AutocompleteErrorEvent.idl */,
</span><span class="cx">                                 BC9462D7107A7B4C00857193 /* BeforeLoadEvent.h */,
</span><span class="lines">@@ -23925,7 +23925,7 @@
</span><span class="cx">                                 0704A4081D6DE9F10086DCDB /* OverconstrainedError.h in Headers */,
</span><span class="cx">                                 E124748410AA161D00B79493 /* AuthenticationClient.h in Headers */,
</span><span class="cx">                                 514C764C0CE9234E007EF3CD /* AuthenticationMac.h in Headers */,
</span><del>-                                E461D65F1BB0C80D00CB5645 /* AuthorStyleSheets.h in Headers */,
</del><ins>+                                E461D65F1BB0C80D00CB5645 /* StyleScope.h in Headers */,
</ins><span class="cx">                                 A501920E132EBF2E008BFE55 /* Autocapitalize.h in Headers */,
</span><span class="cx">                                 760847CE19A6A27800428CCC /* AutocompleteErrorEvent.h in Headers */,
</span><span class="cx">                                 7C1843FE1C8B7283002EB973 /* Autofill.h in Headers */,
</span><span class="lines">@@ -27690,7 +27690,7 @@
</span><span class="cx">                                 7EE6845F12D26E3800E79415 /* AuthenticationCF.cpp in Sources */,
</span><span class="cx">                                 934F71380D5A6EFF00018D69 /* AuthenticationChallengeBase.cpp in Sources */,
</span><span class="cx">                                 514C764D0CE9234E007EF3CD /* AuthenticationMac.mm in Sources */,
</span><del>-                                E461D65D1BB0C7F000CB5645 /* AuthorStyleSheets.cpp in Sources */,
</del><ins>+                                E461D65D1BB0C7F000CB5645 /* StyleScope.cpp in Sources */,
</ins><span class="cx">                                 A5F6E16B132ED46E008EDAE3 /* Autocapitalize.cpp in Sources */,
</span><span class="cx">                                 5597F8261D91C3130066BC21 /* ImageFrameCache.cpp in Sources */,
</span><span class="cx">                                 7C1843FD1C8B7283002EB973 /* Autofill.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSStyleSheetcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSStyleSheet.cpp (206916 => 206917)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSStyleSheet.cpp        2016-10-07 16:41:48 UTC (rev 206916)
+++ trunk/Source/WebCore/css/CSSStyleSheet.cpp        2016-10-07 16:55:11 UTC (rev 206917)
</span><span class="lines">@@ -21,7 +21,6 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;CSSStyleSheet.h&quot;
</span><span class="cx"> 
</span><del>-#include &quot;AuthorStyleSheets.h&quot;
</del><span class="cx"> #include &quot;CSSCharsetRule.h&quot;
</span><span class="cx"> #include &quot;CSSFontFaceRule.h&quot;
</span><span class="cx"> #include &quot;CSSImportRule.h&quot;
</span><span class="lines">@@ -44,7 +43,9 @@
</span><span class="cx"> #include &quot;ShadowRoot.h&quot;
</span><span class="cx"> #include &quot;StyleResolver.h&quot;
</span><span class="cx"> #include &quot;StyleRule.h&quot;
</span><ins>+#include &quot;StyleScope.h&quot;
</ins><span class="cx"> #include &quot;StyleSheetContents.h&quot;
</span><ins>+
</ins><span class="cx"> #include &lt;wtf/text/StringBuilder.h&gt;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -170,7 +171,7 @@
</span><span class="cx">     ASSERT(m_contents-&gt;isMutable());
</span><span class="cx">     ASSERT(m_contents-&gt;hasOneClient());
</span><span class="cx"> 
</span><del>-    auto* scope = styleSheetScope();
</del><ins>+    auto* scope = styleScope();
</ins><span class="cx">     if (!scope)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="lines">@@ -191,7 +192,7 @@
</span><span class="cx"> 
</span><span class="cx"> void CSSStyleSheet::didMutate()
</span><span class="cx"> {
</span><del>-    auto* scope = styleSheetScope();
</del><ins>+    auto* scope = styleScope();
</ins><span class="cx">     if (!scope)
</span><span class="cx">         return;
</span><span class="cx">     scope-&gt;didChangeContentsOrInterpretation();
</span><span class="lines">@@ -415,12 +416,12 @@
</span><span class="cx">     return root.ownerNode() ? &amp;root.ownerNode()-&gt;document() : nullptr;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-AuthorStyleSheets* CSSStyleSheet::styleSheetScope()
</del><ins>+Style::Scope* CSSStyleSheet::styleScope()
</ins><span class="cx"> {
</span><span class="cx">     auto* ownerNode = rootStyleSheet().ownerNode();
</span><span class="cx">     if (!ownerNode)
</span><span class="cx">         return nullptr;
</span><del>-    return &amp;AuthorStyleSheets::forNode(*ownerNode);
</del><ins>+    return &amp;Style::Scope::forNode(*ownerNode);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void CSSStyleSheet::clearChildRuleCSSOMWrappers()
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSStyleSheeth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSStyleSheet.h (206916 => 206917)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSStyleSheet.h        2016-10-07 16:41:48 UTC (rev 206916)
+++ trunk/Source/WebCore/css/CSSStyleSheet.h        2016-10-07 16:55:11 UTC (rev 206917)
</span><span class="lines">@@ -31,7 +31,6 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-class AuthorStyleSheets;
</del><span class="cx"> class CSSCharsetRule;
</span><span class="cx"> class CSSImportRule;
</span><span class="cx"> class CSSParser;
</span><span class="lines">@@ -45,6 +44,10 @@
</span><span class="cx"> class StyleRuleKeyframes;
</span><span class="cx"> class StyleSheetContents;
</span><span class="cx"> 
</span><ins>+namespace Style {
+class Scope;
+}
+
</ins><span class="cx"> typedef int ExceptionCode;
</span><span class="cx"> 
</span><span class="cx"> class CSSStyleSheet final : public StyleSheet {
</span><span class="lines">@@ -87,7 +90,7 @@
</span><span class="cx">     Document* ownerDocument() const;
</span><span class="cx">     CSSStyleSheet&amp; rootStyleSheet();
</span><span class="cx">     const CSSStyleSheet&amp; rootStyleSheet() const;
</span><del>-    AuthorStyleSheets* styleSheetScope();
</del><ins>+    Style::Scope* styleScope();
</ins><span class="cx"> 
</span><span class="cx">     MediaQuerySet* mediaQueries() const { return m_mediaQueries.get(); }
</span><span class="cx">     void setMediaQueries(Ref&lt;MediaQuerySet&gt;&amp;&amp;);
</span></span></pre></div>
<a id="trunkSourceWebCorecssInspectorCSSOMWrapperscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/InspectorCSSOMWrappers.cpp (206916 => 206917)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/InspectorCSSOMWrappers.cpp        2016-10-07 16:41:48 UTC (rev 206916)
+++ trunk/Source/WebCore/css/InspectorCSSOMWrappers.cpp        2016-10-07 16:55:11 UTC (rev 206917)
</span><span class="lines">@@ -29,7 +29,6 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;InspectorCSSOMWrappers.h&quot;
</span><span class="cx"> 
</span><del>-#include &quot;AuthorStyleSheets.h&quot;
</del><span class="cx"> #include &quot;CSSDefaultStyleSheets.h&quot;
</span><span class="cx"> #include &quot;CSSImportRule.h&quot;
</span><span class="cx"> #include &quot;CSSMediaRule.h&quot;
</span><span class="lines">@@ -38,6 +37,7 @@
</span><span class="cx"> #include &quot;CSSStyleSheet.h&quot;
</span><span class="cx"> #include &quot;CSSSupportsRule.h&quot;
</span><span class="cx"> #include &quot;ExtensionStyleSheets.h&quot;
</span><ins>+#include &quot;StyleScope.h&quot;
</ins><span class="cx"> #include &quot;StyleSheetContents.h&quot;
</span><span class="cx"> #include &quot;WebKitCSSRegionRule.h&quot;
</span><span class="cx"> 
</span><span class="lines">@@ -96,7 +96,7 @@
</span><span class="cx">         collect(sheets[i].get());
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-CSSStyleRule* InspectorCSSOMWrappers::getWrapperForRuleInSheets(StyleRule* rule, AuthorStyleSheets&amp; authorStyleSheets, ExtensionStyleSheets&amp; extensionStyleSheets)
</del><ins>+CSSStyleRule* InspectorCSSOMWrappers::getWrapperForRuleInSheets(StyleRule* rule, Style::Scope&amp; styleScope, ExtensionStyleSheets&amp; extensionStyleSheets)
</ins><span class="cx"> {
</span><span class="cx">     if (m_styleRuleToCSSOMWrapperMap.isEmpty()) {
</span><span class="cx">         collectFromStyleSheetContents(m_styleSheetCSSOMWrapperSet, CSSDefaultStyleSheets::simpleDefaultStyleSheet);
</span><span class="lines">@@ -108,7 +108,7 @@
</span><span class="cx">         collectFromStyleSheetContents(m_styleSheetCSSOMWrapperSet, CSSDefaultStyleSheets::fullscreenStyleSheet);
</span><span class="cx">         collectFromStyleSheetContents(m_styleSheetCSSOMWrapperSet, CSSDefaultStyleSheets::plugInsStyleSheet);
</span><span class="cx"> 
</span><del>-        collectFromStyleSheets(authorStyleSheets.activeStyleSheets());
</del><ins>+        collectFromStyleSheets(styleScope.activeStyleSheets());
</ins><span class="cx">         collect(extensionStyleSheets.pageUserSheet());
</span><span class="cx">         collectFromStyleSheets(extensionStyleSheets.injectedUserStyleSheets());
</span><span class="cx">         collectFromStyleSheets(extensionStyleSheets.documentUserStyleSheets());
</span></span></pre></div>
<a id="trunkSourceWebCorecssInspectorCSSOMWrappersh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/InspectorCSSOMWrappers.h (206916 => 206917)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/InspectorCSSOMWrappers.h        2016-10-07 16:41:48 UTC (rev 206916)
+++ trunk/Source/WebCore/css/InspectorCSSOMWrappers.h        2016-10-07 16:55:11 UTC (rev 206917)
</span><span class="lines">@@ -31,7 +31,6 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-class AuthorStyleSheets;
</del><span class="cx"> class CSSStyleRule;
</span><span class="cx"> class CSSStyleSheet;
</span><span class="cx"> class ExtensionStyleSheets;
</span><span class="lines">@@ -38,11 +37,15 @@
</span><span class="cx"> class StyleRule;
</span><span class="cx"> class StyleSheetContents;
</span><span class="cx"> 
</span><ins>+namespace Style {
+class Scope;
+}
+
</ins><span class="cx"> class InspectorCSSOMWrappers {
</span><span class="cx"> public:
</span><span class="cx">     // WARNING. This will construct CSSOM wrappers for all style rules and cache them in a map for significant memory cost.
</span><span class="cx">     // It is here to support inspector. Don't use for any regular engine functions.
</span><del>-    CSSStyleRule* getWrapperForRuleInSheets(StyleRule*, AuthorStyleSheets&amp;, ExtensionStyleSheets&amp;);
</del><ins>+    CSSStyleRule* getWrapperForRuleInSheets(StyleRule*, Style::Scope&amp;, ExtensionStyleSheets&amp;);
</ins><span class="cx">     void collectFromStyleSheetIfNeeded(CSSStyleSheet*);
</span><span class="cx"> 
</span><span class="cx"> private:
</span></span></pre></div>
<a id="trunkSourceWebCorecssStyleSheetListcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/StyleSheetList.cpp (206916 => 206917)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/StyleSheetList.cpp        2016-10-07 16:41:48 UTC (rev 206916)
+++ trunk/Source/WebCore/css/StyleSheetList.cpp        2016-10-07 16:55:11 UTC (rev 206917)
</span><span class="lines">@@ -21,11 +21,11 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;StyleSheetList.h&quot;
</span><span class="cx"> 
</span><del>-#include &quot;AuthorStyleSheets.h&quot;
</del><span class="cx"> #include &quot;CSSStyleSheet.h&quot;
</span><span class="cx"> #include &quot;Document.h&quot;
</span><span class="cx"> #include &quot;HTMLNames.h&quot;
</span><span class="cx"> #include &quot;HTMLStyleElement.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">@@ -45,12 +45,12 @@
</span><span class="cx"> {
</span><span class="cx">     if (!m_document)
</span><span class="cx">         return m_detachedStyleSheets;
</span><del>-    return m_document-&gt;authorStyleSheets().styleSheetsForStyleSheetList();
</del><ins>+    return m_document-&gt;styleScope().styleSheetsForStyleSheetList();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void StyleSheetList::detachFromDocument()
</span><span class="cx"> {
</span><del>-    m_detachedStyleSheets = m_document-&gt;authorStyleSheets().styleSheetsForStyleSheetList();
</del><ins>+    m_detachedStyleSheets = m_document-&gt;styleScope().styleSheetsForStyleSheetList();
</ins><span class="cx">     m_document = nullptr;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoredomAuthorStyleSheetscpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/dom/AuthorStyleSheets.cpp (206916 => 206917)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/AuthorStyleSheets.cpp        2016-10-07 16:41:48 UTC (rev 206916)
+++ trunk/Source/WebCore/dom/AuthorStyleSheets.cpp        2016-10-07 16:55:11 UTC (rev 206917)
</span><span class="lines">@@ -1,487 +0,0 @@
</span><del>-/*
- * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
- *           (C) 1999 Antti Koivisto (koivisto@kde.org)
- *           (C) 2001 Dirk Mueller (mueller@kde.org)
- *           (C) 2006 Alexey Proskuryakov (ap@webkit.org)
- * Copyright (C) 2004-2009, 2011-2012, 2015 Apple Inc. All rights reserved.
- * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
- * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
- * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
- * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB.  If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include &quot;config.h&quot;
-#include &quot;AuthorStyleSheets.h&quot;
-
-#include &quot;CSSStyleSheet.h&quot;
-#include &quot;Element.h&quot;
-#include &quot;ElementChildIterator.h&quot;
-#include &quot;ExtensionStyleSheets.h&quot;
-#include &quot;HTMLIFrameElement.h&quot;
-#include &quot;HTMLLinkElement.h&quot;
-#include &quot;HTMLStyleElement.h&quot;
-#include &quot;InspectorInstrumentation.h&quot;
-#include &quot;Page.h&quot;
-#include &quot;PageGroup.h&quot;
-#include &quot;ProcessingInstruction.h&quot;
-#include &quot;SVGNames.h&quot;
-#include &quot;SVGStyleElement.h&quot;
-#include &quot;Settings.h&quot;
-#include &quot;ShadowRoot.h&quot;
-#include &quot;StyleInvalidationAnalysis.h&quot;
-#include &quot;StyleResolver.h&quot;
-#include &quot;StyleSheetContents.h&quot;
-#include &quot;StyleSheetList.h&quot;
-#include &quot;UserContentController.h&quot;
-#include &quot;UserContentURLPattern.h&quot;
-#include &quot;UserStyleSheet.h&quot;
-
-namespace WebCore {
-
-using namespace ContentExtensions;
-using namespace HTMLNames;
-
-AuthorStyleSheets::AuthorStyleSheets(Document&amp; document)
-    : m_document(document)
-    , m_pendingUpdateTimer(*this, &amp;AuthorStyleSheets::pendingUpdateTimerFired)
-{
-}
-
-AuthorStyleSheets::AuthorStyleSheets(ShadowRoot&amp; shadowRoot)
-    : m_document(shadowRoot.documentScope())
-    , m_shadowRoot(&amp;shadowRoot)
-    , m_pendingUpdateTimer(*this, &amp;AuthorStyleSheets::pendingUpdateTimerFired)
-{
-}
-
-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();
-}
-
-// This method is called whenever a top-level stylesheet has finished loading.
-void AuthorStyleSheets::removePendingSheet(RemovePendingSheetNotificationType notification)
-{
-    // Make sure we knew this sheet was pending, and that our count isn't out of sync.
-    ASSERT(m_pendingStyleSheetCount &gt; 0);
-
-    m_pendingStyleSheetCount--;
-    
-#ifdef INSTRUMENT_LAYOUT_SCHEDULING
-    if (!ownerElement())
-        printf(&quot;Stylesheet loaded at time %d. %d stylesheets still remain.\n&quot;, elapsedTime(), m_pendingStylesheets);
-#endif
-
-    if (m_pendingStyleSheetCount)
-        return;
-
-    if (notification == RemovePendingSheetNotifyLater) {
-        m_document.setNeedsNotifyRemoveAllPendingStylesheet();
-        return;
-    }
-
-    if (m_shadowRoot) {
-        m_shadowRoot-&gt;updateStyle();
-        return;
-    }
-
-    m_document.didRemoveAllPendingStylesheet();
-}
-
-void AuthorStyleSheets::addStyleSheetCandidateNode(Node&amp; node, bool createdByParser)
-{
-    if (!node.inDocument())
-        return;
-    
-    // Until the &lt;body&gt; exists, we have no choice but to compare document positions,
-    // since styles outside of the body and head continue to be shunted into the head
-    // (and thus can shift to end up before dynamically added DOM content that is also
-    // outside the body).
-    if ((createdByParser &amp;&amp; m_document.bodyOrFrameset()) || m_styleSheetCandidateNodes.isEmpty()) {
-        m_styleSheetCandidateNodes.add(&amp;node);
-        return;
-    }
-
-    // Determine an appropriate insertion point.
-    auto begin = m_styleSheetCandidateNodes.begin();
-    auto end = m_styleSheetCandidateNodes.end();
-    auto it = end;
-    Node* followingNode = nullptr;
-    do {
-        --it;
-        Node* n = *it;
-        unsigned short position = n-&gt;compareDocumentPosition(node);
-        if (position == Node::DOCUMENT_POSITION_FOLLOWING) {
-            m_styleSheetCandidateNodes.insertBefore(followingNode, &amp;node);
-            return;
-        }
-        followingNode = n;
-    } while (it != begin);
-    
-    m_styleSheetCandidateNodes.insertBefore(followingNode, &amp;node);
-}
-
-void AuthorStyleSheets::removeStyleSheetCandidateNode(Node&amp; node)
-{
-    if (m_styleSheetCandidateNodes.remove(&amp;node))
-        scheduleActiveSetUpdate();
-}
-
-void AuthorStyleSheets::collectActiveStyleSheets(Vector&lt;RefPtr&lt;StyleSheet&gt;&gt;&amp; sheets)
-{
-    if (m_document.settings() &amp;&amp; !m_document.settings()-&gt;authorAndUserStylesEnabled())
-        return;
-
-    for (auto&amp; node : m_styleSheetCandidateNodes) {
-        StyleSheet* sheet = nullptr;
-        if (is&lt;ProcessingInstruction&gt;(*node)) {
-            // Processing instruction (XML documents only).
-            // We don't support linking to embedded CSS stylesheets, see &lt;https://bugs.webkit.org/show_bug.cgi?id=49281&gt; for discussion.
-            ProcessingInstruction&amp; pi = downcast&lt;ProcessingInstruction&gt;(*node);
-            sheet = pi.sheet();
-#if ENABLE(XSLT)
-            // Don't apply XSL transforms to already transformed documents -- &lt;rdar://problem/4132806&gt;
-            if (pi.isXSL() &amp;&amp; !m_document.transformSourceDocument()) {
-                // Don't apply XSL transforms until loading is finished.
-                if (!m_document.parsing())
-                    m_document.applyXSLTransform(&amp;pi);
-                return;
-            }
-#endif
-        } else if (is&lt;HTMLLinkElement&gt;(*node) || is&lt;HTMLStyleElement&gt;(*node) || is&lt;SVGStyleElement&gt;(*node)) {
-            Element&amp; element = downcast&lt;Element&gt;(*node);
-            AtomicString title = element.attributeWithoutSynchronization(titleAttr);
-            bool enabledViaScript = false;
-            if (is&lt;HTMLLinkElement&gt;(element)) {
-                // &lt;LINK&gt; element
-                HTMLLinkElement&amp; linkElement = downcast&lt;HTMLLinkElement&gt;(element);
-                if (linkElement.isDisabled())
-                    continue;
-                enabledViaScript = linkElement.isEnabledViaScript();
-                if (linkElement.styleSheetIsLoading()) {
-                    // it is loading but we should still decide which style sheet set to use
-                    if (!enabledViaScript &amp;&amp; !title.isEmpty() &amp;&amp; m_preferredStylesheetSetName.isEmpty()) {
-                        if (!linkElement.attributeWithoutSynchronization(relAttr).contains(&quot;alternate&quot;)) {
-                            m_preferredStylesheetSetName = title;
-                            m_selectedStylesheetSetName = title;
-                        }
-                    }
-                    continue;
-                }
-                if (!linkElement.sheet())
-                    title = nullAtom;
-            }
-            // Get the current preferred styleset. This is the
-            // set of sheets that will be enabled.
-            if (is&lt;SVGStyleElement&gt;(element))
-                sheet = downcast&lt;SVGStyleElement&gt;(element).sheet();
-            else if (is&lt;HTMLLinkElement&gt;(element))
-                sheet = downcast&lt;HTMLLinkElement&gt;(element).sheet();
-            else
-                sheet = downcast&lt;HTMLStyleElement&gt;(element).sheet();
-            // Check to see if this sheet belongs to a styleset
-            // (thus making it PREFERRED or ALTERNATE rather than
-            // PERSISTENT).
-            auto&amp; rel = element.attributeWithoutSynchronization(relAttr);
-            if (!enabledViaScript &amp;&amp; !title.isEmpty()) {
-                // Yes, we have a title.
-                if (m_preferredStylesheetSetName.isEmpty()) {
-                    // No preferred set has been established. If
-                    // we are NOT an alternate sheet, then establish
-                    // us as the preferred set. Otherwise, just ignore
-                    // this sheet.
-                    if (is&lt;HTMLStyleElement&gt;(element) || !rel.contains(&quot;alternate&quot;))
-                        m_preferredStylesheetSetName = m_selectedStylesheetSetName = title;
-                }
-                if (title != m_preferredStylesheetSetName)
-                    sheet = nullptr;
-            }
-
-            if (rel.contains(&quot;alternate&quot;) &amp;&amp; title.isEmpty())
-                sheet = nullptr;
-        }
-        if (sheet)
-            sheets.append(sheet);
-    }
-}
-
-AuthorStyleSheets::StyleResolverUpdateType AuthorStyleSheets::analyzeStyleSheetChange(const Vector&lt;RefPtr&lt;CSSStyleSheet&gt;&gt;&amp; newStylesheets, bool&amp; requiresFullStyleRecalc)
-{
-    requiresFullStyleRecalc = true;
-    
-    unsigned newStylesheetCount = newStylesheets.size();
-
-    if (!styleResolverIfExists())
-        return Reconstruct;
-
-    StyleResolver&amp; styleResolver = *styleResolverIfExists();
-
-    // Find out which stylesheets are new.
-    unsigned oldStylesheetCount = m_activeStyleSheets.size();
-    if (newStylesheetCount &lt; oldStylesheetCount)
-        return Reconstruct;
-
-    Vector&lt;StyleSheetContents*&gt; addedSheets;
-    unsigned newIndex = 0;
-    for (unsigned oldIndex = 0; oldIndex &lt; oldStylesheetCount; ++oldIndex) {
-        if (newIndex &gt;= newStylesheetCount)
-            return Reconstruct;
-        while (m_activeStyleSheets[oldIndex] != newStylesheets[newIndex]) {
-            addedSheets.append(&amp;newStylesheets[newIndex]-&gt;contents());
-            ++newIndex;
-            if (newIndex == newStylesheetCount)
-                return Reconstruct;
-        }
-        ++newIndex;
-    }
-    bool hasInsertions = !addedSheets.isEmpty();
-    while (newIndex &lt; newStylesheetCount) {
-        addedSheets.append(&amp;newStylesheets[newIndex]-&gt;contents());
-        ++newIndex;
-    }
-    // If all new sheets were added at the end of the list we can just add them to existing StyleResolver.
-    // If there were insertions we need to re-add all the stylesheets so rules are ordered correctly.
-    auto styleResolverUpdateType = hasInsertions ? Reset : Additive;
-
-    // If we are already parsing the body and so may have significant amount of elements, put some effort into trying to avoid style recalcs.
-    if (!m_document.bodyOrFrameset() || m_document.hasNodesWithPlaceholderStyle())
-        return styleResolverUpdateType;
-
-    StyleInvalidationAnalysis invalidationAnalysis(addedSheets, styleResolver.mediaQueryEvaluator());
-    if (invalidationAnalysis.dirtiesAllStyle())
-        return styleResolverUpdateType;
-    invalidationAnalysis.invalidateStyle(m_document);
-    requiresFullStyleRecalc = false;
-
-    return styleResolverUpdateType;
-}
-
-static void filterEnabledNonemptyCSSStyleSheets(Vector&lt;RefPtr&lt;CSSStyleSheet&gt;&gt;&amp; result, const Vector&lt;RefPtr&lt;StyleSheet&gt;&gt;&amp; sheets)
-{
-    for (auto&amp; sheet : sheets) {
-        if (!is&lt;CSSStyleSheet&gt;(*sheet))
-            continue;
-        CSSStyleSheet&amp; styleSheet = downcast&lt;CSSStyleSheet&gt;(*sheet);
-        if (styleSheet.isLoading())
-            continue;
-        if (styleSheet.disabled())
-            continue;
-        if (!styleSheet.length())
-            continue;
-        result.append(&amp;styleSheet);
-    }
-}
-
-void AuthorStyleSheets::updateActiveStyleSheets(UpdateType updateType)
-{
-    ASSERT(!m_pendingUpdateType);
-
-    if (m_document.inStyleRecalc() || m_document.inRenderTreeUpdate()) {
-        // Protect against deleting style resolver in the middle of a style resolution.
-        // Crash stacks indicate we can get here when a resource load fails synchronously (for example due to content blocking).
-        // FIXME: These kind of cases should be eliminated and this path replaced by an assert.
-        m_pendingUpdateType = UpdateType::ContentsOrInterpretation;
-        m_document.scheduleForcedStyleRecalc();
-        return;
-    }
-
-    if (!m_document.hasLivingRenderTree()) {
-        m_document.clearStyleResolver();
-        return;
-    }
-
-    // Don't bother updating, since we haven't loaded all our style info yet
-    // and haven't calculated the style resolver for the first time.
-    if (!m_shadowRoot &amp;&amp; !m_didUpdateActiveStyleSheets &amp;&amp; m_pendingStyleSheetCount) {
-        m_document.clearStyleResolver();
-        return;
-    }
-
-    // FIXME: Support optimized invalidation in shadow trees.
-    if (m_shadowRoot)
-        updateType = UpdateType::ContentsOrInterpretation;
-
-    m_didUpdateActiveStyleSheets = true;
-
-    Vector&lt;RefPtr&lt;StyleSheet&gt;&gt; activeStyleSheets;
-    collectActiveStyleSheets(activeStyleSheets);
-
-    Vector&lt;RefPtr&lt;CSSStyleSheet&gt;&gt; activeCSSStyleSheets;
-    activeCSSStyleSheets.appendVector(m_document.extensionStyleSheets().injectedAuthorStyleSheets());
-    activeCSSStyleSheets.appendVector(m_document.extensionStyleSheets().authorStyleSheetsForTesting());
-    filterEnabledNonemptyCSSStyleSheets(activeCSSStyleSheets, activeStyleSheets);
-
-    bool requiresFullStyleRecalc = true;
-    StyleResolverUpdateType styleResolverUpdateType = Reconstruct;
-    if (updateType == UpdateType::ActiveSet)
-        styleResolverUpdateType = analyzeStyleSheetChange(activeCSSStyleSheets, requiresFullStyleRecalc);
-
-    updateStyleResolver(activeCSSStyleSheets, styleResolverUpdateType);
-
-    m_weakCopyOfActiveStyleSheetListForFastLookup = nullptr;
-    m_activeStyleSheets.swap(activeCSSStyleSheets);
-    m_styleSheetsForStyleSheetList.swap(activeStyleSheets);
-
-    InspectorInstrumentation::activeStyleSheetsUpdated(m_document);
-
-    for (const auto&amp; sheet : m_activeStyleSheets) {
-        if (sheet-&gt;contents().usesStyleBasedEditability())
-            m_usesStyleBasedEditability = true;
-    }
-
-    if (requiresFullStyleRecalc) {
-        if (m_shadowRoot) {
-            for (auto&amp; shadowChild : childrenOfType&lt;Element&gt;(*m_shadowRoot))
-                shadowChild.setNeedsStyleRecalc();
-        } else
-            m_document.scheduleForcedStyleRecalc();
-    }
-}
-
-void AuthorStyleSheets::updateStyleResolver(Vector&lt;RefPtr&lt;CSSStyleSheet&gt;&gt;&amp; activeStyleSheets, StyleResolverUpdateType updateType)
-{
-    if (updateType == Reconstruct) {
-        if (m_shadowRoot)
-            m_shadowRoot-&gt;resetStyleResolver();
-        else
-            m_document.clearStyleResolver();
-        return;
-    }
-    auto&amp; styleResolver = this-&gt;styleResolver();
-
-    if (updateType == Reset) {
-        styleResolver.ruleSets().resetAuthorStyle();
-        styleResolver.appendAuthorStyleSheets(activeStyleSheets);
-    } else {
-        ASSERT(updateType == Additive);
-        unsigned firstNewIndex = m_activeStyleSheets.size();
-        Vector&lt;RefPtr&lt;CSSStyleSheet&gt;&gt; newStyleSheets;
-        newStyleSheets.appendRange(activeStyleSheets.begin() + firstNewIndex, activeStyleSheets.end());
-        styleResolver.appendAuthorStyleSheets(newStyleSheets);
-    }
-
-    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);
-    }
-}
-
-const Vector&lt;RefPtr&lt;CSSStyleSheet&gt;&gt; AuthorStyleSheets::activeStyleSheetsForInspector() const
-{
-    Vector&lt;RefPtr&lt;CSSStyleSheet&gt;&gt; result;
-
-    result.appendVector(m_document.extensionStyleSheets().injectedAuthorStyleSheets());
-    result.appendVector(m_document.extensionStyleSheets().authorStyleSheetsForTesting());
-
-    for (auto&amp; styleSheet : m_styleSheetsForStyleSheetList) {
-        if (!is&lt;CSSStyleSheet&gt;(*styleSheet))
-            continue;
-
-        CSSStyleSheet&amp; sheet = downcast&lt;CSSStyleSheet&gt;(*styleSheet);
-        if (sheet.disabled())
-            continue;
-
-        result.append(&amp;sheet);
-    }
-
-    return result;
-}
-
-bool AuthorStyleSheets::activeStyleSheetsContains(const CSSStyleSheet* sheet) const
-{
-    if (!m_weakCopyOfActiveStyleSheetListForFastLookup) {
-        m_weakCopyOfActiveStyleSheetListForFastLookup = std::make_unique&lt;HashSet&lt;const CSSStyleSheet*&gt;&gt;();
-        for (auto&amp; activeStyleSheet : m_activeStyleSheets)
-            m_weakCopyOfActiveStyleSheetListForFastLookup-&gt;add(activeStyleSheet.get());
-    }
-    return m_weakCopyOfActiveStyleSheetListForFastLookup-&gt;contains(sheet);
-}
-
-void AuthorStyleSheets::flushPendingUpdate()
-{
-    if (!m_pendingUpdateType)
-        return;
-    auto updateType = *m_pendingUpdateType;
-
-    clearPendingUpdate();
-
-    updateActiveStyleSheets(updateType);
-}
-
-void AuthorStyleSheets::clearPendingUpdate()
-{
-    m_pendingUpdateTimer.stop();
-    m_pendingUpdateType = { };
-}
-
-void AuthorStyleSheets::scheduleActiveSetUpdate()
-{
-    if (m_shadowRoot) {
-        // FIXME: We need to flush updates recursively to support asynchronous updates in shadow trees.
-        didChangeCandidatesForActiveSet();
-        return;
-    }
-    if (m_pendingUpdateTimer.isActive())
-        return;
-    if (!m_pendingUpdateType)
-        m_pendingUpdateType = UpdateType::ActiveSet;
-    m_pendingUpdateTimer.startOneShot(0);
-}
-
-void AuthorStyleSheets::didChangeCandidatesForActiveSet()
-{
-    auto updateType = m_pendingUpdateType.valueOr(UpdateType::ActiveSet);
-    clearPendingUpdate();
-    updateActiveStyleSheets(updateType);
-}
-
-void AuthorStyleSheets::didChangeContentsOrInterpretation()
-{
-    clearPendingUpdate();
-    updateActiveStyleSheets(UpdateType::ContentsOrInterpretation);
-}
-
-void AuthorStyleSheets::pendingUpdateTimerFired()
-{
-    flushPendingUpdate();
-}
-
-}
</del></span></pre></div>
<a id="trunkSourceWebCoredomAuthorStyleSheetsh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/dom/AuthorStyleSheets.h (206916 => 206917)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/AuthorStyleSheets.h        2016-10-07 16:41:48 UTC (rev 206916)
+++ trunk/Source/WebCore/dom/AuthorStyleSheets.h        2016-10-07 16:55:11 UTC (rev 206917)
</span><span class="lines">@@ -1,144 +0,0 @@
</span><del>-/*
- * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
- *           (C) 1999 Antti Koivisto (koivisto@kde.org)
- *           (C) 2001 Dirk Mueller (mueller@kde.org)
- *           (C) 2006 Alexey Proskuryakov (ap@webkit.org)
- * Copyright (C) 2004-2010, 2012-2013, 2015 Apple Inc. All rights reserved.
- * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
- * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
- * Copyright (C) 2011 Google Inc. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB.  If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef AuthorStyleSheets_h
-#define AuthorStyleSheets_h
-
-#include &quot;Timer.h&quot;
-#include &lt;memory&gt;
-#include &lt;wtf/FastMalloc.h&gt;
-#include &lt;wtf/HashMap.h&gt;
-#include &lt;wtf/ListHashSet.h&gt;
-#include &lt;wtf/RefPtr.h&gt;
-#include &lt;wtf/Vector.h&gt;
-#include &lt;wtf/text/WTFString.h&gt;
-
-namespace WebCore {
-
-class CSSStyleSheet;
-class Document;
-class Node;
-class StyleResolver;
-class StyleSheet;
-class StyleSheetContents;
-class StyleSheetList;
-class ShadowRoot;
-class TreeScope;
-
-class AuthorStyleSheets {
-    WTF_MAKE_FAST_ALLOCATED;
-public:
-    explicit AuthorStyleSheets(Document&amp;);
-    explicit AuthorStyleSheets(ShadowRoot&amp;);
-
-    const Vector&lt;RefPtr&lt;CSSStyleSheet&gt;&gt;&amp; activeStyleSheets() const { return m_activeStyleSheets; }
-
-    const Vector&lt;RefPtr&lt;StyleSheet&gt;&gt;&amp; styleSheetsForStyleSheetList() const { return m_styleSheetsForStyleSheetList; }
-    const Vector&lt;RefPtr&lt;CSSStyleSheet&gt;&gt; activeStyleSheetsForInspector() const;
-
-    void addStyleSheetCandidateNode(Node&amp;, bool createdByParser);
-    void removeStyleSheetCandidateNode(Node&amp;);
-
-    String preferredStylesheetSetName() const { return m_preferredStylesheetSetName; }
-    String selectedStylesheetSetName() const { return m_selectedStylesheetSetName; }
-    void setPreferredStylesheetSetName(const String&amp; name) { m_preferredStylesheetSetName = name; }
-    void setSelectedStylesheetSetName(const String&amp; name) { m_selectedStylesheetSetName = name; }
-
-    void addPendingSheet() { m_pendingStyleSheetCount++; }
-    enum RemovePendingSheetNotificationType {
-        RemovePendingSheetNotifyImmediately,
-        RemovePendingSheetNotifyLater
-    };
-    void removePendingSheet(RemovePendingSheetNotificationType = RemovePendingSheetNotifyImmediately);
-
-    bool hasPendingSheets() const { return m_pendingStyleSheetCount &gt; 0; }
-
-    bool usesStyleBasedEditability() { return m_usesStyleBasedEditability; }
-
-    bool activeStyleSheetsContains(const CSSStyleSheet*) const;
-
-    void didChangeCandidatesForActiveSet();
-    void scheduleActiveSetUpdate();
-    WEBCORE_EXPORT void didChangeContentsOrInterpretation();
-
-    bool hasPendingUpdate() const { return !!m_pendingUpdateType; }
-    void flushPendingUpdate();
-
-    StyleResolver&amp; styleResolver();
-    StyleResolver* styleResolverIfExists();
-
-    static AuthorStyleSheets&amp; forNode(Node&amp;);
-
-private:
-    enum class UpdateType { ActiveSet, ContentsOrInterpretation };
-    void updateActiveStyleSheets(UpdateType);
-
-    void collectActiveStyleSheets(Vector&lt;RefPtr&lt;StyleSheet&gt;&gt;&amp;);
-
-    enum StyleResolverUpdateType {
-        Reconstruct,
-        Reset,
-        Additive
-    };
-    StyleResolverUpdateType analyzeStyleSheetChange(const Vector&lt;RefPtr&lt;CSSStyleSheet&gt;&gt;&amp; newStylesheets, bool&amp; requiresFullStyleRecalc);
-    void updateStyleResolver(Vector&lt;RefPtr&lt;CSSStyleSheet&gt;&gt;&amp;, StyleResolverUpdateType);
-
-    void pendingUpdateTimerFired();
-    void clearPendingUpdate();
-
-    Document&amp; m_document;
-    ShadowRoot* m_shadowRoot { nullptr };
-
-    Vector&lt;RefPtr&lt;StyleSheet&gt;&gt; m_styleSheetsForStyleSheetList;
-    Vector&lt;RefPtr&lt;CSSStyleSheet&gt;&gt; m_activeStyleSheets;
-
-    Timer m_pendingUpdateTimer;
-
-    // This is a mirror of m_activeAuthorStyleSheets that gets populated on demand for activeStyleSheetsContains().
-    mutable std::unique_ptr&lt;HashSet&lt;const CSSStyleSheet*&gt;&gt; m_weakCopyOfActiveStyleSheetListForFastLookup;
-
-    // Track the number of currently loading top-level stylesheets needed for rendering.
-    // Sheets loaded using the @import directive are not included in this count.
-    // We use this count of pending sheets to detect when we can begin attaching
-    // elements and when it is safe to execute scripts.
-    int m_pendingStyleSheetCount { 0 };
-    bool m_didUpdateActiveStyleSheets { false };
-
-    Optional&lt;UpdateType&gt; m_pendingUpdateType;
-
-    ListHashSet&lt;Node*&gt; m_styleSheetCandidateNodes;
-
-    String m_preferredStylesheetSetName;
-    String m_selectedStylesheetSetName;
-
-    bool m_usesStyleBasedEditability { false };
-};
-
-}
-
-#endif
-
</del></span></pre></div>
<a id="trunkSourceWebCoredomDocumentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Document.cpp (206916 => 206917)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Document.cpp        2016-10-07 16:41:48 UTC (rev 206916)
+++ trunk/Source/WebCore/dom/Document.cpp        2016-10-07 16:55:11 UTC (rev 206917)
</span><span class="lines">@@ -31,7 +31,6 @@
</span><span class="cx"> #include &quot;AXObjectCache.h&quot;
</span><span class="cx"> #include &quot;AnimationController.h&quot;
</span><span class="cx"> #include &quot;Attr.h&quot;
</span><del>-#include &quot;AuthorStyleSheets.h&quot;
</del><span class="cx"> #include &quot;CDATASection.h&quot;
</span><span class="cx"> #include &quot;CSSFontSelector.h&quot;
</span><span class="cx"> #include &quot;CSSStyleDeclaration.h&quot;
</span><span class="lines">@@ -168,6 +167,7 @@
</span><span class="cx"> #include &quot;StyleProperties.h&quot;
</span><span class="cx"> #include &quot;StyleResolveForDocument.h&quot;
</span><span class="cx"> #include &quot;StyleResolver.h&quot;
</span><ins>+#include &quot;StyleScope.h&quot;
</ins><span class="cx"> #include &quot;StyleSheetContents.h&quot;
</span><span class="cx"> #include &quot;StyleSheetList.h&quot;
</span><span class="cx"> #include &quot;StyleTreeResolver.h&quot;
</span><span class="lines">@@ -451,7 +451,7 @@
</span><span class="cx">     , m_domTreeVersion(++s_globalTreeVersion)
</span><span class="cx">     , m_listenerTypes(0)
</span><span class="cx">     , m_mutationObserverTypes(0)
</span><del>-    , m_authorStyleSheets(std::make_unique&lt;AuthorStyleSheets&gt;(*this))
</del><ins>+    , m_styleScope(std::make_unique&lt;Style::Scope&gt;(*this))
</ins><span class="cx">     , m_extensionStyleSheets(std::make_unique&lt;ExtensionStyleSheets&gt;(*this))
</span><span class="cx">     , m_visitedLinkState(std::make_unique&lt;VisitedLinkState&gt;(*this))
</span><span class="cx">     , m_visuallyOrdered(false)
</span><span class="lines">@@ -1354,7 +1354,7 @@
</span><span class="cx">     m_contentLanguage = language;
</span><span class="cx"> 
</span><span class="cx">     // Recalculate style so language is used when selecting the initial font.
</span><del>-    m_authorStyleSheets-&gt;didChangeContentsOrInterpretation();
</del><ins>+    m_styleScope-&gt;didChangeContentsOrInterpretation();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void Document::setXMLVersion(const String&amp; version, ExceptionCode&amp; ec)
</span><span class="lines">@@ -1812,7 +1812,7 @@
</span><span class="cx">     // re-attaching our containing iframe, which when asked HTMLFrameElementBase::isURLAllowed
</span><span class="cx">     // hits a null-dereference due to security code always assuming the document has a SecurityOrigin.
</span><span class="cx"> 
</span><del>-    authorStyleSheets().flushPendingUpdate();
</del><ins>+    styleScope().flushPendingUpdate();
</ins><span class="cx"> 
</span><span class="cx">     frameView.willRecalcStyle();
</span><span class="cx"> 
</span><span class="lines">@@ -1895,7 +1895,7 @@
</span><span class="cx">     if (pageCacheState() != NotInPageCache)
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><del>-    return m_pendingStyleRecalcShouldForce || childNeedsStyleRecalc() || authorStyleSheets().hasPendingUpdate();
</del><ins>+    return m_pendingStyleRecalcShouldForce || childNeedsStyleRecalc() || styleScope().hasPendingUpdate();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void Document::updateStyleIfNeeded()
</span><span class="lines">@@ -1906,7 +1906,7 @@
</span><span class="cx">     if (!view() || view()-&gt;isInRenderTreeLayout())
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    authorStyleSheets().flushPendingUpdate();
</del><ins>+    styleScope().flushPendingUpdate();
</ins><span class="cx"> 
</span><span class="cx">     if (!needsStyleRecalc())
</span><span class="cx">         return;
</span><span class="lines">@@ -1960,7 +1960,7 @@
</span><span class="cx">         HTMLElement* bodyElement = bodyOrFrameset();
</span><span class="cx">         if (bodyElement &amp;&amp; !bodyElement-&gt;renderer() &amp;&amp; m_pendingSheetLayout == NoLayoutWithPendingSheets) {
</span><span class="cx">             m_pendingSheetLayout = DidLayoutWithPendingSheets;
</span><del>-            authorStyleSheets().didChangeContentsOrInterpretation();
</del><ins>+            styleScope().didChangeContentsOrInterpretation();
</ins><span class="cx">             recalcStyle(Style::Force);
</span><span class="cx">         } else if (m_hasNodesWithPlaceholderStyle)
</span><span class="cx">             // If new nodes have been added or style recalc has been done with style sheets still pending, some nodes 
</span><span class="lines">@@ -2142,7 +2142,7 @@
</span><span class="cx"> void Document::createStyleResolver()
</span><span class="cx"> {
</span><span class="cx">     m_styleResolver = std::make_unique&lt;StyleResolver&gt;(*this);
</span><del>-    m_styleResolver-&gt;appendAuthorStyleSheets(authorStyleSheets().activeStyleSheets());
</del><ins>+    m_styleResolver-&gt;appendAuthorStyleSheets(styleScope().activeStyleSheets());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> StyleResolver&amp; Document::userAgentShadowTreeStyleResolver()
</span><span class="lines">@@ -3085,7 +3085,7 @@
</span><span class="cx"> {
</span><span class="cx">     m_needsNotifyRemoveAllPendingStylesheet = false;
</span><span class="cx"> 
</span><del>-    authorStyleSheets().didChangeCandidatesForActiveSet();
</del><ins>+    styleScope().didChangeCandidatesForActiveSet();
</ins><span class="cx"> 
</span><span class="cx">     if (m_pendingSheetLayout == DidLayoutWithPendingSheets) {
</span><span class="cx">         m_pendingSheetLayout = IgnoreLayoutWithPendingSheets;
</span><span class="lines">@@ -3108,9 +3108,9 @@
</span><span class="cx">     ASSERT(!m_renderView || !m_renderView-&gt;frameView().isPainting());
</span><span class="cx">     ASSERT(!m_inStyleRecalc);
</span><span class="cx"> 
</span><del>-    auto&amp; authorSheets = const_cast&lt;AuthorStyleSheets&amp;&gt;(authorStyleSheets());
-    authorSheets.flushPendingUpdate();
-    return authorSheets.usesStyleBasedEditability();
</del><ins>+    auto&amp; styleScope = const_cast&lt;Style::Scope&amp;&gt;(this-&gt;styleScope());
+    styleScope.flushPendingUpdate();
+    return styleScope.usesStyleBasedEditability();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void Document::setHasElementUsingStyleBasedEditability()
</span><span class="lines">@@ -3156,9 +3156,9 @@
</span><span class="cx">         // For more info, see the test at:
</span><span class="cx">         // http://www.hixie.ch/tests/evil/css/import/main/preferred.html
</span><span class="cx">         // -dwh
</span><del>-        authorStyleSheets().setSelectedStylesheetSetName(content);
-        authorStyleSheets().setPreferredStylesheetSetName(content);
-        authorStyleSheets().didChangeContentsOrInterpretation();
</del><ins>+        styleScope().setSelectedStylesheetSetName(content);
+        styleScope().setPreferredStylesheetSetName(content);
+        styleScope().didChangeContentsOrInterpretation();
</ins><span class="cx">         break;
</span><span class="cx"> 
</span><span class="cx">     case HTTPHeaderName::Refresh: {
</span><span class="lines">@@ -3452,18 +3452,18 @@
</span><span class="cx"> 
</span><span class="cx"> String Document::preferredStylesheetSet() const
</span><span class="cx"> {
</span><del>-    return authorStyleSheets().preferredStylesheetSetName();
</del><ins>+    return styleScope().preferredStylesheetSetName();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> String Document::selectedStylesheetSet() const
</span><span class="cx"> {
</span><del>-    return authorStyleSheets().selectedStylesheetSetName();
</del><ins>+    return styleScope().selectedStylesheetSetName();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void Document::setSelectedStylesheetSet(const String&amp; aString)
</span><span class="cx"> {
</span><del>-    authorStyleSheets().setSelectedStylesheetSetName(aString);
-    authorStyleSheets().didChangeContentsOrInterpretation();
</del><ins>+    styleScope().setSelectedStylesheetSetName(aString);
+    styleScope().didChangeContentsOrInterpretation();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void Document::evaluateMediaQueryList()
</span><span class="lines">@@ -6665,7 +6665,7 @@
</span><span class="cx"> 
</span><span class="cx"> bool Document::haveStylesheetsLoaded() const
</span><span class="cx"> {
</span><del>-    return !authorStyleSheets().hasPendingSheets() || m_ignorePendingStylesheets;
</del><ins>+    return !styleScope().hasPendingSheets() || m_ignorePendingStylesheets;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> Locale&amp; Document::getCachedLocale(const AtomicString&amp; locale)
</span></span></pre></div>
<a id="trunkSourceWebCoredomDocumenth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Document.h (206916 => 206917)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Document.h        2016-10-07 16:41:48 UTC (rev 206916)
+++ trunk/Source/WebCore/dom/Document.h        2016-10-07 16:55:11 UTC (rev 206917)
</span><span class="lines">@@ -74,7 +74,6 @@
</span><span class="cx"> 
</span><span class="cx"> class AXObjectCache;
</span><span class="cx"> class Attr;
</span><del>-class AuthorStyleSheets;
</del><span class="cx"> class CDATASection;
</span><span class="cx"> class CSSFontSelector;
</span><span class="cx"> class CSSStyleDeclaration;
</span><span class="lines">@@ -224,6 +223,10 @@
</span><span class="cx"> class MediaSession;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+namespace Style {
+class Scope;
+};
+
</ins><span class="cx"> const uint64_t HTMLMediaElementInvalidID = 0;
</span><span class="cx"> 
</span><span class="cx"> enum PageshowEventPersistence {
</span><span class="lines">@@ -504,8 +507,8 @@
</span><span class="cx"> 
</span><span class="cx">     WEBCORE_EXPORT StyleSheetList&amp; styleSheets();
</span><span class="cx"> 
</span><del>-    AuthorStyleSheets&amp; authorStyleSheets() { return *m_authorStyleSheets; }
-    const AuthorStyleSheets&amp; authorStyleSheets() const { return *m_authorStyleSheets; }
</del><ins>+    Style::Scope&amp; styleScope() { return *m_styleScope; }
+    const Style::Scope&amp; styleScope() const { return *m_styleScope; }
</ins><span class="cx">     ExtensionStyleSheets&amp; extensionStyleSheets() { return *m_extensionStyleSheets; }
</span><span class="cx">     const ExtensionStyleSheets&amp; extensionStyleSheets() const { return *m_extensionStyleSheets; }
</span><span class="cx"> 
</span><span class="lines">@@ -1469,7 +1472,7 @@
</span><span class="cx"> 
</span><span class="cx">     MutationObserverOptions m_mutationObserverTypes;
</span><span class="cx"> 
</span><del>-    std::unique_ptr&lt;AuthorStyleSheets&gt; m_authorStyleSheets;
</del><ins>+    std::unique_ptr&lt;Style::Scope&gt; m_styleScope;
</ins><span class="cx">     std::unique_ptr&lt;ExtensionStyleSheets&gt; m_extensionStyleSheets;
</span><span class="cx">     RefPtr&lt;StyleSheetList&gt; m_styleSheetList;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoredomExtensionStyleSheetscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/ExtensionStyleSheets.cpp (206916 => 206917)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/ExtensionStyleSheets.cpp        2016-10-07 16:41:48 UTC (rev 206916)
+++ trunk/Source/WebCore/dom/ExtensionStyleSheets.cpp        2016-10-07 16:55:11 UTC (rev 206917)
</span><span class="lines">@@ -28,7 +28,6 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;ExtensionStyleSheets.h&quot;
</span><span class="cx"> 
</span><del>-#include &quot;AuthorStyleSheets.h&quot;
</del><span class="cx"> #include &quot;CSSStyleSheet.h&quot;
</span><span class="cx"> #include &quot;Element.h&quot;
</span><span class="cx"> #include &quot;HTMLIFrameElement.h&quot;
</span><span class="lines">@@ -42,6 +41,7 @@
</span><span class="cx"> #include &quot;Settings.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 &quot;StyleSheetContents.h&quot;
</span><span class="cx"> #include &quot;StyleSheetList.h&quot;
</span><span class="cx"> #include &quot;UserContentController.h&quot;
</span><span class="lines">@@ -83,7 +83,7 @@
</span><span class="cx"> {
</span><span class="cx">     if (m_pageUserSheet) {
</span><span class="cx">         m_pageUserSheet = nullptr;
</span><del>-        m_document.authorStyleSheets().didChangeContentsOrInterpretation();
</del><ins>+        m_document.styleScope().didChangeContentsOrInterpretation();
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -91,7 +91,7 @@
</span><span class="cx"> {
</span><span class="cx">     clearPageUserSheet();
</span><span class="cx">     if (pageUserSheet())
</span><del>-        m_document.authorStyleSheets().didChangeContentsOrInterpretation();
</del><ins>+        m_document.styleScope().didChangeContentsOrInterpretation();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> const Vector&lt;RefPtr&lt;CSSStyleSheet&gt;&gt;&amp; ExtensionStyleSheets::injectedUserStyleSheets() const
</span><span class="lines">@@ -155,7 +155,7 @@
</span><span class="cx">     m_injectedStyleSheetCacheValid = false;
</span><span class="cx">     if (m_injectedUserStyleSheets.isEmpty() &amp;&amp; m_injectedAuthorStyleSheets.isEmpty())
</span><span class="cx">         return;
</span><del>-    m_document.authorStyleSheets().didChangeContentsOrInterpretation();
</del><ins>+    m_document.styleScope().didChangeContentsOrInterpretation();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void ExtensionStyleSheets::addUserStyleSheet(Ref&lt;StyleSheetContents&gt;&amp;&amp; userSheet)
</span><span class="lines">@@ -162,7 +162,7 @@
</span><span class="cx"> {
</span><span class="cx">     ASSERT(userSheet.get().isUserStyleSheet());
</span><span class="cx">     m_userStyleSheets.append(CSSStyleSheet::create(WTFMove(userSheet), m_document));
</span><del>-    m_document.authorStyleSheets().didChangeContentsOrInterpretation();
</del><ins>+    m_document.styleScope().didChangeContentsOrInterpretation();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void ExtensionStyleSheets::addAuthorStyleSheetForTesting(Ref&lt;StyleSheetContents&gt;&amp;&amp; authorSheet)
</span><span class="lines">@@ -169,7 +169,7 @@
</span><span class="cx"> {
</span><span class="cx">     ASSERT(!authorSheet.get().isUserStyleSheet());
</span><span class="cx">     m_authorStyleSheetsForTesting.append(CSSStyleSheet::create(WTFMove(authorSheet), m_document));
</span><del>-    m_document.authorStyleSheets().didChangeContentsOrInterpretation();
</del><ins>+    m_document.styleScope().didChangeContentsOrInterpretation();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(CONTENT_EXTENSIONS)
</span><span class="lines">@@ -201,7 +201,7 @@
</span><span class="cx"> 
</span><span class="cx"> void ExtensionStyleSheets::styleResolverChangedTimerFired()
</span><span class="cx"> {
</span><del>-    m_document.authorStyleSheets().didChangeContentsOrInterpretation();
</del><ins>+    m_document.styleScope().didChangeContentsOrInterpretation();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void ExtensionStyleSheets::detachFromDocument()
</span></span></pre></div>
<a id="trunkSourceWebCoredomInlineStyleSheetOwnercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/InlineStyleSheetOwner.cpp (206916 => 206917)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/InlineStyleSheetOwner.cpp        2016-10-07 16:41:48 UTC (rev 206916)
+++ trunk/Source/WebCore/dom/InlineStyleSheetOwner.cpp        2016-10-07 16:55:11 UTC (rev 206917)
</span><span class="lines">@@ -21,7 +21,6 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;InlineStyleSheetOwner.h&quot;
</span><span class="cx"> 
</span><del>-#include &quot;AuthorStyleSheets.h&quot;
</del><span class="cx"> #include &quot;ContentSecurityPolicy.h&quot;
</span><span class="cx"> #include &quot;Element.h&quot;
</span><span class="cx"> #include &quot;MediaList.h&quot;
</span><span class="lines">@@ -28,6 +27,7 @@
</span><span class="cx"> #include &quot;MediaQueryEvaluator.h&quot;
</span><span class="cx"> #include &quot;ScriptableDocumentParser.h&quot;
</span><span class="cx"> #include &quot;ShadowRoot.h&quot;
</span><ins>+#include &quot;StyleScope.h&quot;
</ins><span class="cx"> #include &quot;StyleSheetContents.h&quot;
</span><span class="cx"> #include &quot;TextNodeTraversal.h&quot;
</span><span class="cx"> #include &lt;wtf/NeverDestroyed.h&gt;
</span><span class="lines">@@ -51,8 +51,8 @@
</span><span class="cx"> 
</span><span class="cx"> void InlineStyleSheetOwner::insertedIntoDocument(Element&amp; element)
</span><span class="cx"> {
</span><del>-    m_styleSheetScope = &amp;AuthorStyleSheets::forNode(element);
-    m_styleSheetScope-&gt;addStyleSheetCandidateNode(element, m_isParsingChildren);
</del><ins>+    m_styleScope = &amp;Style::Scope::forNode(element);
+    m_styleScope-&gt;addStyleSheetCandidateNode(element, m_isParsingChildren);
</ins><span class="cx"> 
</span><span class="cx">     if (m_isParsingChildren)
</span><span class="cx">         return;
</span><span class="lines">@@ -61,9 +61,9 @@
</span><span class="cx"> 
</span><span class="cx"> void InlineStyleSheetOwner::removedFromDocument(Element&amp; element)
</span><span class="cx"> {
</span><del>-    if (m_styleSheetScope) {
-        m_styleSheetScope-&gt;removeStyleSheetCandidateNode(element);
-        m_styleSheetScope = nullptr;
</del><ins>+    if (m_styleScope) {
+        m_styleScope-&gt;removeStyleSheetCandidateNode(element);
+        m_styleScope = nullptr;
</ins><span class="cx">     }
</span><span class="cx">     if (m_sheet)
</span><span class="cx">         clearSheet();
</span><span class="lines">@@ -74,9 +74,9 @@
</span><span class="cx">     if (m_sheet)
</span><span class="cx">         m_sheet-&gt;clearOwnerNode();
</span><span class="cx"> 
</span><del>-    if (m_styleSheetScope) {
-        m_styleSheetScope-&gt;removeStyleSheetCandidateNode(element);
-        m_styleSheetScope = nullptr;
</del><ins>+    if (m_styleScope) {
+        m_styleScope-&gt;removeStyleSheetCandidateNode(element);
+        m_styleScope = nullptr;
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -124,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() &amp;&amp; m_styleSheetScope)
-            m_styleSheetScope-&gt;removePendingSheet();
</del><ins>+        if (m_sheet-&gt;isLoading() &amp;&amp; m_styleScope)
+            m_styleScope-&gt;removePendingSheet();
</ins><span class="cx">         clearSheet();
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -149,8 +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>-    if (m_styleSheetScope)
-        m_styleSheetScope-&gt;addPendingSheet();
</del><ins>+    if (m_styleScope)
+        m_styleScope-&gt;addPendingSheet();
</ins><span class="cx"> 
</span><span class="cx">     m_loading = true;
</span><span class="cx"> 
</span><span class="lines">@@ -177,8 +177,8 @@
</span><span class="cx">     if (isLoading())
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><del>-    if (m_styleSheetScope)
-        m_styleSheetScope-&gt;removePendingSheet();
</del><ins>+    if (m_styleScope)
+        m_styleScope-&gt;removePendingSheet();
</ins><span class="cx"> 
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="lines">@@ -185,8 +185,8 @@
</span><span class="cx"> 
</span><span class="cx"> void InlineStyleSheetOwner::startLoadingDynamicSheet(Element&amp;)
</span><span class="cx"> {
</span><del>-    if (m_styleSheetScope)
-        m_styleSheetScope-&gt;addPendingSheet();
</del><ins>+    if (m_styleScope)
+        m_styleScope-&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 (206916 => 206917)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/InlineStyleSheetOwner.h        2016-10-07 16:41:48 UTC (rev 206916)
+++ trunk/Source/WebCore/dom/InlineStyleSheetOwner.h        2016-10-07 16:55:11 UTC (rev 206917)
</span><span class="lines">@@ -50,7 +50,7 @@
</span><span class="cx">     void childrenChanged(Element&amp;);
</span><span class="cx">     void finishParsingChildren(Element&amp;);
</span><span class="cx"> 
</span><del>-    AuthorStyleSheets* styleSheetScope() { return m_styleSheetScope; }
</del><ins>+    Style::Scope* styleScope() { return m_styleScope; }
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     void createSheet(Element&amp;, const String&amp; text);
</span><span class="lines">@@ -63,7 +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><del>-    AuthorStyleSheets* m_styleSheetScope { nullptr };
</del><ins>+    Style::Scope* m_styleScope { nullptr };
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoredomProcessingInstructioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/ProcessingInstruction.cpp (206916 => 206917)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/ProcessingInstruction.cpp        2016-10-07 16:41:48 UTC (rev 206916)
+++ trunk/Source/WebCore/dom/ProcessingInstruction.cpp        2016-10-07 16:55:11 UTC (rev 206917)
</span><span class="lines">@@ -22,7 +22,6 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;ProcessingInstruction.h&quot;
</span><span class="cx"> 
</span><del>-#include &quot;AuthorStyleSheets.h&quot;
</del><span class="cx"> #include &quot;CSSStyleSheet.h&quot;
</span><span class="cx"> #include &quot;CachedCSSStyleSheet.h&quot;
</span><span class="cx"> #include &quot;CachedResourceLoader.h&quot;
</span><span class="lines">@@ -35,6 +34,7 @@
</span><span class="cx"> #include &quot;XSLStyleSheet.h&quot;
</span><span class="cx"> #include &quot;XMLDocumentParser.h&quot; // for parseAttributes()
</span><span class="cx"> #include &quot;MediaList.h&quot;
</span><ins>+#include &quot;StyleScope.h&quot;
</ins><span class="cx"> #include &quot;StyleSheetContents.h&quot;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -59,7 +59,7 @@
</span><span class="cx">         m_cachedSheet-&gt;removeClient(*this);
</span><span class="cx"> 
</span><span class="cx">     if (inDocument())
</span><del>-        document().authorStyleSheets().removeStyleSheetCandidateNode(*this);
</del><ins>+        document().styleScope().removeStyleSheetCandidateNode(*this);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> String ProcessingInstruction::nodeName() const
</span><span class="lines">@@ -135,7 +135,7 @@
</span><span class="cx">                 return;
</span><span class="cx"> 
</span><span class="cx">             m_loading = true;
</span><del>-            document().authorStyleSheets().addPendingSheet();
</del><ins>+            document().styleScope().addPendingSheet();
</ins><span class="cx"> 
</span><span class="cx"> #if ENABLE(XSLT)
</span><span class="cx">             if (m_isXSL) {
</span><span class="lines">@@ -158,7 +158,7 @@
</span><span class="cx">             else {
</span><span class="cx">                 // The request may have been denied if (for example) the stylesheet is local and the document is remote.
</span><span class="cx">                 m_loading = false;
</span><del>-                document().authorStyleSheets().removePendingSheet();
</del><ins>+                document().styleScope().removePendingSheet();
</ins><span class="cx">             }
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="lines">@@ -176,7 +176,7 @@
</span><span class="cx"> bool ProcessingInstruction::sheetLoaded()
</span><span class="cx"> {
</span><span class="cx">     if (!isLoading()) {
</span><del>-        document().authorStyleSheets().removePendingSheet();
</del><ins>+        document().styleScope().removePendingSheet();
</ins><span class="cx">         return true;
</span><span class="cx">     }
</span><span class="cx">     return false;
</span><span class="lines">@@ -251,7 +251,7 @@
</span><span class="cx">     CharacterData::insertedInto(insertionPoint);
</span><span class="cx">     if (!insertionPoint.inDocument())
</span><span class="cx">         return InsertionDone;
</span><del>-    document().authorStyleSheets().addStyleSheetCandidateNode(*this, m_createdByParser);
</del><ins>+    document().styleScope().addStyleSheetCandidateNode(*this, m_createdByParser);
</ins><span class="cx">     checkStyleSheet();
</span><span class="cx">     return InsertionDone;
</span><span class="cx"> }
</span><span class="lines">@@ -262,7 +262,7 @@
</span><span class="cx">     if (!insertionPoint.inDocument())
</span><span class="cx">         return;
</span><span class="cx">     
</span><del>-    document().authorStyleSheets().removeStyleSheetCandidateNode(*this);
</del><ins>+    document().styleScope().removeStyleSheetCandidateNode(*this);
</ins><span class="cx"> 
</span><span class="cx">     if (m_sheet) {
</span><span class="cx">         ASSERT(m_sheet-&gt;ownerNode() == this);
</span><span class="lines">@@ -272,12 +272,12 @@
</span><span class="cx"> 
</span><span class="cx">     if (m_loading) {
</span><span class="cx">         m_loading = false;
</span><del>-        document().authorStyleSheets().removePendingSheet();
</del><ins>+        document().styleScope().removePendingSheet();
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // If we're in document teardown, then we don't need to do any notification of our sheet's removal.
</span><span class="cx">     if (document().hasLivingRenderTree())
</span><del>-        document().authorStyleSheets().didChangeContentsOrInterpretation();
</del><ins>+        document().styleScope().didChangeContentsOrInterpretation();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void ProcessingInstruction::finishParsingChildren()
</span></span></pre></div>
<a id="trunkSourceWebCoredomShadowRootcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/ShadowRoot.cpp (206916 => 206917)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/ShadowRoot.cpp        2016-10-07 16:41:48 UTC (rev 206916)
+++ trunk/Source/WebCore/dom/ShadowRoot.cpp        2016-10-07 16:55:11 UTC (rev 206917)
</span><span class="lines">@@ -28,7 +28,6 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;ShadowRoot.h&quot;
</span><span class="cx"> 
</span><del>-#include &quot;AuthorStyleSheets.h&quot;
</del><span class="cx"> #include &quot;CSSStyleSheet.h&quot;
</span><span class="cx"> #include &quot;ElementTraversal.h&quot;
</span><span class="cx"> #include &quot;RenderElement.h&quot;
</span><span class="lines">@@ -35,6 +34,7 @@
</span><span class="cx"> #include &quot;RuntimeEnabledFeatures.h&quot;
</span><span class="cx"> #include &quot;SlotAssignment.h&quot;
</span><span class="cx"> #include &quot;StyleResolver.h&quot;
</span><ins>+#include &quot;StyleScope.h&quot;
</ins><span class="cx"> #include &quot;markup.h&quot;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -42,7 +42,7 @@
</span><span class="cx"> struct SameSizeAsShadowRoot : public DocumentFragment, public TreeScope {
</span><span class="cx">     unsigned countersAndFlags[1];
</span><span class="cx">     void* styleResolver;
</span><del>-    void* authorStyleSheets;
</del><ins>+    void* styleScope;
</ins><span class="cx">     void* host;
</span><span class="cx">     void* slotAssignment;
</span><span class="cx"> };
</span><span class="lines">@@ -88,8 +88,8 @@
</span><span class="cx">     if (!m_styleResolver) {
</span><span class="cx">         // FIXME: We could share style resolver with shadow roots that have identical style.
</span><span class="cx">         m_styleResolver = std::make_unique&lt;StyleResolver&gt;(document());
</span><del>-        if (m_authorStyleSheets)
-            m_styleResolver-&gt;appendAuthorStyleSheets(m_authorStyleSheets-&gt;activeStyleSheets());
</del><ins>+        if (m_styleScope)
+            m_styleResolver-&gt;appendAuthorStyleSheets(m_styleScope-&gt;activeStyleSheets());
</ins><span class="cx">     }
</span><span class="cx">     return *m_styleResolver;
</span><span class="cx"> }
</span><span class="lines">@@ -107,19 +107,19 @@
</span><span class="cx">     m_styleResolver = nullptr;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-AuthorStyleSheets&amp; ShadowRoot::authorStyleSheets()
</del><ins>+Style::Scope&amp; ShadowRoot::styleScope()
</ins><span class="cx"> {
</span><del>-    if (!m_authorStyleSheets)
-        m_authorStyleSheets = std::make_unique&lt;AuthorStyleSheets&gt;(*this);
-    return *m_authorStyleSheets;
</del><ins>+    if (!m_styleScope)
+        m_styleScope = std::make_unique&lt;Style::Scope&gt;(*this);
+    return *m_styleScope;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void ShadowRoot::updateStyle()
</span><span class="cx"> {
</span><del>-    if (!m_authorStyleSheets)
</del><ins>+    if (!m_styleScope)
</ins><span class="cx">         return;
</span><span class="cx">     // FIXME: Make optimized updated work.
</span><del>-    m_authorStyleSheets-&gt;didChangeContentsOrInterpretation();
</del><ins>+    m_styleScope-&gt;didChangeContentsOrInterpretation();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> String ShadowRoot::innerHTML() const
</span></span></pre></div>
<a id="trunkSourceWebCoredomShadowRooth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/ShadowRoot.h (206916 => 206917)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/ShadowRoot.h        2016-10-07 16:41:48 UTC (rev 206916)
+++ trunk/Source/WebCore/dom/ShadowRoot.h        2016-10-07 16:55:11 UTC (rev 206917)
</span><span class="lines">@@ -36,7 +36,6 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-class AuthorStyleSheets;
</del><span class="cx"> class HTMLSlotElement;
</span><span class="cx"> class SlotAssignment;
</span><span class="cx"> 
</span><span class="lines">@@ -64,7 +63,7 @@
</span><span class="cx"> 
</span><span class="cx">     StyleResolver&amp; styleResolver();
</span><span class="cx">     StyleResolver* styleResolverIfExists();
</span><del>-    AuthorStyleSheets&amp; authorStyleSheets();
</del><ins>+    Style::Scope&amp; styleScope();
</ins><span class="cx"> 
</span><span class="cx">     void updateStyle();
</span><span class="cx">     void resetStyleResolver();
</span><span class="lines">@@ -116,7 +115,7 @@
</span><span class="cx">     Element* m_host { nullptr };
</span><span class="cx"> 
</span><span class="cx">     std::unique_ptr&lt;StyleResolver&gt; m_styleResolver;
</span><del>-    std::unique_ptr&lt;AuthorStyleSheets&gt; m_authorStyleSheets;
</del><ins>+    std::unique_ptr&lt;Style::Scope&gt; m_styleScope;
</ins><span class="cx"> 
</span><span class="cx">     std::unique_ptr&lt;SlotAssignment&gt; m_slotAssignment;
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLLinkElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLLinkElement.cpp (206916 => 206917)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLLinkElement.cpp        2016-10-07 16:41:48 UTC (rev 206916)
+++ trunk/Source/WebCore/html/HTMLLinkElement.cpp        2016-10-07 16:55:11 UTC (rev 206917)
</span><span class="lines">@@ -26,7 +26,6 @@
</span><span class="cx"> #include &quot;HTMLLinkElement.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;Attribute.h&quot;
</span><del>-#include &quot;AuthorStyleSheets.h&quot;
</del><span class="cx"> #include &quot;CachedCSSStyleSheet.h&quot;
</span><span class="cx"> #include &quot;CachedResource.h&quot;
</span><span class="cx"> #include &quot;CachedResourceLoader.h&quot;
</span><span class="lines">@@ -54,6 +53,7 @@
</span><span class="cx"> #include &quot;Settings.h&quot;
</span><span class="cx"> #include &quot;StyleInheritedData.h&quot;
</span><span class="cx"> #include &quot;StyleResolveForDocument.h&quot;
</span><ins>+#include &quot;StyleScope.h&quot;
</ins><span class="cx"> #include &quot;StyleSheetContents.h&quot;
</span><span class="cx"> #include &lt;wtf/Ref.h&gt;
</span><span class="cx"> #include &lt;wtf/StdLibExtras.h&gt;
</span><span class="lines">@@ -102,7 +102,7 @@
</span><span class="cx">         m_cachedSheet-&gt;removeClient(*this);
</span><span class="cx"> 
</span><span class="cx">     if (inDocument())
</span><del>-        document().authorStyleSheets().removeStyleSheetCandidateNode(*this);
</del><ins>+        document().styleScope().removeStyleSheetCandidateNode(*this);
</ins><span class="cx"> 
</span><span class="cx">     linkLoadEventSender().cancelEvent(*this);
</span><span class="cx">     linkErrorEventSender().cancelEvent(*this);
</span><span class="lines">@@ -140,7 +140,7 @@
</span><span class="cx">         if (!m_sheet &amp;&amp; m_disabledState == EnabledViaScript)
</span><span class="cx">             process();
</span><span class="cx">         else
</span><del>-            document().authorStyleSheets().didChangeContentsOrInterpretation();
</del><ins>+            document().styleScope().didChangeContentsOrInterpretation();
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -176,7 +176,7 @@
</span><span class="cx">         m_media = value.string().convertToASCIILowercase();
</span><span class="cx">         process();
</span><span class="cx">         if (m_sheet &amp;&amp; !isDisabled())
</span><del>-            document().authorStyleSheets().didChangeContentsOrInterpretation();
</del><ins>+            document().styleScope().didChangeContentsOrInterpretation();
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx">     if (name == disabledAttr) {
</span><span class="lines">@@ -283,7 +283,7 @@
</span><span class="cx">     } else if (m_sheet) {
</span><span class="cx">         // we no longer contain a stylesheet, e.g. perhaps rel or type was changed
</span><span class="cx">         clearSheet();
</span><del>-        document().authorStyleSheets().didChangeContentsOrInterpretation();
</del><ins>+        document().styleScope().didChangeContentsOrInterpretation();
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -305,7 +305,7 @@
</span><span class="cx">     if (m_isInShadowTree)
</span><span class="cx">         return InsertionDone;
</span><span class="cx"> 
</span><del>-    document().authorStyleSheets().addStyleSheetCandidateNode(*this, m_createdByParser);
</del><ins>+    document().styleScope().addStyleSheetCandidateNode(*this, m_createdByParser);
</ins><span class="cx"> 
</span><span class="cx">     process();
</span><span class="cx">     return InsertionDone;
</span><span class="lines">@@ -321,7 +321,7 @@
</span><span class="cx">         ASSERT(!m_sheet);
</span><span class="cx">         return;
</span><span class="cx">     }
</span><del>-    document().authorStyleSheets().removeStyleSheetCandidateNode(*this);
</del><ins>+    document().styleScope().removeStyleSheetCandidateNode(*this);
</ins><span class="cx"> 
</span><span class="cx">     if (m_sheet)
</span><span class="cx">         clearSheet();
</span><span class="lines">@@ -544,7 +544,7 @@
</span><span class="cx"> 
</span><span class="cx">     if (m_pendingSheetType == InactiveSheet)
</span><span class="cx">         return;
</span><del>-    document().authorStyleSheets().addPendingSheet();
</del><ins>+    document().styleScope().addPendingSheet();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void HTMLLinkElement::removePendingSheet(RemovePendingSheetNotificationType notification)
</span><span class="lines">@@ -557,14 +557,14 @@
</span><span class="cx"> 
</span><span class="cx">     if (type == InactiveSheet) {
</span><span class="cx">         // Document just needs to know about the sheet for exposure through document.styleSheets
</span><del>-        document().authorStyleSheets().didChangeCandidatesForActiveSet();
</del><ins>+        document().styleScope().didChangeCandidatesForActiveSet();
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    document().authorStyleSheets().removePendingSheet(
</del><ins>+    document().styleScope().removePendingSheet(
</ins><span class="cx">         notification == RemovePendingSheetNotifyImmediately
</span><del>-        ? AuthorStyleSheets::RemovePendingSheetNotifyImmediately
-        : AuthorStyleSheets::RemovePendingSheetNotifyLater);
</del><ins>+        ? Style::Scope::RemovePendingSheetNotifyImmediately
+        : Style::Scope::RemovePendingSheetNotifyLater);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLStyleElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLStyleElement.cpp (206916 => 206917)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLStyleElement.cpp        2016-10-07 16:41:48 UTC (rev 206916)
+++ trunk/Source/WebCore/html/HTMLStyleElement.cpp        2016-10-07 16:55:11 UTC (rev 206917)
</span><span class="lines">@@ -24,7 +24,6 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;HTMLStyleElement.h&quot;
</span><span class="cx"> 
</span><del>-#include &quot;AuthorStyleSheets.h&quot;
</del><span class="cx"> #include &quot;CachedResource.h&quot;
</span><span class="cx"> #include &quot;Document.h&quot;
</span><span class="cx"> #include &quot;Event.h&quot;
</span><span class="lines">@@ -35,6 +34,7 @@
</span><span class="cx"> #include &quot;RuntimeEnabledFeatures.h&quot;
</span><span class="cx"> #include &quot;ScriptableDocumentParser.h&quot;
</span><span class="cx"> #include &quot;ShadowRoot.h&quot;
</span><ins>+#include &quot;StyleScope.h&quot;
</ins><span class="cx"> #include &quot;StyleSheetContents.h&quot;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -76,7 +76,7 @@
</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 (auto* scope = m_styleSheetOwner.styleSheetScope())
</del><ins>+            if (auto* scope = m_styleSheetOwner.styleScope())
</ins><span class="cx">                 scope-&gt;didChangeContentsOrInterpretation();
</span><span class="cx">         } else
</span><span class="cx">             m_styleSheetOwner.childrenChanged(*this);
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorInspectorCSSAgentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp (206916 => 206917)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp        2016-10-07 16:41:48 UTC (rev 206916)
+++ trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp        2016-10-07 16:55:11 UTC (rev 206917)
</span><span class="lines">@@ -26,7 +26,6 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;InspectorCSSAgent.h&quot;
</span><span class="cx"> 
</span><del>-#include &quot;AuthorStyleSheets.h&quot;
</del><span class="cx"> #include &quot;CSSComputedStyleDeclaration.h&quot;
</span><span class="cx"> #include &quot;CSSImportRule.h&quot;
</span><span class="cx"> #include &quot;CSSPropertyNames.h&quot;
</span><span class="lines">@@ -56,6 +55,7 @@
</span><span class="cx"> #include &quot;StylePropertyShorthand.h&quot;
</span><span class="cx"> #include &quot;StyleResolver.h&quot;
</span><span class="cx"> #include &quot;StyleRule.h&quot;
</span><ins>+#include &quot;StyleScope.h&quot;
</ins><span class="cx"> #include &quot;StyleSheetList.h&quot;
</span><span class="cx"> #include &quot;WebKitNamedFlow.h&quot;
</span><span class="cx"> #include &lt;inspector/InspectorProtocolObjects.h&gt;
</span><span class="lines">@@ -670,7 +670,7 @@
</span><span class="cx"> 
</span><span class="cx"> void InspectorCSSAgent::collectAllDocumentStyleSheets(Document&amp; document, Vector&lt;CSSStyleSheet*&gt;&amp; result)
</span><span class="cx"> {
</span><del>-    auto cssStyleSheets = document.authorStyleSheets().activeStyleSheetsForInspector();
</del><ins>+    auto cssStyleSheets = document.styleScope().activeStyleSheetsForInspector();
</ins><span class="cx">     for (auto&amp; cssStyleSheet : cssStyleSheets)
</span><span class="cx">         collectStyleSheets(cssStyleSheet.get(), result);
</span><span class="cx"> }
</span><span class="lines">@@ -889,7 +889,7 @@
</span><span class="cx">         m_nodeIdToForcedPseudoState.set(nodeId, forcedPseudoState);
</span><span class="cx">     else
</span><span class="cx">         m_nodeIdToForcedPseudoState.remove(nodeId);
</span><del>-    element-&gt;document().authorStyleSheets().didChangeContentsOrInterpretation();
</del><ins>+    element-&gt;document().styleScope().didChangeContentsOrInterpretation();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void InspectorCSSAgent::getNamedFlowCollection(ErrorString&amp; errorString, int documentNodeId, RefPtr&lt;Inspector::Protocol::Array&lt;Inspector::Protocol::CSS::NamedFlow&gt;&gt;&amp; result)
</span><span class="lines">@@ -1015,7 +1015,7 @@
</span><span class="cx"> 
</span><span class="cx">     // StyleRules returned by StyleResolver::styleRulesForElement lack parent pointers since that infomation is not cheaply available.
</span><span class="cx">     // Since the inspector wants to walk the parent chain, we construct the full wrappers here.
</span><del>-    CSSStyleRule* cssomWrapper = styleResolver.inspectorCSSOMWrappers().getWrapperForRuleInSheets(styleRule, styleResolver.document().authorStyleSheets(), styleResolver.document().extensionStyleSheets());
</del><ins>+    CSSStyleRule* cssomWrapper = styleResolver.inspectorCSSOMWrappers().getWrapperForRuleInSheets(styleRule, styleResolver.document().styleScope(), styleResolver.document().extensionStyleSheets());
</ins><span class="cx">     if (!cssomWrapper)
</span><span class="cx">         return nullptr;
</span><span class="cx">     InspectorStyleSheet* inspectorStyleSheet = bindStyleSheet(cssomWrapper-&gt;parentStyleSheet());
</span><span class="lines">@@ -1189,7 +1189,7 @@
</span><span class="cx"> 
</span><span class="cx">     m_nodeIdToForcedPseudoState.clear();
</span><span class="cx">     for (auto&amp; document : documentsToChange)
</span><del>-        document-&gt;authorStyleSheets().didChangeContentsOrInterpretation();
</del><ins>+        document-&gt;styleScope().didChangeContentsOrInterpretation();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorInspectorPageAgentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/InspectorPageAgent.cpp (206916 => 206917)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/InspectorPageAgent.cpp        2016-10-07 16:41:48 UTC (rev 206916)
+++ trunk/Source/WebCore/inspector/InspectorPageAgent.cpp        2016-10-07 16:55:11 UTC (rev 206917)
</span><span class="lines">@@ -32,7 +32,6 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;InspectorPageAgent.h&quot;
</span><span class="cx"> 
</span><del>-#include &quot;AuthorStyleSheets.h&quot;
</del><span class="cx"> #include &quot;CachedCSSStyleSheet.h&quot;
</span><span class="cx"> #include &quot;CachedFont.h&quot;
</span><span class="cx"> #include &quot;CachedImage.h&quot;
</span><span class="lines">@@ -67,6 +66,7 @@
</span><span class="cx"> #include &quot;ScriptController.h&quot;
</span><span class="cx"> #include &quot;SecurityOrigin.h&quot;
</span><span class="cx"> #include &quot;Settings.h&quot;
</span><ins>+#include &quot;StyleScope.h&quot;
</ins><span class="cx"> #include &quot;TextEncoding.h&quot;
</span><span class="cx"> #include &quot;TextResourceDecoder.h&quot;
</span><span class="cx"> #include &quot;UserGestureIndicator.h&quot;
</span><span class="lines">@@ -1002,7 +1002,7 @@
</span><span class="cx">     m_emulatedMedia = media;
</span><span class="cx">     Document* document = m_page.mainFrame().document();
</span><span class="cx">     if (document) {
</span><del>-        document-&gt;authorStyleSheets().didChangeContentsOrInterpretation();
</del><ins>+        document-&gt;styleScope().didChangeContentsOrInterpretation();
</ins><span class="cx">         document-&gt;updateLayout();
</span><span class="cx">     }
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorepageDOMWindowcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/DOMWindow.cpp (206916 => 206917)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/DOMWindow.cpp        2016-10-07 16:41:48 UTC (rev 206916)
+++ trunk/Source/WebCore/page/DOMWindow.cpp        2016-10-07 16:55:11 UTC (rev 206917)
</span><span class="lines">@@ -27,7 +27,6 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;DOMWindow.h&quot;
</span><span class="cx"> 
</span><del>-#include &quot;AuthorStyleSheets.h&quot;
</del><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">@@ -97,6 +96,7 @@
</span><span class="cx"> #include &quot;StorageNamespaceProvider.h&quot;
</span><span class="cx"> #include &quot;StyleMedia.h&quot;
</span><span class="cx"> #include &quot;StyleResolver.h&quot;
</span><ins>+#include &quot;StyleScope.h&quot;
</ins><span class="cx"> #include &quot;SuddenTermination.h&quot;
</span><span class="cx"> #include &quot;URL.h&quot;
</span><span class="cx"> #include &quot;UserGestureIndicator.h&quot;
</span><span class="lines">@@ -1432,7 +1432,7 @@
</span><span class="cx">     if (pseudoType == CSSSelector::PseudoElementUnknown &amp;&amp; !pseudoElement.isEmpty())
</span><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><del>-    m_frame-&gt;document()-&gt;authorStyleSheets().flushPendingUpdate();
</del><ins>+    m_frame-&gt;document()-&gt;styleScope().flushPendingUpdate();
</ins><span class="cx"> 
</span><span class="cx">     unsigned rulesToInclude = StyleResolver::AuthorCSSRules;
</span><span class="cx">     if (!authorOnly)
</span></span></pre></div>
<a id="trunkSourceWebCorepageFramecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/Frame.cpp (206916 => 206917)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/Frame.cpp        2016-10-07 16:41:48 UTC (rev 206916)
+++ trunk/Source/WebCore/page/Frame.cpp        2016-10-07 16:55:11 UTC (rev 206917)
</span><span class="lines">@@ -32,7 +32,6 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;AnimationController.h&quot;
</span><span class="cx"> #include &quot;ApplyStyleCommand.h&quot;
</span><del>-#include &quot;AuthorStyleSheets.h&quot;
</del><span class="cx"> #include &quot;BackForwardController.h&quot;
</span><span class="cx"> #include &quot;CSSComputedStyleDeclaration.h&quot;
</span><span class="cx"> #include &quot;CSSPropertyNames.h&quot;
</span><span class="lines">@@ -93,6 +92,7 @@
</span><span class="cx"> #include &quot;ScrollingCoordinator.h&quot;
</span><span class="cx"> #include &quot;Settings.h&quot;
</span><span class="cx"> #include &quot;StyleProperties.h&quot;
</span><ins>+#include &quot;StyleScope.h&quot;
</ins><span class="cx"> #include &quot;TextNodeTraversal.h&quot;
</span><span class="cx"> #include &quot;TextResourceDecoder.h&quot;
</span><span class="cx"> #include &quot;UserContentController.h&quot;
</span><span class="lines">@@ -644,7 +644,7 @@
</span><span class="cx">     m_doc-&gt;setPrinting(printing);
</span><span class="cx">     view()-&gt;adjustMediaTypeForPrinting(printing);
</span><span class="cx"> 
</span><del>-    m_doc-&gt;authorStyleSheets().didChangeContentsOrInterpretation();
</del><ins>+    m_doc-&gt;styleScope().didChangeContentsOrInterpretation();
</ins><span class="cx">     if (shouldUsePrintingLayout()) {
</span><span class="cx">         view()-&gt;forceLayoutForPagination(pageSize, originalPageSize, maximumShrinkRatio, shouldAdjustViewSize);
</span><span class="cx">     } else {
</span></span></pre></div>
<a id="trunkSourceWebCorepageFrameViewcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/FrameView.cpp (206916 => 206917)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/FrameView.cpp        2016-10-07 16:41:48 UTC (rev 206916)
+++ trunk/Source/WebCore/page/FrameView.cpp        2016-10-07 16:55:11 UTC (rev 206917)
</span><span class="lines">@@ -29,7 +29,6 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;AXObjectCache.h&quot;
</span><span class="cx"> #include &quot;AnimationController.h&quot;
</span><del>-#include &quot;AuthorStyleSheets.h&quot;
</del><span class="cx"> #include &quot;BackForwardController.h&quot;
</span><span class="cx"> #include &quot;CachedImage.h&quot;
</span><span class="cx"> #include &quot;CachedResourceLoader.h&quot;
</span><span class="lines">@@ -92,6 +91,7 @@
</span><span class="cx"> #include &quot;ScrollingCoordinator.h&quot;
</span><span class="cx"> #include &quot;Settings.h&quot;
</span><span class="cx"> #include &quot;StyleResolver.h&quot;
</span><ins>+#include &quot;StyleScope.h&quot;
</ins><span class="cx"> #include &quot;TextResourceDecoder.h&quot;
</span><span class="cx"> #include &quot;TextStream.h&quot;
</span><span class="cx"> #include &quot;TiledBacking.h&quot;
</span><span class="lines">@@ -1335,7 +1335,7 @@
</span><span class="cx">         StyleResolver* styleResolver = document.styleResolverIfExists();
</span><span class="cx">         if (!styleResolver || styleResolver-&gt;hasMediaQueriesAffectedByViewportChange()) {
</span><span class="cx">             LOG(Layout, &quot;  hasMediaQueriesAffectedByViewportChange, enqueueing style recalc&quot;);
</span><del>-            document.authorStyleSheets().didChangeContentsOrInterpretation();
</del><ins>+            document.styleScope().didChangeContentsOrInterpretation();
</ins><span class="cx">             // FIXME: This instrumentation event is not strictly accurate since cached media query results do not persist across StyleResolver rebuilds.
</span><span class="cx">             InspectorInstrumentation::mediaQueryResultChanged(document);
</span><span class="cx">         } else
</span><span class="lines">@@ -3532,7 +3532,7 @@
</span><span class="cx"> 
</span><span class="cx">     m_pagination = pagination;
</span><span class="cx"> 
</span><del>-    frame().document()-&gt;authorStyleSheets().didChangeContentsOrInterpretation();
</del><ins>+    frame().document()-&gt;styleScope().didChangeContentsOrInterpretation();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> IntRect FrameView::windowClipRect() const
</span><span class="lines">@@ -5001,7 +5001,7 @@
</span><span class="cx">     if (Document* document = frame().document()) {
</span><span class="cx">         // FIXME: this should probably be updateViewportUnitsOnResize(), but synchronously
</span><span class="cx">         // dirtying style here causes assertions on iOS (rdar://problem/19998166).
</span><del>-        document-&gt;authorStyleSheets().didChangeContentsOrInterpretation();
</del><ins>+        document-&gt;styleScope().didChangeContentsOrInterpretation();
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx">     
</span></span></pre></div>
<a id="trunkSourceWebCorepagePagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/Page.cpp (206916 => 206917)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/Page.cpp        2016-10-07 16:41:48 UTC (rev 206916)
+++ trunk/Source/WebCore/page/Page.cpp        2016-10-07 16:55:11 UTC (rev 206917)
</span><span class="lines">@@ -23,7 +23,6 @@
</span><span class="cx"> #include &quot;AlternativeTextClient.h&quot;
</span><span class="cx"> #include &quot;AnimationController.h&quot;
</span><span class="cx"> #include &quot;ApplicationCacheStorage.h&quot;
</span><del>-#include &quot;AuthorStyleSheets.h&quot;
</del><span class="cx"> #include &quot;BackForwardClient.h&quot;
</span><span class="cx"> #include &quot;BackForwardController.h&quot;
</span><span class="cx"> #include &quot;Chrome.h&quot;
</span><span class="lines">@@ -90,6 +89,7 @@
</span><span class="cx"> #include &quot;StorageNamespace.h&quot;
</span><span class="cx"> #include &quot;StorageNamespaceProvider.h&quot;
</span><span class="cx"> #include &quot;StyleResolver.h&quot;
</span><ins>+#include &quot;StyleScope.h&quot;
</ins><span class="cx"> #include &quot;SubframeLoader.h&quot;
</span><span class="cx"> #include &quot;TextResourceDecoder.h&quot;
</span><span class="cx"> #include &quot;UserContentProvider.h&quot;
</span><span class="lines">@@ -424,7 +424,7 @@
</span><span class="cx">         m_mainFrame-&gt;view()-&gt;forceLayout();
</span><span class="cx"> 
</span><span class="cx">     if (m_mainFrame-&gt;document())
</span><del>-        m_mainFrame-&gt;document()-&gt;authorStyleSheets().didChangeContentsOrInterpretation();
</del><ins>+        m_mainFrame-&gt;document()-&gt;styleScope().didChangeContentsOrInterpretation();
</ins><span class="cx"> }
</span><span class="cx"> #endif // ENABLE(VIEW_MODE_CSS_MEDIA)
</span><span class="cx"> 
</span><span class="lines">@@ -502,7 +502,7 @@
</span><span class="cx"> {
</span><span class="cx">     for (Frame* frame = &amp;mainFrame(); frame; frame = frame-&gt;tree().traverseNext()) {
</span><span class="cx">         if (Document* document = frame-&gt;document())
</span><del>-            document-&gt;authorStyleSheets().didChangeContentsOrInterpretation();
</del><ins>+            document-&gt;styleScope().didChangeContentsOrInterpretation();
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -1163,7 +1163,7 @@
</span><span class="cx">         if (!document)
</span><span class="cx">             continue;
</span><span class="cx">         document-&gt;extensionStyleSheets().invalidateInjectedStyleSheetCache();
</span><del>-        document-&gt;authorStyleSheets().didChangeContentsOrInterpretation();
</del><ins>+        document-&gt;styleScope().didChangeContentsOrInterpretation();
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorestyleStyleScopecppfromrev206916trunkSourceWebCoredomAuthorStyleSheetscpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/style/StyleScope.cpp (from rev 206916, trunk/Source/WebCore/dom/AuthorStyleSheets.cpp) (0 => 206917)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/style/StyleScope.cpp                                (rev 0)
+++ trunk/Source/WebCore/style/StyleScope.cpp        2016-10-07 16:55:11 UTC (rev 206917)
</span><span class="lines">@@ -0,0 +1,490 @@
</span><ins>+/*
+ * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
+ *           (C) 1999 Antti Koivisto (koivisto@kde.org)
+ *           (C) 2001 Dirk Mueller (mueller@kde.org)
+ *           (C) 2006 Alexey Proskuryakov (ap@webkit.org)
+ * Copyright (C) 2004-2009, 2011-2012, 2015-2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
+ * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include &quot;config.h&quot;
+#include &quot;StyleScope.h&quot;
+
+#include &quot;CSSStyleSheet.h&quot;
+#include &quot;Element.h&quot;
+#include &quot;ElementChildIterator.h&quot;
+#include &quot;ExtensionStyleSheets.h&quot;
+#include &quot;HTMLIFrameElement.h&quot;
+#include &quot;HTMLLinkElement.h&quot;
+#include &quot;HTMLStyleElement.h&quot;
+#include &quot;InspectorInstrumentation.h&quot;
+#include &quot;Page.h&quot;
+#include &quot;PageGroup.h&quot;
+#include &quot;ProcessingInstruction.h&quot;
+#include &quot;SVGNames.h&quot;
+#include &quot;SVGStyleElement.h&quot;
+#include &quot;Settings.h&quot;
+#include &quot;ShadowRoot.h&quot;
+#include &quot;StyleInvalidationAnalysis.h&quot;
+#include &quot;StyleResolver.h&quot;
+#include &quot;StyleSheetContents.h&quot;
+#include &quot;StyleSheetList.h&quot;
+#include &quot;UserContentController.h&quot;
+#include &quot;UserContentURLPattern.h&quot;
+#include &quot;UserStyleSheet.h&quot;
+
+namespace WebCore {
+
+using namespace ContentExtensions;
+using namespace HTMLNames;
+
+namespace Style {
+
+Scope::Scope(Document&amp; document)
+    : m_document(document)
+    , m_pendingUpdateTimer(*this, &amp;Scope::pendingUpdateTimerFired)
+{
+}
+
+Scope::Scope(ShadowRoot&amp; shadowRoot)
+    : m_document(shadowRoot.documentScope())
+    , m_shadowRoot(&amp;shadowRoot)
+    , m_pendingUpdateTimer(*this, &amp;Scope::pendingUpdateTimerFired)
+{
+}
+
+StyleResolver&amp; Scope::styleResolver()
+{
+    if (m_shadowRoot)
+        return m_shadowRoot-&gt;styleResolver();
+
+    return m_document.ensureStyleResolver();
+}
+
+StyleResolver* Scope::styleResolverIfExists()
+{
+    if (m_shadowRoot)
+        return m_shadowRoot-&gt;styleResolverIfExists();
+
+    return m_document.styleResolverIfExists();
+}
+
+Scope&amp; Scope::forNode(Node&amp; node)
+{
+    ASSERT(node.inDocument());
+    auto* shadowRoot = node.containingShadowRoot();
+    if (shadowRoot)
+        return shadowRoot-&gt;styleScope();
+    return node.document().styleScope();
+}
+
+// This method is called whenever a top-level stylesheet has finished loading.
+void Scope::removePendingSheet(RemovePendingSheetNotificationType notification)
+{
+    // Make sure we knew this sheet was pending, and that our count isn't out of sync.
+    ASSERT(m_pendingStyleSheetCount &gt; 0);
+
+    m_pendingStyleSheetCount--;
+    
+#ifdef INSTRUMENT_LAYOUT_SCHEDULING
+    if (!ownerElement())
+        printf(&quot;Stylesheet loaded at time %d. %d stylesheets still remain.\n&quot;, elapsedTime(), m_pendingStylesheets);
+#endif
+
+    if (m_pendingStyleSheetCount)
+        return;
+
+    if (notification == RemovePendingSheetNotifyLater) {
+        m_document.setNeedsNotifyRemoveAllPendingStylesheet();
+        return;
+    }
+
+    if (m_shadowRoot) {
+        m_shadowRoot-&gt;updateStyle();
+        return;
+    }
+
+    m_document.didRemoveAllPendingStylesheet();
+}
+
+void Scope::addStyleSheetCandidateNode(Node&amp; node, bool createdByParser)
+{
+    if (!node.inDocument())
+        return;
+    
+    // Until the &lt;body&gt; exists, we have no choice but to compare document positions,
+    // since styles outside of the body and head continue to be shunted into the head
+    // (and thus can shift to end up before dynamically added DOM content that is also
+    // outside the body).
+    if ((createdByParser &amp;&amp; m_document.bodyOrFrameset()) || m_styleSheetCandidateNodes.isEmpty()) {
+        m_styleSheetCandidateNodes.add(&amp;node);
+        return;
+    }
+
+    // Determine an appropriate insertion point.
+    auto begin = m_styleSheetCandidateNodes.begin();
+    auto end = m_styleSheetCandidateNodes.end();
+    auto it = end;
+    Node* followingNode = nullptr;
+    do {
+        --it;
+        Node* n = *it;
+        unsigned short position = n-&gt;compareDocumentPosition(node);
+        if (position == Node::DOCUMENT_POSITION_FOLLOWING) {
+            m_styleSheetCandidateNodes.insertBefore(followingNode, &amp;node);
+            return;
+        }
+        followingNode = n;
+    } while (it != begin);
+    
+    m_styleSheetCandidateNodes.insertBefore(followingNode, &amp;node);
+}
+
+void Scope::removeStyleSheetCandidateNode(Node&amp; node)
+{
+    if (m_styleSheetCandidateNodes.remove(&amp;node))
+        scheduleActiveSetUpdate();
+}
+
+void Scope::collectActiveStyleSheets(Vector&lt;RefPtr&lt;StyleSheet&gt;&gt;&amp; sheets)
+{
+    if (m_document.settings() &amp;&amp; !m_document.settings()-&gt;authorAndUserStylesEnabled())
+        return;
+
+    for (auto&amp; node : m_styleSheetCandidateNodes) {
+        StyleSheet* sheet = nullptr;
+        if (is&lt;ProcessingInstruction&gt;(*node)) {
+            // Processing instruction (XML documents only).
+            // We don't support linking to embedded CSS stylesheets, see &lt;https://bugs.webkit.org/show_bug.cgi?id=49281&gt; for discussion.
+            ProcessingInstruction&amp; pi = downcast&lt;ProcessingInstruction&gt;(*node);
+            sheet = pi.sheet();
+#if ENABLE(XSLT)
+            // Don't apply XSL transforms to already transformed documents -- &lt;rdar://problem/4132806&gt;
+            if (pi.isXSL() &amp;&amp; !m_document.transformSourceDocument()) {
+                // Don't apply XSL transforms until loading is finished.
+                if (!m_document.parsing())
+                    m_document.applyXSLTransform(&amp;pi);
+                return;
+            }
+#endif
+        } else if (is&lt;HTMLLinkElement&gt;(*node) || is&lt;HTMLStyleElement&gt;(*node) || is&lt;SVGStyleElement&gt;(*node)) {
+            Element&amp; element = downcast&lt;Element&gt;(*node);
+            AtomicString title = element.attributeWithoutSynchronization(titleAttr);
+            bool enabledViaScript = false;
+            if (is&lt;HTMLLinkElement&gt;(element)) {
+                // &lt;LINK&gt; element
+                HTMLLinkElement&amp; linkElement = downcast&lt;HTMLLinkElement&gt;(element);
+                if (linkElement.isDisabled())
+                    continue;
+                enabledViaScript = linkElement.isEnabledViaScript();
+                if (linkElement.styleSheetIsLoading()) {
+                    // it is loading but we should still decide which style sheet set to use
+                    if (!enabledViaScript &amp;&amp; !title.isEmpty() &amp;&amp; m_preferredStylesheetSetName.isEmpty()) {
+                        if (!linkElement.attributeWithoutSynchronization(relAttr).contains(&quot;alternate&quot;)) {
+                            m_preferredStylesheetSetName = title;
+                            m_selectedStylesheetSetName = title;
+                        }
+                    }
+                    continue;
+                }
+                if (!linkElement.sheet())
+                    title = nullAtom;
+            }
+            // Get the current preferred styleset. This is the
+            // set of sheets that will be enabled.
+            if (is&lt;SVGStyleElement&gt;(element))
+                sheet = downcast&lt;SVGStyleElement&gt;(element).sheet();
+            else if (is&lt;HTMLLinkElement&gt;(element))
+                sheet = downcast&lt;HTMLLinkElement&gt;(element).sheet();
+            else
+                sheet = downcast&lt;HTMLStyleElement&gt;(element).sheet();
+            // Check to see if this sheet belongs to a styleset
+            // (thus making it PREFERRED or ALTERNATE rather than
+            // PERSISTENT).
+            auto&amp; rel = element.attributeWithoutSynchronization(relAttr);
+            if (!enabledViaScript &amp;&amp; !title.isEmpty()) {
+                // Yes, we have a title.
+                if (m_preferredStylesheetSetName.isEmpty()) {
+                    // No preferred set has been established. If
+                    // we are NOT an alternate sheet, then establish
+                    // us as the preferred set. Otherwise, just ignore
+                    // this sheet.
+                    if (is&lt;HTMLStyleElement&gt;(element) || !rel.contains(&quot;alternate&quot;))
+                        m_preferredStylesheetSetName = m_selectedStylesheetSetName = title;
+                }
+                if (title != m_preferredStylesheetSetName)
+                    sheet = nullptr;
+            }
+
+            if (rel.contains(&quot;alternate&quot;) &amp;&amp; title.isEmpty())
+                sheet = nullptr;
+        }
+        if (sheet)
+            sheets.append(sheet);
+    }
+}
+
+Scope::StyleResolverUpdateType Scope::analyzeStyleSheetChange(const Vector&lt;RefPtr&lt;CSSStyleSheet&gt;&gt;&amp; newStylesheets, bool&amp; requiresFullStyleRecalc)
+{
+    requiresFullStyleRecalc = true;
+    
+    unsigned newStylesheetCount = newStylesheets.size();
+
+    if (!styleResolverIfExists())
+        return Reconstruct;
+
+    StyleResolver&amp; styleResolver = *styleResolverIfExists();
+
+    // Find out which stylesheets are new.
+    unsigned oldStylesheetCount = m_activeStyleSheets.size();
+    if (newStylesheetCount &lt; oldStylesheetCount)
+        return Reconstruct;
+
+    Vector&lt;StyleSheetContents*&gt; addedSheets;
+    unsigned newIndex = 0;
+    for (unsigned oldIndex = 0; oldIndex &lt; oldStylesheetCount; ++oldIndex) {
+        if (newIndex &gt;= newStylesheetCount)
+            return Reconstruct;
+        while (m_activeStyleSheets[oldIndex] != newStylesheets[newIndex]) {
+            addedSheets.append(&amp;newStylesheets[newIndex]-&gt;contents());
+            ++newIndex;
+            if (newIndex == newStylesheetCount)
+                return Reconstruct;
+        }
+        ++newIndex;
+    }
+    bool hasInsertions = !addedSheets.isEmpty();
+    while (newIndex &lt; newStylesheetCount) {
+        addedSheets.append(&amp;newStylesheets[newIndex]-&gt;contents());
+        ++newIndex;
+    }
+    // If all new sheets were added at the end of the list we can just add them to existing StyleResolver.
+    // If there were insertions we need to re-add all the stylesheets so rules are ordered correctly.
+    auto styleResolverUpdateType = hasInsertions ? Reset : Additive;
+
+    // If we are already parsing the body and so may have significant amount of elements, put some effort into trying to avoid style recalcs.
+    if (!m_document.bodyOrFrameset() || m_document.hasNodesWithPlaceholderStyle())
+        return styleResolverUpdateType;
+
+    StyleInvalidationAnalysis invalidationAnalysis(addedSheets, styleResolver.mediaQueryEvaluator());
+    if (invalidationAnalysis.dirtiesAllStyle())
+        return styleResolverUpdateType;
+    invalidationAnalysis.invalidateStyle(m_document);
+    requiresFullStyleRecalc = false;
+
+    return styleResolverUpdateType;
+}
+
+static void filterEnabledNonemptyCSSStyleSheets(Vector&lt;RefPtr&lt;CSSStyleSheet&gt;&gt;&amp; result, const Vector&lt;RefPtr&lt;StyleSheet&gt;&gt;&amp; sheets)
+{
+    for (auto&amp; sheet : sheets) {
+        if (!is&lt;CSSStyleSheet&gt;(*sheet))
+            continue;
+        CSSStyleSheet&amp; styleSheet = downcast&lt;CSSStyleSheet&gt;(*sheet);
+        if (styleSheet.isLoading())
+            continue;
+        if (styleSheet.disabled())
+            continue;
+        if (!styleSheet.length())
+            continue;
+        result.append(&amp;styleSheet);
+    }
+}
+
+void Scope::updateActiveStyleSheets(UpdateType updateType)
+{
+    ASSERT(!m_pendingUpdateType);
+
+    if (m_document.inStyleRecalc() || m_document.inRenderTreeUpdate()) {
+        // Protect against deleting style resolver in the middle of a style resolution.
+        // Crash stacks indicate we can get here when a resource load fails synchronously (for example due to content blocking).
+        // FIXME: These kind of cases should be eliminated and this path replaced by an assert.
+        m_pendingUpdateType = UpdateType::ContentsOrInterpretation;
+        m_document.scheduleForcedStyleRecalc();
+        return;
+    }
+
+    if (!m_document.hasLivingRenderTree()) {
+        m_document.clearStyleResolver();
+        return;
+    }
+
+    // Don't bother updating, since we haven't loaded all our style info yet
+    // and haven't calculated the style resolver for the first time.
+    if (!m_shadowRoot &amp;&amp; !m_didUpdateActiveStyleSheets &amp;&amp; m_pendingStyleSheetCount) {
+        m_document.clearStyleResolver();
+        return;
+    }
+
+    // FIXME: Support optimized invalidation in shadow trees.
+    if (m_shadowRoot)
+        updateType = UpdateType::ContentsOrInterpretation;
+
+    m_didUpdateActiveStyleSheets = true;
+
+    Vector&lt;RefPtr&lt;StyleSheet&gt;&gt; activeStyleSheets;
+    collectActiveStyleSheets(activeStyleSheets);
+
+    Vector&lt;RefPtr&lt;CSSStyleSheet&gt;&gt; activeCSSStyleSheets;
+    activeCSSStyleSheets.appendVector(m_document.extensionStyleSheets().injectedAuthorStyleSheets());
+    activeCSSStyleSheets.appendVector(m_document.extensionStyleSheets().authorStyleSheetsForTesting());
+    filterEnabledNonemptyCSSStyleSheets(activeCSSStyleSheets, activeStyleSheets);
+
+    bool requiresFullStyleRecalc = true;
+    StyleResolverUpdateType styleResolverUpdateType = Reconstruct;
+    if (updateType == UpdateType::ActiveSet)
+        styleResolverUpdateType = analyzeStyleSheetChange(activeCSSStyleSheets, requiresFullStyleRecalc);
+
+    updateStyleResolver(activeCSSStyleSheets, styleResolverUpdateType);
+
+    m_weakCopyOfActiveStyleSheetListForFastLookup = nullptr;
+    m_activeStyleSheets.swap(activeCSSStyleSheets);
+    m_styleSheetsForStyleSheetList.swap(activeStyleSheets);
+
+    InspectorInstrumentation::activeStyleSheetsUpdated(m_document);
+
+    for (const auto&amp; sheet : m_activeStyleSheets) {
+        if (sheet-&gt;contents().usesStyleBasedEditability())
+            m_usesStyleBasedEditability = true;
+    }
+
+    if (requiresFullStyleRecalc) {
+        if (m_shadowRoot) {
+            for (auto&amp; shadowChild : childrenOfType&lt;Element&gt;(*m_shadowRoot))
+                shadowChild.setNeedsStyleRecalc();
+        } else
+            m_document.scheduleForcedStyleRecalc();
+    }
+}
+
+void Scope::updateStyleResolver(Vector&lt;RefPtr&lt;CSSStyleSheet&gt;&gt;&amp; activeStyleSheets, StyleResolverUpdateType updateType)
+{
+    if (updateType == Reconstruct) {
+        if (m_shadowRoot)
+            m_shadowRoot-&gt;resetStyleResolver();
+        else
+            m_document.clearStyleResolver();
+        return;
+    }
+    auto&amp; styleResolver = this-&gt;styleResolver();
+
+    if (updateType == Reset) {
+        styleResolver.ruleSets().resetAuthorStyle();
+        styleResolver.appendAuthorStyleSheets(activeStyleSheets);
+    } else {
+        ASSERT(updateType == Additive);
+        unsigned firstNewIndex = m_activeStyleSheets.size();
+        Vector&lt;RefPtr&lt;CSSStyleSheet&gt;&gt; newStyleSheets;
+        newStyleSheets.appendRange(activeStyleSheets.begin() + firstNewIndex, activeStyleSheets.end());
+        styleResolver.appendAuthorStyleSheets(newStyleSheets);
+    }
+
+    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);
+    }
+}
+
+const Vector&lt;RefPtr&lt;CSSStyleSheet&gt;&gt; Scope::activeStyleSheetsForInspector() const
+{
+    Vector&lt;RefPtr&lt;CSSStyleSheet&gt;&gt; result;
+
+    result.appendVector(m_document.extensionStyleSheets().injectedAuthorStyleSheets());
+    result.appendVector(m_document.extensionStyleSheets().authorStyleSheetsForTesting());
+
+    for (auto&amp; styleSheet : m_styleSheetsForStyleSheetList) {
+        if (!is&lt;CSSStyleSheet&gt;(*styleSheet))
+            continue;
+
+        CSSStyleSheet&amp; sheet = downcast&lt;CSSStyleSheet&gt;(*styleSheet);
+        if (sheet.disabled())
+            continue;
+
+        result.append(&amp;sheet);
+    }
+
+    return result;
+}
+
+bool Scope::activeStyleSheetsContains(const CSSStyleSheet* sheet) const
+{
+    if (!m_weakCopyOfActiveStyleSheetListForFastLookup) {
+        m_weakCopyOfActiveStyleSheetListForFastLookup = std::make_unique&lt;HashSet&lt;const CSSStyleSheet*&gt;&gt;();
+        for (auto&amp; activeStyleSheet : m_activeStyleSheets)
+            m_weakCopyOfActiveStyleSheetListForFastLookup-&gt;add(activeStyleSheet.get());
+    }
+    return m_weakCopyOfActiveStyleSheetListForFastLookup-&gt;contains(sheet);
+}
+
+void Scope::flushPendingUpdate()
+{
+    if (!m_pendingUpdateType)
+        return;
+    auto updateType = *m_pendingUpdateType;
+
+    clearPendingUpdate();
+
+    updateActiveStyleSheets(updateType);
+}
+
+void Scope::clearPendingUpdate()
+{
+    m_pendingUpdateTimer.stop();
+    m_pendingUpdateType = { };
+}
+
+void Scope::scheduleActiveSetUpdate()
+{
+    if (m_shadowRoot) {
+        // FIXME: We need to flush updates recursively to support asynchronous updates in shadow trees.
+        didChangeCandidatesForActiveSet();
+        return;
+    }
+    if (m_pendingUpdateTimer.isActive())
+        return;
+    if (!m_pendingUpdateType)
+        m_pendingUpdateType = UpdateType::ActiveSet;
+    m_pendingUpdateTimer.startOneShot(0);
+}
+
+void Scope::didChangeCandidatesForActiveSet()
+{
+    auto updateType = m_pendingUpdateType.valueOr(UpdateType::ActiveSet);
+    clearPendingUpdate();
+    updateActiveStyleSheets(updateType);
+}
+
+void Scope::didChangeContentsOrInterpretation()
+{
+    clearPendingUpdate();
+    updateActiveStyleSheets(UpdateType::ContentsOrInterpretation);
+}
+
+void Scope::pendingUpdateTimerFired()
+{
+    flushPendingUpdate();
+}
+
+}
+}
</ins></span></pre></div>
<a id="trunkSourceWebCorestyleStyleScopehfromrev206916trunkSourceWebCoredomAuthorStyleSheetsh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/style/StyleScope.h (from rev 206916, trunk/Source/WebCore/dom/AuthorStyleSheets.h) (0 => 206917)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/style/StyleScope.h                                (rev 0)
+++ trunk/Source/WebCore/style/StyleScope.h        2016-10-07 16:55:11 UTC (rev 206917)
</span><span class="lines">@@ -0,0 +1,142 @@
</span><ins>+/*
+ * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
+ *           (C) 1999 Antti Koivisto (koivisto@kde.org)
+ *           (C) 2001 Dirk Mueller (mueller@kde.org)
+ *           (C) 2006 Alexey Proskuryakov (ap@webkit.org)
+ * Copyright (C) 2004-2010, 2012-2013, 2015-2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#pragma once
+
+#include &quot;Timer.h&quot;
+#include &lt;memory&gt;
+#include &lt;wtf/FastMalloc.h&gt;
+#include &lt;wtf/HashMap.h&gt;
+#include &lt;wtf/ListHashSet.h&gt;
+#include &lt;wtf/RefPtr.h&gt;
+#include &lt;wtf/Vector.h&gt;
+#include &lt;wtf/text/WTFString.h&gt;
+
+namespace WebCore {
+
+class CSSStyleSheet;
+class Document;
+class Node;
+class StyleResolver;
+class StyleSheet;
+class StyleSheetContents;
+class StyleSheetList;
+class ShadowRoot;
+class TreeScope;
+
+namespace Style {
+
+class Scope {
+    WTF_MAKE_FAST_ALLOCATED;
+public:
+    explicit Scope(Document&amp;);
+    explicit Scope(ShadowRoot&amp;);
+
+    const Vector&lt;RefPtr&lt;CSSStyleSheet&gt;&gt;&amp; activeStyleSheets() const { return m_activeStyleSheets; }
+
+    const Vector&lt;RefPtr&lt;StyleSheet&gt;&gt;&amp; styleSheetsForStyleSheetList() const { return m_styleSheetsForStyleSheetList; }
+    const Vector&lt;RefPtr&lt;CSSStyleSheet&gt;&gt; activeStyleSheetsForInspector() const;
+
+    void addStyleSheetCandidateNode(Node&amp;, bool createdByParser);
+    void removeStyleSheetCandidateNode(Node&amp;);
+
+    String preferredStylesheetSetName() const { return m_preferredStylesheetSetName; }
+    String selectedStylesheetSetName() const { return m_selectedStylesheetSetName; }
+    void setPreferredStylesheetSetName(const String&amp; name) { m_preferredStylesheetSetName = name; }
+    void setSelectedStylesheetSetName(const String&amp; name) { m_selectedStylesheetSetName = name; }
+
+    void addPendingSheet() { m_pendingStyleSheetCount++; }
+    enum RemovePendingSheetNotificationType {
+        RemovePendingSheetNotifyImmediately,
+        RemovePendingSheetNotifyLater
+    };
+    void removePendingSheet(RemovePendingSheetNotificationType = RemovePendingSheetNotifyImmediately);
+
+    bool hasPendingSheets() const { return m_pendingStyleSheetCount &gt; 0; }
+
+    bool usesStyleBasedEditability() { return m_usesStyleBasedEditability; }
+
+    bool activeStyleSheetsContains(const CSSStyleSheet*) const;
+
+    void didChangeCandidatesForActiveSet();
+    void scheduleActiveSetUpdate();
+    WEBCORE_EXPORT void didChangeContentsOrInterpretation();
+
+    bool hasPendingUpdate() const { return !!m_pendingUpdateType; }
+    void flushPendingUpdate();
+
+    StyleResolver&amp; styleResolver();
+    StyleResolver* styleResolverIfExists();
+
+    static Scope&amp; forNode(Node&amp;);
+
+private:
+    enum class UpdateType { ActiveSet, ContentsOrInterpretation };
+    void updateActiveStyleSheets(UpdateType);
+
+    void collectActiveStyleSheets(Vector&lt;RefPtr&lt;StyleSheet&gt;&gt;&amp;);
+
+    enum StyleResolverUpdateType {
+        Reconstruct,
+        Reset,
+        Additive
+    };
+    StyleResolverUpdateType analyzeStyleSheetChange(const Vector&lt;RefPtr&lt;CSSStyleSheet&gt;&gt;&amp; newStylesheets, bool&amp; requiresFullStyleRecalc);
+    void updateStyleResolver(Vector&lt;RefPtr&lt;CSSStyleSheet&gt;&gt;&amp;, StyleResolverUpdateType);
+
+    void pendingUpdateTimerFired();
+    void clearPendingUpdate();
+
+    Document&amp; m_document;
+    ShadowRoot* m_shadowRoot { nullptr };
+
+    Vector&lt;RefPtr&lt;StyleSheet&gt;&gt; m_styleSheetsForStyleSheetList;
+    Vector&lt;RefPtr&lt;CSSStyleSheet&gt;&gt; m_activeStyleSheets;
+
+    Timer m_pendingUpdateTimer;
+
+    mutable std::unique_ptr&lt;HashSet&lt;const CSSStyleSheet*&gt;&gt; m_weakCopyOfActiveStyleSheetListForFastLookup;
+
+    // Track the number of currently loading top-level stylesheets needed for rendering.
+    // Sheets loaded using the @import directive are not included in this count.
+    // We use this count of pending sheets to detect when we can begin attaching
+    // elements and when it is safe to execute scripts.
+    int m_pendingStyleSheetCount { 0 };
+    bool m_didUpdateActiveStyleSheets { false };
+
+    Optional&lt;UpdateType&gt; m_pendingUpdateType;
+
+    ListHashSet&lt;Node*&gt; m_styleSheetCandidateNodes;
+
+    String m_preferredStylesheetSetName;
+    String m_selectedStylesheetSetName;
+
+    bool m_usesStyleBasedEditability { false };
+};
+
+}
+}
</ins></span></pre></div>
<a id="trunkSourceWebCorestyleStyleTreeResolvercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/style/StyleTreeResolver.cpp (206916 => 206917)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/style/StyleTreeResolver.cpp        2016-10-07 16:41:48 UTC (rev 206916)
+++ trunk/Source/WebCore/style/StyleTreeResolver.cpp        2016-10-07 16:55:11 UTC (rev 206917)
</span><span class="lines">@@ -26,7 +26,6 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;StyleTreeResolver.h&quot;
</span><span class="cx"> 
</span><del>-#include &quot;AuthorStyleSheets.h&quot;
</del><span class="cx"> #include &quot;CSSFontSelector.h&quot;
</span><span class="cx"> #include &quot;ComposedTreeAncestorIterator.h&quot;
</span><span class="cx"> #include &quot;ComposedTreeIterator.h&quot;
</span><span class="lines">@@ -45,6 +44,7 @@
</span><span class="cx"> #include &quot;ShadowRoot.h&quot;
</span><span class="cx"> #include &quot;StyleFontSizeFunctions.h&quot;
</span><span class="cx"> #include &quot;StyleResolver.h&quot;
</span><ins>+#include &quot;StyleScope.h&quot;
</ins><span class="cx"> #include &quot;Text.h&quot;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span></span></pre></div>
<a id="trunkSourceWebCoresvgSVGFontFaceElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/svg/SVGFontFaceElement.cpp (206916 => 206917)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/svg/SVGFontFaceElement.cpp        2016-10-07 16:41:48 UTC (rev 206916)
+++ trunk/Source/WebCore/svg/SVGFontFaceElement.cpp        2016-10-07 16:55:11 UTC (rev 206917)
</span><span class="lines">@@ -24,7 +24,6 @@
</span><span class="cx"> #if ENABLE(SVG_FONTS)
</span><span class="cx"> #include &quot;SVGFontFaceElement.h&quot;
</span><span class="cx"> 
</span><del>-#include &quot;AuthorStyleSheets.h&quot;
</del><span class="cx"> #include &quot;CSSFontFaceSrcValue.h&quot;
</span><span class="cx"> #include &quot;CSSParser.h&quot;
</span><span class="cx"> #include &quot;CSSPropertyNames.h&quot;
</span><span class="lines">@@ -42,6 +41,7 @@
</span><span class="cx"> #include &quot;StyleProperties.h&quot;
</span><span class="cx"> #include &quot;StyleResolver.h&quot;
</span><span class="cx"> #include &quot;StyleRule.h&quot;
</span><ins>+#include &quot;StyleScope.h&quot;
</ins><span class="cx"> #include &lt;math.h&gt;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -267,7 +267,7 @@
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    document().authorStyleSheets().didChangeContentsOrInterpretation();
</del><ins>+    document().styleScope().didChangeContentsOrInterpretation();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> Node::InsertionNotificationRequest SVGFontFaceElement::insertedInto(ContainerNode&amp; rootParent)
</span><span class="lines">@@ -292,7 +292,7 @@
</span><span class="cx">         document().accessSVGExtensions().unregisterSVGFontFaceElement(this);
</span><span class="cx">         m_fontFaceRule-&gt;mutableProperties().clear();
</span><span class="cx"> 
</span><del>-        document().authorStyleSheets().didChangeContentsOrInterpretation();
</del><ins>+        document().styleScope().didChangeContentsOrInterpretation();
</ins><span class="cx">     } else
</span><span class="cx">         ASSERT(!m_fontElement);
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorexmlXMLTreeViewercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/xml/XMLTreeViewer.cpp (206916 => 206917)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/xml/XMLTreeViewer.cpp        2016-10-07 16:41:48 UTC (rev 206916)
+++ trunk/Source/WebCore/xml/XMLTreeViewer.cpp        2016-10-07 16:55:11 UTC (rev 206917)
</span><span class="lines">@@ -32,7 +32,6 @@
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(XSLT)
</span><span class="cx"> 
</span><del>-#include &quot;AuthorStyleSheets.h&quot;
</del><span class="cx"> #include &quot;Document.h&quot;
</span><span class="cx"> #include &quot;Element.h&quot;
</span><span class="cx"> #include &quot;ExceptionCodePlaceholder.h&quot;
</span><span class="lines">@@ -41,6 +40,7 @@
</span><span class="cx"> #include &quot;ScriptSourceCode.h&quot;
</span><span class="cx"> #include &quot;SecurityOrigin.h&quot;
</span><span class="cx"> #include &quot;SecurityOriginPolicy.h&quot;
</span><ins>+#include &quot;StyleScope.h&quot;
</ins><span class="cx"> #include &quot;Text.h&quot;
</span><span class="cx"> #include &quot;XMLViewerCSS.h&quot;
</span><span class="cx"> #include &quot;XMLViewerJS.h&quot;
</span><span class="lines">@@ -64,7 +64,7 @@
</span><span class="cx">     String cssString = StringImpl::createWithoutCopying(XMLViewer_css, sizeof(XMLViewer_css));
</span><span class="cx">     auto text = m_document.createTextNode(cssString);
</span><span class="cx">     m_document.getElementById(String(ASCIILiteral(&quot;xml-viewer-style&quot;)))-&gt;appendChild(text, IGNORE_EXCEPTION);
</span><del>-    m_document.authorStyleSheets().didChangeContentsOrInterpretation();
</del><ins>+    m_document.styleScope().didChangeContentsOrInterpretation();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCorexmlparserXMLDocumentParsercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/xml/parser/XMLDocumentParser.cpp (206916 => 206917)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/xml/parser/XMLDocumentParser.cpp        2016-10-07 16:41:48 UTC (rev 206916)
+++ trunk/Source/WebCore/xml/parser/XMLDocumentParser.cpp        2016-10-07 16:55:11 UTC (rev 206917)
</span><span class="lines">@@ -26,7 +26,6 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;XMLDocumentParser.h&quot;
</span><span class="cx"> 
</span><del>-#include &quot;AuthorStyleSheets.h&quot;
</del><span class="cx"> #include &quot;CDATASection.h&quot;
</span><span class="cx"> #include &quot;CachedScript.h&quot;
</span><span class="cx"> #include &quot;Comment.h&quot;
</span><span class="lines">@@ -49,6 +48,7 @@
</span><span class="cx"> #include &quot;SVGStyleElement.h&quot;
</span><span class="cx"> #include &quot;ScriptElement.h&quot;
</span><span class="cx"> #include &quot;ScriptSourceCode.h&quot;
</span><ins>+#include &quot;StyleScope.h&quot;
</ins><span class="cx"> #include &quot;TextResourceDecoder.h&quot;
</span><span class="cx"> #include &quot;TreeDepthLimit.h&quot;
</span><span class="cx"> #include &lt;wtf/Ref.h&gt;
</span><span class="lines">@@ -200,7 +200,7 @@
</span><span class="cx">         insertErrorMessageBlock();
</span><span class="cx">     else {
</span><span class="cx">         updateLeafTextNode();
</span><del>-        document()-&gt;authorStyleSheets().didChangeContentsOrInterpretation();
</del><ins>+        document()-&gt;styleScope().didChangeContentsOrInterpretation();
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (isParsing())
</span></span></pre></div>
<a id="trunkSourceWebCorexmlparserXMLDocumentParserLibxml2cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp (206916 => 206917)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp        2016-10-07 16:41:48 UTC (rev 206916)
+++ trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp        2016-10-07 16:55:11 UTC (rev 206917)
</span><span class="lines">@@ -28,7 +28,6 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;XMLDocumentParser.h&quot;
</span><span class="cx"> 
</span><del>-#include &quot;AuthorStyleSheets.h&quot;
</del><span class="cx"> #include &quot;CDATASection.h&quot;
</span><span class="cx"> #include &quot;CachedScript.h&quot;
</span><span class="cx"> #include &quot;Comment.h&quot;
</span><span class="lines">@@ -56,6 +55,7 @@
</span><span class="cx"> #include &quot;ScriptSourceCode.h&quot;
</span><span class="cx"> #include &quot;SecurityOrigin.h&quot;
</span><span class="cx"> #include &quot;Settings.h&quot;
</span><ins>+#include &quot;StyleScope.h&quot;
</ins><span class="cx"> #include &quot;TextResourceDecoder.h&quot;
</span><span class="cx"> #include &quot;TransformSource.h&quot;
</span><span class="cx"> #include &quot;XMLNSNames.h&quot;
</span><span class="lines">@@ -1387,7 +1387,7 @@
</span><span class="cx">         document()-&gt;setTransformSource(std::make_unique&lt;TransformSource&gt;(doc));
</span><span class="cx"> 
</span><span class="cx">         document()-&gt;setParsing(false); // Make the document think it's done, so it will apply XSL stylesheets.
</span><del>-        document()-&gt;authorStyleSheets().didChangeContentsOrInterpretation();
</del><ins>+        document()-&gt;styleScope().didChangeContentsOrInterpretation();
</ins><span class="cx"> 
</span><span class="cx">         // styleResolverChanged() call can detach the parser and null out its document.
</span><span class="cx">         // In that case, we just bail out.
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebViewWebHTMLViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebView/WebHTMLView.mm (206916 => 206917)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebView/WebHTMLView.mm        2016-10-07 16:41:48 UTC (rev 206916)
+++ trunk/Source/WebKit/mac/WebView/WebHTMLView.mm        2016-10-07 16:55:11 UTC (rev 206917)
</span><span class="lines">@@ -72,7 +72,6 @@
</span><span class="cx"> #import &quot;WebTypesInternal.h&quot;
</span><span class="cx"> #import &quot;WebUIDelegatePrivate.h&quot;
</span><span class="cx"> #import &quot;WebViewInternal.h&quot;
</span><del>-#import &lt;WebCore/AuthorStyleSheets.h&gt;
</del><span class="cx"> #import &lt;WebCore/CSSStyleDeclaration.h&gt;
</span><span class="cx"> #import &lt;WebCore/CachedImage.h&gt;
</span><span class="cx"> #import &lt;WebCore/CachedResourceClient.h&gt;
</span><span class="lines">@@ -119,6 +118,7 @@
</span><span class="cx"> #import &lt;WebCore/RuntimeApplicationChecks.h&gt;
</span><span class="cx"> #import &lt;WebCore/SharedBuffer.h&gt;
</span><span class="cx"> #import &lt;WebCore/StyleProperties.h&gt;
</span><ins>+#import &lt;WebCore/StyleScope.h&gt;
</ins><span class="cx"> #import &lt;WebCore/Text.h&gt;
</span><span class="cx"> #import &lt;WebCore/TextAlternativeWithRange.h&gt;
</span><span class="cx"> #import &lt;WebCore/TextIndicator.h&gt;
</span><span class="lines">@@ -3612,7 +3612,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     if (Frame* coreFrame = core([self _frame])) {
</span><del>-        coreFrame-&gt;document()-&gt;authorStyleSheets().didChangeContentsOrInterpretation();
</del><ins>+        coreFrame-&gt;document()-&gt;styleScope().didChangeContentsOrInterpretation();
</ins><span class="cx">         coreFrame-&gt;document()-&gt;updateStyleIfNeeded();
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -5007,7 +5007,7 @@
</span><span class="cx"> 
</span><span class="cx">             document-&gt;setPaginatedForScreen(_private-&gt;paginateScreenContent);
</span><span class="cx">             document-&gt;setPrinting(_private-&gt;printing);
</span><del>-            document-&gt;authorStyleSheets().didChangeContentsOrInterpretation();
</del><ins>+            document-&gt;styleScope().didChangeContentsOrInterpretation();
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>