<!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>[187064] branches/safari-601.1-branch</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/187064">187064</a></dd>
<dt>Author</dt> <dd>matthew_hanson@apple.com</dd>
<dt>Date</dt> <dd>2015-07-20 21:37:05 -0700 (Mon, 20 Jul 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/186957">r186957</a>. rdar://problem/21867831</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari6011branchLayoutTestsChangeLog">branches/safari-601.1-branch/LayoutTests/ChangeLog</a></li>
<li><a href="#branchessafari6011branchSourceWebCoreChangeLog">branches/safari-601.1-branch/Source/WebCore/ChangeLog</a></li>
<li><a href="#branchessafari6011branchSourceWebCorecontentextensionsContentExtensionCompilercpp">branches/safari-601.1-branch/Source/WebCore/contentextensions/ContentExtensionCompiler.cpp</a></li>
<li><a href="#branchessafari6011branchSourceWebCorecontentextensionsContentExtensionRuleh">branches/safari-601.1-branch/Source/WebCore/contentextensions/ContentExtensionRule.h</a></li>
<li><a href="#branchessafari6011branchSourceWebCorecontentextensionsContentExtensionsBackendcpp">branches/safari-601.1-branch/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp</a></li>
<li><a href="#branchessafari6011branchSourceWebCoreloaderDocumentLoadercpp">branches/safari-601.1-branch/Source/WebCore/loader/DocumentLoader.cpp</a></li>
<li><a href="#branchessafari6011branchSourceWebCoreloaderDocumentLoaderh">branches/safari-601.1-branch/Source/WebCore/loader/DocumentLoader.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#branchessafari6011branchLayoutTestshttptestscontentextensionscssdisplaynonewithdifferentcasesensitivityarenotmergedexpectedtxt">branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/css-display-none-with-different-case-sensitivity-are-not-merged-expected.txt</a></li>
<li><a href="#branchessafari6011branchLayoutTestshttptestscontentextensionscssdisplaynonewithdifferentcasesensitivityarenotmergedhtml">branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/css-display-none-with-different-case-sensitivity-are-not-merged.html</a></li>
<li><a href="#branchessafari6011branchLayoutTestshttptestscontentextensionscssdisplaynonewithdifferentcasesensitivityarenotmergedhtmljson">branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/css-display-none-with-different-case-sensitivity-are-not-merged.html.json</a></li>
<li><a href="#branchessafari6011branchLayoutTestshttptestscontentextensionscssdisplaynonewithdifferenttriggersarenotmergedexpectedtxt">branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/css-display-none-with-different-triggers-are-not-merged-expected.txt</a></li>
<li><a href="#branchessafari6011branchLayoutTestshttptestscontentextensionscssdisplaynonewithdifferenttriggersarenotmergedhtml">branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/css-display-none-with-different-triggers-are-not-merged.html</a></li>
<li><a href="#branchessafari6011branchLayoutTestshttptestscontentextensionscssdisplaynonewithdifferenttriggersarenotmergedhtmljson">branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/css-display-none-with-different-triggers-are-not-merged.html.json</a></li>
<li><a href="#branchessafari6011branchLayoutTestshttptestscontentextensionstwodistinguishablecssdisplaynonerulesonmainresourceexpectedtxt">branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/two-distinguishable-css-display-none-rules-on-main-resource-expected.txt</a></li>
<li><a href="#branchessafari6011branchLayoutTestshttptestscontentextensionstwodistinguishablecssdisplaynonerulesonmainresourcehtml">branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/two-distinguishable-css-display-none-rules-on-main-resource.html</a></li>
<li><a href="#branchessafari6011branchLayoutTestshttptestscontentextensionstwodistinguishablecssdisplaynonerulesonmainresourcehtmljson">branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/two-distinguishable-css-display-none-rules-on-main-resource.html.json</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari6011branchLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1-branch/LayoutTests/ChangeLog (187063 => 187064)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1-branch/LayoutTests/ChangeLog        2015-07-21 04:37:00 UTC (rev 187063)
+++ branches/safari-601.1-branch/LayoutTests/ChangeLog        2015-07-21 04:37:05 UTC (rev 187064)
</span><span class="lines">@@ -1,5 +1,26 @@
</span><span class="cx"> 2015-07-20  Matthew Hanson  &lt;matthew_hanson@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Merge r186957. rdar://problem/21867831
+
+    2015-07-17  Benjamin Poulain  &lt;bpoulain@apple.com&gt;
+
+            [Content Extensions] CSS-display-none rules are not working properly
+            https://bugs.webkit.org/show_bug.cgi?id=147024
+
+            Reviewed by Sam Weinig.
+
+            * http/tests/contentextensions/css-display-none-with-different-case-sensitivity-are-not-merged-expected.txt: Added.
+            * http/tests/contentextensions/css-display-none-with-different-case-sensitivity-are-not-merged.html: Added.
+            * http/tests/contentextensions/css-display-none-with-different-case-sensitivity-are-not-merged.html.json: Added.
+            * http/tests/contentextensions/css-display-none-with-different-triggers-are-not-merged-expected.txt: Added.
+            * http/tests/contentextensions/css-display-none-with-different-triggers-are-not-merged.html: Added.
+            * http/tests/contentextensions/css-display-none-with-different-triggers-are-not-merged.html.json: Added.
+            * http/tests/contentextensions/two-distinguishable-css-display-none-rules-on-main-resource-expected.txt: Added.
+            * http/tests/contentextensions/two-distinguishable-css-display-none-rules-on-main-resource.html: Added.
+            * http/tests/contentextensions/two-distinguishable-css-display-none-rules-on-main-resource.html.json: Added.
+
+2015-07-20  Matthew Hanson  &lt;matthew_hanson@apple.com&gt;
+
</ins><span class="cx">         Merge r186858. rdar://problem/21643094
</span><span class="cx"> 
</span><span class="cx">     2015-07-15  Tim Horton  &lt;timothy_horton@apple.com&gt;
</span></span></pre></div>
<a id="branchessafari6011branchLayoutTestshttptestscontentextensionscssdisplaynonewithdifferentcasesensitivityarenotmergedexpectedtxt"></a>
<div class="addfile"><h4>Added: branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/css-display-none-with-different-case-sensitivity-are-not-merged-expected.txt (0 => 187064)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/css-display-none-with-different-case-sensitivity-are-not-merged-expected.txt                                (rev 0)
+++ branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/css-display-none-with-different-case-sensitivity-are-not-merged-expected.txt        2015-07-21 04:37:05 UTC (rev 187064)
</span><span class="lines">@@ -0,0 +1,5 @@
</span><ins>+This text should be visible
+
+This text should be visible
+
+This text should be visible
</ins></span></pre></div>
<a id="branchessafari6011branchLayoutTestshttptestscontentextensionscssdisplaynonewithdifferentcasesensitivityarenotmergedhtml"></a>
<div class="addfile"><h4>Added: branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/css-display-none-with-different-case-sensitivity-are-not-merged.html (0 => 187064)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/css-display-none-with-different-case-sensitivity-are-not-merged.html                                (rev 0)
+++ branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/css-display-none-with-different-case-sensitivity-are-not-merged.html        2015-07-21 04:37:05 UTC (rev 187064)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+&lt;head&gt;
+&lt;meta charset=&quot;UTF-8&quot;&gt;&lt;/meta&gt;
+&lt;script&gt;
+    testRunner.dumpAsText();
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p class=&quot;hidden1&quot;&gt;This text should be visible&lt;/p&gt;
+&lt;p class=&quot;hidden2&quot;&gt;This text should not be visible!!!&lt;/p&gt;
+&lt;p class=&quot;hidden3&quot;&gt;This text should be visible&lt;/p&gt;
+&lt;p class=&quot;hidden4&quot;&gt;This text should be visible&lt;/p&gt;
+&lt;/body&gt;
</ins></span></pre></div>
<a id="branchessafari6011branchLayoutTestshttptestscontentextensionscssdisplaynonewithdifferentcasesensitivityarenotmergedhtmljson"></a>
<div class="addfile"><h4>Added: branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/css-display-none-with-different-case-sensitivity-are-not-merged.html.json (0 => 187064)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/css-display-none-with-different-case-sensitivity-are-not-merged.html.json                                (rev 0)
+++ branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/css-display-none-with-different-case-sensitivity-are-not-merged.html.json        2015-07-21 04:37:05 UTC (rev 187064)
</span><span class="lines">@@ -0,0 +1,56 @@
</span><ins>+[
+    {
+        &quot;action&quot;: {
+            &quot;type&quot;: &quot;block&quot;
+        },
+        &quot;trigger&quot;: {
+            &quot;url-filter&quot;: &quot;this-should-not-block&quot;
+        }
+    },
+    {
+        &quot;action&quot;: {
+            &quot;type&quot;: &quot;css-display-none&quot;,
+            &quot;selector&quot;: &quot;.hidden1&quot;
+        },
+        &quot;trigger&quot;: {
+            &quot;url-filter&quot;: &quot;this-should-not-match&quot;
+        }
+    },
+    {
+        &quot;action&quot;: {
+            &quot;type&quot;: &quot;css-display-none&quot;,
+            &quot;selector&quot;: &quot;.hidden2&quot;
+        },
+        &quot;trigger&quot;: {
+            &quot;url-filter&quot;: &quot;css-display-none-with-different-case-sensitivity-are-not-merged.html$&quot;
+        }
+    },
+    {
+        &quot;action&quot;: {
+            &quot;type&quot;: &quot;css-display-none&quot;,
+            &quot;selector&quot;: &quot;.hidden3&quot;
+        },
+        &quot;trigger&quot;: {
+            &quot;url-filter-is-case-sensitive&quot;: true,
+            &quot;url-filter&quot;: &quot;css-display-none-with-different-Case-sensitivity-are-not-merged.html$&quot;
+        }
+    },
+    {
+        &quot;action&quot;: {
+            &quot;type&quot;: &quot;css-display-none&quot;,
+            &quot;selector&quot;: &quot;.hidden4&quot;
+        },
+        &quot;trigger&quot;: {
+            &quot;url-filter&quot;: &quot;this-does-not-match-the-url-either&quot;
+        }
+    },
+    {
+        &quot;action&quot;: {
+            &quot;type&quot;: &quot;block&quot;
+        },
+        &quot;trigger&quot;: {
+            &quot;url-filter-is-case-sensitive&quot;: true,
+            &quot;url-filter&quot;: &quot;css-display-none-with-different-Case-sensitivity-are-not-merged.html$&quot;
+        }
+    }
+]
</ins></span></pre></div>
<a id="branchessafari6011branchLayoutTestshttptestscontentextensionscssdisplaynonewithdifferenttriggersarenotmergedexpectedtxt"></a>
<div class="addfile"><h4>Added: branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/css-display-none-with-different-triggers-are-not-merged-expected.txt (0 => 187064)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/css-display-none-with-different-triggers-are-not-merged-expected.txt                                (rev 0)
+++ branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/css-display-none-with-different-triggers-are-not-merged-expected.txt        2015-07-21 04:37:05 UTC (rev 187064)
</span><span class="lines">@@ -0,0 +1,3 @@
</span><ins>+This text should be visible
+
+This text should be visible
</ins></span></pre></div>
<a id="branchessafari6011branchLayoutTestshttptestscontentextensionscssdisplaynonewithdifferenttriggersarenotmergedhtml"></a>
<div class="addfile"><h4>Added: branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/css-display-none-with-different-triggers-are-not-merged.html (0 => 187064)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/css-display-none-with-different-triggers-are-not-merged.html                                (rev 0)
+++ branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/css-display-none-with-different-triggers-are-not-merged.html        2015-07-21 04:37:05 UTC (rev 187064)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+&lt;head&gt;
+&lt;meta charset=&quot;UTF-8&quot;&gt;&lt;/meta&gt;
+&lt;script&gt;
+    testRunner.dumpAsText();
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p class=&quot;hidden1&quot;&gt;This text should be visible&lt;/p&gt;
+&lt;p class=&quot;hidden2&quot;&gt;This text should not be visible!!!&lt;/p&gt;
+&lt;p class=&quot;hidden3&quot;&gt;This text should be visible&lt;/p&gt;
+&lt;/body&gt;
</ins></span></pre></div>
<a id="branchessafari6011branchLayoutTestshttptestscontentextensionscssdisplaynonewithdifferenttriggersarenotmergedhtmljson"></a>
<div class="addfile"><h4>Added: branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/css-display-none-with-different-triggers-are-not-merged.html.json (0 => 187064)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/css-display-none-with-different-triggers-are-not-merged.html.json                                (rev 0)
+++ branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/css-display-none-with-different-triggers-are-not-merged.html.json        2015-07-21 04:37:05 UTC (rev 187064)
</span><span class="lines">@@ -0,0 +1,29 @@
</span><ins>+[
+    {
+        &quot;action&quot;: {
+            &quot;type&quot;: &quot;css-display-none&quot;,
+            &quot;selector&quot;: &quot;.hidden1&quot;
+        },
+        &quot;trigger&quot;: {
+            &quot;url-filter&quot;: &quot;this-does-not-match-the-url&quot;
+        }
+    },
+    {
+        &quot;action&quot;: {
+            &quot;type&quot;: &quot;css-display-none&quot;,
+            &quot;selector&quot;: &quot;.hidden2&quot;
+        },
+        &quot;trigger&quot;: {
+            &quot;url-filter&quot;: &quot;css-display-none-with-different-triggers-are-not-merged.html&quot;
+        }
+    },
+    {
+        &quot;action&quot;: {
+            &quot;type&quot;: &quot;css-display-none&quot;,
+            &quot;selector&quot;: &quot;.hidden3&quot;
+        },
+        &quot;trigger&quot;: {
+            &quot;url-filter&quot;: &quot;this-does-not-match-the-url-either&quot;
+        }
+    }
+]
</ins></span></pre></div>
<a id="branchessafari6011branchLayoutTestshttptestscontentextensionstwodistinguishablecssdisplaynonerulesonmainresourceexpectedtxt"></a>
<div class="addfile"><h4>Added: branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/two-distinguishable-css-display-none-rules-on-main-resource-expected.txt (0 => 187064)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/two-distinguishable-css-display-none-rules-on-main-resource-expected.txt                                (rev 0)
+++ branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/two-distinguishable-css-display-none-rules-on-main-resource-expected.txt        2015-07-21 04:37:05 UTC (rev 187064)
</span><span class="lines">@@ -0,0 +1,3 @@
</span><ins>+This text should be visible.
+
+This text should be visible.
</ins></span></pre></div>
<a id="branchessafari6011branchLayoutTestshttptestscontentextensionstwodistinguishablecssdisplaynonerulesonmainresourcehtml"></a>
<div class="addfile"><h4>Added: branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/two-distinguishable-css-display-none-rules-on-main-resource.html (0 => 187064)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/two-distinguishable-css-display-none-rules-on-main-resource.html                                (rev 0)
+++ branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/two-distinguishable-css-display-none-rules-on-main-resource.html        2015-07-21 04:37:05 UTC (rev 187064)
</span><span class="lines">@@ -0,0 +1,13 @@
</span><ins>+&lt;head&gt;
+&lt;meta charset=&quot;UTF-8&quot;&gt;&lt;/meta&gt;
+&lt;script&gt;
+    testRunner.dumpAsText();
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p id=&quot;hidden&quot;&gt;This text should be visible.&lt;/p&gt;
+&lt;p class=&quot;hidden1&quot;&gt;This text should not be visible!!! 1&lt;/p&gt;
+&lt;p class=&quot;hidden2&quot;&gt;This text should not be visible!!! 2&lt;/p&gt;
+&lt;p class=&quot;hidden1 hidden2&quot;&gt;This text should not be visible!!! 3&lt;/p&gt;
+&lt;p id=&quot;hidden3&quot;&gt;This text should be visible.&lt;/p&gt;
+&lt;/body&gt;
</ins></span></pre></div>
<a id="branchessafari6011branchLayoutTestshttptestscontentextensionstwodistinguishablecssdisplaynonerulesonmainresourcehtmljson"></a>
<div class="addfile"><h4>Added: branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/two-distinguishable-css-display-none-rules-on-main-resource.html.json (0 => 187064)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/two-distinguishable-css-display-none-rules-on-main-resource.html.json                                (rev 0)
+++ branches/safari-601.1-branch/LayoutTests/http/tests/contentextensions/two-distinguishable-css-display-none-rules-on-main-resource.html.json        2015-07-21 04:37:05 UTC (rev 187064)
</span><span class="lines">@@ -0,0 +1,21 @@
</span><ins>+[
+    {
+        &quot;action&quot;: {
+            &quot;type&quot;: &quot;css-display-none&quot;,
+            &quot;selector&quot;: &quot;.hidden1&quot;
+        },
+        &quot;trigger&quot;: {
+            &quot;url-filter&quot;: &quot;two-distinguishable-css-display-none-rules-on-main-resource.html&quot;
+        }
+    },
+    {
+        &quot;action&quot;: {
+            &quot;type&quot;: &quot;css-display-none&quot;,
+            &quot;selector&quot;: &quot;.hidden2&quot;
+        },
+        &quot;trigger&quot;: {
+            &quot;resource-type&quot;: [&quot;document&quot;],
+            &quot;url-filter&quot;: &quot;distinguishable-css-display-none-rules-on-main-resource.html$&quot;
+        }
+    }
+]
</ins></span></pre></div>
<a id="branchessafari6011branchSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1-branch/Source/WebCore/ChangeLog (187063 => 187064)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1-branch/Source/WebCore/ChangeLog        2015-07-21 04:37:00 UTC (rev 187063)
+++ branches/safari-601.1-branch/Source/WebCore/ChangeLog        2015-07-21 04:37:05 UTC (rev 187064)
</span><span class="lines">@@ -1,5 +1,55 @@
</span><span class="cx"> 2015-07-20  Matthew Hanson  &lt;matthew_hanson@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Merge r186957. rdar://problem/21867831
+
+    2015-07-17  Benjamin Poulain  &lt;bpoulain@apple.com&gt;
+
+            [Content Extensions] CSS-display-none rules are not working properly
+            https://bugs.webkit.org/show_bug.cgi?id=147024
+
+            Reviewed by Sam Weinig.
+
+            There were 2 bugs prevening rules with css-display-none and a url-filter from working
+            correctly.
+
+            First, ContentExtensions::serializeActions() was merging selectors regardless of their
+            trigger. All the CSS Selectors would be grouped together and applied regardless of which
+            rule apply.
+
+            That problem was fixed by grouping CSS rules by trigger. We want all the undistinguishable
+            CSS rules to be merged. The trigger makes 2 rules dinstinguishable as one rule can apply
+            on a page while the next rule does not. The simplest approach is to group by trigger.
+
+            The second problem had to do with rules added before the document is created.
+            When accumulating those rules, we were only keeping the last one. The reason was that
+            DocumentLoader::addPendingContentExtensionDisplayNoneSelector() would only keep a single
+            selector list by extension.
+
+            This is fixed by keeping a vector of all the rules that apply.
+
+            Tests: http/tests/contentextensions/css-display-none-with-different-case-sensitivity-are-not-merged.html
+                   http/tests/contentextensions/css-display-none-with-different-triggers-are-not-merged.html
+                   http/tests/contentextensions/two-distinguishable-css-display-none-rules-on-main-resource.html
+
+            * contentextensions/ContentExtensionCompiler.cpp:
+            (WebCore::ContentExtensions::serializeActions):
+            * contentextensions/ContentExtensionRule.h:
+            (WebCore::ContentExtensions::Trigger::isEmpty):
+            (WebCore::ContentExtensions::TriggerHash::hash):
+            (WebCore::ContentExtensions::TriggerHash::equal):
+            (WebCore::ContentExtensions::TriggerHashTraits::constructDeletedValue):
+            (WebCore::ContentExtensions::TriggerHashTraits::isDeletedValue):
+            (WebCore::ContentExtensions::TriggerHashTraits::emptyValue):
+            (WebCore::ContentExtensions::TriggerHashTraits::isEmptyValue):
+            * contentextensions/ContentExtensionsBackend.cpp:
+            (WebCore::ContentExtensions::ContentExtensionsBackend::processContentExtensionRulesForLoad): Deleted.
+            * loader/DocumentLoader.cpp:
+            (WebCore::DocumentLoader::commitData):
+            (WebCore::DocumentLoader::addPendingContentExtensionDisplayNoneSelector):
+            * loader/DocumentLoader.h:
+
+2015-07-20  Matthew Hanson  &lt;matthew_hanson@apple.com&gt;
+
</ins><span class="cx">         Merge r186956. rdar://problem/21643094
</span><span class="cx"> 
</span><span class="cx">     2015-07-17  Tim Horton  &lt;timothy_horton@apple.com&gt;
</span></span></pre></div>
<a id="branchessafari6011branchSourceWebCorecontentextensionsContentExtensionCompilercpp"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1-branch/Source/WebCore/contentextensions/ContentExtensionCompiler.cpp (187063 => 187064)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1-branch/Source/WebCore/contentextensions/ContentExtensionCompiler.cpp        2015-07-21 04:37:00 UTC (rev 187063)
+++ branches/safari-601.1-branch/Source/WebCore/contentextensions/ContentExtensionCompiler.cpp        2015-07-21 04:37:05 UTC (rev 187064)
</span><span class="lines">@@ -74,7 +74,7 @@
</span><span class="cx">     Vector&lt;String&gt; selectors;
</span><span class="cx">     Vector&lt;unsigned&gt; clientLocations;
</span><span class="cx"> };
</span><del>-typedef HashMap&lt;uint32_t, PendingDisplayNoneActions, DefaultHash&lt;uint32_t&gt;::Hash, WTF::UnsignedWithZeroKeyHashTraits&lt;uint32_t&gt;&gt; PendingDisplayNoneActionsMap;
</del><ins>+typedef HashMap&lt;Trigger, PendingDisplayNoneActions, TriggerHash, TriggerHashTraits&gt; PendingDisplayNoneActionsMap;
</ins><span class="cx"> 
</span><span class="cx"> static void resolvePendingDisplayNoneActions(Vector&lt;SerializedActionByte&gt;&amp; actions, Vector&lt;unsigned&gt;&amp; actionLocations, PendingDisplayNoneActionsMap&amp; pendingDisplayNoneActionsMap)
</span><span class="cx"> {
</span><span class="lines">@@ -167,7 +167,7 @@
</span><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx">         case ActionType::CSSDisplayNoneSelector: {
</span><del>-            const auto addResult = cssDisplayNoneActionsMap.add(flags, PendingDisplayNoneActions());
</del><ins>+            const auto addResult = cssDisplayNoneActionsMap.add(rule.trigger(), PendingDisplayNoneActions());
</ins><span class="cx">             PendingDisplayNoneActions&amp; pendingDisplayNoneActions = addResult.iterator-&gt;value;
</span><span class="cx">             pendingDisplayNoneActions.selectors.append(rule.action().stringArgument());
</span><span class="cx">             pendingDisplayNoneActions.clientLocations.append(actionLocations.size());
</span></span></pre></div>
<a id="branchessafari6011branchSourceWebCorecontentextensionsContentExtensionRuleh"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1-branch/Source/WebCore/contentextensions/ContentExtensionRule.h (187063 => 187064)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1-branch/Source/WebCore/contentextensions/ContentExtensionRule.h        2015-07-21 04:37:00 UTC (rev 187063)
+++ branches/safari-601.1-branch/Source/WebCore/contentextensions/ContentExtensionRule.h        2015-07-21 04:37:05 UTC (rev 187064)
</span><span class="lines">@@ -51,12 +51,21 @@
</span><span class="cx">         IfDomain,
</span><span class="cx">         UnlessDomain,
</span><span class="cx">     } domainCondition { DomainCondition::None };
</span><del>-    
</del><ins>+
</ins><span class="cx">     ~Trigger()
</span><span class="cx">     {
</span><span class="cx">         ASSERT(domains.isEmpty() == (domainCondition == DomainCondition::None));
</span><span class="cx">     }
</span><del>-    
</del><ins>+
+    bool isEmpty() const
+    {
+        return urlFilter.isEmpty()
+            &amp;&amp; !urlFilterIsCaseSensitive
+            &amp;&amp; !flags
+            &amp;&amp; domains.isEmpty()
+            &amp;&amp; domainCondition == DomainCondition::None;
+    }
+
</ins><span class="cx">     bool operator==(const Trigger&amp; other) const
</span><span class="cx">     {
</span><span class="cx">         return urlFilter == other.urlFilter
</span><span class="lines">@@ -66,7 +75,58 @@
</span><span class="cx">             &amp;&amp; domainCondition == other.domainCondition;
</span><span class="cx">     }
</span><span class="cx"> };
</span><del>-    
</del><ins>+
+struct TriggerHash {
+    static unsigned hash(const Trigger&amp; trigger)
+    {
+        unsigned hash = trigger.urlFilterIsCaseSensitive ? 10619863 : 40960001;
+        if (!trigger.urlFilter.isNull())
+            hash ^= StringHash::hash(trigger.urlFilter);
+        hash = WTF::pairIntHash(hash, DefaultHash&lt;ResourceFlags&gt;::Hash::hash(trigger.flags));
+
+        for (const String&amp; domain : trigger.domains)
+            hash ^= StringHash::hash(domain);
+
+        if (trigger.domainCondition == Trigger::DomainCondition::IfDomain)
+            hash |= 1 &lt;&lt; 16;
+        else if (trigger.domainCondition == Trigger::DomainCondition::IfDomain)
+            hash |= 1 &lt;&lt; 31;
+        return hash;
+    }
+
+    static bool equal(const Trigger&amp; a, const Trigger&amp; b)
+    {
+        return a == b;
+    }
+
+    static const bool safeToCompareToEmptyOrDeleted = false;
+};
+
+struct TriggerHashTraits : public WTF::CustomHashTraits&lt;Trigger&gt; {
+    static const bool emptyValueIsZero = false;
+    static const bool hasIsEmptyValueFunction = true;
+
+    static void constructDeletedValue(Trigger&amp; trigger)
+    {
+        new (NotNull, std::addressof(trigger.urlFilter)) String(WTF::HashTableDeletedValue);
+    }
+
+    static bool isDeletedValue(const Trigger&amp; trigger)
+    {
+        return trigger.urlFilter.isHashTableDeletedValue();
+    }
+
+    static Trigger emptyValue()
+    {
+        return Trigger();
+    }
+
+    static bool isEmptyValue(const Trigger&amp; trigger)
+    {
+        return trigger.isEmpty();
+    }
+};
+
</ins><span class="cx"> struct Action {
</span><span class="cx">     Action()
</span><span class="cx">         : m_type(ActionType::InvalidAction)
</span></span></pre></div>
<a id="branchessafari6011branchSourceWebCorecontentextensionsContentExtensionsBackendcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1-branch/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp (187063 => 187064)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1-branch/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp        2015-07-21 04:37:00 UTC (rev 187063)
+++ branches/safari-601.1-branch/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp        2015-07-21 04:37:05 UTC (rev 187064)
</span><span class="lines">@@ -156,7 +156,6 @@
</span><span class="cx">     ResourceLoadInfo resourceLoadInfo = { request.url(), mainDocumentURL, resourceType };
</span><span class="cx">     Vector&lt;ContentExtensions::Action&gt; actions = actionsForResourceLoad(resourceLoadInfo);
</span><span class="cx"> 
</span><del>-    StringBuilder css;
</del><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></pre></div>
<a id="branchessafari6011branchSourceWebCoreloaderDocumentLoadercpp"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1-branch/Source/WebCore/loader/DocumentLoader.cpp (187063 => 187064)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1-branch/Source/WebCore/loader/DocumentLoader.cpp        2015-07-21 04:37:00 UTC (rev 187063)
+++ branches/safari-601.1-branch/Source/WebCore/loader/DocumentLoader.cpp        2015-07-21 04:37:05 UTC (rev 187064)
</span><span class="lines">@@ -836,8 +836,10 @@
</span><span class="cx"> 
</span><span class="cx">     for (auto&amp; pendingStyleSheet : m_pendingNamedContentExtensionStyleSheets)
</span><span class="cx">         styleSheetCollection.maybeAddContentExtensionSheet(pendingStyleSheet.key, *pendingStyleSheet.value);
</span><del>-    for (auto&amp; pendingSelector : m_pendingContentExtensionDisplayNoneSelectors)
-        styleSheetCollection.addDisplayNoneSelector(pendingSelector.key, pendingSelector.value.first, pendingSelector.value.second);
</del><ins>+    for (auto&amp; pendingSelectorEntry : m_pendingContentExtensionDisplayNoneSelectors) {
+        for (const auto&amp; pendingSelector : pendingSelectorEntry.value)
+            styleSheetCollection.addDisplayNoneSelector(pendingSelectorEntry.key, pendingSelector.first, pendingSelector.second);
+    }
</ins><span class="cx"> 
</span><span class="cx">     m_pendingNamedContentExtensionStyleSheets.clear();
</span><span class="cx">     m_pendingContentExtensionDisplayNoneSelectors.clear();
</span><span class="lines">@@ -1585,7 +1587,8 @@
</span><span class="cx"> void DocumentLoader::addPendingContentExtensionDisplayNoneSelector(const String&amp; identifier, const String&amp; selector, uint32_t selectorID)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(!m_gotFirstByte);
</span><del>-    m_pendingContentExtensionDisplayNoneSelectors.set(identifier, std::make_pair(selector, selectorID));
</del><ins>+    auto addResult = m_pendingContentExtensionDisplayNoneSelectors.add(identifier, Vector&lt;std::pair&lt;String, uint32_t&gt;&gt;());
+    addResult.iterator-&gt;value.append(std::make_pair(selector, selectorID));
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchessafari6011branchSourceWebCoreloaderDocumentLoaderh"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1-branch/Source/WebCore/loader/DocumentLoader.h (187063 => 187064)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1-branch/Source/WebCore/loader/DocumentLoader.h        2015-07-21 04:37:00 UTC (rev 187063)
+++ branches/safari-601.1-branch/Source/WebCore/loader/DocumentLoader.h        2015-07-21 04:37:05 UTC (rev 187064)
</span><span class="lines">@@ -445,7 +445,7 @@
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(CONTENT_EXTENSIONS)
</span><span class="cx">         HashMap&lt;String, RefPtr&lt;StyleSheetContents&gt;&gt; m_pendingNamedContentExtensionStyleSheets;
</span><del>-        HashMap&lt;String, std::pair&lt;String, uint32_t&gt;&gt; m_pendingContentExtensionDisplayNoneSelectors;
</del><ins>+        HashMap&lt;String, Vector&lt;std::pair&lt;String, uint32_t&gt;&gt;&gt; m_pendingContentExtensionDisplayNoneSelectors;
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #ifndef NDEBUG
</span></span></pre>
</div>
</div>

</body>
</html>