<!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 <beidson@apple.com>
+
+ 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 <dino@apple.com>
</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: "This text should not be visible once the css selector is applied (not done yet)."
- RenderBlock {P} at (0,34) size 784x18
- RenderText {#text} at (0,0) size 522x18
- text run at (0,0) width 522: "This text should also not be visible once the css selector is applied (not done yet)."
- 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: "This text should be visible."
</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>+<head>
+<meta charset="UTF-8"></meta>
+</head>
</ins><span class="cx"> <body>
</span><del>-<p class="hidden">This text should not be visible once the css selector is applied (not done yet).</p>
-<p class="hidden_Ž">This text should also not be visible once the css selector is applied (not done yet).</p>
</del><ins>+<p class="hidden_global">This text should not be visible once the global css selector is applied.</p>
+<p class="hidden">This text should not be visible once the particular css selector is applied.</p>
+<p class="hidden_Ž">This text should not be visible once the particular css selector with non-ascii characters is applied.</p>
</ins><span class="cx"> <p class="not_hidden">This text should be visible.</p>
</span><span class="cx"> </body>
</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"> "trigger": {
</span><span class="cx"> "url-filter": ".*css-display-none.html"
</span><span class="cx"> }
</span><ins>+ },
+ {
+ "action": {
+ "type": "css-display-none",
+ "selector": ".hidden_global"
+ },
+ "trigger": {
+ "url-filter": ".*"
+ }
</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 <beidson@apple.com>
+
+ 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 <andersca@apple.com>
</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 = "<group>"; };
</span><span class="cx">                 51B07A431823248B00AA8D1A /* IDBPendingDeleteCall.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IDBPendingDeleteCall.h; sourceTree = "<group>"; };
</span><span class="cx">                 51B2417A0D931F3F00E83F5C /* LegacyWebArchiveMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LegacyWebArchiveMac.mm; sourceTree = "<group>"; };
</span><ins>+                51B45D1E1AB8D1E200117CD2 /* ContentExtension.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ContentExtension.cpp; sourceTree = "<group>"; };
+                51B45D1F1AB8D1E200117CD2 /* ContentExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContentExtension.h; sourceTree = "<group>"; };
</ins><span class="cx">                 51BE37DE0DAEE00E001085FC /* StorageArea.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StorageArea.h; sourceTree = "<group>"; };
</span><span class="cx">                 51C0AA380F2AA10A001648C2 /* CachedFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedFrame.h; sourceTree = "<group>"; };
</span><span class="cx">                 51C0AA400F2AA15E001648C2 /* CachedFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = CachedFrame.cpp; sourceTree = "<group>"; 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 "config.h"
+#include "ContentExtension.h"
+
+#include "CompiledContentExtension.h"
+#include "StyleSheetContents.h"
+#include "UserContentController.h"
+#include <wtf/text/StringBuilder.h>
+
+#if ENABLE(CONTENT_EXTENSIONS)
+
+namespace WebCore {
+namespace ContentExtensions {
+
+RefPtr<ContentExtension> ContentExtension::create(const String& identifier, Ref<CompiledContentExtension>&& compiledExtension)
+{
+ return adoptRef(*new ContentExtension(identifier, WTF::move(compiledExtension)));
+}
+
+ContentExtension::ContentExtension(const String& identifier, Ref<CompiledContentExtension>&& 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<String> selectors = m_compiledExtension->globalDisplayNoneSelectors();
+ if (selectors.isEmpty())
+ return nullptr;
+
+ StringBuilder css;
+ for (auto& selector : selectors) {
+ css.append(selector);
+ css.append(UserContentController::displayNoneCSSRule());
+ }
+
+ m_globalDisplayNoneStyleSheet = StyleSheetContents::create();
+ m_globalDisplayNoneStyleSheet->setIsUserStyleSheet(true);
+ if (!m_globalDisplayNoneStyleSheet->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 <wtf/Ref.h>
+#include <wtf/RefCounted.h>
+#include <wtf/RefPtr.h>
+
+#if ENABLE(CONTENT_EXTENSIONS)
+
+#include "StyleSheetContents.h"
+
+namespace WebCore {
+
+namespace ContentExtensions {
+
+class CompiledContentExtension;
+
+class ContentExtension : public RefCounted<ContentExtension> {
+public:
+ static RefPtr<ContentExtension> create(const String& identifier, Ref<CompiledContentExtension>&&);
+
+ const String& identifier() const { return m_identifier; }
+ const CompiledContentExtension& compiledExtension() const { return m_compiledExtension.get(); }
+ StyleSheetContents* globalDisplayNoneStyleSheet();
+
+private:
+ ContentExtension(const String& identifier, Ref<CompiledContentExtension>&&);
+
+ String m_identifier;
+ Ref<CompiledContentExtension> m_compiledExtension;
+ RefPtr<StyleSheetContents> 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 "CompiledContentExtension.h"
</span><ins>+#include "ContentExtension.h"
</ins><span class="cx"> #include "DFABytecodeInterpreter.h"
</span><span class="cx"> #include "ResourceLoadInfo.h"
</span><span class="cx"> #include "URL.h"
</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<ContentExtension> 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& identifier)
</span><span class="lines">@@ -70,12 +72,13 @@
</span><span class="cx">
</span><span class="cx"> Vector<Action> finalActions;
</span><span class="cx"> ResourceFlags flags = resourceLoadInfo.getResourceFlags();
</span><del>- for (auto& compiledContentExtension : m_contentExtensions) {
- DFABytecodeInterpreter interpreter(compiledContentExtension.value->bytecode(), compiledContentExtension.value->bytecodeLength());
</del><ins>+ for (auto& contentExtension : m_contentExtensions.values()) {
+ const CompiledContentExtension& compiledExtension = contentExtension->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->actions();
- const unsigned actionsLength = compiledContentExtension.value->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<unsigned> 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 && contentExtension->globalDisplayNoneStyleSheet())
+ finalActions.append(Action(ActionType::CSSDisplayNoneStyleSheet, contentExtension->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& identifier) const
+{
+ const auto& contentExtension = m_contentExtensions.get(identifier);
+ return contentExtension ? contentExtension->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 "ContentExtension.h"
</ins><span class="cx"> #include "ContentExtensionRule.h"
</span><span class="cx"> #include <wtf/HashMap.h>
</span><span class="cx"> #include <wtf/text/StringHash.h>
</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<Action> actionsForResourceLoad(const ResourceLoadInfo&) const;
</span><ins>+ StyleSheetContents* globalDisplayNoneStyleSheet(const String& identifier) const;
</ins><span class="cx">
</span><span class="cx"> private:
</span><del>- HashMap<String, RefPtr<CompiledContentExtension>> m_contentExtensions;
</del><ins>+ HashMap<String, RefPtr<ContentExtension>> 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<DFABytecodeInstruction>(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 <= 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& identifier, StyleSheetContents& sheet)
+{
+ ASSERT(sheet.isUserStyleSheet());
+
+ if (m_contentExtensionSheets.contains(identifier))
+ return;
+
+ Ref<CSSStyleSheet> cssSheet = CSSStyleSheet::create(sheet, &m_document);
+ m_contentExtensionSheets.set(identifier, &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 <memory>
</span><span class="cx"> #include <wtf/FastMalloc.h>
</span><ins>+#include <wtf/HashMap.h>
</ins><span class="cx"> #include <wtf/ListHashSet.h>
</span><span class="cx"> #include <wtf/RefPtr.h>
</span><span class="cx"> #include <wtf/Vector.h>
</span><span class="lines">@@ -69,6 +70,7 @@
</span><span class="cx">
</span><span class="cx"> WEBCORE_EXPORT void addAuthorSheet(Ref<StyleSheetContents>&& authorSheet);
</span><span class="cx"> WEBCORE_EXPORT void addUserSheet(Ref<StyleSheetContents>&& userSheet);
</span><ins>+ void maybeAddContentExtensionSheet(const String& identifier, StyleSheetContents&);
</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<RefPtr<CSSStyleSheet>> m_userStyleSheets;
</span><span class="cx"> Vector<RefPtr<CSSStyleSheet>> m_authorStyleSheets;
</span><ins>+ HashMap<String, RefPtr<CSSStyleSheet>> 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& styleSheetCollection = m_frame->document()->styleSheetCollection();
+
+ for (auto& pendingStyleSheet : m_pendingNamedContentExtensionStyleSheets)
+ styleSheetCollection.maybeAddContentExtensionSheet(pendingStyleSheet.key, *pendingStyleSheet.value);
+ for (auto& pendingStyleSheet : m_pendingUnnamedContentExtensionStyleSheets)
+ styleSheetCollection.addUserSheet(*pendingStyleSheet);
+
+ m_pendingNamedContentExtensionStyleSheets.clear();
+ m_pendingUnnamedContentExtensionStyleSheets.clear();
+#endif
+
</ins><span class="cx"> ASSERT(m_frame->document()->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<ResourceLoaderOptions> 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->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()->stopDeferringEvents();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+#if ENABLE(CONTENT_EXTENSIONS)
+void DocumentLoader::addPendingContentExtensionSheet(const String& identifier, StyleSheetContents& sheet)
+{
+ ASSERT(!m_gotFirstByte);
+ m_pendingNamedContentExtensionStyleSheets.set(identifier, &sheet);
+}
+
+void DocumentLoader::addPendingContentExtensionSheet(StyleSheetContents& sheet)
+{
+ ASSERT(!m_gotFirstByte);
+ m_pendingUnnamedContentExtensionStyleSheets.add(&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 "ResourceRequest.h"
</span><span class="cx"> #include "ResourceResponse.h"
</span><span class="cx"> #include "StringWithDirection.h"
</span><ins>+#include "StyleSheetContents.h"
</ins><span class="cx"> #include "SubstituteData.h"
</span><span class="cx"> #include "Timer.h"
</span><span class="cx"> #include <wtf/HashSet.h>
</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& identifier, StyleSheetContents&);
+ void addPendingContentExtensionSheet(StyleSheetContents&);
+#endif
+
</ins><span class="cx"> protected:
</span><span class="cx"> WEBCORE_EXPORT DocumentLoader(const ResourceRequest&, const SubstituteData&);
</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<QuickLookHandle> m_quickLookHandle;
</span><span class="cx"> #endif
</span><ins>+
+#if ENABLE(CONTENT_EXTENSIONS)
+ HashMap<String, RefPtr<StyleSheetContents>> m_pendingNamedContentExtensionStyleSheets;
+ HashSet<RefPtr<StyleSheetContents>> m_pendingUnnamedContentExtensionStyleSheets;
+#endif
+
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> inline void DocumentLoader::recordMemoryCacheLoadForFutureClientNotification(const ResourceRequest& 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 "SecurityOrigin.h"
</span><span class="cx"> #include "SessionID.h"
</span><span class="cx"> #include "Settings.h"
</span><ins>+#include "StyleSheetContents.h"
</ins><span class="cx"> #include "UserContentController.h"
</span><ins>+#include "UserStyleSheet.h"
</ins><span class="cx"> #include <wtf/text/CString.h>
</span><span class="cx"> #include <wtf/text/WTFString.h>
</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<ContentExtensions::Action> actions;
-
</del><span class="cx"> URL mainDocumentURL;
</span><span class="cx"> if (frame() && frame()->mainFrame().document())
</span><span class="cx"> mainDocumentURL = frame()->mainFrame().document()->url();
</span><del>-
</del><ins>+
</ins><span class="cx"> ResourceLoadInfo resourceLoadInfo = { url, mainDocumentURL, toResourceType(type) };
</span><del>-
- if (frame() && frame()->mainFrame().page() && frame()->mainFrame().page()->userContentController())
- actions = frame()->mainFrame().page()->userContentController()->actionsForResourceLoad(resourceLoadInfo);
</del><span class="cx">
</span><ins>+ Vector<ContentExtensions::Action> actions;
+ UserContentController* userContentController = nullptr;
+ if (frame() && frame()->mainFrame().page())
+ userContentController = frame()->mainFrame().page()->userContentController();
+
+ if (userContentController)
+ actions = userContentController->actionsForResourceLoad(resourceLoadInfo);
+
+ StringBuilder css;
</ins><span class="cx"> bool willBlockLoad = false;
</span><span class="cx"> for (const auto& 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->globalDisplayNoneStyleSheet(action.stringArgument());
+ RELEASE_ASSERT(styleSheetContents);
+
+ if (type == CachedResource::MainResource && request.initiatingDocumentLoader())
+ request.initiatingDocumentLoader()->addPendingContentExtensionSheet(action.stringArgument(), *styleSheetContents);
+ else if (m_document)
+ m_document->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<StyleSheetContents> styleSheet = StyleSheetContents::create();
+ styleSheet->setIsUserStyleSheet(true);
+
+ if (styleSheet->parseString(css.toString())) {
+ if (type == CachedResource::MainResource && request.initiatingDocumentLoader())
+ request.initiatingDocumentLoader()->addPendingContentExtensionSheet(styleSheet);
+ else if (m_document)
+ m_document->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& documentLoader)
+{
+ m_initiatingDocumentLoader = &documentLoader;
+}
+
</ins><span class="cx"> const AtomicString& 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 "DocumentLoader.h"
</ins><span class="cx"> #include "Element.h"
</span><span class="cx"> #include "ResourceLoadPriority.h"
</span><span class="cx"> #include "ResourceLoaderOptions.h"
</span><span class="lines">@@ -60,6 +61,9 @@
</span><span class="cx"> void setInitiator(const AtomicString& name);
</span><span class="cx"> const AtomicString& initiatorName() const;
</span><span class="cx">
</span><ins>+ void setInitiator(DocumentLoader&);
+ 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<Element> m_initiatorElement;
</span><span class="cx"> AtomicString m_initiatorName;
</span><ins>+ RefPtr<DocumentLoader> 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 "ResourceLoadInfo.h"
</span><span class="cx"> #include "UserScript.h"
</span><span class="cx"> #include "UserStyleSheet.h"
</span><ins>+#include <wtf/NeverDestroyed.h>
</ins><span class="cx">
</span><span class="cx"> #if ENABLE(USER_MESSAGE_HANDLERS)
</span><span class="cx"> #include "UserMessageHandlerDescriptor.h"
</span><span class="lines">@@ -212,6 +213,20 @@
</span><span class="cx"> return m_contentExtensionBackend->actionsForResourceLoad(resourceLoadInfo);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+StyleSheetContents* UserContentController::globalDisplayNoneStyleSheet(const String& identifier) const
+{
+ if (!m_contentExtensionBackend)
+ return nullptr;
+
+ return m_contentExtensionBackend->globalDisplayNoneStyleSheet(identifier);
+}
+
+const String& UserContentController::displayNoneCSSRule()
+{
+ static NeverDestroyed<const String> rule(ASCIILiteral("{display:none !important;}\n"));
+ 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<ContentExtensions::Action> actionsForResourceLoad(const ResourceLoadInfo&);
</span><ins>+ StyleSheetContents* globalDisplayNoneStyleSheet(const String& identifier) const;
+ static const String& displayNoneCSSRule();
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> private:
</span></span></pre>
</div>
</div>
</body>
</html>