<!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>[181876] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/181876">181876</a></dd>
<dt>Author</dt> <dd>beidson@apple.com</dd>
<dt>Date</dt> <dd>2015-03-23 15:34:53 -0700 (Mon, 23 Mar 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Content extensions should apply css selectors
https://bugs.webkit.org/show_bug.cgi?id=142604

Reviewed by Alex Christensen.

Source/WebCore:

Tests: http/tests/contentextensions/css-display-none.html

* WebCore.xcodeproj/project.pbxproj:

* contentextensions/ContentExtension.cpp:
(WebCore::ContentExtensions::ContentExtension::create):
(WebCore::ContentExtensions::ContentExtension::ContentExtension):
(WebCore::ContentExtensions::ContentExtension::globalDisplayNoneStyleSheet):
* contentextensions/ContentExtension.h:
(WebCore::ContentExtensions::ContentExtension::identifier):
(WebCore::ContentExtensions::ContentExtension::compiledExtension):

* contentextensions/ContentExtensionsBackend.cpp:
(WebCore::ContentExtensions::ContentExtensionsBackend::addContentExtension):
(WebCore::ContentExtensions::ContentExtensionsBackend::actionsForResourceLoad):
(WebCore::ContentExtensions::ContentExtensionsBackend::globalDisplayNoneStyleSheet):
* contentextensions/ContentExtensionsBackend.h:

* contentextensions/DFABytecodeInterpreter.cpp:
(WebCore::ContentExtensions::DFABytecodeInterpreter::interpret):

* dom/DocumentStyleSheetCollection.cpp:
(WebCore::DocumentStyleSheetCollection::maybeAddContentExtensionSheet):
* dom/DocumentStyleSheetCollection.h:

* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::commitData):
(WebCore::DocumentLoader::startLoadingMainResource):
(WebCore::DocumentLoader::addPendingContentExtensionSheet):
* loader/DocumentLoader.h:

* loader/cache/CachedResourceLoader.cpp:
(WebCore::CachedResourceLoader::requestResource):

* loader/cache/CachedResourceRequest.cpp:
(WebCore::CachedResourceRequest::setInitiator):
* loader/cache/CachedResourceRequest.h:
(WebCore::CachedResourceRequest::initiatingDocumentLoader):

* page/UserContentController.cpp:
(WebCore::UserContentController::globalDisplayNoneStyleSheet):
(WebCore::UserContentController::displayNoneCSSRule):
* page/UserContentController.h:

LayoutTests:

* http/tests/contentextensions/css-display-none-expected.txt:
* http/tests/contentextensions/css-display-none.html:
* http/tests/contentextensions/css-display-none.html.json:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestshttptestscontentextensionscssdisplaynoneexpectedtxt">trunk/LayoutTests/http/tests/contentextensions/css-display-none-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestscontentextensionscssdisplaynonehtml">trunk/LayoutTests/http/tests/contentextensions/css-display-none.html</a></li>
<li><a href="#trunkLayoutTestshttptestscontentextensionscssdisplaynonehtmljson">trunk/LayoutTests/http/tests/contentextensions/css-display-none.html.json</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="#trunkSourceWebCorecontentextensionsContentExtensionsBackendcpp">trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp</a></li>
<li><a href="#trunkSourceWebCorecontentextensionsContentExtensionsBackendh">trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.h</a></li>
<li><a href="#trunkSourceWebCorecontentextensionsDFABytecodeInterpretercpp">trunk/Source/WebCore/contentextensions/DFABytecodeInterpreter.cpp</a></li>
<li><a href="#trunkSourceWebCoredomDocumentStyleSheetCollectioncpp">trunk/Source/WebCore/dom/DocumentStyleSheetCollection.cpp</a></li>
<li><a href="#trunkSourceWebCoredomDocumentStyleSheetCollectionh">trunk/Source/WebCore/dom/DocumentStyleSheetCollection.h</a></li>
<li><a href="#trunkSourceWebCoreloaderDocumentLoadercpp">trunk/Source/WebCore/loader/DocumentLoader.cpp</a></li>
<li><a href="#trunkSourceWebCoreloaderDocumentLoaderh">trunk/Source/WebCore/loader/DocumentLoader.h</a></li>
<li><a href="#trunkSourceWebCoreloadercacheCachedResourceLoadercpp">trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp</a></li>
<li><a href="#trunkSourceWebCoreloadercacheCachedResourceRequestcpp">trunk/Source/WebCore/loader/cache/CachedResourceRequest.cpp</a></li>
<li><a href="#trunkSourceWebCoreloadercacheCachedResourceRequesth">trunk/Source/WebCore/loader/cache/CachedResourceRequest.h</a></li>
<li><a href="#trunkSourceWebCorepageUserContentControllercpp">trunk/Source/WebCore/page/UserContentController.cpp</a></li>
<li><a href="#trunkSourceWebCorepageUserContentControllerh">trunk/Source/WebCore/page/UserContentController.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCorecontentextensionsContentExtensioncpp">trunk/Source/WebCore/contentextensions/ContentExtension.cpp</a></li>
<li><a href="#trunkSourceWebCorecontentextensionsContentExtensionh">trunk/Source/WebCore/contentextensions/ContentExtension.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (181875 => 181876)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-03-23 22:31:07 UTC (rev 181875)
+++ trunk/LayoutTests/ChangeLog        2015-03-23 22:34:53 UTC (rev 181876)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2015-03-23  Brady Eidson  &lt;beidson@apple.com&gt;
+
+        Content extensions should apply css selectors
+        https://bugs.webkit.org/show_bug.cgi?id=142604
+
+        Reviewed by Alex Christensen.
+
+        * http/tests/contentextensions/css-display-none-expected.txt:
+        * http/tests/contentextensions/css-display-none.html:
+        * http/tests/contentextensions/css-display-none.html.json:
+
</ins><span class="cx"> 2015-03-23  Dean Jackson  &lt;dino@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         ES7: Implement Array.prototype.includes
</span></span></pre></div>
<a id="trunkLayoutTestshttptestscontentextensionscssdisplaynoneexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/contentextensions/css-display-none-expected.txt (181875 => 181876)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/contentextensions/css-display-none-expected.txt        2015-03-23 22:31:07 UTC (rev 181875)
+++ trunk/LayoutTests/http/tests/contentextensions/css-display-none-expected.txt        2015-03-23 22:34:53 UTC (rev 181876)
</span><span class="lines">@@ -4,11 +4,5 @@
</span><span class="cx">   RenderBlock {HTML} at (0,0) size 800x600
</span><span class="cx">     RenderBody {BODY} at (8,8) size 784x576
</span><span class="cx">       RenderBlock {P} at (0,0) size 784x18
</span><del>-        RenderText {#text} at (0,0) size 492x18
-          text run at (0,0) width 492: &quot;This text should not be visible once the css selector is applied (not done yet).&quot;
-      RenderBlock {P} at (0,34) size 784x18
-        RenderText {#text} at (0,0) size 522x18
-          text run at (0,0) width 522: &quot;This text should also not be visible once the css selector is applied (not done yet).&quot;
-      RenderBlock {P} at (0,68) size 784x18
</del><span class="cx">         RenderText {#text} at (0,0) size 173x18
</span><span class="cx">           text run at (0,0) width 173: &quot;This text should be visible.&quot;
</span></span></pre></div>
<a id="trunkLayoutTestshttptestscontentextensionscssdisplaynonehtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/contentextensions/css-display-none.html (181875 => 181876)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/contentextensions/css-display-none.html        2015-03-23 22:31:07 UTC (rev 181875)
+++ trunk/LayoutTests/http/tests/contentextensions/css-display-none.html        2015-03-23 22:34:53 UTC (rev 181876)
</span><span class="lines">@@ -1,5 +1,9 @@
</span><ins>+&lt;head&gt;
+&lt;meta charset=&quot;UTF-8&quot;&gt;&lt;/meta&gt;
+&lt;/head&gt;
</ins><span class="cx"> &lt;body&gt;
</span><del>-&lt;p class=&quot;hidden&quot;&gt;This text should not be visible once the css selector is applied (not done yet).&lt;/p&gt;
-&lt;p class=&quot;hidden_Ž&quot;&gt;This text should also not be visible once the css selector is applied (not done yet).&lt;/p&gt;
</del><ins>+&lt;p class=&quot;hidden_global&quot;&gt;This text should not be visible once the global css selector is applied.&lt;/p&gt;
+&lt;p class=&quot;hidden&quot;&gt;This text should not be visible once the particular css selector is applied.&lt;/p&gt;
+&lt;p class=&quot;hidden_Ž&quot;&gt;This text should not be visible once the particular css selector with non-ascii characters is applied.&lt;/p&gt;
</ins><span class="cx"> &lt;p class=&quot;not_hidden&quot;&gt;This text should be visible.&lt;/p&gt;
</span><span class="cx"> &lt;/body&gt;
</span></span></pre></div>
<a id="trunkLayoutTestshttptestscontentextensionscssdisplaynonehtmljson"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/contentextensions/css-display-none.html.json (181875 => 181876)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/contentextensions/css-display-none.html.json        2015-03-23 22:31:07 UTC (rev 181875)
+++ trunk/LayoutTests/http/tests/contentextensions/css-display-none.html.json        2015-03-23 22:34:53 UTC (rev 181876)
</span><span class="lines">@@ -16,5 +16,14 @@
</span><span class="cx">         &quot;trigger&quot;: {
</span><span class="cx">             &quot;url-filter&quot;: &quot;.*css-display-none.html&quot;
</span><span class="cx">         }
</span><ins>+    },
+    {
+        &quot;action&quot;: {
+            &quot;type&quot;: &quot;css-display-none&quot;,
+            &quot;selector&quot;: &quot;.hidden_global&quot;
+        },
+        &quot;trigger&quot;: {
+            &quot;url-filter&quot;: &quot;.*&quot;
+        }
</ins><span class="cx">     }
</span><span class="cx"> ]
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (181875 => 181876)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-03-23 22:31:07 UTC (rev 181875)
+++ trunk/Source/WebCore/ChangeLog        2015-03-23 22:34:53 UTC (rev 181876)
</span><span class="lines">@@ -1,3 +1,54 @@
</span><ins>+2015-03-23  Brady Eidson  &lt;beidson@apple.com&gt;
+
+        Content extensions should apply css selectors
+        https://bugs.webkit.org/show_bug.cgi?id=142604
+
+        Reviewed by Alex Christensen.
+
+        Tests: http/tests/contentextensions/css-display-none.html
+
+        * WebCore.xcodeproj/project.pbxproj:
+
+        * contentextensions/ContentExtension.cpp:
+        (WebCore::ContentExtensions::ContentExtension::create):
+        (WebCore::ContentExtensions::ContentExtension::ContentExtension):
+        (WebCore::ContentExtensions::ContentExtension::globalDisplayNoneStyleSheet):
+        * contentextensions/ContentExtension.h:
+        (WebCore::ContentExtensions::ContentExtension::identifier):
+        (WebCore::ContentExtensions::ContentExtension::compiledExtension):
+
+        * contentextensions/ContentExtensionsBackend.cpp:
+        (WebCore::ContentExtensions::ContentExtensionsBackend::addContentExtension):
+        (WebCore::ContentExtensions::ContentExtensionsBackend::actionsForResourceLoad):
+        (WebCore::ContentExtensions::ContentExtensionsBackend::globalDisplayNoneStyleSheet):
+        * contentextensions/ContentExtensionsBackend.h:
+
+        * contentextensions/DFABytecodeInterpreter.cpp:
+        (WebCore::ContentExtensions::DFABytecodeInterpreter::interpret):
+
+        * dom/DocumentStyleSheetCollection.cpp:
+        (WebCore::DocumentStyleSheetCollection::maybeAddContentExtensionSheet):
+        * dom/DocumentStyleSheetCollection.h:
+
+        * loader/DocumentLoader.cpp:
+        (WebCore::DocumentLoader::commitData):
+        (WebCore::DocumentLoader::startLoadingMainResource):
+        (WebCore::DocumentLoader::addPendingContentExtensionSheet):
+        * loader/DocumentLoader.h:
+
+        * loader/cache/CachedResourceLoader.cpp:
+        (WebCore::CachedResourceLoader::requestResource):
+
+        * loader/cache/CachedResourceRequest.cpp:
+        (WebCore::CachedResourceRequest::setInitiator):
+        * loader/cache/CachedResourceRequest.h:
+        (WebCore::CachedResourceRequest::initiatingDocumentLoader):
+
+        * page/UserContentController.cpp:
+        (WebCore::UserContentController::globalDisplayNoneStyleSheet):
+        (WebCore::UserContentController::displayNoneCSSRule):
+        * page/UserContentController.h:
+
</ins><span class="cx"> 2015-03-23  Anders Carlsson  &lt;andersca@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         -[_WKWebsiteDataStore removeDataOfTypes:modifiedSince:completionHandler:] doesn't remove cookies
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (181875 => 181876)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2015-03-23 22:31:07 UTC (rev 181875)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2015-03-23 22:34:53 UTC (rev 181876)
</span><span class="lines">@@ -1988,6 +1988,8 @@
</span><span class="cx">                 51AF503616F100F60095B2E8 /* ResourceLoaderTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 51AF503516F100F60095B2E8 /* ResourceLoaderTypes.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 51B07A441823248B00AA8D1A /* IDBPendingDeleteCall.h in Headers */ = {isa = PBXBuildFile; fileRef = 51B07A431823248B00AA8D1A /* IDBPendingDeleteCall.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 51B2417B0D931F3F00E83F5C /* LegacyWebArchiveMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51B2417A0D931F3F00E83F5C /* LegacyWebArchiveMac.mm */; };
</span><ins>+                51B45D201AB8D1E200117CD2 /* ContentExtension.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51B45D1E1AB8D1E200117CD2 /* ContentExtension.cpp */; };
+                51B45D211AB8D1E200117CD2 /* ContentExtension.h in Headers */ = {isa = PBXBuildFile; fileRef = 51B45D1F1AB8D1E200117CD2 /* ContentExtension.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">                 51B58FD4195A964D002990B0 /* PlatformGamepad.h in Headers */ = {isa = PBXBuildFile; fileRef = 515E5FEF195101470086CA5E /* PlatformGamepad.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 51BE37E00DAEE00E001085FC /* StorageArea.h in Headers */ = {isa = PBXBuildFile; fileRef = 51BE37DE0DAEE00E001085FC /* StorageArea.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 51C0AA390F2AA10A001648C2 /* CachedFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = 51C0AA380F2AA10A001648C2 /* CachedFrame.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -6307,7 +6309,7 @@
</span><span class="cx">                 E4E9B11B18145692003ACCDF /* SimpleLineLayoutFunctions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4E9B11A18145692003ACCDF /* SimpleLineLayoutFunctions.cpp */; };
</span><span class="cx">                 E4E9B11D1814569C003ACCDF /* SimpleLineLayoutFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = E4E9B11C1814569C003ACCDF /* SimpleLineLayoutFunctions.h */; };
</span><span class="cx">                 E4F9EEF2156D9FFA00D23E7E /* StyleSheetContents.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4F9EEF0156D84C400D23E7E /* StyleSheetContents.cpp */; };
</span><del>-                E4F9EEF3156DA00700D23E7E /* StyleSheetContents.h in Headers */ = {isa = PBXBuildFile; fileRef = E4F9EEF1156D84C400D23E7E /* StyleSheetContents.h */; };
</del><ins>+                E4F9EEF3156DA00700D23E7E /* StyleSheetContents.h in Headers */ = {isa = PBXBuildFile; fileRef = E4F9EEF1156D84C400D23E7E /* StyleSheetContents.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">                 E51A81DF17298D7700BFCA61 /* JSPerformance.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E51A81DE17298D7700BFCA61 /* JSPerformance.cpp */; };
</span><span class="cx">                 E526AF3F1727F8F200E41781 /* Performance.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E526AF3E1727F8F200E41781 /* Performance.cpp */; };
</span><span class="cx">                 E55F497A151B888000BB67DB /* LengthFunctions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E55F4979151B888000BB67DB /* LengthFunctions.cpp */; };
</span><span class="lines">@@ -9156,6 +9158,8 @@
</span><span class="cx">                 51AF503516F100F60095B2E8 /* ResourceLoaderTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceLoaderTypes.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 51B07A431823248B00AA8D1A /* IDBPendingDeleteCall.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IDBPendingDeleteCall.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 51B2417A0D931F3F00E83F5C /* LegacyWebArchiveMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LegacyWebArchiveMac.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                51B45D1E1AB8D1E200117CD2 /* ContentExtension.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ContentExtension.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                51B45D1F1AB8D1E200117CD2 /* ContentExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContentExtension.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 51BE37DE0DAEE00E001085FC /* StorageArea.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StorageArea.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 51C0AA380F2AA10A001648C2 /* CachedFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedFrame.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 51C0AA400F2AA15E001648C2 /* CachedFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = CachedFrame.cpp; sourceTree = &quot;&lt;group&gt;&quot;; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
</span><span class="lines">@@ -15483,6 +15487,8 @@
</span><span class="cx">                 26F0C8901A2D79CB002794F8 /* contentextensions */ = {
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><ins>+                                51B45D1E1AB8D1E200117CD2 /* ContentExtension.cpp */,
+                                51B45D1F1AB8D1E200117CD2 /* ContentExtension.h */,
</ins><span class="cx">                                 7C93F3471AA6BA5E00A98BAB /* CompiledContentExtension.cpp */,
</span><span class="cx">                                 7C93F3481AA6BA5E00A98BAB /* CompiledContentExtension.h */,
</span><span class="cx">                                 5CDFA6C71AA4F2DA00EA8746 /* ContentExtensionActions.h */,
</span><span class="lines">@@ -25902,6 +25908,7 @@
</span><span class="cx">                                 84730D921248F0B300D3A9C9 /* PointLightSource.h in Headers */,
</span><span class="cx">                                 97059978107D975200A50A7C /* PolicyCallback.h in Headers */,
</span><span class="cx">                                 9705997A107D975200A50A7C /* PolicyChecker.h in Headers */,
</span><ins>+                                51B45D211AB8D1E200117CD2 /* ContentExtension.h in Headers */,
</ins><span class="cx">                                 FD45A957175D414C00C21EC8 /* PolygonShape.h in Headers */,
</span><span class="cx">                                 5174E20A10A1F44F00F95E6F /* PopStateEvent.h in Headers */,
</span><span class="cx">                                 0668E18B0ADD9624004128E0 /* PopupMenu.h in Headers */,
</span><span class="lines">@@ -30302,6 +30309,7 @@
</span><span class="cx">                                 0B9056F80F2685F30095FF6A /* WorkerThreadableLoader.cpp in Sources */,
</span><span class="cx">                                 97AABD2C14FA09D5007457AE /* WorkerThreadableWebSocketChannel.cpp in Sources */,
</span><span class="cx">                                 93309E23099E64920056E581 /* WrapContentsInDummySpanCommand.cpp in Sources */,
</span><ins>+                                51B45D201AB8D1E200117CD2 /* ContentExtension.cpp in Sources */,
</ins><span class="cx">                                 A833C7CC0A2CF07400D57664 /* XLinkNames.cpp in Sources */,
</span><span class="cx">                                 00B9318713BA8DB30035A948 /* XMLDocumentParser.cpp in Sources */,
</span><span class="cx">                                 00B9318913BA8DBC0035A948 /* XMLDocumentParserLibxml2.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsContentExtensioncpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/contentextensions/ContentExtension.cpp (0 => 181876)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/ContentExtension.cpp                                (rev 0)
+++ trunk/Source/WebCore/contentextensions/ContentExtension.cpp        2015-03-23 22:34:53 UTC (rev 181876)
</span><span class="lines">@@ -0,0 +1,79 @@
</span><ins>+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include &quot;config.h&quot;
+#include &quot;ContentExtension.h&quot;
+
+#include &quot;CompiledContentExtension.h&quot;
+#include &quot;StyleSheetContents.h&quot;
+#include &quot;UserContentController.h&quot;
+#include &lt;wtf/text/StringBuilder.h&gt;
+
+#if ENABLE(CONTENT_EXTENSIONS)
+
+namespace WebCore {
+namespace ContentExtensions {
+
+RefPtr&lt;ContentExtension&gt; ContentExtension::create(const String&amp; identifier, Ref&lt;CompiledContentExtension&gt;&amp;&amp; compiledExtension)
+{
+    return adoptRef(*new ContentExtension(identifier, WTF::move(compiledExtension)));
+}
+
+ContentExtension::ContentExtension(const String&amp; identifier, Ref&lt;CompiledContentExtension&gt;&amp;&amp; compiledExtension)
+    : m_identifier(identifier)
+    , m_compiledExtension(WTF::move(compiledExtension))
+    , m_parsedGlobalDisplayNoneStyleSheet(false)
+{
+}
+
+StyleSheetContents* ContentExtension::globalDisplayNoneStyleSheet()
+{
+    if (m_parsedGlobalDisplayNoneStyleSheet)
+        return m_globalDisplayNoneStyleSheet.get();
+
+    m_parsedGlobalDisplayNoneStyleSheet = true;
+
+    Vector&lt;String&gt; selectors = m_compiledExtension-&gt;globalDisplayNoneSelectors();
+    if (selectors.isEmpty())
+        return nullptr;
+
+    StringBuilder css;
+    for (auto&amp; selector : selectors) {
+        css.append(selector);
+        css.append(UserContentController::displayNoneCSSRule());
+    }
+
+    m_globalDisplayNoneStyleSheet = StyleSheetContents::create();
+    m_globalDisplayNoneStyleSheet-&gt;setIsUserStyleSheet(true);
+    if (!m_globalDisplayNoneStyleSheet-&gt;parseString(css.toString()))
+        m_globalDisplayNoneStyleSheet = nullptr;
+
+    return m_globalDisplayNoneStyleSheet.get();
+}
+
+} // namespace ContentExtensions
+} // namespace WebCore
+
+#endif // ENABLE(CONTENT_EXTENSIONS)
</ins></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsContentExtensionhfromrev181875trunkSourceWebCorecontentextensionsContentExtensionsBackendh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/contentextensions/ContentExtension.h (from rev 181875, trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.h) (0 => 181876)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/ContentExtension.h                                (rev 0)
+++ trunk/Source/WebCore/contentextensions/ContentExtension.h        2015-03-23 22:34:53 UTC (rev 181876)
</span><span class="lines">@@ -0,0 +1,64 @@
</span><ins>+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ContentExtension_h
+#define ContentExtension_h
+
+#include &lt;wtf/Ref.h&gt;
+#include &lt;wtf/RefCounted.h&gt;
+#include &lt;wtf/RefPtr.h&gt;
+
+#if ENABLE(CONTENT_EXTENSIONS)
+
+#include &quot;StyleSheetContents.h&quot;
+
+namespace WebCore {
+
+namespace ContentExtensions {
+
+class CompiledContentExtension;
+
+class ContentExtension : public RefCounted&lt;ContentExtension&gt; {
+public:
+    static RefPtr&lt;ContentExtension&gt; create(const String&amp; identifier, Ref&lt;CompiledContentExtension&gt;&amp;&amp;);
+
+    const String&amp; identifier() const { return m_identifier; }
+    const CompiledContentExtension&amp; compiledExtension() const { return m_compiledExtension.get(); }
+    StyleSheetContents* globalDisplayNoneStyleSheet();
+
+private:
+    ContentExtension(const String&amp; identifier, Ref&lt;CompiledContentExtension&gt;&amp;&amp;);
+
+    String m_identifier;
+    Ref&lt;CompiledContentExtension&gt; m_compiledExtension;
+    RefPtr&lt;StyleSheetContents&gt; m_globalDisplayNoneStyleSheet;
+    bool m_parsedGlobalDisplayNoneStyleSheet;
+};
+
+} // namespace ContentExtensions
+} // namespace WebCore
+
+#endif // ENABLE(CONTENT_EXTENSIONS)
+#endif // ContentExtension_h
</ins></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsContentExtensionsBackendcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp (181875 => 181876)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp        2015-03-23 22:31:07 UTC (rev 181875)
+++ trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp        2015-03-23 22:34:53 UTC (rev 181876)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> #if ENABLE(CONTENT_EXTENSIONS)
</span><span class="cx"> 
</span><span class="cx"> #include &quot;CompiledContentExtension.h&quot;
</span><ins>+#include &quot;ContentExtension.h&quot;
</ins><span class="cx"> #include &quot;DFABytecodeInterpreter.h&quot;
</span><span class="cx"> #include &quot;ResourceLoadInfo.h&quot;
</span><span class="cx"> #include &quot;URL.h&quot;
</span><span class="lines">@@ -49,7 +50,8 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    m_contentExtensions.set(identifier, compiledContentExtension);
</del><ins>+    RefPtr&lt;ContentExtension&gt; extension = ContentExtension::create(identifier, adoptRef(*compiledContentExtension.leakRef()));
+    m_contentExtensions.set(identifier, WTF::move(extension));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void ContentExtensionsBackend::removeContentExtension(const String&amp; identifier)
</span><span class="lines">@@ -70,12 +72,13 @@
</span><span class="cx"> 
</span><span class="cx">     Vector&lt;Action&gt; finalActions;
</span><span class="cx">     ResourceFlags flags = resourceLoadInfo.getResourceFlags();
</span><del>-    for (auto&amp; compiledContentExtension : m_contentExtensions) {
-        DFABytecodeInterpreter interpreter(compiledContentExtension.value-&gt;bytecode(), compiledContentExtension.value-&gt;bytecodeLength());
</del><ins>+    for (auto&amp; contentExtension : m_contentExtensions.values()) {
+        const CompiledContentExtension&amp; compiledExtension = contentExtension-&gt;compiledExtension();
+        DFABytecodeInterpreter interpreter(compiledExtension.bytecode(), compiledExtension.bytecodeLength());
</ins><span class="cx">         DFABytecodeInterpreter::Actions triggeredActions = interpreter.interpret(urlCString, flags);
</span><span class="cx">         
</span><del>-        const SerializedActionByte* actions = compiledContentExtension.value-&gt;actions();
-        const unsigned actionsLength = compiledContentExtension.value-&gt;actionsLength();
</del><ins>+        const SerializedActionByte* actions = compiledExtension.actions();
+        const unsigned actionsLength = compiledExtension.actionsLength();
</ins><span class="cx">         
</span><span class="cx">         if (!triggeredActions.isEmpty()) {
</span><span class="cx">             Vector&lt;unsigned&gt; actionLocations;
</span><span class="lines">@@ -96,13 +99,19 @@
</span><span class="cx">                 finalActions.append(action);
</span><span class="cx">             }
</span><span class="cx"> 
</span><del>-            if (!sawIgnorePreviousRules)
-                finalActions.append(Action(ActionType::CSSDisplayNoneStyleSheet, compiledContentExtension.key));
</del><ins>+            if (!sawIgnorePreviousRules &amp;&amp; contentExtension-&gt;globalDisplayNoneStyleSheet())
+                finalActions.append(Action(ActionType::CSSDisplayNoneStyleSheet, contentExtension-&gt;identifier()));
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     return finalActions;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+StyleSheetContents* ContentExtensionsBackend::globalDisplayNoneStyleSheet(const String&amp; identifier) const
+{
+    const auto&amp; contentExtension = m_contentExtensions.get(identifier);
+    return contentExtension ? contentExtension-&gt;globalDisplayNoneStyleSheet() : nullptr;
+}
+
</ins><span class="cx"> } // namespace ContentExtensions
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsContentExtensionsBackendh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.h (181875 => 181876)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.h        2015-03-23 22:31:07 UTC (rev 181875)
+++ trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.h        2015-03-23 22:34:53 UTC (rev 181876)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(CONTENT_EXTENSIONS)
</span><span class="cx"> 
</span><ins>+#include &quot;ContentExtension.h&quot;
</ins><span class="cx"> #include &quot;ContentExtensionRule.h&quot;
</span><span class="cx"> #include &lt;wtf/HashMap.h&gt;
</span><span class="cx"> #include &lt;wtf/text/StringHash.h&gt;
</span><span class="lines">@@ -60,9 +61,10 @@
</span><span class="cx"> 
</span><span class="cx">     // - Internal WebCore Interface.
</span><span class="cx">     WEBCORE_EXPORT Vector&lt;Action&gt; actionsForResourceLoad(const ResourceLoadInfo&amp;) const;
</span><ins>+    StyleSheetContents* globalDisplayNoneStyleSheet(const String&amp; identifier) const;
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    HashMap&lt;String, RefPtr&lt;CompiledContentExtension&gt;&gt; m_contentExtensions;
</del><ins>+    HashMap&lt;String, RefPtr&lt;ContentExtension&gt;&gt; m_contentExtensions;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace ContentExtensions
</span></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsDFABytecodeInterpretercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/contentextensions/DFABytecodeInterpreter.cpp (181875 => 181876)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/DFABytecodeInterpreter.cpp        2015-03-23 22:31:07 UTC (rev 181875)
+++ trunk/Source/WebCore/contentextensions/DFABytecodeInterpreter.cpp        2015-03-23 22:34:53 UTC (rev 181876)
</span><span class="lines">@@ -62,8 +62,9 @@
</span><span class="cx">     bool urlIndexIsAfterEndOfString = false;
</span><span class="cx">     Actions actions;
</span><span class="cx">     
</span><del>-    // FIXME: Skip the actions from the root once they are used through actionsFromDFARoot. Change AppendAction to AppendActions to make this faster.
-    
</del><ins>+    while (static_cast&lt;DFABytecodeInstruction&gt;(m_bytecode[programCounter]) == DFABytecodeInstruction::AppendAction)
+        programCounter += instructionSizeWithArguments(DFABytecodeInstruction::AppendAction);
+
</ins><span class="cx">     // This should always terminate if interpreting correctly compiled bytecode.
</span><span class="cx">     while (true) {
</span><span class="cx">         ASSERT(programCounter &lt;= m_bytecodeLength);
</span></span></pre></div>
<a id="trunkSourceWebCoredomDocumentStyleSheetCollectioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/DocumentStyleSheetCollection.cpp (181875 => 181876)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/DocumentStyleSheetCollection.cpp        2015-03-23 22:31:07 UTC (rev 181875)
+++ trunk/Source/WebCore/dom/DocumentStyleSheetCollection.cpp        2015-03-23 22:34:53 UTC (rev 181876)
</span><span class="lines">@@ -191,6 +191,18 @@
</span><span class="cx">     m_document.styleResolverChanged(RecalcStyleImmediately);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void DocumentStyleSheetCollection::maybeAddContentExtensionSheet(const String&amp; identifier, StyleSheetContents&amp; sheet)
+{
+    ASSERT(sheet.isUserStyleSheet());
+
+    if (m_contentExtensionSheets.contains(identifier))
+        return;
+
+    Ref&lt;CSSStyleSheet&gt; cssSheet = CSSStyleSheet::create(sheet, &amp;m_document);
+    m_contentExtensionSheets.set(identifier, &amp;cssSheet.get());
+    m_userStyleSheets.append(adoptRef(cssSheet.leakRef()));
+}
+
</ins><span class="cx"> // This method is called whenever a top-level stylesheet has finished loading.
</span><span class="cx"> void DocumentStyleSheetCollection::removePendingSheet(RemovePendingSheetNotificationType notification)
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebCoredomDocumentStyleSheetCollectionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/DocumentStyleSheetCollection.h (181875 => 181876)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/DocumentStyleSheetCollection.h        2015-03-23 22:31:07 UTC (rev 181875)
+++ trunk/Source/WebCore/dom/DocumentStyleSheetCollection.h        2015-03-23 22:34:53 UTC (rev 181876)
</span><span class="lines">@@ -30,6 +30,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include &lt;memory&gt;
</span><span class="cx"> #include &lt;wtf/FastMalloc.h&gt;
</span><ins>+#include &lt;wtf/HashMap.h&gt;
</ins><span class="cx"> #include &lt;wtf/ListHashSet.h&gt;
</span><span class="cx"> #include &lt;wtf/RefPtr.h&gt;
</span><span class="cx"> #include &lt;wtf/Vector.h&gt;
</span><span class="lines">@@ -69,6 +70,7 @@
</span><span class="cx"> 
</span><span class="cx">     WEBCORE_EXPORT void addAuthorSheet(Ref&lt;StyleSheetContents&gt;&amp;&amp; authorSheet);
</span><span class="cx">     WEBCORE_EXPORT void addUserSheet(Ref&lt;StyleSheetContents&gt;&amp;&amp; userSheet);
</span><ins>+    void maybeAddContentExtensionSheet(const String&amp; identifier, StyleSheetContents&amp;);
</ins><span class="cx"> 
</span><span class="cx">     enum UpdateFlag { NoUpdate = 0, OptimizedUpdate, FullUpdate };
</span><span class="cx"> 
</span><span class="lines">@@ -146,6 +148,7 @@
</span><span class="cx"> 
</span><span class="cx">     Vector&lt;RefPtr&lt;CSSStyleSheet&gt;&gt; m_userStyleSheets;
</span><span class="cx">     Vector&lt;RefPtr&lt;CSSStyleSheet&gt;&gt; m_authorStyleSheets;
</span><ins>+    HashMap&lt;String, RefPtr&lt;CSSStyleSheet&gt;&gt; m_contentExtensionSheets;
</ins><span class="cx"> 
</span><span class="cx">     bool m_hadActiveLoadingStylesheet;
</span><span class="cx">     UpdateFlag m_pendingUpdateType;
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderDocumentLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/DocumentLoader.cpp (181875 => 181876)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/DocumentLoader.cpp        2015-03-23 22:31:07 UTC (rev 181875)
+++ trunk/Source/WebCore/loader/DocumentLoader.cpp        2015-03-23 22:34:53 UTC (rev 181876)
</span><span class="lines">@@ -840,6 +840,19 @@
</span><span class="cx"> 
</span><span class="cx">         m_writer.setEncoding(encoding, userChosen);
</span><span class="cx">     }
</span><ins>+
+#if ENABLE(CONTENT_EXTENSIONS)
+    DocumentStyleSheetCollection&amp; styleSheetCollection = m_frame-&gt;document()-&gt;styleSheetCollection();
+
+    for (auto&amp; pendingStyleSheet : m_pendingNamedContentExtensionStyleSheets)
+        styleSheetCollection.maybeAddContentExtensionSheet(pendingStyleSheet.key, *pendingStyleSheet.value);
+    for (auto&amp; pendingStyleSheet : m_pendingUnnamedContentExtensionStyleSheets)
+        styleSheetCollection.addUserSheet(*pendingStyleSheet);
+
+    m_pendingNamedContentExtensionStyleSheets.clear();
+    m_pendingUnnamedContentExtensionStyleSheets.clear();
+#endif
+
</ins><span class="cx">     ASSERT(m_frame-&gt;document()-&gt;parsing());
</span><span class="cx">     m_writer.addData(bytes, length);
</span><span class="cx"> }
</span><span class="lines">@@ -1441,6 +1454,7 @@
</span><span class="cx">     ResourceRequest request(m_request);
</span><span class="cx">     static NeverDestroyed&lt;ResourceLoaderOptions&gt; mainResourceLoadOptions(SendCallbacks, SniffContent, BufferData, AllowStoredCredentials, AskClientForAllCredentials, SkipSecurityCheck, UseDefaultOriginRestrictionsForType, IncludeCertificateInfo);
</span><span class="cx">     CachedResourceRequest cachedResourceRequest(request, mainResourceLoadOptions);
</span><ins>+    cachedResourceRequest.setInitiator(*this);
</ins><span class="cx">     m_mainResource = m_cachedResourceLoader-&gt;requestMainResource(cachedResourceRequest);
</span><span class="cx">     if (!m_mainResource) {
</span><span class="cx">         setRequest(ResourceRequest());
</span><span class="lines">@@ -1572,4 +1586,18 @@
</span><span class="cx">     applicationCacheHost()-&gt;stopDeferringEvents();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#if ENABLE(CONTENT_EXTENSIONS)
+void DocumentLoader::addPendingContentExtensionSheet(const String&amp; identifier, StyleSheetContents&amp; sheet)
+{
+    ASSERT(!m_gotFirstByte);
+    m_pendingNamedContentExtensionStyleSheets.set(identifier, &amp;sheet);
+}
+
+void DocumentLoader::addPendingContentExtensionSheet(StyleSheetContents&amp; sheet)
+{
+    ASSERT(!m_gotFirstByte);
+    m_pendingUnnamedContentExtensionStyleSheets.add(&amp;sheet);
+}
+#endif
+
</ins><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderDocumentLoaderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/DocumentLoader.h (181875 => 181876)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/DocumentLoader.h        2015-03-23 22:31:07 UTC (rev 181875)
+++ trunk/Source/WebCore/loader/DocumentLoader.h        2015-03-23 22:34:53 UTC (rev 181876)
</span><span class="lines">@@ -41,6 +41,7 @@
</span><span class="cx"> #include &quot;ResourceRequest.h&quot;
</span><span class="cx"> #include &quot;ResourceResponse.h&quot;
</span><span class="cx"> #include &quot;StringWithDirection.h&quot;
</span><ins>+#include &quot;StyleSheetContents.h&quot;
</ins><span class="cx"> #include &quot;SubstituteData.h&quot;
</span><span class="cx"> #include &quot;Timer.h&quot;
</span><span class="cx"> #include &lt;wtf/HashSet.h&gt;
</span><span class="lines">@@ -267,6 +268,11 @@
</span><span class="cx">         QuickLookHandle* quickLookHandle() const { return m_quickLookHandle.get(); }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if ENABLE(CONTENT_EXTENSIONS)
+        void addPendingContentExtensionSheet(const String&amp; identifier, StyleSheetContents&amp;);
+        void addPendingContentExtensionSheet(StyleSheetContents&amp;);
+#endif
+
</ins><span class="cx">     protected:
</span><span class="cx">         WEBCORE_EXPORT DocumentLoader(const ResourceRequest&amp;, const SubstituteData&amp;);
</span><span class="cx"> 
</span><span class="lines">@@ -424,6 +430,12 @@
</span><span class="cx"> #if USE(QUICK_LOOK)
</span><span class="cx">         std::unique_ptr&lt;QuickLookHandle&gt; m_quickLookHandle;
</span><span class="cx"> #endif
</span><ins>+
+#if ENABLE(CONTENT_EXTENSIONS)
+        HashMap&lt;String, RefPtr&lt;StyleSheetContents&gt;&gt; m_pendingNamedContentExtensionStyleSheets;
+        HashSet&lt;RefPtr&lt;StyleSheetContents&gt;&gt; m_pendingUnnamedContentExtensionStyleSheets;
+#endif
+
</ins><span class="cx">     };
</span><span class="cx"> 
</span><span class="cx">     inline void DocumentLoader::recordMemoryCacheLoadForFutureClientNotification(const ResourceRequest&amp; request)
</span></span></pre></div>
<a id="trunkSourceWebCoreloadercacheCachedResourceLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp (181875 => 181876)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp        2015-03-23 22:31:07 UTC (rev 181875)
+++ trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp        2015-03-23 22:34:53 UTC (rev 181876)
</span><span class="lines">@@ -64,7 +64,9 @@
</span><span class="cx"> #include &quot;SecurityOrigin.h&quot;
</span><span class="cx"> #include &quot;SessionID.h&quot;
</span><span class="cx"> #include &quot;Settings.h&quot;
</span><ins>+#include &quot;StyleSheetContents.h&quot;
</ins><span class="cx"> #include &quot;UserContentController.h&quot;
</span><ins>+#include &quot;UserStyleSheet.h&quot;
</ins><span class="cx"> #include &lt;wtf/text/CString.h&gt;
</span><span class="cx"> #include &lt;wtf/text/WTFString.h&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -506,17 +508,21 @@
</span><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(CONTENT_EXTENSIONS)
</span><del>-    Vector&lt;ContentExtensions::Action&gt; actions;
-
</del><span class="cx">     URL mainDocumentURL;
</span><span class="cx">     if (frame() &amp;&amp; frame()-&gt;mainFrame().document())
</span><span class="cx">         mainDocumentURL = frame()-&gt;mainFrame().document()-&gt;url();
</span><del>-    
</del><ins>+
</ins><span class="cx">     ResourceLoadInfo resourceLoadInfo = { url, mainDocumentURL, toResourceType(type) };
</span><del>-    
-    if (frame() &amp;&amp; frame()-&gt;mainFrame().page() &amp;&amp; frame()-&gt;mainFrame().page()-&gt;userContentController())
-        actions = frame()-&gt;mainFrame().page()-&gt;userContentController()-&gt;actionsForResourceLoad(resourceLoadInfo);
</del><span class="cx"> 
</span><ins>+    Vector&lt;ContentExtensions::Action&gt; actions;
+    UserContentController* userContentController = nullptr;
+    if (frame() &amp;&amp; frame()-&gt;mainFrame().page())
+        userContentController = frame()-&gt;mainFrame().page()-&gt;userContentController();
+
+    if (userContentController)
+        actions = userContentController-&gt;actionsForResourceLoad(resourceLoadInfo);
+
+    StringBuilder css;
</ins><span class="cx">     bool willBlockLoad = false;
</span><span class="cx">     for (const auto&amp; action : actions) {
</span><span class="cx">         switch (action.type()) {
</span><span class="lines">@@ -527,17 +533,38 @@
</span><span class="cx">             request.mutableResourceRequest().setAllowCookies(false);
</span><span class="cx">             break;
</span><span class="cx">         case ContentExtensions::ActionType::CSSDisplayNoneSelector:
</span><del>-            // action.cssSelector() is the css to use here.
-            // FIXME: That css selector should be used to apply display:none.
</del><ins>+            css.append(action.stringArgument());
+            css.append(UserContentController::displayNoneCSSRule());
</ins><span class="cx">             break;
</span><del>-        case ContentExtensions::ActionType::CSSDisplayNoneStyleSheet:
-            // FIXME: Apply cached stylesheet here
</del><ins>+        case ContentExtensions::ActionType::CSSDisplayNoneStyleSheet: {
+            StyleSheetContents* styleSheetContents = userContentController-&gt;globalDisplayNoneStyleSheet(action.stringArgument());
+            RELEASE_ASSERT(styleSheetContents);
+
+            if (type == CachedResource::MainResource &amp;&amp; request.initiatingDocumentLoader())
+                request.initiatingDocumentLoader()-&gt;addPendingContentExtensionSheet(action.stringArgument(), *styleSheetContents);
+            else if (m_document)
+                m_document-&gt;styleSheetCollection().maybeAddContentExtensionSheet(action.stringArgument(), *styleSheetContents);
+
</ins><span class="cx">             break;
</span><ins>+        }
</ins><span class="cx">         case ContentExtensions::ActionType::IgnorePreviousRules:
</span><span class="cx">         case ContentExtensions::ActionType::InvalidAction:
</span><span class="cx">             RELEASE_ASSERT_NOT_REACHED();
</span><span class="cx">         }
</span><span class="cx">     }
</span><ins>+
+    if (css.length()) {
+        Ref&lt;StyleSheetContents&gt; styleSheet = StyleSheetContents::create();
+        styleSheet-&gt;setIsUserStyleSheet(true);
+
+        if (styleSheet-&gt;parseString(css.toString())) {
+            if (type == CachedResource::MainResource &amp;&amp; request.initiatingDocumentLoader())
+                request.initiatingDocumentLoader()-&gt;addPendingContentExtensionSheet(styleSheet);
+            else if (m_document)
+                m_document-&gt;styleSheetCollection().addUserSheet(WTF::move(styleSheet));
+        }
+    }
+
</ins><span class="cx">     if (willBlockLoad)
</span><span class="cx">         return nullptr;
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCoreloadercacheCachedResourceRequestcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/cache/CachedResourceRequest.cpp (181875 => 181876)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/cache/CachedResourceRequest.cpp        2015-03-23 22:31:07 UTC (rev 181875)
+++ trunk/Source/WebCore/loader/cache/CachedResourceRequest.cpp        2015-03-23 22:34:53 UTC (rev 181876)
</span><span class="lines">@@ -75,6 +75,11 @@
</span><span class="cx">     m_initiatorName = name;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void CachedResourceRequest::setInitiator(DocumentLoader&amp; documentLoader)
+{
+    m_initiatingDocumentLoader = &amp;documentLoader;
+}
+
</ins><span class="cx"> const AtomicString&amp; CachedResourceRequest::initiatorName() const
</span><span class="cx"> {
</span><span class="cx">     if (m_initiatorElement)
</span></span></pre></div>
<a id="trunkSourceWebCoreloadercacheCachedResourceRequesth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/cache/CachedResourceRequest.h (181875 => 181876)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/cache/CachedResourceRequest.h        2015-03-23 22:31:07 UTC (rev 181875)
+++ trunk/Source/WebCore/loader/cache/CachedResourceRequest.h        2015-03-23 22:34:53 UTC (rev 181876)
</span><span class="lines">@@ -26,6 +26,7 @@
</span><span class="cx"> #ifndef CachedResourceRequest_h
</span><span class="cx"> #define CachedResourceRequest_h
</span><span class="cx"> 
</span><ins>+#include &quot;DocumentLoader.h&quot;
</ins><span class="cx"> #include &quot;Element.h&quot;
</span><span class="cx"> #include &quot;ResourceLoadPriority.h&quot;
</span><span class="cx"> #include &quot;ResourceLoaderOptions.h&quot;
</span><span class="lines">@@ -60,6 +61,9 @@
</span><span class="cx">     void setInitiator(const AtomicString&amp; name);
</span><span class="cx">     const AtomicString&amp; initiatorName() const;
</span><span class="cx"> 
</span><ins>+    void setInitiator(DocumentLoader&amp;);
+    DocumentLoader* initiatingDocumentLoader() const { return m_initiatingDocumentLoader.get(); }
+
</ins><span class="cx"> private:
</span><span class="cx">     ResourceRequest m_resourceRequest;
</span><span class="cx">     String m_charset;
</span><span class="lines">@@ -69,6 +73,7 @@
</span><span class="cx">     DeferOption m_defer;
</span><span class="cx">     RefPtr&lt;Element&gt; m_initiatorElement;
</span><span class="cx">     AtomicString m_initiatorName;
</span><ins>+    RefPtr&lt;DocumentLoader&gt; m_initiatingDocumentLoader;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCorepageUserContentControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/UserContentController.cpp (181875 => 181876)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/UserContentController.cpp        2015-03-23 22:31:07 UTC (rev 181875)
+++ trunk/Source/WebCore/page/UserContentController.cpp        2015-03-23 22:34:53 UTC (rev 181876)
</span><span class="lines">@@ -33,6 +33,7 @@
</span><span class="cx"> #include &quot;ResourceLoadInfo.h&quot;
</span><span class="cx"> #include &quot;UserScript.h&quot;
</span><span class="cx"> #include &quot;UserStyleSheet.h&quot;
</span><ins>+#include &lt;wtf/NeverDestroyed.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> #if ENABLE(USER_MESSAGE_HANDLERS)
</span><span class="cx"> #include &quot;UserMessageHandlerDescriptor.h&quot;
</span><span class="lines">@@ -212,6 +213,20 @@
</span><span class="cx">     return m_contentExtensionBackend-&gt;actionsForResourceLoad(resourceLoadInfo);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+StyleSheetContents* UserContentController::globalDisplayNoneStyleSheet(const String&amp; identifier) const
+{
+    if (!m_contentExtensionBackend)
+        return nullptr;
+
+    return m_contentExtensionBackend-&gt;globalDisplayNoneStyleSheet(identifier);
+}
+
+const String&amp; UserContentController::displayNoneCSSRule()
+{
+    static NeverDestroyed&lt;const String&gt; rule(ASCIILiteral(&quot;{display:none !important;}\n&quot;));
+    return rule;
+}
+
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> void UserContentController::removeAllUserContent()
</span></span></pre></div>
<a id="trunkSourceWebCorepageUserContentControllerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/UserContentController.h (181875 => 181876)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/UserContentController.h        2015-03-23 22:31:07 UTC (rev 181875)
+++ trunk/Source/WebCore/page/UserContentController.h        2015-03-23 22:34:53 UTC (rev 181876)
</span><span class="lines">@@ -40,6 +40,7 @@
</span><span class="cx"> 
</span><span class="cx"> class DOMWrapperWorld;
</span><span class="cx"> class Page;
</span><ins>+class StyleSheetContents;
</ins><span class="cx"> class URL;
</span><span class="cx"> class UserScript;
</span><span class="cx"> class UserStyleSheet;
</span><span class="lines">@@ -87,6 +88,8 @@
</span><span class="cx">     WEBCORE_EXPORT void removeAllUserContentExtensions();
</span><span class="cx">     
</span><span class="cx">     Vector&lt;ContentExtensions::Action&gt; actionsForResourceLoad(const ResourceLoadInfo&amp;);
</span><ins>+    StyleSheetContents* globalDisplayNoneStyleSheet(const String&amp; identifier) const;
+    static const String&amp; displayNoneCSSRule();
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> private:
</span></span></pre>
</div>
</div>

</body>
</html>