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

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

<h3>Log Message</h3>
<pre>[Content Extensions] Cache actions with domains that match everything
https://bugs.webkit.org/show_bug.cgi?id=147050

Reviewed by Benjamin Poulain.

Source/WebCore:

If you have lots of rules with triggers like {&quot;url-filter&quot;:&quot;.*&quot;,&quot;if-domain&quot;:[&quot;*webkit.org&quot;]}
we will spend a lot of time adding unnecessary actions to HashSets when you are not on webkit.org.
Caching all the rules and only adding them to a collection once when the domain changes saves a lot of URL interpreting time.

We already had an optimization for the css-display-none actions with triggers that matched everything using a special bytecode operation.
This removes the need for a special bytecode operation by caching the triggers that match everything with and without domains,
then from those cached actions we compile a stylesheet, and create cached actions for every new domain we visit.

All functionality is covered by existing API tests.

* contentextensions/CompiledContentExtension.cpp:
(WebCore::ContentExtensions::CompiledContentExtension::~CompiledContentExtension):
(WebCore::ContentExtensions::CompiledContentExtension::globalDisplayNoneSelectors): Deleted.
* contentextensions/CompiledContentExtension.h:
* contentextensions/ContentExtension.cpp:
(WebCore::ContentExtensions::ContentExtension::ContentExtension):
(WebCore::ContentExtensions::ContentExtension::findFirstIgnorePreviousRules):
(WebCore::ContentExtensions::ContentExtension::globalDisplayNoneStyleSheet):
(WebCore::ContentExtensions::ContentExtension::compileGlobalDisplayNoneStyleSheet):
(WebCore::ContentExtensions::ContentExtension::populateDomainCacheIfNeeded):
(WebCore::ContentExtensions::ContentExtension::cachedDomainActions):
(WebCore::ContentExtensions::ContentExtension::universalActionsWithDomains):
* contentextensions/ContentExtension.h:
(WebCore::ContentExtensions::ContentExtension::compiledExtension):
(WebCore::ContentExtensions::ContentExtension::universalActionsWithoutDomains):
* contentextensions/ContentExtensionCompiler.cpp:
(WebCore::ContentExtensions::compileRuleList):
* contentextensions/ContentExtensionRule.cpp:
(WebCore::ContentExtensions::ContentExtensionRule::ContentExtensionRule):
(WebCore::ContentExtensions::Action::deserialize):
(WebCore::ContentExtensions::Action::deserializeType):
(WebCore::ContentExtensions::Action::serializedLength):
* contentextensions/ContentExtensionRule.h:
(WebCore::ContentExtensions::Action::operator==):
(WebCore::ContentExtensions::Action::setExtensionIdentifier):
(WebCore::ContentExtensions::Action::extensionIdentifier):
* contentextensions/ContentExtensionsBackend.cpp:
(WebCore::ContentExtensions::ContentExtensionsBackend::actionsForResourceLoad):
* contentextensions/DFABytecode.h:
(WebCore::ContentExtensions::instructionSizeWithArguments):
* contentextensions/DFABytecodeCompiler.cpp:
(WebCore::ContentExtensions::DFABytecodeCompiler::emitAppendAction):
* contentextensions/DFABytecodeInterpreter.cpp:
(WebCore::ContentExtensions::DFABytecodeInterpreter::interpretAppendAction):
(WebCore::ContentExtensions::DFABytecodeInterpreter::interpretTestFlagsAndAppendAction):
(WebCore::ContentExtensions::DFABytecodeInterpreter::actionsMatchingEverything):
(WebCore::ContentExtensions::DFABytecodeInterpreter::interpret):
(WebCore::ContentExtensions::DFABytecodeInterpreter::actionsForDefaultStylesheetFromDFARoot): Deleted.
* contentextensions/DFABytecodeInterpreter.h:
* loader/ResourceLoadInfo.h:

Source/WebKit2:

* UIProcess/API/APIUserContentExtensionStore.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorecontentextensionsCompiledContentExtensioncpp">trunk/Source/WebCore/contentextensions/CompiledContentExtension.cpp</a></li>
<li><a href="#trunkSourceWebCorecontentextensionsCompiledContentExtensionh">trunk/Source/WebCore/contentextensions/CompiledContentExtension.h</a></li>
<li><a href="#trunkSourceWebCorecontentextensionsContentExtensioncpp">trunk/Source/WebCore/contentextensions/ContentExtension.cpp</a></li>
<li><a href="#trunkSourceWebCorecontentextensionsContentExtensionh">trunk/Source/WebCore/contentextensions/ContentExtension.h</a></li>
<li><a href="#trunkSourceWebCorecontentextensionsContentExtensionCompilercpp">trunk/Source/WebCore/contentextensions/ContentExtensionCompiler.cpp</a></li>
<li><a href="#trunkSourceWebCorecontentextensionsContentExtensionRulecpp">trunk/Source/WebCore/contentextensions/ContentExtensionRule.cpp</a></li>
<li><a href="#trunkSourceWebCorecontentextensionsContentExtensionRuleh">trunk/Source/WebCore/contentextensions/ContentExtensionRule.h</a></li>
<li><a href="#trunkSourceWebCorecontentextensionsContentExtensionsBackendcpp">trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp</a></li>
<li><a href="#trunkSourceWebCorecontentextensionsDFABytecodeh">trunk/Source/WebCore/contentextensions/DFABytecode.h</a></li>
<li><a href="#trunkSourceWebCorecontentextensionsDFABytecodeCompilercpp">trunk/Source/WebCore/contentextensions/DFABytecodeCompiler.cpp</a></li>
<li><a href="#trunkSourceWebCorecontentextensionsDFABytecodeInterpretercpp">trunk/Source/WebCore/contentextensions/DFABytecodeInterpreter.cpp</a></li>
<li><a href="#trunkSourceWebCorecontentextensionsDFABytecodeInterpreterh">trunk/Source/WebCore/contentextensions/DFABytecodeInterpreter.h</a></li>
<li><a href="#trunkSourceWebCoreloaderResourceLoadInfoh">trunk/Source/WebCore/loader/ResourceLoadInfo.h</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIAPIUserContentExtensionStoreh">trunk/Source/WebKit2/UIProcess/API/APIUserContentExtensionStore.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (187048 => 187049)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-07-20 23:48:45 UTC (rev 187048)
+++ trunk/Source/WebCore/ChangeLog        2015-07-21 00:12:13 UTC (rev 187049)
</span><span class="lines">@@ -1,3 +1,61 @@
</span><ins>+2015-07-20  Alex Christensen  &lt;achristensen@webkit.org&gt;
+
+        [Content Extensions] Cache actions with domains that match everything
+        https://bugs.webkit.org/show_bug.cgi?id=147050
+
+        Reviewed by Benjamin Poulain.
+
+        If you have lots of rules with triggers like {&quot;url-filter&quot;:&quot;.*&quot;,&quot;if-domain&quot;:[&quot;*webkit.org&quot;]}
+        we will spend a lot of time adding unnecessary actions to HashSets when you are not on webkit.org.
+        Caching all the rules and only adding them to a collection once when the domain changes saves a lot of URL interpreting time.
+
+        We already had an optimization for the css-display-none actions with triggers that matched everything using a special bytecode operation.
+        This removes the need for a special bytecode operation by caching the triggers that match everything with and without domains,
+        then from those cached actions we compile a stylesheet, and create cached actions for every new domain we visit.
+
+        All functionality is covered by existing API tests.
+
+        * contentextensions/CompiledContentExtension.cpp:
+        (WebCore::ContentExtensions::CompiledContentExtension::~CompiledContentExtension):
+        (WebCore::ContentExtensions::CompiledContentExtension::globalDisplayNoneSelectors): Deleted.
+        * contentextensions/CompiledContentExtension.h:
+        * contentextensions/ContentExtension.cpp:
+        (WebCore::ContentExtensions::ContentExtension::ContentExtension):
+        (WebCore::ContentExtensions::ContentExtension::findFirstIgnorePreviousRules):
+        (WebCore::ContentExtensions::ContentExtension::globalDisplayNoneStyleSheet):
+        (WebCore::ContentExtensions::ContentExtension::compileGlobalDisplayNoneStyleSheet):
+        (WebCore::ContentExtensions::ContentExtension::populateDomainCacheIfNeeded):
+        (WebCore::ContentExtensions::ContentExtension::cachedDomainActions):
+        (WebCore::ContentExtensions::ContentExtension::universalActionsWithDomains):
+        * contentextensions/ContentExtension.h:
+        (WebCore::ContentExtensions::ContentExtension::compiledExtension):
+        (WebCore::ContentExtensions::ContentExtension::universalActionsWithoutDomains):
+        * contentextensions/ContentExtensionCompiler.cpp:
+        (WebCore::ContentExtensions::compileRuleList):
+        * contentextensions/ContentExtensionRule.cpp:
+        (WebCore::ContentExtensions::ContentExtensionRule::ContentExtensionRule):
+        (WebCore::ContentExtensions::Action::deserialize):
+        (WebCore::ContentExtensions::Action::deserializeType):
+        (WebCore::ContentExtensions::Action::serializedLength):
+        * contentextensions/ContentExtensionRule.h:
+        (WebCore::ContentExtensions::Action::operator==):
+        (WebCore::ContentExtensions::Action::setExtensionIdentifier):
+        (WebCore::ContentExtensions::Action::extensionIdentifier):
+        * contentextensions/ContentExtensionsBackend.cpp:
+        (WebCore::ContentExtensions::ContentExtensionsBackend::actionsForResourceLoad):
+        * contentextensions/DFABytecode.h:
+        (WebCore::ContentExtensions::instructionSizeWithArguments):
+        * contentextensions/DFABytecodeCompiler.cpp:
+        (WebCore::ContentExtensions::DFABytecodeCompiler::emitAppendAction):
+        * contentextensions/DFABytecodeInterpreter.cpp:
+        (WebCore::ContentExtensions::DFABytecodeInterpreter::interpretAppendAction):
+        (WebCore::ContentExtensions::DFABytecodeInterpreter::interpretTestFlagsAndAppendAction):
+        (WebCore::ContentExtensions::DFABytecodeInterpreter::actionsMatchingEverything):
+        (WebCore::ContentExtensions::DFABytecodeInterpreter::interpret):
+        (WebCore::ContentExtensions::DFABytecodeInterpreter::actionsForDefaultStylesheetFromDFARoot): Deleted.
+        * contentextensions/DFABytecodeInterpreter.h:
+        * loader/ResourceLoadInfo.h:
+
</ins><span class="cx"> 2015-07-20  Jeremy Jones  &lt;jeremyj@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Adopt AVPlayerLayerView
</span></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsCompiledContentExtensioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/contentextensions/CompiledContentExtension.cpp (187048 => 187049)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/CompiledContentExtension.cpp        2015-07-20 23:48:45 UTC (rev 187048)
+++ trunk/Source/WebCore/contentextensions/CompiledContentExtension.cpp        2015-07-21 00:12:13 UTC (rev 187049)
</span><span class="lines">@@ -35,25 +35,7 @@
</span><span class="cx"> CompiledContentExtension::~CompiledContentExtension()
</span><span class="cx"> {
</span><span class="cx"> }
</span><del>-
-Vector&lt;String&gt; CompiledContentExtension::globalDisplayNoneSelectors()
-{
-    DFABytecodeInterpreter interpreter(filtersWithoutDomainsBytecode(), filtersWithoutDomainsBytecodeLength());
-    DFABytecodeInterpreter::Actions actionLocations = interpreter.actionsForDefaultStylesheetFromDFARoot();
</del><span class="cx">     
</span><del>-    Vector&lt;Action&gt; globalActions;
-    for (uint64_t actionLocation : actionLocations)
-        globalActions.append(Action::deserialize(actions(), actionsLength(), static_cast&lt;unsigned&gt;(actionLocation)));
-    
-    Vector&lt;String&gt; selectors;
-    for (Action&amp; action : globalActions) {
-        if (action.type() == ActionType::CSSDisplayNoneSelector)
-            selectors.append(action.stringArgument());
-    }
-    
-    return selectors;
-}
-    
</del><span class="cx"> } // namespace ContentExtensions
</span><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsCompiledContentExtensionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/contentextensions/CompiledContentExtension.h (187048 => 187049)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/CompiledContentExtension.h        2015-07-20 23:48:45 UTC (rev 187048)
+++ trunk/Source/WebCore/contentextensions/CompiledContentExtension.h        2015-07-21 00:12:13 UTC (rev 187049)
</span><span class="lines">@@ -48,7 +48,6 @@
</span><span class="cx">     virtual unsigned domainFiltersBytecodeLength() const = 0;
</span><span class="cx">     virtual const SerializedActionByte* actions() const = 0;
</span><span class="cx">     virtual unsigned actionsLength() const = 0;
</span><del>-    Vector&lt;String&gt; globalDisplayNoneSelectors();
</del><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace ContentExtensions
</span></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsContentExtensioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/contentextensions/ContentExtension.cpp (187048 => 187049)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/ContentExtension.cpp        2015-07-20 23:48:45 UTC (rev 187048)
+++ trunk/Source/WebCore/contentextensions/ContentExtension.cpp        2015-07-21 00:12:13 UTC (rev 187049)
</span><span class="lines">@@ -44,38 +44,79 @@
</span><span class="cx"> ContentExtension::ContentExtension(const String&amp; identifier, Ref&lt;CompiledContentExtension&gt;&amp;&amp; compiledExtension)
</span><span class="cx">     : m_identifier(identifier)
</span><span class="cx">     , m_compiledExtension(WTF::move(compiledExtension))
</span><del>-    , m_parsedGlobalDisplayNoneStyleSheet(false)
</del><span class="cx"> {
</span><ins>+    DFABytecodeInterpreter withoutDomains(m_compiledExtension-&gt;filtersWithoutDomainsBytecode(), m_compiledExtension-&gt;filtersWithoutDomainsBytecodeLength());
+    DFABytecodeInterpreter withDomains(m_compiledExtension-&gt;filtersWithDomainsBytecode(), m_compiledExtension-&gt;filtersWithDomainsBytecodeLength());
+    for (uint64_t action : withoutDomains.actionsMatchingEverything()) {
+        ASSERT(static_cast&lt;uint32_t&gt;(action) == action);
+        m_universalActionsWithoutDomains.append(static_cast&lt;uint32_t&gt;(action));
+    }
+    for (uint64_t action : withDomains.actionsMatchingEverything()) {
+        ASSERT((action &amp; ~IfDomainFlag) == static_cast&lt;uint32_t&gt;(action));
+        m_universalActionsWithDomains.append(action);
+    }
+    
+    compileGlobalDisplayNoneStyleSheet();
+    m_universalActionsWithoutDomains.shrinkToFit();
+    m_universalActionsWithDomains.shrinkToFit();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+uint32_t ContentExtension::findFirstIgnorePreviousRules() const
+{
+    auto* actions = m_compiledExtension-&gt;actions();
+    uint32_t actionsLength = m_compiledExtension-&gt;actionsLength();
+    uint32_t currentActionIndex = 0;
+    while (currentActionIndex &lt; actionsLength) {
+        if (Action::deserializeType(actions, actionsLength, currentActionIndex) == ActionType::IgnorePreviousRules)
+            return currentActionIndex;
+        currentActionIndex += Action::serializedLength(actions, actionsLength, currentActionIndex);
+    }
+    return std::numeric_limits&lt;uint32_t&gt;::max();
+}
+    
</ins><span class="cx"> StyleSheetContents* ContentExtension::globalDisplayNoneStyleSheet()
</span><span class="cx"> {
</span><del>-    if (m_parsedGlobalDisplayNoneStyleSheet)
-        return m_globalDisplayNoneStyleSheet.get();
</del><ins>+    return m_globalDisplayNoneStyleSheet.get();
+}
</ins><span class="cx"> 
</span><del>-    m_parsedGlobalDisplayNoneStyleSheet = true;
</del><ins>+void ContentExtension::compileGlobalDisplayNoneStyleSheet()
+{
+    uint32_t firstIgnorePreviousRules = findFirstIgnorePreviousRules();
+    
+    auto* actions = m_compiledExtension-&gt;actions();
+    uint32_t actionsLength = m_compiledExtension-&gt;actionsLength();
</ins><span class="cx"> 
</span><del>-    Vector&lt;String&gt; selectors = m_compiledExtension-&gt;globalDisplayNoneSelectors();
-    if (selectors.isEmpty())
-        return nullptr;
-
</del><ins>+    auto inGlobalDisplayNoneStyleSheet = [&amp;](const uint32_t location)
+    {
+        return location &lt; firstIgnorePreviousRules &amp;&amp; Action::deserializeType(actions, actionsLength, location) == ActionType::CSSDisplayNoneSelector;
+    };
+    
</ins><span class="cx">     StringBuilder css;
</span><del>-    for (auto&amp; selector : selectors) {
-        css.append(selector);
-        css.append(&quot;{&quot;);
-        css.append(ContentExtensionsBackend::displayNoneCSSRule());
-        css.append(&quot;}&quot;);
</del><ins>+    for (uint32_t universalActionLocation : m_universalActionsWithoutDomains) {
+        if (inGlobalDisplayNoneStyleSheet(universalActionLocation)) {
+            if (!css.isEmpty())
+                css.append(',');
+            Action action = Action::deserialize(actions, actionsLength, universalActionLocation);
+            ASSERT(action.type() == ActionType::CSSDisplayNoneSelector);
+            css.append(action.stringArgument());
+        }
</ins><span class="cx">     }
</span><ins>+    if (css.isEmpty())
+        return;
+    css.append(&quot;{&quot;);
+    css.append(ContentExtensionsBackend::displayNoneCSSRule());
+    css.append(&quot;}&quot;);
</ins><span class="cx"> 
</span><span class="cx">     m_globalDisplayNoneStyleSheet = StyleSheetContents::create();
</span><span class="cx">     m_globalDisplayNoneStyleSheet-&gt;setIsUserStyleSheet(true);
</span><span class="cx">     if (!m_globalDisplayNoneStyleSheet-&gt;parseString(css.toString()))
</span><span class="cx">         m_globalDisplayNoneStyleSheet = nullptr;
</span><span class="cx"> 
</span><del>-    return m_globalDisplayNoneStyleSheet.get();
</del><ins>+    // These actions don't need to be applied individually any more. They will all be applied to every page as a precompiled style sheet.
+    m_universalActionsWithoutDomains.removeAllMatching(inGlobalDisplayNoneStyleSheet);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-const DFABytecodeInterpreter::Actions&amp; ContentExtension::cachedDomainActions(const String&amp; domain)
</del><ins>+void ContentExtension::populateDomainCacheIfNeeded(const String&amp; domain)
</ins><span class="cx"> {
</span><span class="cx">     if (m_cachedDomain != domain) {
</span><span class="cx">         DFABytecodeInterpreter interpreter(m_compiledExtension-&gt;domainFiltersBytecode(), m_compiledExtension-&gt;domainFiltersBytecodeLength());
</span><span class="lines">@@ -85,10 +126,30 @@
</span><span class="cx">         m_cachedDomainActions.clear();
</span><span class="cx">         for (uint64_t action : domainActions)
</span><span class="cx">             m_cachedDomainActions.add(action);
</span><ins>+        
+        m_cachedUniversalDomainActions.clear();
+        for (uint64_t action : m_universalActionsWithDomains) {
+            ASSERT_WITH_MESSAGE((action &amp; ~IfDomainFlag) == static_cast&lt;uint32_t&gt;(action), &quot;Universal actions with domains should not have flags.&quot;);
+            if (!!(action &amp; IfDomainFlag) == m_cachedDomainActions.contains(action))
+                m_cachedUniversalDomainActions.append(static_cast&lt;uint32_t&gt;(action));
+        }
+        m_cachedDomainActions.shrinkToFit();
+        m_cachedUniversalDomainActions.shrinkToFit();
</ins><span class="cx">         m_cachedDomain = domain;
</span><span class="cx">     }
</span><ins>+}
+
+const DFABytecodeInterpreter::Actions&amp; ContentExtension::cachedDomainActions(const String&amp; domain)
+{
+    populateDomainCacheIfNeeded(domain);
</ins><span class="cx">     return m_cachedDomainActions;
</span><span class="cx"> }
</span><ins>+
+const Vector&lt;uint32_t&gt;&amp; ContentExtension::universalActionsWithDomains(const String&amp; domain)
+{
+    populateDomainCacheIfNeeded(domain);
+    return m_cachedUniversalDomainActions;
+}
</ins><span class="cx">     
</span><span class="cx"> } // namespace ContentExtensions
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsContentExtensionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/contentextensions/ContentExtension.h (187048 => 187049)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/ContentExtension.h        2015-07-20 23:48:45 UTC (rev 187048)
+++ trunk/Source/WebCore/contentextensions/ContentExtension.h        2015-07-21 00:12:13 UTC (rev 187049)
</span><span class="lines">@@ -49,17 +49,26 @@
</span><span class="cx">     const CompiledContentExtension&amp; compiledExtension() const { return m_compiledExtension.get(); }
</span><span class="cx">     StyleSheetContents* globalDisplayNoneStyleSheet();
</span><span class="cx">     const DFABytecodeInterpreter::Actions&amp; cachedDomainActions(const String&amp; domain);
</span><ins>+    const Vector&lt;uint32_t&gt;&amp; universalActionsWithoutDomains() { return m_universalActionsWithoutDomains; }
+    const Vector&lt;uint32_t&gt;&amp; universalActionsWithDomains(const String&amp; domain);
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     ContentExtension(const String&amp; identifier, Ref&lt;CompiledContentExtension&gt;&amp;&amp;);
</span><del>-
</del><ins>+    uint32_t findFirstIgnorePreviousRules() const;
+    
</ins><span class="cx">     String m_identifier;
</span><span class="cx">     Ref&lt;CompiledContentExtension&gt; m_compiledExtension;
</span><ins>+
</ins><span class="cx">     RefPtr&lt;StyleSheetContents&gt; m_globalDisplayNoneStyleSheet;
</span><del>-    bool m_parsedGlobalDisplayNoneStyleSheet;
-    
</del><ins>+    void compileGlobalDisplayNoneStyleSheet();
+
</ins><span class="cx">     String m_cachedDomain;
</span><ins>+    void populateDomainCacheIfNeeded(const String&amp; domain);
</ins><span class="cx">     DFABytecodeInterpreter::Actions m_cachedDomainActions;
</span><ins>+    Vector&lt;uint32_t&gt; m_cachedUniversalDomainActions;
+
+    Vector&lt;uint32_t&gt; m_universalActionsWithoutDomains;
+    Vector&lt;uint64_t&gt; m_universalActionsWithDomains;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace ContentExtensions
</span></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsContentExtensionCompilercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/contentextensions/ContentExtensionCompiler.cpp (187048 => 187049)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/ContentExtensionCompiler.cpp        2015-07-20 23:48:45 UTC (rev 187048)
+++ trunk/Source/WebCore/contentextensions/ContentExtensionCompiler.cpp        2015-07-21 00:12:13 UTC (rev 187049)
</span><span class="lines">@@ -251,11 +251,9 @@
</span><span class="cx">     URLFilterParser filtersWithoutDomainParser(filtersWithoutDomains);
</span><span class="cx">     URLFilterParser filtersWithDomainParser(filtersWithDomains);
</span><span class="cx">     
</span><del>-    bool ignorePreviousRulesSeen = false;
</del><span class="cx">     for (unsigned ruleIndex = 0; ruleIndex &lt; parsedRuleList.size(); ++ruleIndex) {
</span><span class="cx">         const ContentExtensionRule&amp; contentExtensionRule = parsedRuleList[ruleIndex];
</span><span class="cx">         const Trigger&amp; trigger = contentExtensionRule.trigger();
</span><del>-        const Action&amp; action = contentExtensionRule.action();
</del><span class="cx">         ASSERT(trigger.urlFilter.length());
</span><span class="cx"> 
</span><span class="cx">         // High bits are used for flags. This should match how they are used in DFABytecodeCompiler::compileNode.
</span><span class="lines">@@ -267,11 +265,6 @@
</span><span class="cx">             ASSERT(trigger.domainCondition == Trigger::DomainCondition::None);
</span><span class="cx">             status = filtersWithoutDomainParser.addPattern(trigger.urlFilter, trigger.urlFilterIsCaseSensitive, actionLocationAndFlags);
</span><span class="cx">             if (status == URLFilterParser::MatchesEverything) {
</span><del>-                if (!ignorePreviousRulesSeen
-                    &amp;&amp; trigger.domainCondition == Trigger::DomainCondition::None
-                    &amp;&amp; action.type() == ActionType::CSSDisplayNoneSelector
-                    &amp;&amp; !trigger.flags)
-                    actionLocationAndFlags |= DisplayNoneStyleSheetFlag;
</del><span class="cx">                 universalActionsWithoutDomains.add(actionLocationAndFlags);
</span><span class="cx">                 status = URLFilterParser::Ok;
</span><span class="cx">             }
</span><span class="lines">@@ -300,9 +293,6 @@
</span><span class="cx">                 domainFilters.addDomain(actionLocationAndFlags, domain);
</span><span class="cx">         }
</span><span class="cx">         ASSERT(status == URLFilterParser::Ok);
</span><del>-        
-        if (action.type() == ActionType::IgnorePreviousRules)
-            ignorePreviousRulesSeen = true;
</del><span class="cx">     }
</span><span class="cx">     LOG_LARGE_STRUCTURES(parsedRuleList, parsedRuleList.capacity() * sizeof(ContentExtensionRule)); // Doesn't include strings.
</span><span class="cx">     LOG_LARGE_STRUCTURES(actionLocations, actionLocations.capacity() * sizeof(unsigned));
</span></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsContentExtensionRulecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/contentextensions/ContentExtensionRule.cpp (187048 => 187049)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/ContentExtensionRule.cpp        2015-07-20 23:48:45 UTC (rev 187048)
+++ trunk/Source/WebCore/contentextensions/ContentExtensionRule.cpp        2015-07-21 00:12:13 UTC (rev 187049)
</span><span class="lines">@@ -39,8 +39,9 @@
</span><span class="cx">     ASSERT(!m_trigger.urlFilter.isEmpty());
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-Action Action::deserialize(const SerializedActionByte* actions, const unsigned actionsLength, unsigned location)
</del><ins>+Action Action::deserialize(const SerializedActionByte* actions, const uint32_t actionsLength, uint32_t location)
</ins><span class="cx"> {
</span><ins>+    RELEASE_ASSERT(location &lt; actionsLength);
</ins><span class="cx">     switch (static_cast&lt;ActionType&gt;(actions[location])) {
</span><span class="cx">     case ActionType::BlockCookies:
</span><span class="cx">         return Action(ActionType::BlockCookies, location);
</span><span class="lines">@@ -49,10 +50,11 @@
</span><span class="cx">     case ActionType::IgnorePreviousRules:
</span><span class="cx">         return Action(ActionType::IgnorePreviousRules, location);
</span><span class="cx">     case ActionType::CSSDisplayNoneSelector: {
</span><del>-        unsigned stringStartIndex = location + sizeof(ActionType) + sizeof(unsigned) + sizeof(bool);
</del><ins>+        uint32_t headerLength = sizeof(ActionType) + sizeof(uint32_t) + sizeof(bool);
+        uint32_t stringStartIndex = location + headerLength;
</ins><span class="cx">         RELEASE_ASSERT(actionsLength &gt;= stringStartIndex);
</span><del>-        unsigned selectorLength = *reinterpret_cast&lt;const unsigned*&gt;(&amp;actions[location + sizeof(ActionType)]);
-        bool wideCharacters = actions[location + sizeof(ActionType) + sizeof(unsigned)];
</del><ins>+        uint32_t selectorLength = *reinterpret_cast&lt;const unsigned*&gt;(&amp;actions[location + sizeof(ActionType)]);
+        bool wideCharacters = actions[location + sizeof(ActionType) + sizeof(uint32_t)];
</ins><span class="cx">         
</span><span class="cx">         if (wideCharacters) {
</span><span class="cx">             RELEASE_ASSERT(actionsLength &gt;= stringStartIndex + selectorLength * sizeof(UChar));
</span><span class="lines">@@ -63,12 +65,56 @@
</span><span class="cx">     }
</span><span class="cx">     case ActionType::CSSDisplayNoneStyleSheet:
</span><span class="cx">     case ActionType::InvalidAction:
</span><ins>+    default:
</ins><span class="cx">         RELEASE_ASSERT_NOT_REACHED();
</span><span class="cx">     }
</span><span class="cx"> }
</span><del>-
</del><ins>+    
+ActionType Action::deserializeType(const SerializedActionByte* actions, const uint32_t actionsLength, uint32_t location)
+{
+    RELEASE_ASSERT(location &lt; actionsLength);
+    ActionType type = static_cast&lt;ActionType&gt;(actions[location]);
+    switch (type) {
+    case ActionType::BlockCookies:
+    case ActionType::BlockLoad:
+    case ActionType::IgnorePreviousRules:
+    case ActionType::CSSDisplayNoneSelector:
+        return type;
+    case ActionType::CSSDisplayNoneStyleSheet:
+    case ActionType::InvalidAction:
+    default:
+        RELEASE_ASSERT_NOT_REACHED();
+    }
</ins><span class="cx"> }
</span><ins>+    
+uint32_t Action::serializedLength(const SerializedActionByte* actions, const uint32_t actionsLength, uint32_t location)
+{
+    RELEASE_ASSERT(location &lt; actionsLength);
+    switch (static_cast&lt;ActionType&gt;(actions[location])) {
+    case ActionType::BlockCookies:
+    case ActionType::BlockLoad:
+    case ActionType::IgnorePreviousRules:
+        return sizeof(ActionType);
+    case ActionType::CSSDisplayNoneSelector: {
+        uint32_t headerLength = sizeof(ActionType) + sizeof(uint32_t) + sizeof(bool);
+        uint32_t stringStartIndex = location + headerLength;
+        RELEASE_ASSERT(actionsLength &gt;= stringStartIndex);
+        uint32_t selectorLength = *reinterpret_cast&lt;const unsigned*&gt;(&amp;actions[location + sizeof(ActionType)]);
+        bool wideCharacters = actions[location + sizeof(ActionType) + sizeof(uint32_t)];
+        
+        if (wideCharacters)
+            return headerLength + selectorLength * sizeof(UChar);
+        return headerLength + selectorLength * sizeof(LChar);
+    }
+    case ActionType::CSSDisplayNoneStyleSheet:
+    case ActionType::InvalidAction:
+    default:
+        RELEASE_ASSERT_NOT_REACHED();
+    }
+}
</ins><span class="cx"> 
</span><ins>+} // namespace ContentExtensions
+
</ins><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><span class="cx"> #endif // ENABLE(CONTENT_EXTENSIONS)
</span></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsContentExtensionRuleh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/contentextensions/ContentExtensionRule.h (187048 => 187049)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/ContentExtensionRule.h        2015-07-20 23:48:45 UTC (rev 187048)
+++ trunk/Source/WebCore/contentextensions/ContentExtensionRule.h        2015-07-21 00:12:13 UTC (rev 187049)
</span><span class="lines">@@ -157,7 +157,9 @@
</span><span class="cx">             &amp;&amp; m_stringArgument == other.m_stringArgument;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    static Action deserialize(const SerializedActionByte* actions, const unsigned actionsLength, uint32_t location);
</del><ins>+    static Action deserialize(const SerializedActionByte* actions, const uint32_t actionsLength, uint32_t location);
+    static ActionType deserializeType(const SerializedActionByte* actions, const uint32_t actionsLength, uint32_t location);
+    static uint32_t serializedLength(const SerializedActionByte* actions, const uint32_t actionsLength, uint32_t location);
</ins><span class="cx"> 
</span><span class="cx">     void setExtensionIdentifier(const String&amp; extensionIdentifier) { m_extensionIdentifier = extensionIdentifier; }
</span><span class="cx">     const String&amp; extensionIdentifier() const { return m_extensionIdentifier; }
</span></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsContentExtensionsBackendcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp (187048 => 187049)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp        2015-07-20 23:48:45 UTC (rev 187048)
+++ trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp        2015-07-21 00:12:13 UTC (rev 187049)
</span><span class="lines">@@ -92,20 +92,27 @@
</span><span class="cx">         DFABytecodeInterpreter withoutDomainsInterpreter(compiledExtension.filtersWithoutDomainsBytecode(), compiledExtension.filtersWithoutDomainsBytecodeLength());
</span><span class="cx">         DFABytecodeInterpreter::Actions withoutDomainsActions = withoutDomainsInterpreter.interpret(urlCString, flags);
</span><span class="cx">         
</span><ins>+        String domain = resourceLoadInfo.mainDocumentURL.host();
</ins><span class="cx">         DFABytecodeInterpreter withDomainsInterpreter(compiledExtension.filtersWithDomainsBytecode(), compiledExtension.filtersWithDomainsBytecodeLength());
</span><del>-        DFABytecodeInterpreter::Actions withDomainsActions = withDomainsInterpreter.interpretWithDomains(urlCString, flags, contentExtension-&gt;cachedDomainActions(resourceLoadInfo.mainDocumentURL.host()));
</del><ins>+        DFABytecodeInterpreter::Actions withDomainsActions = withDomainsInterpreter.interpretWithDomains(urlCString, flags, contentExtension-&gt;cachedDomainActions(domain));
</ins><span class="cx">         
</span><span class="cx">         const SerializedActionByte* actions = compiledExtension.actions();
</span><span class="cx">         const unsigned actionsLength = compiledExtension.actionsLength();
</span><span class="cx">         
</span><span class="cx">         bool sawIgnorePreviousRules = false;
</span><del>-        if (!withoutDomainsActions.isEmpty() || !withDomainsActions.isEmpty()) {
</del><ins>+        const Vector&lt;uint32_t&gt;&amp; universalWithDomains = contentExtension-&gt;universalActionsWithDomains(domain);
+        const Vector&lt;uint32_t&gt;&amp; universalWithoutDomains = contentExtension-&gt;universalActionsWithoutDomains();
+        if (!withoutDomainsActions.isEmpty() || !withDomainsActions.isEmpty() || !universalWithDomains.isEmpty() || !universalWithoutDomains.isEmpty()) {
</ins><span class="cx">             Vector&lt;uint32_t&gt; actionLocations;
</span><del>-            actionLocations.reserveInitialCapacity(withoutDomainsActions.size() + withDomainsActions.size());
</del><ins>+            actionLocations.reserveInitialCapacity(withoutDomainsActions.size() + withDomainsActions.size() + universalWithoutDomains.size() + universalWithDomains.size());
</ins><span class="cx">             for (uint64_t actionLocation : withoutDomainsActions)
</span><span class="cx">                 actionLocations.uncheckedAppend(static_cast&lt;uint32_t&gt;(actionLocation));
</span><span class="cx">             for (uint64_t actionLocation : withDomainsActions)
</span><span class="cx">                 actionLocations.uncheckedAppend(static_cast&lt;uint32_t&gt;(actionLocation));
</span><ins>+            for (uint32_t actionLocation : universalWithoutDomains)
+                actionLocations.uncheckedAppend(actionLocation);
+            for (uint32_t actionLocation : universalWithDomains)
+                actionLocations.uncheckedAppend(actionLocation);
</ins><span class="cx">             std::sort(actionLocations.begin(), actionLocations.end());
</span><span class="cx"> 
</span><span class="cx">             // Add actions in reverse order to properly deal with IgnorePreviousRules.
</span><span class="lines">@@ -126,7 +133,7 @@
</span><span class="cx">     }
</span><span class="cx"> #if CONTENT_EXTENSIONS_PERFORMANCE_REPORTING
</span><span class="cx">     double addedTimeEnd = monotonicallyIncreasingTime();
</span><del>-    WTFLogAlways(&quot;Time added: %f microseconds %s&quot;, (addedTimeEnd - addedTimeStart) * 1.0e6, resourceLoadInfo.resourceURL.string().utf8().data());
</del><ins>+    dataLogF(&quot;Time added: %f microseconds %s \n&quot;, (addedTimeEnd - addedTimeStart) * 1.0e6, resourceLoadInfo.resourceURL.string().utf8().data());
</ins><span class="cx"> #endif
</span><span class="cx">     return finalActions;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsDFABytecodeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/contentextensions/DFABytecode.h (187048 => 187049)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/DFABytecode.h        2015-07-20 23:48:45 UTC (rev 187048)
+++ trunk/Source/WebCore/contentextensions/DFABytecode.h        2015-07-21 00:12:13 UTC (rev 187049)
</span><span class="lines">@@ -55,21 +55,20 @@
</span><span class="cx">     // AppendAction has one argument:
</span><span class="cx">     // The action to append (4 bytes).
</span><span class="cx">     AppendAction = 0x4,
</span><del>-    AppendActionDefaultStylesheet = 0x5,
-    AppendActionWithIfDomain = 0x6,
</del><ins>+    AppendActionWithIfDomain = 0x5,
</ins><span class="cx">     
</span><span class="cx">     // TestFlagsAndAppendAction has two arguments:
</span><span class="cx">     // The flags to check before appending (2 bytes).
</span><span class="cx">     // The action to append (4 bytes).
</span><del>-    TestFlagsAndAppendAction = 0x7,
-    TestFlagsAndAppendActionWithIfDomain = 0x8,
</del><ins>+    TestFlagsAndAppendAction = 0x6,
+    TestFlagsAndAppendActionWithIfDomain = 0x7,
</ins><span class="cx"> 
</span><span class="cx">     // Terminate has no arguments.
</span><del>-    Terminate = 0x9,
</del><ins>+    Terminate = 0x8,
</ins><span class="cx"> 
</span><span class="cx">     // Jump has one argument:
</span><span class="cx">     // The distance to jump (1-4 bytes, signed).
</span><del>-    Jump = 0xA,
</del><ins>+    Jump = 0x9,
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> // The last four bits contain the instruction type.
</span><span class="lines">@@ -110,7 +109,6 @@
</span><span class="cx">     case DFABytecodeInstruction::Jump:
</span><span class="cx">         RELEASE_ASSERT_NOT_REACHED(); // Variable instruction size.
</span><span class="cx">     case DFABytecodeInstruction::AppendAction:
</span><del>-    case DFABytecodeInstruction::AppendActionDefaultStylesheet:
</del><span class="cx">     case DFABytecodeInstruction::AppendActionWithIfDomain:
</span><span class="cx">         return sizeof(DFABytecodeInstruction) + sizeof(uint32_t);
</span><span class="cx">     case DFABytecodeInstruction::TestFlagsAndAppendAction:
</span></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsDFABytecodeCompilercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/contentextensions/DFABytecodeCompiler.cpp (187048 => 187049)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/DFABytecodeCompiler.cpp        2015-07-20 23:48:45 UTC (rev 187048)
+++ trunk/Source/WebCore/contentextensions/DFABytecodeCompiler.cpp        2015-07-21 00:12:13 UTC (rev 187049)
</span><span class="lines">@@ -81,7 +81,6 @@
</span><span class="cx"> {
</span><span class="cx">     // High bits are used to store flags. See compileRuleList.
</span><span class="cx">     if (action &amp; ActionFlagMask) {
</span><del>-        ASSERT(!(action &amp; DisplayNoneStyleSheetFlag));
</del><span class="cx">         if (action &amp; IfDomainFlag)
</span><span class="cx">             append&lt;DFABytecodeInstruction&gt;(m_bytecode, DFABytecodeInstruction::TestFlagsAndAppendActionWithIfDomain);
</span><span class="cx">         else
</span><span class="lines">@@ -89,10 +88,7 @@
</span><span class="cx">         append&lt;uint16_t&gt;(m_bytecode, static_cast&lt;uint16_t&gt;(action &gt;&gt; 32));
</span><span class="cx">         append&lt;uint32_t&gt;(m_bytecode, static_cast&lt;uint32_t&gt;(action));
</span><span class="cx">     } else {
</span><del>-        if (action &amp; DisplayNoneStyleSheetFlag) {
-            RELEASE_ASSERT(!(action &amp; IfDomainFlag));
-            append&lt;DFABytecodeInstruction&gt;(m_bytecode, DFABytecodeInstruction::AppendActionDefaultStylesheet);
-        } else if (action &amp; IfDomainFlag)
</del><ins>+        if (action &amp; IfDomainFlag)
</ins><span class="cx">             append&lt;DFABytecodeInstruction&gt;(m_bytecode, DFABytecodeInstruction::AppendActionWithIfDomain);
</span><span class="cx">         else
</span><span class="cx">             append&lt;DFABytecodeInstruction&gt;(m_bytecode, DFABytecodeInstruction::AppendAction);
</span></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsDFABytecodeInterpretercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/contentextensions/DFABytecodeInterpreter.cpp (187048 => 187049)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/DFABytecodeInterpreter.cpp        2015-07-20 23:48:45 UTC (rev 187048)
+++ trunk/Source/WebCore/contentextensions/DFABytecodeInterpreter.cpp        2015-07-21 00:12:13 UTC (rev 187049)
</span><span class="lines">@@ -96,15 +96,13 @@
</span><span class="cx"> void DFABytecodeInterpreter::interpretAppendAction(uint32_t&amp; programCounter, Actions&amp; actions, bool ifDomain)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(getInstruction(m_bytecode, m_bytecodeLength, programCounter) == DFABytecodeInstruction::AppendAction
</span><del>-        || getInstruction(m_bytecode, m_bytecodeLength, programCounter) == DFABytecodeInstruction::AppendActionWithIfDomain
-        || getInstruction(m_bytecode, m_bytecodeLength, programCounter) == DFABytecodeInstruction::AppendActionDefaultStylesheet);
</del><ins>+        || getInstruction(m_bytecode, m_bytecodeLength, programCounter) == DFABytecodeInstruction::AppendActionWithIfDomain);
</ins><span class="cx">     uint64_t action = (ifDomain ? IfDomainFlag : 0) | static_cast&lt;uint64_t&gt;(getBits&lt;uint32_t&gt;(m_bytecode, m_bytecodeLength, programCounter + sizeof(DFABytecodeInstruction)));
</span><span class="cx">     if (!m_domainActions || matchesDomain(action, *m_domainActions))
</span><span class="cx">         actions.add(action);
</span><span class="cx">     
</span><span class="cx">     programCounter += instructionSizeWithArguments(DFABytecodeInstruction::AppendAction);
</span><span class="cx">     ASSERT(instructionSizeWithArguments(DFABytecodeInstruction::AppendAction) == instructionSizeWithArguments(DFABytecodeInstruction::AppendActionWithIfDomain));
</span><del>-    ASSERT(instructionSizeWithArguments(DFABytecodeInstruction::AppendAction) == instructionSizeWithArguments(DFABytecodeInstruction::AppendActionDefaultStylesheet));
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void DFABytecodeInterpreter::interpretTestFlagsAndAppendAction(uint32_t&amp; programCounter, uint16_t flags, Actions&amp; actions, bool ifDomain)
</span><span class="lines">@@ -128,7 +126,7 @@
</span><span class="cx">     ASSERT(instructionSizeWithArguments(DFABytecodeInstruction::TestFlagsAndAppendAction) == instructionSizeWithArguments(DFABytecodeInstruction::TestFlagsAndAppendActionWithIfDomain));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-DFABytecodeInterpreter::Actions DFABytecodeInterpreter::actionsForDefaultStylesheetFromDFARoot()
</del><ins>+DFABytecodeInterpreter::Actions DFABytecodeInterpreter::actionsMatchingEverything()
</ins><span class="cx"> {
</span><span class="cx">     Actions actions;
</span><span class="cx"> 
</span><span class="lines">@@ -138,19 +136,16 @@
</span><span class="cx"> 
</span><span class="cx">     while (programCounter &lt; dfaBytecodeLength) {
</span><span class="cx">         DFABytecodeInstruction instruction = getInstruction(m_bytecode, m_bytecodeLength, programCounter);
</span><del>-        if (instruction == DFABytecodeInstruction::AppendActionDefaultStylesheet)
</del><ins>+        if (instruction == DFABytecodeInstruction::AppendAction)
</ins><span class="cx">             interpretAppendAction(programCounter, actions, false);
</span><del>-        else if (instruction == DFABytecodeInstruction::AppendAction)
-            programCounter += instructionSizeWithArguments(DFABytecodeInstruction::AppendAction);
</del><ins>+        else if (instruction == DFABytecodeInstruction::AppendActionWithIfDomain)
+            interpretAppendAction(programCounter, actions, true);
</ins><span class="cx">         else if (instruction == DFABytecodeInstruction::TestFlagsAndAppendAction)
</span><span class="cx">             programCounter += instructionSizeWithArguments(DFABytecodeInstruction::TestFlagsAndAppendAction);
</span><del>-        else {
-            // actionsForDefaultStylesheetFromDFARoot should only be called on the DFA without domains,
-            // which should never have any actions with if-domain.
-            ASSERT(instruction != DFABytecodeInstruction::TestFlagsAndAppendActionWithIfDomain);
-            ASSERT(instruction != DFABytecodeInstruction::AppendActionWithIfDomain);
</del><ins>+        else if (instruction == DFABytecodeInstruction::TestFlagsAndAppendActionWithIfDomain)
+            programCounter += instructionSizeWithArguments(DFABytecodeInstruction::TestFlagsAndAppendActionWithIfDomain);
+        else
</ins><span class="cx">             break;
</span><del>-        }
</del><span class="cx">     }
</span><span class="cx">     return actions;
</span><span class="cx"> }
</span><span class="lines">@@ -179,16 +174,18 @@
</span><span class="cx">         uint32_t dfaBytecodeLength = getBits&lt;uint32_t&gt;(m_bytecode, m_bytecodeLength, programCounter);
</span><span class="cx">         programCounter += sizeof(uint32_t);
</span><span class="cx"> 
</span><del>-        // Skip the default stylesheet actions on the DFA root. These are accessed via actionsForDefaultStylesheetFromDFARoot.
</del><ins>+        // Skip the actions without flags on the DFA root. These are accessed via actionsMatchingEverything.
</ins><span class="cx">         if (!dfaStart) {
</span><span class="cx">             while (programCounter &lt; dfaBytecodeLength) {
</span><span class="cx">                 DFABytecodeInstruction instruction = getInstruction(m_bytecode, m_bytecodeLength, programCounter);
</span><del>-                if (instruction == DFABytecodeInstruction::AppendActionDefaultStylesheet)
-                    programCounter += instructionSizeWithArguments(DFABytecodeInstruction::AppendActionDefaultStylesheet);
-                else if (instruction == DFABytecodeInstruction::AppendAction)
-                    interpretAppendAction(programCounter, actions, false);
</del><ins>+                if (instruction == DFABytecodeInstruction::AppendAction)
+                    programCounter += instructionSizeWithArguments(DFABytecodeInstruction::AppendAction);
+                else if (instruction == DFABytecodeInstruction::AppendActionWithIfDomain)
+                    programCounter += instructionSizeWithArguments(DFABytecodeInstruction::AppendActionWithIfDomain);
</ins><span class="cx">                 else if (instruction == DFABytecodeInstruction::TestFlagsAndAppendAction)
</span><span class="cx">                     interpretTestFlagsAndAppendAction(programCounter, flags, actions, false);
</span><ins>+                else if (instruction == DFABytecodeInstruction::TestFlagsAndAppendActionWithIfDomain)
+                    interpretTestFlagsAndAppendAction(programCounter, flags, actions, true);
</ins><span class="cx">                 else
</span><span class="cx">                     break;
</span><span class="cx">             }
</span><span class="lines">@@ -196,7 +193,9 @@
</span><span class="cx">                 return actions;
</span><span class="cx">         } else {
</span><span class="cx">             ASSERT_WITH_MESSAGE(getInstruction(m_bytecode, m_bytecodeLength, programCounter) != DFABytecodeInstruction::AppendAction
</span><del>-                &amp;&amp; getInstruction(m_bytecode, m_bytecodeLength, programCounter) != DFABytecodeInstruction::TestFlagsAndAppendAction,
</del><ins>+                &amp;&amp; getInstruction(m_bytecode, m_bytecodeLength, programCounter) != DFABytecodeInstruction::AppendActionWithIfDomain
+                &amp;&amp; getInstruction(m_bytecode, m_bytecodeLength, programCounter) != DFABytecodeInstruction::TestFlagsAndAppendAction
+                &amp;&amp; getInstruction(m_bytecode, m_bytecodeLength, programCounter) != DFABytecodeInstruction::TestFlagsAndAppendActionWithIfDomain,
</ins><span class="cx">                 &quot;Triggers that match everything should only be in the first DFA.&quot;);
</span><span class="cx">         }
</span><span class="cx">         
</span></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsDFABytecodeInterpreterh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/contentextensions/DFABytecodeInterpreter.h (187048 => 187049)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/DFABytecodeInterpreter.h        2015-07-20 23:48:45 UTC (rev 187048)
+++ trunk/Source/WebCore/contentextensions/DFABytecodeInterpreter.h        2015-07-21 00:12:13 UTC (rev 187049)
</span><span class="lines">@@ -51,7 +51,7 @@
</span><span class="cx">     
</span><span class="cx">     Actions interpret(const CString&amp;, uint16_t flags);
</span><span class="cx">     Actions interpretWithDomains(const CString&amp;, uint16_t flags, const DFABytecodeInterpreter::Actions&amp; domainActions);
</span><del>-    Actions actionsForDefaultStylesheetFromDFARoot();
</del><ins>+    Actions actionsMatchingEverything();
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     void interpretAppendAction(unsigned&amp; programCounter, Actions&amp;, bool ifDomain);
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderResourceLoadInfoh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/ResourceLoadInfo.h (187048 => 187049)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/ResourceLoadInfo.h        2015-07-20 23:48:45 UTC (rev 187048)
+++ trunk/Source/WebCore/loader/ResourceLoadInfo.h        2015-07-21 00:12:13 UTC (rev 187049)
</span><span class="lines">@@ -62,7 +62,6 @@
</span><span class="cx"> // The values -1 and -2 are used for removed and empty values in HashTables.
</span><span class="cx"> const uint64_t ActionFlagMask = 0x0000FFFF00000000;
</span><span class="cx"> const uint64_t IfDomainFlag = 0x0001000000000000;
</span><del>-const uint64_t DisplayNoneStyleSheetFlag = 0x0002000000000000;
</del><span class="cx"> 
</span><span class="cx"> ResourceType toResourceType(CachedResource::Type);
</span><span class="cx"> uint16_t readResourceType(const String&amp;);
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (187048 => 187049)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2015-07-20 23:48:45 UTC (rev 187048)
+++ trunk/Source/WebKit2/ChangeLog        2015-07-21 00:12:13 UTC (rev 187049)
</span><span class="lines">@@ -1,3 +1,12 @@
</span><ins>+2015-07-20  Alex Christensen  &lt;achristensen@webkit.org&gt;
+
+        [Content Extensions] Cache actions with domains that match everything
+        https://bugs.webkit.org/show_bug.cgi?id=147050
+
+        Reviewed by Benjamin Poulain.
+
+        * UIProcess/API/APIUserContentExtensionStore.h:
+
</ins><span class="cx"> 2015-07-20  Gordon Sheridan  &lt;gordon_sheridan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Support blocking a plug-in for non-security reasons
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIAPIUserContentExtensionStoreh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/APIUserContentExtensionStore.h (187048 => 187049)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/APIUserContentExtensionStore.h        2015-07-20 23:48:45 UTC (rev 187048)
+++ trunk/Source/WebKit2/UIProcess/API/APIUserContentExtensionStore.h        2015-07-21 00:12:13 UTC (rev 187049)
</span><span class="lines">@@ -51,7 +51,7 @@
</span><span class="cx">     
</span><span class="cx">     // This should be incremented every time a functional change is made to the bytecode, file format, etc.
</span><span class="cx">     // to prevent crashing while loading old data.
</span><del>-    const static uint32_t CurrentContentExtensionFileVersion = 5;
</del><ins>+    const static uint32_t CurrentContentExtensionFileVersion = 6;
</ins><span class="cx"> 
</span><span class="cx">     static UserContentExtensionStore&amp; defaultStore();
</span><span class="cx">     static Ref&lt;UserContentExtensionStore&gt; storeWithPath(const WTF::String&amp; storePath);
</span></span></pre>
</div>
</div>

</body>
</html>