[Content Extensions] Cache actions with domains that match everything
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Jul 2015 00:12:13 +0000 (00:12 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Jul 2015 00:12:13 +0000 (00:12 +0000)
commit1ef6e15d2fce76ec3777401f385e28cec1e129b3
tree8db7d561f72ac7d2055981c53a5c02b12c70f965
parentcfe0e19eced385d756f0beac406b7fba0bc07c0f
[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 {"url-filter":".*","if-domain":["*webkit.org"]}
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:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@187049 268f45cc-cd09-0410-ab3c-d52691b4dbfc
16 files changed:
Source/WebCore/ChangeLog
Source/WebCore/contentextensions/CompiledContentExtension.cpp
Source/WebCore/contentextensions/CompiledContentExtension.h
Source/WebCore/contentextensions/ContentExtension.cpp
Source/WebCore/contentextensions/ContentExtension.h
Source/WebCore/contentextensions/ContentExtensionCompiler.cpp
Source/WebCore/contentextensions/ContentExtensionRule.cpp
Source/WebCore/contentextensions/ContentExtensionRule.h
Source/WebCore/contentextensions/ContentExtensionsBackend.cpp
Source/WebCore/contentextensions/DFABytecode.h
Source/WebCore/contentextensions/DFABytecodeCompiler.cpp
Source/WebCore/contentextensions/DFABytecodeInterpreter.cpp
Source/WebCore/contentextensions/DFABytecodeInterpreter.h
Source/WebCore/loader/ResourceLoadInfo.h
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/APIUserContentExtensionStore.h