<!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>[184644] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/184644">184644</a></dd>
<dt>Author</dt> <dd>achristensen@apple.com</dd>
<dt>Date</dt> <dd>2015-05-20 10:56:17 -0700 (Wed, 20 May 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>[Content Extensions] Relax restrictions on triggers that match everything.
https://bugs.webkit.org/show_bug.cgi?id=145069
Reviewed by Benjamin Poulain.
Source/WebCore:
Added API tests that cover the new functionality and test for correctness in behavior.
* contentextensions/CompiledContentExtension.cpp:
(WebCore::ContentExtensions::CompiledContentExtension::globalDisplayNoneSelectors):
* contentextensions/ContentExtensionCompiler.cpp:
(WebCore::ContentExtensions::addUniversalActionsToDFA):
(WebCore::ContentExtensions::compileRuleList):
Put universalActionsWithoutDomains into the DFA from filtersWithoutDomains and
put universalActionsWithDomains into the DFA from filtersWithDomains.
* contentextensions/ContentExtensionError.cpp:
(WebCore::ContentExtensions::contentExtensionErrorCategory):
* contentextensions/ContentExtensionError.h:
Remove error codes for errors that are not errors any more.
* contentextensions/ContentExtensionsBackend.cpp:
(WebCore::ContentExtensions::ContentExtensionsBackend::actionsForResourceLoad):
* contentextensions/ContentExtensionsBackend.h:
* contentextensions/DFABytecode.h:
(WebCore::ContentExtensions::instructionSizeWithArguments):
* contentextensions/DFABytecodeCompiler.cpp:
(WebCore::ContentExtensions::set32Bits):
(WebCore::ContentExtensions::DFABytecodeCompiler::emitAppendAction):
(WebCore::ContentExtensions::DFABytecodeCompiler::emitJump):
(WebCore::ContentExtensions::DFABytecodeCompiler::emitCheckValue):
(WebCore::ContentExtensions::DFABytecodeCompiler::emitCheckValueRange):
(WebCore::ContentExtensions::DFABytecodeCompiler::compileNode):
(WebCore::ContentExtensions::DFABytecodeCompiler::compile):
(WebCore::ContentExtensions::DFABytecodeCompiler::emitTestFlagsAndAppendAction): Deleted.
* contentextensions/DFABytecodeCompiler.h:
* contentextensions/DFABytecodeInterpreter.cpp:
(WebCore::ContentExtensions::DFABytecodeInterpreter::interpretAppendAction):
(WebCore::ContentExtensions::DFABytecodeInterpreter::interpretTestFlagsAndAppendAction):
(WebCore::ContentExtensions::DFABytecodeInterpreter::actionsForDefaultStylesheetFromDFARoot):
(WebCore::ContentExtensions::DFABytecodeInterpreter::interpret):
(WebCore::ContentExtensions::DFABytecodeInterpreter::actionsFromDFARoot): Deleted.
* contentextensions/DFABytecodeInterpreter.h:
Add a new bytecode AppendActionDefaultStylesheet to mark actions that are css-display-none
that need to be put in the default stylesheet to be ignored or not as a whole.
css-display-none actions with flags or domain rules and css-display-none actions
after ignore-previous-rules actions are not to be in this precompiled stylesheet, but
they will be applied as needed per page. The precompiled stylesheet is already applied
if no ignore-previous-rules action is triggered.
* loader/ResourceLoadInfo.h:
Source/WebKit2:
* UIProcess/API/APIUserContentExtensionStore.h:
Increment version number to reflect changes in DFABytecode.
Tools:
* TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp:
(TestWebKitAPI::TEST_F):
Update and add tests for new possibilities with .*</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="#trunkSourceWebCorecontentextensionsContentExtensionCompilercpp">trunk/Source/WebCore/contentextensions/ContentExtensionCompiler.cpp</a></li>
<li><a href="#trunkSourceWebCorecontentextensionsContentExtensionErrorcpp">trunk/Source/WebCore/contentextensions/ContentExtensionError.cpp</a></li>
<li><a href="#trunkSourceWebCorecontentextensionsContentExtensionErrorh">trunk/Source/WebCore/contentextensions/ContentExtensionError.h</a></li>
<li><a href="#trunkSourceWebCorecontentextensionsContentExtensionsBackendcpp">trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp</a></li>
<li><a href="#trunkSourceWebCorecontentextensionsContentExtensionsBackendh">trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.h</a></li>
<li><a href="#trunkSourceWebCorecontentextensionsDFABytecodeh">trunk/Source/WebCore/contentextensions/DFABytecode.h</a></li>
<li><a href="#trunkSourceWebCorecontentextensionsDFABytecodeCompilercpp">trunk/Source/WebCore/contentextensions/DFABytecodeCompiler.cpp</a></li>
<li><a href="#trunkSourceWebCorecontentextensionsDFABytecodeCompilerh">trunk/Source/WebCore/contentextensions/DFABytecodeCompiler.h</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>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebCoreContentExtensionscpp">trunk/Tools/TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (184643 => 184644)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-05-20 17:39:11 UTC (rev 184643)
+++ trunk/Source/WebCore/ChangeLog        2015-05-20 17:56:17 UTC (rev 184644)
</span><span class="lines">@@ -1,3 +1,53 @@
</span><ins>+2015-05-20 Alex Christensen <achristensen@webkit.org>
+
+ [Content Extensions] Relax restrictions on triggers that match everything.
+ https://bugs.webkit.org/show_bug.cgi?id=145069
+
+ Reviewed by Benjamin Poulain.
+
+ Added API tests that cover the new functionality and test for correctness in behavior.
+
+ * contentextensions/CompiledContentExtension.cpp:
+ (WebCore::ContentExtensions::CompiledContentExtension::globalDisplayNoneSelectors):
+ * contentextensions/ContentExtensionCompiler.cpp:
+ (WebCore::ContentExtensions::addUniversalActionsToDFA):
+ (WebCore::ContentExtensions::compileRuleList):
+ Put universalActionsWithoutDomains into the DFA from filtersWithoutDomains and
+ put universalActionsWithDomains into the DFA from filtersWithDomains.
+ * contentextensions/ContentExtensionError.cpp:
+ (WebCore::ContentExtensions::contentExtensionErrorCategory):
+ * contentextensions/ContentExtensionError.h:
+ Remove error codes for errors that are not errors any more.
+ * contentextensions/ContentExtensionsBackend.cpp:
+ (WebCore::ContentExtensions::ContentExtensionsBackend::actionsForResourceLoad):
+ * contentextensions/ContentExtensionsBackend.h:
+ * contentextensions/DFABytecode.h:
+ (WebCore::ContentExtensions::instructionSizeWithArguments):
+ * contentextensions/DFABytecodeCompiler.cpp:
+ (WebCore::ContentExtensions::set32Bits):
+ (WebCore::ContentExtensions::DFABytecodeCompiler::emitAppendAction):
+ (WebCore::ContentExtensions::DFABytecodeCompiler::emitJump):
+ (WebCore::ContentExtensions::DFABytecodeCompiler::emitCheckValue):
+ (WebCore::ContentExtensions::DFABytecodeCompiler::emitCheckValueRange):
+ (WebCore::ContentExtensions::DFABytecodeCompiler::compileNode):
+ (WebCore::ContentExtensions::DFABytecodeCompiler::compile):
+ (WebCore::ContentExtensions::DFABytecodeCompiler::emitTestFlagsAndAppendAction): Deleted.
+ * contentextensions/DFABytecodeCompiler.h:
+ * contentextensions/DFABytecodeInterpreter.cpp:
+ (WebCore::ContentExtensions::DFABytecodeInterpreter::interpretAppendAction):
+ (WebCore::ContentExtensions::DFABytecodeInterpreter::interpretTestFlagsAndAppendAction):
+ (WebCore::ContentExtensions::DFABytecodeInterpreter::actionsForDefaultStylesheetFromDFARoot):
+ (WebCore::ContentExtensions::DFABytecodeInterpreter::interpret):
+ (WebCore::ContentExtensions::DFABytecodeInterpreter::actionsFromDFARoot): Deleted.
+ * contentextensions/DFABytecodeInterpreter.h:
+ Add a new bytecode AppendActionDefaultStylesheet to mark actions that are css-display-none
+ that need to be put in the default stylesheet to be ignored or not as a whole.
+ css-display-none actions with flags or domain rules and css-display-none actions
+ after ignore-previous-rules actions are not to be in this precompiled stylesheet, but
+ they will be applied as needed per page. The precompiled stylesheet is already applied
+ if no ignore-previous-rules action is triggered.
+ * loader/ResourceLoadInfo.h:
+
</ins><span class="cx"> 2015-05-20 Youenn Fablet <youenn.fablet@crf.canon.fr>
</span><span class="cx">
</span><span class="cx"> JS binding generator should create a member variable for each Promise attribute of an interface
</span></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsCompiledContentExtensioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/contentextensions/CompiledContentExtension.cpp (184643 => 184644)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/CompiledContentExtension.cpp        2015-05-20 17:39:11 UTC (rev 184643)
+++ trunk/Source/WebCore/contentextensions/CompiledContentExtension.cpp        2015-05-20 17:56:17 UTC (rev 184644)
</span><span class="lines">@@ -39,7 +39,7 @@
</span><span class="cx"> Vector<String> CompiledContentExtension::globalDisplayNoneSelectors(Vector<bool>& pagesUsed)
</span><span class="cx"> {
</span><span class="cx"> DFABytecodeInterpreter interpreter(filtersWithoutDomainsBytecode(), filtersWithoutDomainsBytecodeLength(), pagesUsed);
</span><del>- DFABytecodeInterpreter::Actions actionLocations = interpreter.actionsFromDFARoot();
</del><ins>+ DFABytecodeInterpreter::Actions actionLocations = interpreter.actionsForDefaultStylesheetFromDFARoot();
</ins><span class="cx">
</span><span class="cx"> Vector<Action> globalActions;
</span><span class="cx"> for (uint64_t actionLocation : actionLocations)
</span></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsContentExtensionCompilercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/contentextensions/ContentExtensionCompiler.cpp (184643 => 184644)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/ContentExtensionCompiler.cpp        2015-05-20 17:39:11 UTC (rev 184643)
+++ trunk/Source/WebCore/contentextensions/ContentExtensionCompiler.cpp        2015-05-20 17:56:17 UTC (rev 184644)
</span><span class="lines">@@ -121,21 +121,24 @@
</span><span class="cx"> return actionLocations;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-typedef HashSet<uint64_t, DefaultHash<uint64_t>::Hash, WTF::UnsignedWithZeroKeyHashTraits<uint64_t>> UniversalActionLocationsSet;
</del><ins>+typedef HashSet<uint64_t, DefaultHash<uint64_t>::Hash, WTF::UnsignedWithZeroKeyHashTraits<uint64_t>> UniversalActionSet;
</ins><span class="cx">
</span><del>-static void addUniversalActionsToDFA(DFA& dfa, const UniversalActionLocationsSet& universalActionLocations)
</del><ins>+static void addUniversalActionsToDFA(DFA& dfa, const UniversalActionSet& universalActions)
</ins><span class="cx"> {
</span><del>- if (universalActionLocations.isEmpty())
</del><ins>+ if (universalActions.isEmpty())
</ins><span class="cx"> return;
</span><span class="cx">
</span><ins>+ DFANode& root = dfa.nodes[dfa.root];
+ ASSERT(!root.actionsLength());
</ins><span class="cx"> unsigned actionsStart = dfa.actions.size();
</span><del>- dfa.actions.reserveCapacity(dfa.actions.size() + universalActionLocations.size());
- for (uint64_t actionLocation : universalActionLocations)
- dfa.actions.uncheckedAppend(actionLocation);
</del><ins>+ dfa.actions.reserveCapacity(dfa.actions.size() + universalActions.size());
+ for (uint64_t action : universalActions)
+ dfa.actions.uncheckedAppend(action);
</ins><span class="cx"> unsigned actionsEnd = dfa.actions.size();
</span><ins>+
</ins><span class="cx"> unsigned actionsLength = actionsEnd - actionsStart;
</span><span class="cx"> RELEASE_ASSERT_WITH_MESSAGE(actionsLength < std::numeric_limits<uint16_t>::max(), "Too many uncombined actions that match everything");
</span><del>- dfa.nodes[dfa.root].setActions(actionsStart, static_cast<uint16_t>(actionsLength));
</del><ins>+ root.setActions(actionsStart, static_cast<uint16_t>(actionsLength));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> std::error_code compileRuleList(ContentExtensionCompilationClient& client, String&& ruleList)
</span><span class="lines">@@ -156,7 +159,8 @@
</span><span class="cx"> LOG_LARGE_STRUCTURES(actions, actions.capacity() * sizeof(SerializedActionByte));
</span><span class="cx"> actions.clear();
</span><span class="cx">
</span><del>- UniversalActionLocationsSet universalActionLocations;
</del><ins>+ UniversalActionSet universalActionsWithoutDomains;
+ UniversalActionSet universalActionsWithDomains;
</ins><span class="cx">
</span><span class="cx"> // FIXME: These don't all need to be in memory at the same time.
</span><span class="cx"> CombinedURLFilters filtersWithoutDomains;
</span><span class="lines">@@ -169,6 +173,7 @@
</span><span class="cx"> for (unsigned ruleIndex = 0; ruleIndex < parsedRuleList.size(); ++ruleIndex) {
</span><span class="cx"> const ContentExtensionRule& contentExtensionRule = parsedRuleList[ruleIndex];
</span><span class="cx"> const Trigger& trigger = contentExtensionRule.trigger();
</span><ins>+ const Action& action = contentExtensionRule.action();
</ins><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">@@ -178,9 +183,12 @@
</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)
- return ContentExtensionError::RegexMatchesEverythingAfterIgnorePreviousRules;
- universalActionLocations.add(actionLocationAndFlags);
</del><ins>+ if (!ignorePreviousRulesSeen
+ && trigger.domainCondition == Trigger::DomainCondition::None
+ && action.type() == ActionType::CSSDisplayNoneSelector
+ && !trigger.flags)
+ actionLocationAndFlags |= DisplayNoneStyleSheetFlag;
+ universalActionsWithoutDomains.add(actionLocationAndFlags);
</ins><span class="cx"> status = URLFilterParser::Ok;
</span><span class="cx"> }
</span><span class="cx"> if (status != URLFilterParser::Ok) {
</span><span class="lines">@@ -196,8 +204,10 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> status = filtersWithDomainParser.addPattern(trigger.urlFilter, trigger.urlFilterIsCaseSensitive, actionLocationAndFlags);
</span><del>- if (status == URLFilterParser::MatchesEverything)
- return ContentExtensionError::RegexMatchesEverythingWithDomains;
</del><ins>+ if (status == URLFilterParser::MatchesEverything) {
+ universalActionsWithDomains.add(actionLocationAndFlags);
+ status = URLFilterParser::Ok;
+ }
</ins><span class="cx"> if (status != URLFilterParser::Ok) {
</span><span class="cx"> dataLogF("Error while parsing %s: %s\n", trigger.urlFilter.utf8().data(), URLFilterParser::statusString(status).utf8().data());
</span><span class="cx"> return ContentExtensionError::JSONInvalidRegex;
</span><span class="lines">@@ -207,7 +217,7 @@
</span><span class="cx"> }
</span><span class="cx"> ASSERT(status == URLFilterParser::Ok);
</span><span class="cx">
</span><del>- if (contentExtensionRule.action().type() == ActionType::IgnorePreviousRules)
</del><ins>+ if (action.type() == ActionType::IgnorePreviousRules)
</ins><span class="cx"> ignorePreviousRulesSeen = true;
</span><span class="cx"> }
</span><span class="cx"> LOG_LARGE_STRUCTURES(parsedRuleList, parsedRuleList.capacity() * sizeof(ContentExtensionRule)); // Doesn't include strings.
</span><span class="lines">@@ -231,7 +241,7 @@
</span><span class="cx"> // FIXME: This can be tuned. More NFAs take longer to interpret, fewer use more memory and time to compile.
</span><span class="cx"> const unsigned maxNFASize = 50000;
</span><span class="cx">
</span><del>- bool firstNFASeen = false;
</del><ins>+ bool firstNFAWithoutDomainsSeen = false;
</ins><span class="cx"> // FIXME: Combine small NFAs to reduce the number of NFAs.
</span><span class="cx"> filtersWithoutDomains.processNFAs(maxNFASize, [&](NFA&& nfa) {
</span><span class="cx"> #if CONTENT_EXTENSIONS_STATE_MACHINE_DEBUGGING
</span><span class="lines">@@ -252,9 +262,9 @@
</span><span class="cx"> #endif
</span><span class="cx"> ASSERT_WITH_MESSAGE(!dfa.nodes[dfa.root].hasActions(), "All actions on the DFA root should come from regular expressions that match everything.");
</span><span class="cx">
</span><del>- if (!firstNFASeen) {
</del><ins>+ if (!firstNFAWithoutDomainsSeen) {
</ins><span class="cx"> // Put all the universal actions on the first DFA.
</span><del>- addUniversalActionsToDFA(dfa, universalActionLocations);
</del><ins>+ addUniversalActionsToDFA(dfa, universalActionsWithoutDomains);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> Vector<DFABytecode> bytecode;
</span><span class="lines">@@ -263,18 +273,18 @@
</span><span class="cx"> LOG_LARGE_STRUCTURES(bytecode, bytecode.capacity() * sizeof(uint8_t));
</span><span class="cx"> client.writeFiltersWithoutDomainsBytecode(WTF::move(bytecode));
</span><span class="cx">
</span><del>- firstNFASeen = true;
</del><ins>+ firstNFAWithoutDomainsSeen = true;
</ins><span class="cx"> });
</span><span class="cx"> ASSERT(filtersWithoutDomains.isEmpty());
</span><span class="cx">
</span><del>- if (!firstNFASeen) {
</del><ins>+ if (!firstNFAWithoutDomainsSeen) {
</ins><span class="cx"> // Our bytecode interpreter expects to have at least one DFA, so if we haven't seen any
</span><span class="cx"> // create a dummy one and add any universal actions.
</span><span class="cx">
</span><span class="cx"> NFA dummyNFA;
</span><span class="cx"> DFA dummyDFA = NFAToDFA::convert(dummyNFA);
</span><span class="cx">
</span><del>- addUniversalActionsToDFA(dummyDFA, universalActionLocations);
</del><ins>+ addUniversalActionsToDFA(dummyDFA, universalActionsWithoutDomains);
</ins><span class="cx">
</span><span class="cx"> Vector<DFABytecode> bytecode;
</span><span class="cx"> DFABytecodeCompiler compiler(dummyDFA, bytecode);
</span><span class="lines">@@ -282,9 +292,10 @@
</span><span class="cx"> LOG_LARGE_STRUCTURES(bytecode, bytecode.capacity() * sizeof(uint8_t));
</span><span class="cx"> client.writeFiltersWithoutDomainsBytecode(WTF::move(bytecode));
</span><span class="cx"> }
</span><del>- LOG_LARGE_STRUCTURES(universalActionLocations, universalActionLocations.capacity() * sizeof(unsigned));
- universalActionLocations.clear();
</del><ins>+ LOG_LARGE_STRUCTURES(universalAction, universalAction.capacity() * sizeof(unsigned));
+ universalActionsWithoutDomains.clear();
</ins><span class="cx">
</span><ins>+ bool firstNFAWithDomainsSeen = false;
</ins><span class="cx"> filtersWithDomains.processNFAs(maxNFASize, [&](NFA&& nfa) {
</span><span class="cx"> #if CONTENT_EXTENSIONS_STATE_MACHINE_DEBUGGING
</span><span class="cx"> dataLogF("filtersWithDomains NFA\n");
</span><span class="lines">@@ -304,13 +315,38 @@
</span><span class="cx"> #endif
</span><span class="cx"> ASSERT_WITH_MESSAGE(!dfa.nodes[dfa.root].hasActions(), "Filters with domains that match everything are not allowed right now.");
</span><span class="cx">
</span><ins>+ if (!firstNFAWithDomainsSeen) {
+ // Put all the universal actions on the first DFA.
+ addUniversalActionsToDFA(dfa, universalActionsWithDomains);
+ }
+
</ins><span class="cx"> Vector<DFABytecode> bytecode;
</span><span class="cx"> DFABytecodeCompiler compiler(dfa, bytecode);
</span><span class="cx"> compiler.compile();
</span><span class="cx"> LOG_LARGE_STRUCTURES(bytecode, bytecode.capacity() * sizeof(uint8_t));
</span><span class="cx"> client.writeFiltersWithDomainsBytecode(WTF::move(bytecode));
</span><ins>+
+ firstNFAWithDomainsSeen = true;
</ins><span class="cx"> });
</span><span class="cx"> ASSERT(filtersWithDomains.isEmpty());
</span><ins>+
+ if (!firstNFAWithDomainsSeen) {
+ // Our bytecode interpreter expects to have at least one DFA, so if we haven't seen any
+ // create a dummy one and add any universal actions.
+
+ NFA dummyNFA;
+ DFA dummyDFA = NFAToDFA::convert(dummyNFA);
+
+ addUniversalActionsToDFA(dummyDFA, universalActionsWithDomains);
+
+ Vector<DFABytecode> bytecode;
+ DFABytecodeCompiler compiler(dummyDFA, bytecode);
+ compiler.compile();
+ LOG_LARGE_STRUCTURES(bytecode, bytecode.capacity() * sizeof(uint8_t));
+ client.writeFiltersWithDomainsBytecode(WTF::move(bytecode));
+ }
+ LOG_LARGE_STRUCTURES(universalActionsWithDomains, universalActionsWithDomains.capacity() * sizeof(unsigned));
+ universalActionsWithDomains.clear();
</ins><span class="cx">
</span><span class="cx"> domainFilters.processNFAs(maxNFASize, [&](NFA&& nfa) {
</span><span class="cx"> #if CONTENT_EXTENSIONS_STATE_MACHINE_DEBUGGING
</span></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsContentExtensionErrorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/contentextensions/ContentExtensionError.cpp (184643 => 184644)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/ContentExtensionError.cpp        2015-05-20 17:39:11 UTC (rev 184643)
+++ trunk/Source/WebCore/contentextensions/ContentExtensionError.cpp        2015-05-20 17:56:17 UTC (rev 184644)
</span><span class="lines">@@ -75,10 +75,6 @@
</span><span class="cx"> return "Invalid css-display-none action type. Requires a selector.";
</span><span class="cx"> case ContentExtensionError::JSONInvalidRegex:
</span><span class="cx"> return "Invalid or unsupported regular expression.";
</span><del>- case ContentExtensionError::RegexMatchesEverythingAfterIgnorePreviousRules:
- return "Regular expressions that match everything are only allowed before the first ignore-previous-rules.";
- case ContentExtensionError::RegexMatchesEverythingWithDomains:
- return "Regular expressions that match everything are not allowed with unless- or if-domain.";
</del><span class="cx"> case ContentExtensionError::JSONInvalidDomainList:
</span><span class="cx"> return "Invalid domain list.";
</span><span class="cx"> case ContentExtensionError::JSONDomainNotLowerCaseASCII:
</span></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsContentExtensionErrorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/contentextensions/ContentExtensionError.h (184643 => 184644)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/ContentExtensionError.h        2015-05-20 17:39:11 UTC (rev 184643)
+++ trunk/Source/WebCore/contentextensions/ContentExtensionError.h        2015-05-20 17:56:17 UTC (rev 184644)
</span><span class="lines">@@ -57,9 +57,6 @@
</span><span class="cx"> JSONInvalidActionType,
</span><span class="cx"> JSONInvalidCSSDisplayNoneActionType,
</span><span class="cx"> JSONInvalidRegex,
</span><del>-
- RegexMatchesEverythingAfterIgnorePreviousRules,
- RegexMatchesEverythingWithDomains,
</del><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> WEBCORE_EXPORT const std::error_category& contentExtensionErrorCategory();
</span></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsContentExtensionsBackendcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp (184643 => 184644)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp        2015-05-20 17:39:11 UTC (rev 184643)
+++ trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp        2015-05-20 17:56:17 UTC (rev 184644)
</span><span class="lines">@@ -146,16 +146,6 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx"> if (!sawIgnorePreviousRules) {
</span><del>- DFABytecodeInterpreter::Actions universalActions = withoutDomainsInterpreter.actionsFromDFARoot();
- for (uint64_t actionLocation : universalActions) {
- // FIXME: We shouldn't deserialize an action all the way if it is a css-display-none selector.
- Action action = Action::deserialize(actions, actionsLength, static_cast<unsigned>(actionLocation));
- action.setExtensionIdentifier(contentExtension->identifier());
-
- // CSS selectors were already compiled into a stylesheet using globalDisplayNoneSelectors.
- if (action.type() != ActionType::CSSDisplayNoneSelector)
- finalActions.append(action);
- }
</del><span class="cx"> finalActions.append(Action(ActionType::CSSDisplayNoneStyleSheet, contentExtension->identifier()));
</span><span class="cx"> finalActions.last().setExtensionIdentifier(contentExtension->identifier());
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsContentExtensionsBackendh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.h (184643 => 184644)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.h        2015-05-20 17:39:11 UTC (rev 184643)
+++ trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.h        2015-05-20 17:56:17 UTC (rev 184644)
</span><span class="lines">@@ -63,7 +63,7 @@
</span><span class="cx">
</span><span class="cx"> // - Internal WebCore Interface.
</span><span class="cx"> WEBCORE_EXPORT Vector<Action> actionsForResourceLoad(const ResourceLoadInfo&) const;
</span><del>- StyleSheetContents* globalDisplayNoneStyleSheet(const String& identifier) const;
</del><ins>+ WEBCORE_EXPORT StyleSheetContents* globalDisplayNoneStyleSheet(const String& identifier) const;
</ins><span class="cx">
</span><span class="cx"> void processContentExtensionRulesForLoad(ResourceRequest&, ResourceType, DocumentLoader& initiatingDocumentLoader);
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsDFABytecodeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/contentextensions/DFABytecode.h (184643 => 184644)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/DFABytecode.h        2015-05-20 17:39:11 UTC (rev 184643)
+++ trunk/Source/WebCore/contentextensions/DFABytecode.h        2015-05-20 17:56:17 UTC (rev 184644)
</span><span class="lines">@@ -55,6 +55,7 @@
</span><span class="cx"> // AppendAction has one argument:
</span><span class="cx"> // The action to append (4 bytes).
</span><span class="cx"> AppendAction,
</span><ins>+ AppendActionDefaultStylesheet,
</ins><span class="cx"> AppendActionWithIfDomain,
</span><span class="cx">
</span><span class="cx"> // TestFlagsAndAppendAction has two arguments:
</span><span class="lines">@@ -76,20 +77,21 @@
</span><span class="cx"> switch (instruction) {
</span><span class="cx"> case DFABytecodeInstruction::CheckValueCaseSensitive:
</span><span class="cx"> case DFABytecodeInstruction::CheckValueCaseInsensitive:
</span><del>- return sizeof(DFABytecodeInstruction) + sizeof(uint8_t) + sizeof(unsigned);
</del><ins>+ return sizeof(DFABytecodeInstruction) + sizeof(uint8_t) + sizeof(uint32_t);
</ins><span class="cx"> case DFABytecodeInstruction::CheckValueRangeCaseSensitive:
</span><span class="cx"> case DFABytecodeInstruction::CheckValueRangeCaseInsensitive:
</span><del>- return sizeof(DFABytecodeInstruction) + sizeof(uint8_t) + sizeof(uint8_t) + sizeof(unsigned);
</del><ins>+ return sizeof(DFABytecodeInstruction) + sizeof(uint8_t) + sizeof(uint8_t) + sizeof(uint32_t);
</ins><span class="cx"> case DFABytecodeInstruction::AppendAction:
</span><ins>+ case DFABytecodeInstruction::AppendActionDefaultStylesheet:
</ins><span class="cx"> case DFABytecodeInstruction::AppendActionWithIfDomain:
</span><del>- return sizeof(DFABytecodeInstruction) + sizeof(unsigned);
</del><ins>+ return sizeof(DFABytecodeInstruction) + sizeof(uint32_t);
</ins><span class="cx"> case DFABytecodeInstruction::TestFlagsAndAppendAction:
</span><span class="cx"> case DFABytecodeInstruction::TestFlagsAndAppendActionWithIfDomain:
</span><del>- return sizeof(DFABytecodeInstruction) + sizeof(uint16_t) + sizeof(unsigned);
</del><ins>+ return sizeof(DFABytecodeInstruction) + sizeof(uint16_t) + sizeof(uint32_t);
</ins><span class="cx"> case DFABytecodeInstruction::Terminate:
</span><span class="cx"> return sizeof(DFABytecodeInstruction);
</span><span class="cx"> case DFABytecodeInstruction::Jump:
</span><del>- return sizeof(DFABytecodeInstruction) + sizeof(unsigned);
</del><ins>+ return sizeof(DFABytecodeInstruction) + sizeof(uint32_t);
</ins><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsDFABytecodeCompilercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/contentextensions/DFABytecodeCompiler.cpp (184643 => 184644)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/DFABytecodeCompiler.cpp        2015-05-20 17:39:11 UTC (rev 184643)
+++ trunk/Source/WebCore/contentextensions/DFABytecodeCompiler.cpp        2015-05-20 17:56:17 UTC (rev 184644)
</span><span class="lines">@@ -43,47 +43,50 @@
</span><span class="cx"> *reinterpret_cast<IntType*>(&bytecode[bytecode.size() - sizeof(IntType)]) = value;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-inline void set32Bits(Vector<DFABytecode>& bytecode, unsigned index, unsigned value)
</del><ins>+inline void set32Bits(Vector<DFABytecode>& bytecode, uint32_t index, uint32_t value)
</ins><span class="cx"> {
</span><del>- *reinterpret_cast<unsigned*>(&bytecode[index]) = value;
</del><ins>+ *reinterpret_cast<uint32_t*>(&bytecode[index]) = value;
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-void DFABytecodeCompiler::emitAppendAction(unsigned action, bool ifDomain)
</del><ins>+void DFABytecodeCompiler::emitAppendAction(uint64_t action)
</ins><span class="cx"> {
</span><del>- if (ifDomain)
- append<DFABytecodeInstruction>(m_bytecode, DFABytecodeInstruction::AppendActionWithIfDomain);
- else
- append<DFABytecodeInstruction>(m_bytecode, DFABytecodeInstruction::AppendAction);
- append<unsigned>(m_bytecode, action);
</del><ins>+ // High bits are used to store flags. See compileRuleList.
+ if (action & 0xFFFF00000000) {
+ ASSERT(!(action & DisplayNoneStyleSheetFlag));
+ if (action & IfDomainFlag)
+ append<DFABytecodeInstruction>(m_bytecode, DFABytecodeInstruction::TestFlagsAndAppendActionWithIfDomain);
+ else
+ append<DFABytecodeInstruction>(m_bytecode, DFABytecodeInstruction::TestFlagsAndAppendAction);
+ append<uint16_t>(m_bytecode, static_cast<uint16_t>(action >> 32));
+ append<uint32_t>(m_bytecode, static_cast<uint32_t>(action));
+ } else {
+ if (action & DisplayNoneStyleSheetFlag) {
+ RELEASE_ASSERT(!(action & IfDomainFlag));
+ append<DFABytecodeInstruction>(m_bytecode, DFABytecodeInstruction::AppendActionDefaultStylesheet);
+ } else if (action & IfDomainFlag)
+ append<DFABytecodeInstruction>(m_bytecode, DFABytecodeInstruction::AppendActionWithIfDomain);
+ else
+ append<DFABytecodeInstruction>(m_bytecode, DFABytecodeInstruction::AppendAction);
+ append<uint32_t>(m_bytecode, static_cast<uint32_t>(action));
+ }
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-void DFABytecodeCompiler::emitTestFlagsAndAppendAction(uint16_t flags, unsigned action, bool ifDomain)
</del><ins>+void DFABytecodeCompiler::emitJump(uint32_t destinationNodeIndex)
</ins><span class="cx"> {
</span><del>- ASSERT(flags);
- if (ifDomain)
- append<DFABytecodeInstruction>(m_bytecode, DFABytecodeInstruction::TestFlagsAndAppendActionWithIfDomain);
- else
- append<DFABytecodeInstruction>(m_bytecode, DFABytecodeInstruction::TestFlagsAndAppendAction);
- append<uint16_t>(m_bytecode, flags);
- append<unsigned>(m_bytecode, action);
-}
-
-void DFABytecodeCompiler::emitJump(unsigned destinationNodeIndex)
-{
</del><span class="cx"> append<DFABytecodeInstruction>(m_bytecode, DFABytecodeInstruction::Jump);
</span><span class="cx"> m_linkRecords.append(std::make_pair(m_bytecode.size(), destinationNodeIndex));
</span><del>- append<unsigned>(m_bytecode, 0); // This value will be set when linking.
</del><ins>+ append<uint32_t>(m_bytecode, 0); // This value will be set when linking.
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-void DFABytecodeCompiler::emitCheckValue(uint8_t value, unsigned destinationNodeIndex, bool caseSensitive)
</del><ins>+void DFABytecodeCompiler::emitCheckValue(uint8_t value, uint32_t destinationNodeIndex, bool caseSensitive)
</ins><span class="cx"> {
</span><span class="cx"> append<DFABytecodeInstruction>(m_bytecode, caseSensitive ? DFABytecodeInstruction::CheckValueCaseSensitive : DFABytecodeInstruction::CheckValueCaseInsensitive);
</span><span class="cx"> append<uint8_t>(m_bytecode, value);
</span><span class="cx"> m_linkRecords.append(std::make_pair(m_bytecode.size(), destinationNodeIndex));
</span><del>- append<unsigned>(m_bytecode, 0); // This value will be set when linking.
</del><ins>+ append<uint32_t>(m_bytecode, 0); // This value will be set when linking.
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-void DFABytecodeCompiler::emitCheckValueRange(uint8_t lowValue, uint8_t highValue, unsigned destinationNodeIndex, bool caseSensitive)
</del><ins>+void DFABytecodeCompiler::emitCheckValueRange(uint8_t lowValue, uint8_t highValue, uint32_t destinationNodeIndex, bool caseSensitive)
</ins><span class="cx"> {
</span><span class="cx"> ASSERT_WITH_MESSAGE(lowValue < highValue, "The instruction semantic impose lowValue is strictly less than highValue.");
</span><span class="cx">
</span><span class="lines">@@ -91,7 +94,7 @@
</span><span class="cx"> append<uint8_t>(m_bytecode, lowValue);
</span><span class="cx"> append<uint8_t>(m_bytecode, highValue);
</span><span class="cx"> m_linkRecords.append(std::make_pair(m_bytecode.size(), destinationNodeIndex));
</span><del>- append<unsigned>(m_bytecode, 0); // This value will be set when linking.
</del><ins>+ append<uint32_t>(m_bytecode, 0); // This value will be set when linking.
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void DFABytecodeCompiler::emitTerminate()
</span><span class="lines">@@ -99,11 +102,11 @@
</span><span class="cx"> append<DFABytecodeInstruction>(m_bytecode, DFABytecodeInstruction::Terminate);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void DFABytecodeCompiler::compileNode(unsigned index, bool root)
</del><ins>+void DFABytecodeCompiler::compileNode(uint32_t index, bool root)
</ins><span class="cx"> {
</span><span class="cx"> const DFANode& node = m_dfa.nodes[index];
</span><span class="cx"> if (node.isKilled()) {
</span><del>- m_nodeStartOffsets[index] = std::numeric_limits<unsigned>::max();
</del><ins>+ m_nodeStartOffsets[index] = std::numeric_limits<uint32_t>::max();
</ins><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -111,13 +114,8 @@
</span><span class="cx"> if (!root)
</span><span class="cx"> m_nodeStartOffsets[index] = m_bytecode.size();
</span><span class="cx">
</span><del>- for (uint64_t action : node.actions(m_dfa)) {
- // High bits are used to store flags. A boolean is stored in the 48th bit. See compileRuleList.
- if (action & 0xFFFF00000000)
- emitTestFlagsAndAppendAction(static_cast<uint16_t>(action >> 32), static_cast<unsigned>(action), action & IfDomainFlag);
- else
- emitAppendAction(static_cast<unsigned>(action), action & IfDomainFlag);
- }
</del><ins>+ for (uint64_t action : node.actions(m_dfa))
+ emitAppendAction(action);
</ins><span class="cx">
</span><span class="cx"> // If we jump to the root, we don't want to re-add its actions to a HashSet.
</span><span class="cx"> // We know we have already added them because the root is always compiled first and we always start interpreting at the beginning.
</span><span class="lines">@@ -212,24 +210,24 @@
</span><span class="cx"> void DFABytecodeCompiler::compile()
</span><span class="cx"> {
</span><span class="cx"> // DFA header.
</span><del>- unsigned startLocation = m_bytecode.size();
- append<unsigned>(m_bytecode, 0);
</del><ins>+ uint32_t startLocation = m_bytecode.size();
+ append<uint32_t>(m_bytecode, 0);
</ins><span class="cx"> m_nodeStartOffsets.resize(m_dfa.nodes.size());
</span><span class="cx">
</span><span class="cx"> // Make sure the root is always at the beginning of the bytecode.
</span><span class="cx"> compileNode(m_dfa.root, true);
</span><del>- for (unsigned i = 0; i < m_dfa.nodes.size(); i++) {
</del><ins>+ for (uint32_t i = 0; i < m_dfa.nodes.size(); i++) {
</ins><span class="cx"> if (i != m_dfa.root)
</span><span class="cx"> compileNode(i, false);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Link.
</span><span class="cx"> for (const auto& linkRecord : m_linkRecords) {
</span><del>- unsigned offset = linkRecord.first;
- ASSERT(!(*reinterpret_cast<unsigned*>(&m_bytecode[offset])));
</del><ins>+ uint32_t offset = linkRecord.first;
+ ASSERT(!(*reinterpret_cast<uint32_t*>(&m_bytecode[offset])));
</ins><span class="cx">
</span><del>- unsigned target = m_nodeStartOffsets[linkRecord.second];
- RELEASE_ASSERT(target != std::numeric_limits<unsigned>::max());
</del><ins>+ uint32_t target = m_nodeStartOffsets[linkRecord.second];
+ RELEASE_ASSERT(target != std::numeric_limits<uint32_t>::max());
</ins><span class="cx"> set32Bits(m_bytecode, offset, m_nodeStartOffsets[linkRecord.second]);
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsDFABytecodeCompilerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/contentextensions/DFABytecodeCompiler.h (184643 => 184644)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/DFABytecodeCompiler.h        2015-05-20 17:39:11 UTC (rev 184643)
+++ trunk/Source/WebCore/contentextensions/DFABytecodeCompiler.h        2015-05-20 17:56:17 UTC (rev 184644)
</span><span class="lines">@@ -50,7 +50,7 @@
</span><span class="cx">
</span><span class="cx"> private:
</span><span class="cx"> struct Range {
</span><del>- Range(uint8_t min, uint8_t max, unsigned destination, bool caseSensitive)
</del><ins>+ Range(uint8_t min, uint8_t max, uint32_t destination, bool caseSensitive)
</ins><span class="cx"> : min(min)
</span><span class="cx"> , max(max)
</span><span class="cx"> , destination(destination)
</span><span class="lines">@@ -59,28 +59,27 @@
</span><span class="cx"> }
</span><span class="cx"> uint8_t min;
</span><span class="cx"> uint8_t max;
</span><del>- unsigned destination;
</del><ins>+ uint32_t destination;
</ins><span class="cx"> bool caseSensitive;
</span><span class="cx"> };
</span><del>- void compileNode(unsigned, bool root);
</del><ins>+ void compileNode(uint32_t, bool root);
</ins><span class="cx"> void compileNodeTransitions(const DFANode&);
</span><span class="cx"> void compileCheckForRange(const Range&);
</span><span class="cx">
</span><del>- void emitAppendAction(unsigned, bool ifDomain);
- void emitTestFlagsAndAppendAction(uint16_t flags, unsigned, bool ifDomain);
- void emitJump(unsigned destinationNodeIndex);
- void emitCheckValue(uint8_t value, unsigned destinationNodeIndex, bool caseSensitive);
- void emitCheckValueRange(uint8_t lowValue, uint8_t highValue, unsigned destinationNodeIndex, bool caseSensitive);
</del><ins>+ void emitAppendAction(uint64_t);
+ void emitJump(uint32_t destinationNodeIndex);
+ void emitCheckValue(uint8_t value, uint32_t destinationNodeIndex, bool caseSensitive);
+ void emitCheckValueRange(uint8_t lowValue, uint8_t highValue, uint32_t destinationNodeIndex, bool caseSensitive);
</ins><span class="cx"> void emitTerminate();
</span><span class="cx">
</span><span class="cx"> Vector<DFABytecode>& m_bytecode;
</span><span class="cx"> const DFA& m_dfa;
</span><span class="cx">
</span><del>- Vector<unsigned> m_nodeStartOffsets;
</del><ins>+ Vector<uint32_t> m_nodeStartOffsets;
</ins><span class="cx">
</span><span class="cx"> // The first value is the index in the bytecode buffer where the jump is to be written.
</span><span class="cx"> // The second value is the index of the node to jump to.
</span><del>- Vector<std::pair<unsigned, unsigned>> m_linkRecords;
</del><ins>+ Vector<std::pair<uint32_t, uint32_t>> m_linkRecords;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } // namespace ContentExtensions
</span></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsDFABytecodeInterpretercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/contentextensions/DFABytecodeInterpreter.cpp (184643 => 184644)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/DFABytecodeInterpreter.cpp        2015-05-20 17:39:11 UTC (rev 184643)
+++ trunk/Source/WebCore/contentextensions/DFABytecodeInterpreter.cpp        2015-05-20 17:56:17 UTC (rev 184644)
</span><span class="lines">@@ -53,9 +53,12 @@
</span><span class="cx"> void DFABytecodeInterpreter::interpretAppendAction(unsigned& programCounter, Actions& actions, bool ifDomain)
</span><span class="cx"> {
</span><span class="cx"> ASSERT(getBits<DFABytecodeInstruction>(m_bytecode, m_bytecodeLength, programCounter, m_pagesUsed) == DFABytecodeInstruction::AppendAction
</span><del>- || getBits<DFABytecodeInstruction>(m_bytecode, m_bytecodeLength, programCounter, m_pagesUsed) == DFABytecodeInstruction::AppendActionWithIfDomain);
</del><ins>+ || getBits<DFABytecodeInstruction>(m_bytecode, m_bytecodeLength, programCounter, m_pagesUsed) == DFABytecodeInstruction::AppendActionWithIfDomain
+ || getBits<DFABytecodeInstruction>(m_bytecode, m_bytecodeLength, programCounter, m_pagesUsed) == DFABytecodeInstruction::AppendActionDefaultStylesheet);
</ins><span class="cx"> actions.add((ifDomain ? IfDomainFlag : 0) | static_cast<uint64_t>(getBits<unsigned>(m_bytecode, m_bytecodeLength, programCounter + sizeof(DFABytecode), m_pagesUsed)));
</span><span class="cx"> programCounter += instructionSizeWithArguments(DFABytecodeInstruction::AppendAction);
</span><ins>+ ASSERT(instructionSizeWithArguments(DFABytecodeInstruction::AppendAction) == instructionSizeWithArguments(DFABytecodeInstruction::AppendActionWithIfDomain));
+ ASSERT(instructionSizeWithArguments(DFABytecodeInstruction::AppendAction) == instructionSizeWithArguments(DFABytecodeInstruction::AppendActionDefaultStylesheet));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void DFABytecodeInterpreter::interpretTestFlagsAndAppendAction(unsigned& programCounter, uint16_t flags, Actions& actions, bool ifDomain)
</span><span class="lines">@@ -65,9 +68,10 @@
</span><span class="cx"> if (flags & getBits<uint16_t>(m_bytecode, m_bytecodeLength, programCounter + sizeof(DFABytecode), m_pagesUsed))
</span><span class="cx"> actions.add((ifDomain ? IfDomainFlag : 0) | static_cast<uint64_t>(getBits<unsigned>(m_bytecode, m_bytecodeLength, programCounter + sizeof(DFABytecode) + sizeof(uint16_t), m_pagesUsed)));
</span><span class="cx"> programCounter += instructionSizeWithArguments(DFABytecodeInstruction::TestFlagsAndAppendAction);
</span><ins>+ ASSERT(instructionSizeWithArguments(DFABytecodeInstruction::TestFlagsAndAppendAction) == instructionSizeWithArguments(DFABytecodeInstruction::TestFlagsAndAppendActionWithIfDomain));
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-DFABytecodeInterpreter::Actions DFABytecodeInterpreter::actionsFromDFARoot()
</del><ins>+DFABytecodeInterpreter::Actions DFABytecodeInterpreter::actionsForDefaultStylesheetFromDFARoot()
</ins><span class="cx"> {
</span><span class="cx"> Actions actions;
</span><span class="cx">
</span><span class="lines">@@ -77,12 +81,19 @@
</span><span class="cx">
</span><span class="cx"> while (programCounter < dfaBytecodeLength) {
</span><span class="cx"> DFABytecodeInstruction instruction = static_cast<DFABytecodeInstruction>(m_bytecode[programCounter]);
</span><del>- if (instruction == DFABytecodeInstruction::AppendAction)
</del><ins>+ if (instruction == DFABytecodeInstruction::AppendActionDefaultStylesheet)
</ins><span class="cx"> interpretAppendAction(programCounter, actions, false);
</span><ins>+ else if (instruction == DFABytecodeInstruction::AppendAction)
+ programCounter += instructionSizeWithArguments(DFABytecodeInstruction::AppendAction);
</ins><span class="cx"> else if (instruction == DFABytecodeInstruction::TestFlagsAndAppendAction)
</span><span class="cx"> programCounter += instructionSizeWithArguments(DFABytecodeInstruction::TestFlagsAndAppendAction);
</span><del>- else
</del><ins>+ 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);
</ins><span class="cx"> break;
</span><ins>+ }
</ins><span class="cx"> }
</span><span class="cx"> return actions;
</span><span class="cx"> }
</span><span class="lines">@@ -102,12 +113,14 @@
</span><span class="cx"> unsigned dfaBytecodeLength = getBits<unsigned>(m_bytecode, m_bytecodeLength, programCounter, m_pagesUsed);
</span><span class="cx"> programCounter += sizeof(unsigned);
</span><span class="cx">
</span><del>- // Skip the actions on the DFA root. These are accessed via actionsFromDFARoot.
</del><ins>+ // Skip the default stylesheet actions on the DFA root. These are accessed via actionsForDefaultStylesheetFromDFARoot.
</ins><span class="cx"> if (!dfaStart) {
</span><span class="cx"> while (programCounter < dfaBytecodeLength) {
</span><span class="cx"> DFABytecodeInstruction instruction = static_cast<DFABytecodeInstruction>(m_bytecode[programCounter]);
</span><del>- if (instruction == DFABytecodeInstruction::AppendAction)
- programCounter += instructionSizeWithArguments(DFABytecodeInstruction::AppendAction);
</del><ins>+ if (instruction == DFABytecodeInstruction::AppendActionDefaultStylesheet)
+ programCounter += instructionSizeWithArguments(DFABytecodeInstruction::AppendActionDefaultStylesheet);
+ else if (instruction == DFABytecodeInstruction::AppendAction)
+ interpretAppendAction(programCounter, actions, false);
</ins><span class="cx"> else if (instruction == DFABytecodeInstruction::TestFlagsAndAppendAction)
</span><span class="cx"> interpretTestFlagsAndAppendAction(programCounter, flags, actions, false);
</span><span class="cx"> else
</span></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsDFABytecodeInterpreterh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/contentextensions/DFABytecodeInterpreter.h (184643 => 184644)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/DFABytecodeInterpreter.h        2015-05-20 17:39:11 UTC (rev 184643)
+++ trunk/Source/WebCore/contentextensions/DFABytecodeInterpreter.h        2015-05-20 17:56:17 UTC (rev 184644)
</span><span class="lines">@@ -60,7 +60,7 @@
</span><span class="cx"> typedef HashSet<uint64_t, DefaultHash<uint64_t>::Hash, WTF::UnsignedWithZeroKeyHashTraits<uint64_t>> Actions;
</span><span class="cx">
</span><span class="cx"> Actions interpret(const CString&, uint16_t flags);
</span><del>- Actions actionsFromDFARoot();
</del><ins>+ Actions actionsForDefaultStylesheetFromDFARoot();
</ins><span class="cx">
</span><span class="cx"> private:
</span><span class="cx"> void interpretAppendAction(unsigned& programCounter, Actions&, bool ifDomain);
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderResourceLoadInfoh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/ResourceLoadInfo.h (184643 => 184644)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/ResourceLoadInfo.h        2015-05-20 17:39:11 UTC (rev 184643)
+++ trunk/Source/WebCore/loader/ResourceLoadInfo.h        2015-05-20 17:56:17 UTC (rev 184644)
</span><span class="lines">@@ -56,8 +56,10 @@
</span><span class="cx"> // The first 32 bits of a uint64_t action are used for the action location.
</span><span class="cx"> // The next 16 bits are used for the flags (ResourceType and LoadType).
</span><span class="cx"> // The next bit is used to mark actions that are from a rule with an if-domain condition.
</span><ins>+// The next bit is used to mark actions that in the default stylesheet.
</ins><span class="cx"> // The values -1 and -2 are used for removed and empty values in HashTables.
</span><span class="cx"> const uint64_t IfDomainFlag = 0x0001000000000000;
</span><ins>+const uint64_t DisplayNoneStyleSheetFlag = 0x0002000000000000;
</ins><span class="cx">
</span><span class="cx"> ResourceType toResourceType(CachedResource::Type);
</span><span class="cx"> uint16_t readResourceType(const String&);
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (184643 => 184644)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2015-05-20 17:39:11 UTC (rev 184643)
+++ trunk/Source/WebKit2/ChangeLog        2015-05-20 17:56:17 UTC (rev 184644)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2015-05-20 Alex Christensen <achristensen@webkit.org>
+
+ [Content Extensions] Relax restrictions on triggers that match everything.
+ https://bugs.webkit.org/show_bug.cgi?id=145069
+
+ Reviewed by Benjamin Poulain.
+
+ * UIProcess/API/APIUserContentExtensionStore.h:
+ Increment version number to reflect changes in DFABytecode.
+
</ins><span class="cx"> 2015-05-20 Sungmann Cho <sungmann.cho@navercorp.com>
</span><span class="cx">
</span><span class="cx"> Minor cleanups to PluginProcessProxy.
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIAPIUserContentExtensionStoreh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/APIUserContentExtensionStore.h (184643 => 184644)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/APIUserContentExtensionStore.h        2015-05-20 17:39:11 UTC (rev 184643)
+++ trunk/Source/WebKit2/UIProcess/API/APIUserContentExtensionStore.h        2015-05-20 17:56:17 UTC (rev 184644)
</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 = 2;
</del><ins>+ const static uint32_t CurrentContentExtensionFileVersion = 3;
</ins><span class="cx">
</span><span class="cx"> static UserContentExtensionStore& defaultStore();
</span><span class="cx">
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (184643 => 184644)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2015-05-20 17:39:11 UTC (rev 184643)
+++ trunk/Tools/ChangeLog        2015-05-20 17:56:17 UTC (rev 184644)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2015-05-20 Alex Christensen <achristensen@webkit.org>
+
+ [Content Extensions] Relax restrictions on triggers that match everything.
+ https://bugs.webkit.org/show_bug.cgi?id=145069
+
+ Reviewed by Benjamin Poulain.
+
+ * TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp:
+ (TestWebKitAPI::TEST_F):
+ Update and add tests for new possibilities with .*
+
</ins><span class="cx"> 2015-05-20 Rohit Kumar <kumar.rohit@samsung.com>
</span><span class="cx">
</span><span class="cx"> [EFL][Minibrowser] Hide URL bar on fullscreen mode for HTML elements and browser window in WebKit EFL Minibrowser
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebCoreContentExtensionscpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp (184643 => 184644)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp        2015-05-20 17:39:11 UTC (rev 184643)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp        2015-05-20 17:56:17 UTC (rev 184644)
</span><span class="lines">@@ -743,6 +743,37 @@
</span><span class="cx"> EXPECT_STREQ(compilerError.category().name(), expectedError.category().name());
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+TEST_F(ContentExtensionTest, MatchesEverything)
+{
+ // Only css-display-none rules with triggers that match everything, no domain rules, and no flags
+ // should go in the global display:none stylesheet. css-display-none rules with domain rules or flags
+ // are applied separately on pages where they apply.
+ auto backend1 = makeBackend("[{\"action\":{\"type\":\"css-display-none\",\"selector\":\".hidden\"},\"trigger\":{\"url-filter\":\".*\"}}]");
+ EXPECT_TRUE(nullptr != backend1.globalDisplayNoneStyleSheet(ASCIILiteral("testFilter")));
+ testRequest(backend1, mainDocumentRequest("http://webkit.org"), { }); // Selector is in global stylesheet.
+
+ auto backend2 = makeBackend("[{\"action\":{\"type\":\"css-display-none\",\"selector\":\".hidden\"},\"trigger\":{\"url-filter\":\".*\",\"if-domain\":[\"webkit.org\"]}}]");
+ EXPECT_EQ(nullptr, backend2.globalDisplayNoneStyleSheet(ASCIILiteral("testFilter")));
+ testRequest(backend2, mainDocumentRequest("http://webkit.org"), { ContentExtensions::ActionType::CSSDisplayNoneSelector });
+ testRequest(backend2, mainDocumentRequest("http://w3c.org"), { });
+
+ auto backend3 = makeBackend("[{\"action\":{\"type\":\"css-display-none\",\"selector\":\".hidden\"},\"trigger\":{\"url-filter\":\".*\",\"unless-domain\":[\"webkit.org\"]}}]");
+ EXPECT_EQ(nullptr, backend3.globalDisplayNoneStyleSheet(ASCIILiteral("testFilter")));
+ testRequest(backend3, mainDocumentRequest("http://webkit.org"), { });
+ testRequest(backend3, mainDocumentRequest("http://w3c.org"), { ContentExtensions::ActionType::CSSDisplayNoneSelector });
+
+ auto backend4 = makeBackend("[{\"action\":{\"type\":\"css-display-none\",\"selector\":\".hidden\"},\"trigger\":{\"url-filter\":\".*\",\"load-type\":[\"third-party\"]}}]");
+ EXPECT_EQ(nullptr, backend4.globalDisplayNoneStyleSheet(ASCIILiteral("testFilter")));
+ testRequest(backend4, mainDocumentRequest("http://webkit.org"), { });
+ testRequest(backend4, subResourceRequest("http://not_webkit.org", "http://webkit.org"), { ContentExtensions::ActionType::CSSDisplayNoneSelector });
+
+ // css-display-none rules after ignore-previous-rules should not be put in the default stylesheet.
+ auto backend5 = makeBackend("[{\"action\":{\"type\":\"ignore-previous-rules\"},\"trigger\":{\"url-filter\":\".*\"}},"
+ "{\"action\":{\"type\":\"css-display-none\",\"selector\":\".hidden\"},\"trigger\":{\"url-filter\":\".*\"}}]");
+ EXPECT_EQ(nullptr, backend5.globalDisplayNoneStyleSheet(ASCIILiteral("testFilter")));
+ testRequest(backend5, mainDocumentRequest("http://webkit.org"), { ContentExtensions::ActionType::CSSDisplayNoneSelector }, true);
+}
+
</ins><span class="cx"> TEST_F(ContentExtensionTest, InvalidJSON)
</span><span class="cx"> {
</span><span class="cx"> checkCompilerError("[", ContentExtensions::ContentExtensionError::JSONInvalid);
</span><span class="lines">@@ -803,10 +834,9 @@
</span><span class="cx"> ContentExtensions::ContentExtensionError::JSONInvalidCSSDisplayNoneActionType);
</span><span class="cx">
</span><span class="cx"> checkCompilerError("[{\"action\":{\"type\":\"ignore-previous-rules\"},\"trigger\":{\"url-filter\":\"webkit.org\"}},"
</span><del>- "{\"action\":{\"type\":\"css-display-none\",\"selector\":\".hidden\"},\"trigger\":{\"url-filter\":\".*\"}}]",
- ContentExtensions::ContentExtensionError::RegexMatchesEverythingAfterIgnorePreviousRules);
- checkCompilerError("[{\"action\":{\"type\":\"block\"},\"trigger\":{\"url-filter\":\".*\",\"if-domain\":[\"a\"]}}]", ContentExtensions::ContentExtensionError::RegexMatchesEverythingWithDomains);
- checkCompilerError("[{\"action\":{\"type\":\"block\"},\"trigger\":{\"url-filter\":\".*\",\"unless-domain\":[\"a\"]}}]", ContentExtensions::ContentExtensionError::RegexMatchesEverythingWithDomains);
</del><ins>+ "{\"action\":{\"type\":\"css-display-none\",\"selector\":\".hidden\"},\"trigger\":{\"url-filter\":\".*\"}}]", { });
+ checkCompilerError("[{\"action\":{\"type\":\"block\"},\"trigger\":{\"url-filter\":\".*\",\"if-domain\":[\"a\"]}}]", { });
+ checkCompilerError("[{\"action\":{\"type\":\"block\"},\"trigger\":{\"url-filter\":\".*\",\"unless-domain\":[\"a\"]}}]", { });
</ins><span class="cx"> checkCompilerError("[{\"action\":{\"type\":\"block\"},\"trigger\":{\"url-filter\":\"[\"}}]",
</span><span class="cx"> ContentExtensions::ContentExtensionError::JSONInvalidRegex);
</span><span class="cx"> }
</span></span></pre>
</div>
</div>
</body>
</html>