haikuwebkit/Source/WebKit/Shared/WebCompiledContentRuleListD...

130 lines
4.7 KiB
C++
Raw Permalink Normal View History

[WK2] Start a prototype for declarative site specific extensions https://bugs.webkit.org/show_bug.cgi?id=140160 Reviewed by Andreas Kling. Source/WebCore: Currently, clients have various ways to execute custom code for certain URLs. Each of those mechanism implies messaging the UIProcess, executing some code calling back to the WebProcess, then actually load the resource. All this back and forth introduces delays before we actually load resources. Since the set of actions is done per site is actually simple and limited, it may be possible to do everything in WebCore and shortcut the defered loading. This patch provides the starting point for this idea. The "rules" (currently just blocking) are be passed to WebCore in a JSON format. In WebCore, we create a state machine to match the rules and we execute the action when the state machine tells us to. * WebCore.exp.in: * WebCore.xcodeproj/project.pbxproj: * contentextensions/ContentExtensionRule.cpp: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. (WebCore::ContentExtensions::ContentExtensionRule::ContentExtensionRule): * contentextensions/ContentExtensionRule.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. (WebCore::ContentExtensions::ContentExtensionRule::trigger): (WebCore::ContentExtensions::ContentExtensionRule::action): * contentextensions/ContentExtensionsBackend.cpp: Added. (WebCore::ContentExtensions::ContentExtensionsBackend::sharedInstance): (WebCore::ContentExtensions::ContentExtensionsBackend::setRuleList): (WebCore::ContentExtensions::ContentExtensionsBackend::removeRuleList): (WebCore::ContentExtensions::ContentExtensionsBackend::shouldBlockURL): * contentextensions/ContentExtensionsBackend.h: Added. * contentextensions/ContentExtensionsInterface.cpp: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. (WebCore::ContentExtensions::shouldBlockURL): * contentextensions/ContentExtensionsInterface.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. * contentextensions/ContentExtensionsManager.cpp: Added. (WebCore::ContentExtensions::ExtensionsManager::loadTrigger): (WebCore::ContentExtensions::ExtensionsManager::loadAction): (WebCore::ContentExtensions::ExtensionsManager::loadRule): (WebCore::ContentExtensions::ExtensionsManager::loadExtension): * contentextensions/ContentExtensionsManager.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. * contentextensions/DFA.cpp: Added. (WebCore::ContentExtensions::DFA::DFA): (WebCore::ContentExtensions::DFA::operator=): (WebCore::ContentExtensions::DFA::nextState): (WebCore::ContentExtensions::DFA::actions): (WebCore::ContentExtensions::DFA::debugPrintDot): * contentextensions/DFA.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. (WebCore::ContentExtensions::DFA::root): * contentextensions/DFANode.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. * contentextensions/NFA.cpp: Added. (WebCore::ContentExtensions::NFA::NFA): (WebCore::ContentExtensions::NFA::createNode): (WebCore::ContentExtensions::NFA::addTransition): (WebCore::ContentExtensions::NFA::addEpsilonTransition): (WebCore::ContentExtensions::NFA::setFinal): (WebCore::ContentExtensions::NFA::debugPrintDot): * contentextensions/NFA.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. (WebCore::ContentExtensions::NFA::root): * contentextensions/NFANode.cpp: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. (WebCore::ContentExtensions::NFANode::NFANode): * contentextensions/NFANode.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. * contentextensions/NFAToDFA.cpp: Added. (WebCore::ContentExtensions::epsilonClosure): (WebCore::ContentExtensions::setTransitionsExcludingEpsilon): (WebCore::ContentExtensions::HashableNodeIdSet::HashableNodeIdSet): (WebCore::ContentExtensions::HashableNodeIdSet::operator=): (WebCore::ContentExtensions::HashableNodeIdSet::isEmptyValue): (WebCore::ContentExtensions::HashableNodeIdSet::isDeletedValue): (WebCore::ContentExtensions::HashableNodeIdSet::nodeIdSet): (WebCore::ContentExtensions::HashableNodeIdSetHash::hash): (WebCore::ContentExtensions::HashableNodeIdSetHash::equal): (WebCore::ContentExtensions::addDFAState): (WebCore::ContentExtensions::NFAToDFA::convert): * contentextensions/NFAToDFA.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. * loader/cache/CachedResourceLoader.cpp: (WebCore::CachedResourceLoader::requestResource): Source/WebKit2: Provide a small SPI for OS X. This will likely move to a better place. * UIProcess/API/Cocoa/WKProcessPool.mm: (-[WKProcessPool _loadContentExtensionWithIdentifier:serializedRules:successCompletionHandler:errorCompletionHandler:]): * UIProcess/API/Cocoa/WKProcessPoolPrivate.h: * UIProcess/WebProcessPool.cpp: (WebKit::WebProcessPool::processDidFinishLaunching): (WebKit::WebProcessPool::loadContentExtension): * UIProcess/WebProcessPool.h: * WebProcess/WebProcess.cpp: (WebKit::WebProcess::loadContentExtension): * WebProcess/WebProcess.h: * WebProcess/WebProcess.messages.in: Source/WTF: * wtf/FeatureDefines.h: Canonical link: https://commits.webkit.org/158244@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@178151 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-01-09 01:56:00 +00:00
/*
Add initial experimental user content filtering API https://bugs.webkit.org/show_bug.cgi?id=140584 Reviewed by Benjamin Poulain. Source/WebCore: Change content extensions to be managed through the UserContentController. * WebCore.exp.in: Update exports. * WebCore.xcodeproj/project.pbxproj: Update for removed files. * contentextensions/ContentExtensionsBackend.cpp: (WebCore::ContentExtensions::ContentExtensionsBackend::removeAllRuleLists): (WebCore::ContentExtensions::ContentExtensionsBackend::sharedInstance): Deleted. * contentextensions/ContentExtensionsBackend.h: Remove concept of a shared instance and add a removeAllRuleLists() function. * contentextensions/ContentExtensionsInterface.cpp: Removed. * contentextensions/ContentExtensionsInterface.h: Removed. Since there is no shared instance anymore, checking if a URL should be blocked now has to go directly to the backend. * contentextensions/ContentExtensionsManager.cpp: (WebCore::ContentExtensions::ExtensionsManager::createRuleList): (WebCore::ContentExtensions::ExtensionsManager::loadExtension): Deleted. * contentextensions/ContentExtensionsManager.h: Update interface to accommodate the lack of a shared instance. Now, all this file does is take a serialized rule list and outputs the Vector of ContentExtensionRules * loader/cache/CachedResourceLoader.cpp: (WebCore::CachedResourceLoader::requestResource): Check with the UserContentController to see if the URL should be blocked. * page/UserContentController.cpp: (WebCore::UserContentController::addUserContentFilter): (WebCore::UserContentController::removeAllUserContentFilters): (WebCore::UserContentController::contentFilterBlocksURL): * page/UserContentController.h: Add single point of interaction for both the WebKit level to add and remove content filters and WebCore to check to see if URLs should be blocked. Source/WebKit2: Moves content filtering from being per-ProcessPool to per-UserContentController. * Shared/API/APIObject.h: * Shared/API/c/WKBase.h: * UIProcess/API/APIUserContentFilter.cpp: Added. (API::UserContentFilter::UserContentFilter): (API::UserContentFilter::~UserContentFilter): * UIProcess/API/APIUserContentFilter.h: Added. * UIProcess/API/C/WKAPICast.h: * UIProcess/API/C/WKUserContentFilterRef.cpp: Added. (WKUserContentFilterGetTypeID): (WKUserContentFilterCreate): * UIProcess/API/C/WKUserContentFilterRef.h: Added. * UIProcess/API/C/WebKit2_C.h: * UIProcess/API/Cocoa/_WKUserContentFilter.h: Added. * UIProcess/API/Cocoa/_WKUserContentFilter.mm: Added. (WKUserContentControllerAddUserContentFilter): (WKUserContentControllerRemoveAllUserContentFilters): (-[_WKUserContentFilter _initWithName:ruleList:]): * UIProcess/API/Cocoa/_WKUserContentFilterInternal.h: Added. Add a basic UserContentFilter type and expose it via both the Objective-C API (as _WKUserContentFilter) and via the C SPI (as WKUserContentFilterRef). * UIProcess/API/C/WKUserContentControllerRef.h: * UIProcess/API/C/WKUserContentControllerRef.cpp: Add C-SPI to set and remove WKUserContentFilterRefs. * UIProcess/API/Cocoa/WKProcessPool.mm: (-[WKProcessPool _loadContentExtensionWithIdentifier:serializedRules:successCompletionHandler:errorCompletionHandler:]): Deleted. * UIProcess/API/Cocoa/WKProcessPoolPrivate.h: * UIProcess/WebProcessPool.cpp: (WebKit::WebProcessPool::processDidFinishLaunching): (WebKit::WebProcessPool::loadContentExtension): Deleted. * UIProcess/WebProcessPool.h: * WebProcess/WebProcess.cpp: (WebKit::WebProcess::loadContentExtension): Deleted. * WebProcess/WebProcess.h: * WebProcess/WebProcess.messages.in: Remove the old SPI for loading content filters that was per-ProcessPool. Content filters now follow the same pattern as UserScripts and UserStyleSheets as being per-UserContentController. * UIProcess/API/Cocoa/WKUserContentController.mm: (-[WKUserContentController _addUserContentFilter:]): (-[WKUserContentController _removeAllUserContentFilters]): * UIProcess/API/Cocoa/WKUserContentControllerInternal.h: * UIProcess/API/Cocoa/WKUserContentControllerPrivate.h: Added. * UIProcess/UserContent/WebUserContentControllerProxy.cpp: (WebKit::WebUserContentControllerProxy::WebUserContentControllerProxy): (WebKit::WebUserContentControllerProxy::addProcess): (WebKit::WebUserContentControllerProxy::addUserContentFilter): (WebKit::WebUserContentControllerProxy::removeAllUserContentFilters): * UIProcess/UserContent/WebUserContentControllerProxy.h: * WebProcess/UserContent/WebUserContentController.cpp: (WebKit::WebUserContentController::addUserContentFilters): (WebKit::WebUserContentController::removeAllUserContentFilters): * WebProcess/UserContent/WebUserContentController.h: * WebProcess/UserContent/WebUserContentController.messages.in: Pipe user content filters over to all the WebProcesses that the UserContentController is connected to. * WebKit2.xcodeproj/project.pbxproj: Add new files. Canonical link: https://commits.webkit.org/158567@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@178634 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-01-18 21:54:12 +00:00
* Copyright (C) 2015 Apple Inc. All rights reserved.
[WK2] Start a prototype for declarative site specific extensions https://bugs.webkit.org/show_bug.cgi?id=140160 Reviewed by Andreas Kling. Source/WebCore: Currently, clients have various ways to execute custom code for certain URLs. Each of those mechanism implies messaging the UIProcess, executing some code calling back to the WebProcess, then actually load the resource. All this back and forth introduces delays before we actually load resources. Since the set of actions is done per site is actually simple and limited, it may be possible to do everything in WebCore and shortcut the defered loading. This patch provides the starting point for this idea. The "rules" (currently just blocking) are be passed to WebCore in a JSON format. In WebCore, we create a state machine to match the rules and we execute the action when the state machine tells us to. * WebCore.exp.in: * WebCore.xcodeproj/project.pbxproj: * contentextensions/ContentExtensionRule.cpp: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. (WebCore::ContentExtensions::ContentExtensionRule::ContentExtensionRule): * contentextensions/ContentExtensionRule.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. (WebCore::ContentExtensions::ContentExtensionRule::trigger): (WebCore::ContentExtensions::ContentExtensionRule::action): * contentextensions/ContentExtensionsBackend.cpp: Added. (WebCore::ContentExtensions::ContentExtensionsBackend::sharedInstance): (WebCore::ContentExtensions::ContentExtensionsBackend::setRuleList): (WebCore::ContentExtensions::ContentExtensionsBackend::removeRuleList): (WebCore::ContentExtensions::ContentExtensionsBackend::shouldBlockURL): * contentextensions/ContentExtensionsBackend.h: Added. * contentextensions/ContentExtensionsInterface.cpp: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. (WebCore::ContentExtensions::shouldBlockURL): * contentextensions/ContentExtensionsInterface.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. * contentextensions/ContentExtensionsManager.cpp: Added. (WebCore::ContentExtensions::ExtensionsManager::loadTrigger): (WebCore::ContentExtensions::ExtensionsManager::loadAction): (WebCore::ContentExtensions::ExtensionsManager::loadRule): (WebCore::ContentExtensions::ExtensionsManager::loadExtension): * contentextensions/ContentExtensionsManager.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. * contentextensions/DFA.cpp: Added. (WebCore::ContentExtensions::DFA::DFA): (WebCore::ContentExtensions::DFA::operator=): (WebCore::ContentExtensions::DFA::nextState): (WebCore::ContentExtensions::DFA::actions): (WebCore::ContentExtensions::DFA::debugPrintDot): * contentextensions/DFA.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. (WebCore::ContentExtensions::DFA::root): * contentextensions/DFANode.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. * contentextensions/NFA.cpp: Added. (WebCore::ContentExtensions::NFA::NFA): (WebCore::ContentExtensions::NFA::createNode): (WebCore::ContentExtensions::NFA::addTransition): (WebCore::ContentExtensions::NFA::addEpsilonTransition): (WebCore::ContentExtensions::NFA::setFinal): (WebCore::ContentExtensions::NFA::debugPrintDot): * contentextensions/NFA.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. (WebCore::ContentExtensions::NFA::root): * contentextensions/NFANode.cpp: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. (WebCore::ContentExtensions::NFANode::NFANode): * contentextensions/NFANode.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. * contentextensions/NFAToDFA.cpp: Added. (WebCore::ContentExtensions::epsilonClosure): (WebCore::ContentExtensions::setTransitionsExcludingEpsilon): (WebCore::ContentExtensions::HashableNodeIdSet::HashableNodeIdSet): (WebCore::ContentExtensions::HashableNodeIdSet::operator=): (WebCore::ContentExtensions::HashableNodeIdSet::isEmptyValue): (WebCore::ContentExtensions::HashableNodeIdSet::isDeletedValue): (WebCore::ContentExtensions::HashableNodeIdSet::nodeIdSet): (WebCore::ContentExtensions::HashableNodeIdSetHash::hash): (WebCore::ContentExtensions::HashableNodeIdSetHash::equal): (WebCore::ContentExtensions::addDFAState): (WebCore::ContentExtensions::NFAToDFA::convert): * contentextensions/NFAToDFA.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. * loader/cache/CachedResourceLoader.cpp: (WebCore::CachedResourceLoader::requestResource): Source/WebKit2: Provide a small SPI for OS X. This will likely move to a better place. * UIProcess/API/Cocoa/WKProcessPool.mm: (-[WKProcessPool _loadContentExtensionWithIdentifier:serializedRules:successCompletionHandler:errorCompletionHandler:]): * UIProcess/API/Cocoa/WKProcessPoolPrivate.h: * UIProcess/WebProcessPool.cpp: (WebKit::WebProcessPool::processDidFinishLaunching): (WebKit::WebProcessPool::loadContentExtension): * UIProcess/WebProcessPool.h: * WebProcess/WebProcess.cpp: (WebKit::WebProcess::loadContentExtension): * WebProcess/WebProcess.h: * WebProcess/WebProcess.messages.in: Source/WTF: * wtf/FeatureDefines.h: Canonical link: https://commits.webkit.org/158244@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@178151 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-01-09 01:56:00 +00:00
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
Rename WKContentExtension to WKContentRuleList https://bugs.webkit.org/show_bug.cgi?id=172053 <rdar://problem/32141005> Reviewed by Geoffrey Garen. Source/WebCore: Covered by existing API tests. * English.lproj/Localizable.strings: Source/WebKit2: * Shared/API/APIObject.h: * Shared/API/Cocoa/WebKit.h: * Shared/API/c/WKDeprecatedFunctions.cpp: (WKPageGroupAddUserContentFilter): (WKPageGroupRemoveUserContentFilter): * Shared/Cocoa/APIObject.mm: (API::Object::newObject): * Shared/WebCompiledContentExtension.cpp: Removed. * Shared/WebCompiledContentExtension.h: Removed. * Shared/WebCompiledContentExtensionData.cpp: Removed. * Shared/WebCompiledContentExtensionData.h: Removed. * Shared/WebCompiledContentRuleList.cpp: Copied from Source/WebKit2/Shared/WebCompiledContentExtension.cpp. (WebKit::WebCompiledContentRuleList::create): (WebKit::WebCompiledContentRuleList::WebCompiledContentRuleList): (WebKit::WebCompiledContentRuleList::~WebCompiledContentRuleList): (WebKit::WebCompiledContentRuleList::conditionsApplyOnlyToDomain): (WebKit::WebCompiledContentRuleList::filtersWithoutConditionsBytecode): (WebKit::WebCompiledContentRuleList::filtersWithoutConditionsBytecodeLength): (WebKit::WebCompiledContentRuleList::filtersWithConditionsBytecode): (WebKit::WebCompiledContentRuleList::filtersWithConditionsBytecodeLength): (WebKit::WebCompiledContentRuleList::topURLFiltersBytecode): (WebKit::WebCompiledContentRuleList::topURLFiltersBytecodeLength): (WebKit::WebCompiledContentRuleList::actions): (WebKit::WebCompiledContentRuleList::actionsLength): (WebKit::WebCompiledContentExtension::create): Deleted. (WebKit::WebCompiledContentExtension::WebCompiledContentExtension): Deleted. (WebKit::WebCompiledContentExtension::~WebCompiledContentExtension): Deleted. (WebKit::WebCompiledContentExtension::conditionsApplyOnlyToDomain): Deleted. (WebKit::WebCompiledContentExtension::filtersWithoutConditionsBytecode): Deleted. (WebKit::WebCompiledContentExtension::filtersWithoutConditionsBytecodeLength): Deleted. (WebKit::WebCompiledContentExtension::filtersWithConditionsBytecode): Deleted. (WebKit::WebCompiledContentExtension::filtersWithConditionsBytecodeLength): Deleted. (WebKit::WebCompiledContentExtension::topURLFiltersBytecode): Deleted. (WebKit::WebCompiledContentExtension::topURLFiltersBytecodeLength): Deleted. (WebKit::WebCompiledContentExtension::actions): Deleted. (WebKit::WebCompiledContentExtension::actionsLength): Deleted. * Shared/WebCompiledContentRuleList.h: Copied from Source/WebKit2/Shared/WebCompiledContentExtension.h. * Shared/WebCompiledContentRuleListData.cpp: Copied from Source/WebKit2/Shared/WebCompiledContentExtensionData.cpp. (WebKit::WebCompiledContentRuleListData::encode): (WebKit::WebCompiledContentRuleListData::decode): (WebKit::WebCompiledContentExtensionData::encode): Deleted. (WebKit::WebCompiledContentExtensionData::decode): Deleted. * Shared/WebCompiledContentRuleListData.h: Copied from Source/WebKit2/Shared/WebCompiledContentExtensionData.h. (WebKit::WebCompiledContentRuleListData::WebCompiledContentRuleListData): (WebKit::WebCompiledContentExtensionData::WebCompiledContentExtensionData): Deleted. * Shared/WebPageCreationParameters.cpp: (WebKit::WebPageCreationParameters::encode): (WebKit::WebPageCreationParameters::decode): * Shared/WebPageCreationParameters.h: * UIProcess/API/APIContentExtension.cpp: Removed. * UIProcess/API/APIContentExtension.h: Removed. * UIProcess/API/APIContentExtensionStore.cpp: Removed. * UIProcess/API/APIContentExtensionStore.h: Removed. * UIProcess/API/APIContentRuleList.cpp: Copied from Source/WebKit2/UIProcess/API/APIContentExtension.cpp. (API::ContentRuleList::ContentRuleList): (API::ContentRuleList::~ContentRuleList): (API::ContentExtension::ContentExtension): Deleted. (API::ContentExtension::~ContentExtension): Deleted. * UIProcess/API/APIContentRuleList.h: Copied from Source/WebKit2/UIProcess/API/APIContentExtension.h. * UIProcess/API/APIContentRuleListStore.cpp: Copied from Source/WebKit2/UIProcess/API/APIContentExtensionStore.cpp. (API::ContentRuleListStore::legacyDefaultStore): (API::ContentRuleListStore::nonLegacyDdefaultStore): (API::ContentRuleListStore::defaultStore): (API::ContentRuleListStore::storeWithPath): (API::ContentRuleListStore::ContentRuleListStore): (API::ContentRuleListStore::~ContentRuleListStore): (API::constructedPathPrefix): (API::ContentRuleListMetaData::fileSize): (API::encodeContentRuleListMetaData): (API::decodeContentRuleListMetaData): (API::openAndMapContentRuleList): (API::compiledToFile): (API::createExtension): (API::ContentRuleListStore::lookupContentRuleList): (API::ContentRuleListStore::getAvailableContentRuleListIdentifiers): (API::ContentRuleListStore::compileContentRuleList): (API::ContentRuleListStore::removeContentRuleList): (API::ContentRuleListStore::synchronousRemoveAllContentRuleLists): (API::ContentRuleListStore::invalidateContentRuleListVersion): (API::ContentRuleListStore::getContentRuleListSource): (API::contentRuleListStoreErrorCategory): (API::ContentExtensionStore::defaultStore): Deleted. (API::ContentExtensionStore::storeWithPath): Deleted. (API::ContentExtensionStore::ContentExtensionStore): Deleted. (API::ContentExtensionStore::~ContentExtensionStore): Deleted. (API::ContentExtensionMetaData::fileSize): Deleted. (API::encodeContentExtensionMetaData): Deleted. (API::decodeContentExtensionMetaData): Deleted. (API::openAndMapContentExtension): Deleted. (API::ContentExtensionStore::lookupContentExtension): Deleted. (API::ContentExtensionStore::getAvailableContentExtensionIdentifiers): Deleted. (API::ContentExtensionStore::compileContentExtension): Deleted. (API::ContentExtensionStore::removeContentExtension): Deleted. (API::ContentExtensionStore::synchronousRemoveAllContentExtensions): Deleted. (API::ContentExtensionStore::invalidateContentExtensionVersion): Deleted. (API::ContentExtensionStore::getContentExtensionSource): Deleted. (API::contentExtensionStoreErrorCategory): Deleted. * UIProcess/API/APIContentRuleListStore.h: Copied from Source/WebKit2/UIProcess/API/APIContentExtensionStore.h. (API::make_error_code): * UIProcess/API/C/WKAPICast.h: * UIProcess/API/C/WKPageGroup.cpp: * UIProcess/API/C/WKUserContentControllerRef.cpp: (WKUserContentControllerAddUserContentFilter): (WKUserContentControllerRemoveAllUserContentFilters): * UIProcess/API/C/WKUserContentExtensionStoreRef.cpp: (WKUserContentExtensionStoreGetTypeID): * UIProcess/API/Cocoa/APIUserContentExtensionStoreCocoa.mm: (API::ContentRuleListStore::defaultStorePath): (API::ContentExtensionStore::defaultStorePath): Deleted. * UIProcess/API/Cocoa/WKContentExtension.h: Removed. * UIProcess/API/Cocoa/WKContentExtension.mm: Removed. * UIProcess/API/Cocoa/WKContentExtensionInternal.h: Removed. * UIProcess/API/Cocoa/WKContentExtensionStore.h: Removed. * UIProcess/API/Cocoa/WKContentExtensionStore.mm: Removed. * UIProcess/API/Cocoa/WKContentExtensionStoreInternal.h: Removed. * UIProcess/API/Cocoa/WKContentExtensionStorePrivate.h: Removed. * UIProcess/API/Cocoa/WKContentRuleList.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKContentExtension.h. * UIProcess/API/Cocoa/WKContentRuleList.mm: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKContentExtension.mm. (-[WKContentRuleList dealloc]): (-[WKContentRuleList _apiObject]): (-[WKContentRuleList identifier]): (-[WKContentExtension dealloc]): Deleted. (-[WKContentExtension _apiObject]): Deleted. (-[WKContentExtension identifier]): Deleted. * UIProcess/API/Cocoa/WKContentRuleListInternal.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKContentExtensionInternal.h. (WebKit::wrapper): * UIProcess/API/Cocoa/WKContentRuleListStore.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKContentExtensionStore.h. * UIProcess/API/Cocoa/WKContentRuleListStore.mm: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKContentExtensionStore.mm. (toWKErrorCode): (-[WKContentRuleListStore dealloc]): (+[WKContentRuleListStore defaultStore]): (+[WKContentRuleListStore storeWithURL:]): (-[WKContentRuleListStore compileContentRuleListForIdentifier:encodedContentRuleList:completionHandler:]): (-[WKContentRuleListStore _compileContentRuleListForIdentifier:encodedContentRuleList:completionHandler:releasesArgument:]): (-[WKContentRuleListStore lookUpContentRuleListForIdentifier:completionHandler:]): (-[WKContentRuleListStore getAvailableContentRuleListIdentifiers:]): (-[WKContentRuleListStore removeContentRuleListForIdentifier:completionHandler:]): (-[WKContentRuleListStore _apiObject]): (-[WKContentRuleListStore _removeAllContentRuleLists]): (-[WKContentRuleListStore _invalidateContentRuleListVersionForIdentifier:]): (-[WKContentRuleListStore _getContentRuleListSourceForIdentifier:completionHandler:]): (-[WKContentRuleListStore _compileContentRuleListForIdentifier:encodedContentRuleList:completionHandler:]): (-[WKContentExtensionStore dealloc]): Deleted. (+[WKContentExtensionStore defaultStore]): Deleted. (+[WKContentExtensionStore storeWithURL:]): Deleted. (-[WKContentExtensionStore compileContentExtensionForIdentifier:encodedContentExtension:completionHandler:]): Deleted. (-[WKContentExtensionStore _compileContentExtensionForIdentifier:encodedContentExtension:completionHandler:releasesArgument:]): Deleted. (-[WKContentExtensionStore lookUpContentExtensionForIdentifier:completionHandler:]): Deleted. (-[WKContentExtensionStore getAvailableContentExtensionIdentifiers:]): Deleted. (-[WKContentExtensionStore removeContentExtensionForIdentifier:completionHandler:]): Deleted. (-[WKContentExtensionStore _apiObject]): Deleted. (-[WKContentExtensionStore _removeAllContentExtensions]): Deleted. (-[WKContentExtensionStore _invalidateContentExtensionVersionForIdentifier:]): Deleted. (-[WKContentExtensionStore _getContentExtensionSourceForIdentifier:completionHandler:]): Deleted. (-[WKContentExtensionStore _compileContentExtensionForIdentifier:encodedContentExtension:completionHandler:]): Deleted. * UIProcess/API/Cocoa/WKContentRuleListStoreInternal.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKContentExtensionStoreInternal.h. (WebKit::wrapper): * UIProcess/API/Cocoa/WKContentRuleListStorePrivate.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKContentExtensionStorePrivate.h. * UIProcess/API/Cocoa/WKError.h: * UIProcess/API/Cocoa/WKError.mm: (localizedDescriptionForErrorCode): * UIProcess/API/Cocoa/WKUserContentController.h: * UIProcess/API/Cocoa/WKUserContentController.mm: (-[WKUserContentController addContentRuleList:]): (-[WKUserContentController removeContentRuleList:]): (-[WKUserContentController removeAllContentRuleLists]): (-[WKUserContentController _addUserContentFilter:]): (-[WKUserContentController _removeUserContentFilter:]): (-[WKUserContentController _removeAllUserContentFilters]): (-[WKUserContentController addContentExtension:]): Deleted. (-[WKUserContentController removeContentExtension:]): Deleted. (-[WKUserContentController removeAllContentExtensions]): Deleted. * UIProcess/API/Cocoa/_WKUserContentExtensionStore.mm: (toUserContentRuleListStoreError): (+[_WKUserContentExtensionStore defaultStore]): (+[_WKUserContentExtensionStore storeWithURL:]): (-[_WKUserContentExtensionStore compileContentExtensionForIdentifier:encodedContentExtension:completionHandler:]): (-[_WKUserContentExtensionStore lookupContentExtensionForIdentifier:completionHandler:]): (-[_WKUserContentExtensionStore removeContentExtensionForIdentifier:completionHandler:]): (-[_WKUserContentExtensionStore _apiObject]): (-[_WKUserContentExtensionStore _removeAllContentExtensions]): (-[_WKUserContentExtensionStore _invalidateContentExtensionVersionForIdentifier:]): (-[_WKUserContentExtensionStore _initWithWKContentRuleListStore:]): (toUserContentExtensionStoreError): Deleted. (-[_WKUserContentExtensionStore _initWithWKContentExtensionStore:]): Deleted. * UIProcess/API/Cocoa/_WKUserContentExtensionStoreInternal.h: * UIProcess/API/Cocoa/_WKUserContentExtensionStorePrivate.h: * UIProcess/API/Cocoa/_WKUserContentFilter.mm: (-[_WKUserContentFilter _apiObject]): (-[_WKUserContentFilter _initWithWKContentRuleList:]): (-[_WKUserContentFilter _initWithWKContentExtension:]): Deleted. * UIProcess/API/Cocoa/_WKUserContentFilterInternal.h: * UIProcess/API/Cocoa/_WKUserContentFilterPrivate.h: * UIProcess/UserContent/WebUserContentControllerProxy.cpp: (WebKit::WebUserContentControllerProxy::addProcess): (WebKit::WebUserContentControllerProxy::addContentRuleList): (WebKit::WebUserContentControllerProxy::removeContentRuleList): (WebKit::WebUserContentControllerProxy::removeAllContentRuleLists): (WebKit::WebUserContentControllerProxy::addContentExtension): Deleted. (WebKit::WebUserContentControllerProxy::removeContentExtension): Deleted. (WebKit::WebUserContentControllerProxy::removeAllContentExtensions): Deleted. * UIProcess/UserContent/WebUserContentControllerProxy.h: * UIProcess/WebPageGroup.cpp: * WebKit2.xcodeproj/project.pbxproj: * WebProcess/UserContent/WebUserContentController.cpp: (WebKit::WebUserContentController::addContentRuleLists): (WebKit::WebUserContentController::removeContentRuleList): (WebKit::WebUserContentController::removeAllContentRuleLists): (WebKit::WebUserContentController::addContentExtensions): Deleted. (WebKit::WebUserContentController::removeContentExtension): Deleted. (WebKit::WebUserContentController::removeAllContentExtensions): Deleted. * WebProcess/UserContent/WebUserContentController.h: * WebProcess/UserContent/WebUserContentController.messages.in: * WebProcess/WebPage/WebPage.cpp: (WebKit::m_backgroundCPULimit): Tools: * TestWebKitAPI/Tests/WebKit2Cocoa/WKContentExtensionStore.mm: (WKContentRuleListStoreTest::SetUp): (TEST_F): (-[ContentRuleListDelegate webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:]): (WKContentExtensionStoreTest::SetUp): Deleted. (-[ContentExtensionDelegate webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:]): Deleted. Canonical link: https://commits.webkit.org/189003@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@216809 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-05-13 01:33:13 +00:00
#include "WebCompiledContentRuleListData.h"
[WK2] Start a prototype for declarative site specific extensions https://bugs.webkit.org/show_bug.cgi?id=140160 Reviewed by Andreas Kling. Source/WebCore: Currently, clients have various ways to execute custom code for certain URLs. Each of those mechanism implies messaging the UIProcess, executing some code calling back to the WebProcess, then actually load the resource. All this back and forth introduces delays before we actually load resources. Since the set of actions is done per site is actually simple and limited, it may be possible to do everything in WebCore and shortcut the defered loading. This patch provides the starting point for this idea. The "rules" (currently just blocking) are be passed to WebCore in a JSON format. In WebCore, we create a state machine to match the rules and we execute the action when the state machine tells us to. * WebCore.exp.in: * WebCore.xcodeproj/project.pbxproj: * contentextensions/ContentExtensionRule.cpp: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. (WebCore::ContentExtensions::ContentExtensionRule::ContentExtensionRule): * contentextensions/ContentExtensionRule.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. (WebCore::ContentExtensions::ContentExtensionRule::trigger): (WebCore::ContentExtensions::ContentExtensionRule::action): * contentextensions/ContentExtensionsBackend.cpp: Added. (WebCore::ContentExtensions::ContentExtensionsBackend::sharedInstance): (WebCore::ContentExtensions::ContentExtensionsBackend::setRuleList): (WebCore::ContentExtensions::ContentExtensionsBackend::removeRuleList): (WebCore::ContentExtensions::ContentExtensionsBackend::shouldBlockURL): * contentextensions/ContentExtensionsBackend.h: Added. * contentextensions/ContentExtensionsInterface.cpp: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. (WebCore::ContentExtensions::shouldBlockURL): * contentextensions/ContentExtensionsInterface.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. * contentextensions/ContentExtensionsManager.cpp: Added. (WebCore::ContentExtensions::ExtensionsManager::loadTrigger): (WebCore::ContentExtensions::ExtensionsManager::loadAction): (WebCore::ContentExtensions::ExtensionsManager::loadRule): (WebCore::ContentExtensions::ExtensionsManager::loadExtension): * contentextensions/ContentExtensionsManager.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. * contentextensions/DFA.cpp: Added. (WebCore::ContentExtensions::DFA::DFA): (WebCore::ContentExtensions::DFA::operator=): (WebCore::ContentExtensions::DFA::nextState): (WebCore::ContentExtensions::DFA::actions): (WebCore::ContentExtensions::DFA::debugPrintDot): * contentextensions/DFA.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. (WebCore::ContentExtensions::DFA::root): * contentextensions/DFANode.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. * contentextensions/NFA.cpp: Added. (WebCore::ContentExtensions::NFA::NFA): (WebCore::ContentExtensions::NFA::createNode): (WebCore::ContentExtensions::NFA::addTransition): (WebCore::ContentExtensions::NFA::addEpsilonTransition): (WebCore::ContentExtensions::NFA::setFinal): (WebCore::ContentExtensions::NFA::debugPrintDot): * contentextensions/NFA.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. (WebCore::ContentExtensions::NFA::root): * contentextensions/NFANode.cpp: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. (WebCore::ContentExtensions::NFANode::NFANode): * contentextensions/NFANode.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. * contentextensions/NFAToDFA.cpp: Added. (WebCore::ContentExtensions::epsilonClosure): (WebCore::ContentExtensions::setTransitionsExcludingEpsilon): (WebCore::ContentExtensions::HashableNodeIdSet::HashableNodeIdSet): (WebCore::ContentExtensions::HashableNodeIdSet::operator=): (WebCore::ContentExtensions::HashableNodeIdSet::isEmptyValue): (WebCore::ContentExtensions::HashableNodeIdSet::isDeletedValue): (WebCore::ContentExtensions::HashableNodeIdSet::nodeIdSet): (WebCore::ContentExtensions::HashableNodeIdSetHash::hash): (WebCore::ContentExtensions::HashableNodeIdSetHash::equal): (WebCore::ContentExtensions::addDFAState): (WebCore::ContentExtensions::NFAToDFA::convert): * contentextensions/NFAToDFA.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. * loader/cache/CachedResourceLoader.cpp: (WebCore::CachedResourceLoader::requestResource): Source/WebKit2: Provide a small SPI for OS X. This will likely move to a better place. * UIProcess/API/Cocoa/WKProcessPool.mm: (-[WKProcessPool _loadContentExtensionWithIdentifier:serializedRules:successCompletionHandler:errorCompletionHandler:]): * UIProcess/API/Cocoa/WKProcessPoolPrivate.h: * UIProcess/WebProcessPool.cpp: (WebKit::WebProcessPool::processDidFinishLaunching): (WebKit::WebProcessPool::loadContentExtension): * UIProcess/WebProcessPool.h: * WebProcess/WebProcess.cpp: (WebKit::WebProcess::loadContentExtension): * WebProcess/WebProcess.h: * WebProcess/WebProcess.messages.in: Source/WTF: * wtf/FeatureDefines.h: Canonical link: https://commits.webkit.org/158244@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@178151 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-01-09 01:56:00 +00:00
[Content Extensions] Move compiling of content extensions to the UIProcess https://bugs.webkit.org/show_bug.cgi?id=142402 Reviewed by Benjamin Poulain. Source/WebCore: * contentextensions/CompiledContentExtension.cpp: (WebCore::ContentExtensions::CompiledContentExtension::~CompiledContentExtension): (WebCore::ContentExtensions::CompiledContentExtension::create): Deleted. (WebCore::ContentExtensions::CompiledContentExtension::CompiledContentExtension): Deleted. * contentextensions/CompiledContentExtension.h: (WebCore::ContentExtensions::CompiledContentExtension::bytecode): Deleted. (WebCore::ContentExtensions::CompiledContentExtension::actions): Deleted. Convert CompiledContentExtension to be an abstract base class so that we can back it however we like at the WebKit level. Since it doesn't necessarily use Vectors for its backing store any more, change the interface to use pointer/length. * contentextensions/ContentExtensionCompiler.cpp: (WebCore::ContentExtensions::compileRuleList): * contentextensions/ContentExtensionCompiler.h: Change compileRuleList to return compiled result as the raw Vectors rather than as a CompiledContentExtension, since that class is now abstract. It is up to the caller to copy the data into its final home. * contentextensions/ContentExtensionRule.cpp: (WebCore::ContentExtensions::Action::deserialize): * contentextensions/ContentExtensionRule.h: Switch Action::deserialize to take pointer/length rather than a Vector. * contentextensions/ContentExtensionsBackend.cpp: (WebCore::ContentExtensions::ContentExtensionsBackend::actionsForURL): Pull getting the serialized actions from the compiled extension out of the loop to avoid calling the virtual function multiple times. Pass the bytecode and actions as pointer/length pairs rather than Vectors. * contentextensions/DFABytecodeInterpreter.cpp: (WebCore::ContentExtensions::getBits): (WebCore::ContentExtensions::DFABytecodeInterpreter::interpret): * contentextensions/DFABytecodeInterpreter.h: (WebCore::ContentExtensions::DFABytecodeInterpreter::DFABytecodeInterpreter): Switch the interpreter to take pointer/length rather than a Vector. * page/UserContentController.cpp: (WebCore::UserContentController::addUserContentExtension): (WebCore::UserContentController::removeUserContentExtension): (WebCore::UserContentController::removeAllUserContentExtensions): (WebCore::UserContentController::addUserContentFilter): Deleted. (WebCore::UserContentController::removeUserContentFilter): Deleted. (WebCore::UserContentController::removeAllUserContentFilters): Deleted. * page/UserContentController.h: Unify terminology to use the term UserContentExtension rather than UserContentFilter. Source/WebKit2: * Shared/API/APIObject.h: Rename UserContentFilter type to UserContentExtension to match new unified naming. * Shared/WebCompiledContentExtension.cpp: Added. (WebKit::WebCompiledContentExtension::create): (WebKit::WebCompiledContentExtension::WebCompiledContentExtension): (WebKit::WebCompiledContentExtension::~WebCompiledContentExtension): (WebKit::WebCompiledContentExtension::bytecode): (WebKit::WebCompiledContentExtension::bytecodeLength): (WebKit::WebCompiledContentExtension::actions): (WebKit::WebCompiledContentExtension::actionsLength): * Shared/WebCompiledContentExtension.h: Added. Add new WebKit2 implementation of CompiledContentExtension. Right now it is the same as the old WebCore based CompiledContentExtension, but in subsequent patches, it will use shared/file backed memory. * Shared/WebCompiledContentExtensionData.cpp: Added. (WebKit::WebCompiledContentExtensionData::encode): (WebKit::WebCompiledContentExtensionData::decode): * Shared/WebCompiledContentExtensionData.h: Added. Add encodable/decodable holder for the compiled content extension data for use in IPC. Right now it is doing the naive thing and always copying the data, but in subsequent patches, it will use shared/file backed memory. * Shared/WebPageGroupData.cpp: (WebKit::WebPageGroupData::encode): (WebKit::WebPageGroupData::decode): * Shared/WebPageGroupData.h: Rename member to match new unification on the name userContentExtension. Change the value from the serialized JSON (as a String) to WebCompiledContentExtensionData. * UIProcess/API/APIUserContentExtension.cpp: Copied from Source/WebKit2/UIProcess/API/APIUserContentFilter.cpp. (API::UserContentExtension::UserContentExtension): (API::UserContentExtension::~UserContentExtension): (API::UserContentFilter::UserContentFilter): Deleted. (API::UserContentFilter::~UserContentFilter): Deleted. * UIProcess/API/APIUserContentExtension.h: Copied from Source/WebKit2/UIProcess/API/APIUserContentFilter.h. * UIProcess/API/APIUserContentFilter.cpp: Removed. * UIProcess/API/APIUserContentFilter.h: Removed. Renamed UserContentFilter to APIUserContentExtension. Updated to store the compiled extension (as a WebCompiledContentExtension) rather than the serialized JSON. * UIProcess/API/C/WKAPICast.h: * UIProcess/API/C/WKPageGroup.cpp: (WKPageGroupAddUserContentFilter): (WKPageGroupRemoveUserContentFilter): (WKPageGroupRemoveAllUserContentFilters): * UIProcess/API/C/WKUserContentControllerRef.cpp: (WKUserContentControllerAddUserContentFilter): (WKUserContentControllerRemoveAllUserContentFilters): * UIProcess/API/Cocoa/WKUserContentController.mm: (-[WKUserContentController _addUserContentFilter:]): (-[WKUserContentController _removeUserContentFilter:]): (-[WKUserContentController _removeAllUserContentFilters]): Update for rename of APIUserContentFilter -> UserContentExtension. * UIProcess/API/C/WKUserContentFilterRef.cpp: (WKUserContentFilterGetTypeID): (WKUserContentFilterCreate): Update for rename of APIUserContentFilter -> UserContentExtension. Also make WKUserContentFilterCreate eagerly compile rule list to a WebCompiledContentExtensionData. * UIProcess/API/Cocoa/_WKUserContentFilter.mm: (-[_WKUserContentFilter initWithName:serializedRules:]): (-[_WKUserContentFilter dealloc]): (-[_WKUserContentFilter _apiObject]): Update for rename of APIUserContentFilter -> UserContentExtension. Also make initWithName:serializedRules: eagerly compile rule list to a WebCompiledContentExtensionData. * UIProcess/API/Cocoa/_WKUserContentFilterInternal.h: (WebKit::wrapper): Update for rename of APIUserContentFilter -> UserContentExtension. * UIProcess/UserContent/WebUserContentControllerProxy.cpp: (WebKit::WebUserContentControllerProxy::addProcess): (WebKit::WebUserContentControllerProxy::addUserContentExtension): (WebKit::WebUserContentControllerProxy::removeUserContentExtension): (WebKit::WebUserContentControllerProxy::removeAllUserContentExtensions): (WebKit::WebUserContentControllerProxy::addUserContentFilter): Deleted. (WebKit::WebUserContentControllerProxy::removeUserContentFilter): Deleted. (WebKit::WebUserContentControllerProxy::removeAllUserContentFilters): Deleted. * UIProcess/UserContent/WebUserContentControllerProxy.h: * UIProcess/WebPageGroup.cpp: (WebKit::WebPageGroup::addUserContentExtension): (WebKit::WebPageGroup::removeUserContentExtension): (WebKit::WebPageGroup::removeAllUserContentExtensions): (WebKit::WebPageGroup::addUserContentFilter): Deleted. (WebKit::WebPageGroup::removeUserContentFilter): Deleted. (WebKit::WebPageGroup::removeAllUserContentFilters): Deleted. * UIProcess/WebPageGroup.h: * WebKit2.xcodeproj/project.pbxproj: * WebProcess/UserContent/WebUserContentController.cpp: (WebKit::WebUserContentController::addUserContentExtensions): (WebKit::WebUserContentController::removeUserContentExtension): (WebKit::WebUserContentController::removeAllUserContentExtensions): (WebKit::WebUserContentController::addUserContentFilters): Deleted. (WebKit::WebUserContentController::removeUserContentFilter): Deleted. (WebKit::WebUserContentController::removeAllUserContentFilters): Deleted. * WebProcess/UserContent/WebUserContentController.h: * WebProcess/UserContent/WebUserContentController.messages.in: * WebProcess/WebPage/WebPageGroupProxy.cpp: (WebKit::WebPageGroupProxy::WebPageGroupProxy): (WebKit::WebPageGroupProxy::addUserContentExtension): (WebKit::WebPageGroupProxy::removeUserContentExtension): (WebKit::WebPageGroupProxy::removeAllUserContentExtensions): (WebKit::WebPageGroupProxy::addUserContentFilter): Deleted. (WebKit::WebPageGroupProxy::removeUserContentFilter): Deleted. (WebKit::WebPageGroupProxy::removeAllUserContentFilters): Deleted. * WebProcess/WebPage/WebPageGroupProxy.h: * WebProcess/WebPage/WebPageGroupProxy.messages.in: Pipe the compiled extension from the UIProcess to the WebProcess. Tools: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp: Copied from Tools/TestWebKitAPI/Tests/WebCore/ContentFilter.cpp. (TestWebKitAPI::InMemoryCompiledContentExtension::create): (TestWebKitAPI::InMemoryCompiledContentExtension::~InMemoryCompiledContentExtension): (TestWebKitAPI::InMemoryCompiledContentExtension::InMemoryCompiledContentExtension): (TestWebKitAPI::TEST_F): * TestWebKitAPI/Tests/WebCore/ContentFilter.cpp: Removed. Update test for new name (ContentFilter -> ContentExtensions) and API (CompiledContentExtension is now abstract). Canonical link: https://commits.webkit.org/160480@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@181200 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-03-07 02:41:44 +00:00
#if ENABLE(CONTENT_EXTENSIONS)
[WK2] Start a prototype for declarative site specific extensions https://bugs.webkit.org/show_bug.cgi?id=140160 Reviewed by Andreas Kling. Source/WebCore: Currently, clients have various ways to execute custom code for certain URLs. Each of those mechanism implies messaging the UIProcess, executing some code calling back to the WebProcess, then actually load the resource. All this back and forth introduces delays before we actually load resources. Since the set of actions is done per site is actually simple and limited, it may be possible to do everything in WebCore and shortcut the defered loading. This patch provides the starting point for this idea. The "rules" (currently just blocking) are be passed to WebCore in a JSON format. In WebCore, we create a state machine to match the rules and we execute the action when the state machine tells us to. * WebCore.exp.in: * WebCore.xcodeproj/project.pbxproj: * contentextensions/ContentExtensionRule.cpp: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. (WebCore::ContentExtensions::ContentExtensionRule::ContentExtensionRule): * contentextensions/ContentExtensionRule.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. (WebCore::ContentExtensions::ContentExtensionRule::trigger): (WebCore::ContentExtensions::ContentExtensionRule::action): * contentextensions/ContentExtensionsBackend.cpp: Added. (WebCore::ContentExtensions::ContentExtensionsBackend::sharedInstance): (WebCore::ContentExtensions::ContentExtensionsBackend::setRuleList): (WebCore::ContentExtensions::ContentExtensionsBackend::removeRuleList): (WebCore::ContentExtensions::ContentExtensionsBackend::shouldBlockURL): * contentextensions/ContentExtensionsBackend.h: Added. * contentextensions/ContentExtensionsInterface.cpp: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. (WebCore::ContentExtensions::shouldBlockURL): * contentextensions/ContentExtensionsInterface.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. * contentextensions/ContentExtensionsManager.cpp: Added. (WebCore::ContentExtensions::ExtensionsManager::loadTrigger): (WebCore::ContentExtensions::ExtensionsManager::loadAction): (WebCore::ContentExtensions::ExtensionsManager::loadRule): (WebCore::ContentExtensions::ExtensionsManager::loadExtension): * contentextensions/ContentExtensionsManager.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. * contentextensions/DFA.cpp: Added. (WebCore::ContentExtensions::DFA::DFA): (WebCore::ContentExtensions::DFA::operator=): (WebCore::ContentExtensions::DFA::nextState): (WebCore::ContentExtensions::DFA::actions): (WebCore::ContentExtensions::DFA::debugPrintDot): * contentextensions/DFA.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. (WebCore::ContentExtensions::DFA::root): * contentextensions/DFANode.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. * contentextensions/NFA.cpp: Added. (WebCore::ContentExtensions::NFA::NFA): (WebCore::ContentExtensions::NFA::createNode): (WebCore::ContentExtensions::NFA::addTransition): (WebCore::ContentExtensions::NFA::addEpsilonTransition): (WebCore::ContentExtensions::NFA::setFinal): (WebCore::ContentExtensions::NFA::debugPrintDot): * contentextensions/NFA.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. (WebCore::ContentExtensions::NFA::root): * contentextensions/NFANode.cpp: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. (WebCore::ContentExtensions::NFANode::NFANode): * contentextensions/NFANode.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. * contentextensions/NFAToDFA.cpp: Added. (WebCore::ContentExtensions::epsilonClosure): (WebCore::ContentExtensions::setTransitionsExcludingEpsilon): (WebCore::ContentExtensions::HashableNodeIdSet::HashableNodeIdSet): (WebCore::ContentExtensions::HashableNodeIdSet::operator=): (WebCore::ContentExtensions::HashableNodeIdSet::isEmptyValue): (WebCore::ContentExtensions::HashableNodeIdSet::isDeletedValue): (WebCore::ContentExtensions::HashableNodeIdSet::nodeIdSet): (WebCore::ContentExtensions::HashableNodeIdSetHash::hash): (WebCore::ContentExtensions::HashableNodeIdSetHash::equal): (WebCore::ContentExtensions::addDFAState): (WebCore::ContentExtensions::NFAToDFA::convert): * contentextensions/NFAToDFA.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. * loader/cache/CachedResourceLoader.cpp: (WebCore::CachedResourceLoader::requestResource): Source/WebKit2: Provide a small SPI for OS X. This will likely move to a better place. * UIProcess/API/Cocoa/WKProcessPool.mm: (-[WKProcessPool _loadContentExtensionWithIdentifier:serializedRules:successCompletionHandler:errorCompletionHandler:]): * UIProcess/API/Cocoa/WKProcessPoolPrivate.h: * UIProcess/WebProcessPool.cpp: (WebKit::WebProcessPool::processDidFinishLaunching): (WebKit::WebProcessPool::loadContentExtension): * UIProcess/WebProcessPool.h: * WebProcess/WebProcess.cpp: (WebKit::WebProcess::loadContentExtension): * WebProcess/WebProcess.h: * WebProcess/WebProcess.messages.in: Source/WTF: * wtf/FeatureDefines.h: Canonical link: https://commits.webkit.org/158244@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@178151 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-01-09 01:56:00 +00:00
[Content Extensions] Move compiling of content extensions to the UIProcess https://bugs.webkit.org/show_bug.cgi?id=142402 Reviewed by Benjamin Poulain. Source/WebCore: * contentextensions/CompiledContentExtension.cpp: (WebCore::ContentExtensions::CompiledContentExtension::~CompiledContentExtension): (WebCore::ContentExtensions::CompiledContentExtension::create): Deleted. (WebCore::ContentExtensions::CompiledContentExtension::CompiledContentExtension): Deleted. * contentextensions/CompiledContentExtension.h: (WebCore::ContentExtensions::CompiledContentExtension::bytecode): Deleted. (WebCore::ContentExtensions::CompiledContentExtension::actions): Deleted. Convert CompiledContentExtension to be an abstract base class so that we can back it however we like at the WebKit level. Since it doesn't necessarily use Vectors for its backing store any more, change the interface to use pointer/length. * contentextensions/ContentExtensionCompiler.cpp: (WebCore::ContentExtensions::compileRuleList): * contentextensions/ContentExtensionCompiler.h: Change compileRuleList to return compiled result as the raw Vectors rather than as a CompiledContentExtension, since that class is now abstract. It is up to the caller to copy the data into its final home. * contentextensions/ContentExtensionRule.cpp: (WebCore::ContentExtensions::Action::deserialize): * contentextensions/ContentExtensionRule.h: Switch Action::deserialize to take pointer/length rather than a Vector. * contentextensions/ContentExtensionsBackend.cpp: (WebCore::ContentExtensions::ContentExtensionsBackend::actionsForURL): Pull getting the serialized actions from the compiled extension out of the loop to avoid calling the virtual function multiple times. Pass the bytecode and actions as pointer/length pairs rather than Vectors. * contentextensions/DFABytecodeInterpreter.cpp: (WebCore::ContentExtensions::getBits): (WebCore::ContentExtensions::DFABytecodeInterpreter::interpret): * contentextensions/DFABytecodeInterpreter.h: (WebCore::ContentExtensions::DFABytecodeInterpreter::DFABytecodeInterpreter): Switch the interpreter to take pointer/length rather than a Vector. * page/UserContentController.cpp: (WebCore::UserContentController::addUserContentExtension): (WebCore::UserContentController::removeUserContentExtension): (WebCore::UserContentController::removeAllUserContentExtensions): (WebCore::UserContentController::addUserContentFilter): Deleted. (WebCore::UserContentController::removeUserContentFilter): Deleted. (WebCore::UserContentController::removeAllUserContentFilters): Deleted. * page/UserContentController.h: Unify terminology to use the term UserContentExtension rather than UserContentFilter. Source/WebKit2: * Shared/API/APIObject.h: Rename UserContentFilter type to UserContentExtension to match new unified naming. * Shared/WebCompiledContentExtension.cpp: Added. (WebKit::WebCompiledContentExtension::create): (WebKit::WebCompiledContentExtension::WebCompiledContentExtension): (WebKit::WebCompiledContentExtension::~WebCompiledContentExtension): (WebKit::WebCompiledContentExtension::bytecode): (WebKit::WebCompiledContentExtension::bytecodeLength): (WebKit::WebCompiledContentExtension::actions): (WebKit::WebCompiledContentExtension::actionsLength): * Shared/WebCompiledContentExtension.h: Added. Add new WebKit2 implementation of CompiledContentExtension. Right now it is the same as the old WebCore based CompiledContentExtension, but in subsequent patches, it will use shared/file backed memory. * Shared/WebCompiledContentExtensionData.cpp: Added. (WebKit::WebCompiledContentExtensionData::encode): (WebKit::WebCompiledContentExtensionData::decode): * Shared/WebCompiledContentExtensionData.h: Added. Add encodable/decodable holder for the compiled content extension data for use in IPC. Right now it is doing the naive thing and always copying the data, but in subsequent patches, it will use shared/file backed memory. * Shared/WebPageGroupData.cpp: (WebKit::WebPageGroupData::encode): (WebKit::WebPageGroupData::decode): * Shared/WebPageGroupData.h: Rename member to match new unification on the name userContentExtension. Change the value from the serialized JSON (as a String) to WebCompiledContentExtensionData. * UIProcess/API/APIUserContentExtension.cpp: Copied from Source/WebKit2/UIProcess/API/APIUserContentFilter.cpp. (API::UserContentExtension::UserContentExtension): (API::UserContentExtension::~UserContentExtension): (API::UserContentFilter::UserContentFilter): Deleted. (API::UserContentFilter::~UserContentFilter): Deleted. * UIProcess/API/APIUserContentExtension.h: Copied from Source/WebKit2/UIProcess/API/APIUserContentFilter.h. * UIProcess/API/APIUserContentFilter.cpp: Removed. * UIProcess/API/APIUserContentFilter.h: Removed. Renamed UserContentFilter to APIUserContentExtension. Updated to store the compiled extension (as a WebCompiledContentExtension) rather than the serialized JSON. * UIProcess/API/C/WKAPICast.h: * UIProcess/API/C/WKPageGroup.cpp: (WKPageGroupAddUserContentFilter): (WKPageGroupRemoveUserContentFilter): (WKPageGroupRemoveAllUserContentFilters): * UIProcess/API/C/WKUserContentControllerRef.cpp: (WKUserContentControllerAddUserContentFilter): (WKUserContentControllerRemoveAllUserContentFilters): * UIProcess/API/Cocoa/WKUserContentController.mm: (-[WKUserContentController _addUserContentFilter:]): (-[WKUserContentController _removeUserContentFilter:]): (-[WKUserContentController _removeAllUserContentFilters]): Update for rename of APIUserContentFilter -> UserContentExtension. * UIProcess/API/C/WKUserContentFilterRef.cpp: (WKUserContentFilterGetTypeID): (WKUserContentFilterCreate): Update for rename of APIUserContentFilter -> UserContentExtension. Also make WKUserContentFilterCreate eagerly compile rule list to a WebCompiledContentExtensionData. * UIProcess/API/Cocoa/_WKUserContentFilter.mm: (-[_WKUserContentFilter initWithName:serializedRules:]): (-[_WKUserContentFilter dealloc]): (-[_WKUserContentFilter _apiObject]): Update for rename of APIUserContentFilter -> UserContentExtension. Also make initWithName:serializedRules: eagerly compile rule list to a WebCompiledContentExtensionData. * UIProcess/API/Cocoa/_WKUserContentFilterInternal.h: (WebKit::wrapper): Update for rename of APIUserContentFilter -> UserContentExtension. * UIProcess/UserContent/WebUserContentControllerProxy.cpp: (WebKit::WebUserContentControllerProxy::addProcess): (WebKit::WebUserContentControllerProxy::addUserContentExtension): (WebKit::WebUserContentControllerProxy::removeUserContentExtension): (WebKit::WebUserContentControllerProxy::removeAllUserContentExtensions): (WebKit::WebUserContentControllerProxy::addUserContentFilter): Deleted. (WebKit::WebUserContentControllerProxy::removeUserContentFilter): Deleted. (WebKit::WebUserContentControllerProxy::removeAllUserContentFilters): Deleted. * UIProcess/UserContent/WebUserContentControllerProxy.h: * UIProcess/WebPageGroup.cpp: (WebKit::WebPageGroup::addUserContentExtension): (WebKit::WebPageGroup::removeUserContentExtension): (WebKit::WebPageGroup::removeAllUserContentExtensions): (WebKit::WebPageGroup::addUserContentFilter): Deleted. (WebKit::WebPageGroup::removeUserContentFilter): Deleted. (WebKit::WebPageGroup::removeAllUserContentFilters): Deleted. * UIProcess/WebPageGroup.h: * WebKit2.xcodeproj/project.pbxproj: * WebProcess/UserContent/WebUserContentController.cpp: (WebKit::WebUserContentController::addUserContentExtensions): (WebKit::WebUserContentController::removeUserContentExtension): (WebKit::WebUserContentController::removeAllUserContentExtensions): (WebKit::WebUserContentController::addUserContentFilters): Deleted. (WebKit::WebUserContentController::removeUserContentFilter): Deleted. (WebKit::WebUserContentController::removeAllUserContentFilters): Deleted. * WebProcess/UserContent/WebUserContentController.h: * WebProcess/UserContent/WebUserContentController.messages.in: * WebProcess/WebPage/WebPageGroupProxy.cpp: (WebKit::WebPageGroupProxy::WebPageGroupProxy): (WebKit::WebPageGroupProxy::addUserContentExtension): (WebKit::WebPageGroupProxy::removeUserContentExtension): (WebKit::WebPageGroupProxy::removeAllUserContentExtensions): (WebKit::WebPageGroupProxy::addUserContentFilter): Deleted. (WebKit::WebPageGroupProxy::removeUserContentFilter): Deleted. (WebKit::WebPageGroupProxy::removeAllUserContentFilters): Deleted. * WebProcess/WebPage/WebPageGroupProxy.h: * WebProcess/WebPage/WebPageGroupProxy.messages.in: Pipe the compiled extension from the UIProcess to the WebProcess. Tools: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp: Copied from Tools/TestWebKitAPI/Tests/WebCore/ContentFilter.cpp. (TestWebKitAPI::InMemoryCompiledContentExtension::create): (TestWebKitAPI::InMemoryCompiledContentExtension::~InMemoryCompiledContentExtension): (TestWebKitAPI::InMemoryCompiledContentExtension::InMemoryCompiledContentExtension): (TestWebKitAPI::TEST_F): * TestWebKitAPI/Tests/WebCore/ContentFilter.cpp: Removed. Update test for new name (ContentFilter -> ContentExtensions) and API (CompiledContentExtension is now abstract). Canonical link: https://commits.webkit.org/160480@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@181200 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-03-07 02:41:44 +00:00
#include "ArgumentCoders.h"
WebKit should build successfully even with -DENABLE_UNIFIED_BUILDS=OFF https://bugs.webkit.org/show_bug.cgi?id=196845 Reviewed by Ryosuke Niwa. Source/WebCore: * html/canvas/CanvasRenderingContext2DBase.cpp: (WebCore::CanvasRenderingContext2DBase::FontProxy::initialize): (WebCore::CanvasRenderingContext2DBase::FontProxy::fontMetrics const): (WebCore::CanvasRenderingContext2DBase::FontProxy::fontDescription const): (WebCore::CanvasRenderingContext2DBase::FontProxy::width const): (WebCore::CanvasRenderingContext2DBase::FontProxy::drawBidiText const): (WebCore::CanvasRenderingContext2DBase::beginCompositeLayer): (WebCore::CanvasRenderingContext2DBase::endCompositeLayer): Remove inline specifier to address linking errors (regardless of CMake platform). Doing this in a .cpp file interferes with symbol creation. * Modules/mediastream/MediaStreamTrack.cpp: * Modules/webvr/VREyeParameters.cpp: * Modules/webvr/VRFrameData.cpp: * Modules/webvr/VRPose.cpp: * accessibility/AccessibilityList.cpp: * accessibility/isolatedtree/AXIsolatedTree.cpp: * accessibility/isolatedtree/AXIsolatedTreeNode.cpp: * bindings/js/JSDOMConvertWebGL.cpp: * bindings/js/JSHistoryCustom.cpp: * bindings/js/JSIDBCursorWithValueCustom.cpp: * bindings/js/JSPerformanceObserverCustom.cpp: * bindings/js/WindowProxy.cpp: * platform/ColorData.gperf: * platform/mediastream/RealtimeMediaSourceSettings.cpp: * platform/network/DNSResolveQueue.cpp: * workers/service/ServiceWorkerClientQueryOptions.h: * workers/service/ServiceWorkerContainer.cpp: Add missing includes to address compiler errors on GTK. Source/WebKit: * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h: * NetworkProcess/NetworkCORSPreflightChecker.cpp: * NetworkProcess/NetworkDataTask.cpp: * NetworkProcess/NetworkHTTPSUpgradeChecker.cpp: * NetworkProcess/NetworkHTTPSUpgradeChecker.h: Include wtf/Forward.h for String and CompletionHandler fwd decls. * NetworkProcess/NetworkProcess.cpp: * NetworkProcess/NetworkResourceLoadMap.cpp: * NetworkProcess/NetworkResourceLoadMap.h: * NetworkProcess/NetworkResourceLoader.cpp: * NetworkProcess/PingLoad.h: * Shared/WebCompiledContentRuleListData.cpp: * Shared/gtk/WebEventFactory.cpp: * UIProcess/API/C/WKWebsiteDataStoreRef.cpp: (WKWebsiteDataStoreStatisticsClearInMemoryAndPersistentStore): (WKWebsiteDataStoreStatisticsClearInMemoryAndPersistentStoreModifiedSinceHours): (WKWebsiteDataStoreStatisticsResetToConsistentState): * UIProcess/Downloads/DownloadProxyMap.cpp: * UIProcess/InspectorTargetProxy.cpp: * UIProcess/PageClient.h: * UIProcess/ProcessAssertion.cpp: * UIProcess/ProvisionalPageProxy.h: * UIProcess/WebPageInspectorTargetAgent.h: * UIProcess/geoclue/GeoclueGeolocationProvider.cpp: * WebProcess/Cache/WebCacheStorageConnection.cpp: (WebKit::WebCacheStorageConnection::updateQuotaBasedOnSpaceUsage): * WebProcess/InjectedBundle/API/c/WKBundle.cpp: (WKBundleSetDatabaseQuota): * WebProcess/Storage/WebServiceWorkerFetchTaskClient.h: Add missing includes / forward declarations to address compiler errors on GTK / WinCairo. Canonical link: https://commits.webkit.org/211134@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@244225 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-04-12 18:18:25 +00:00
#include "DataReference.h"
Add a WKContentRuleList variant that uses copied memory instead of mmap'd shared memory for class A containerized apps https://bugs.webkit.org/show_bug.cgi?id=195511 <rdar://problem/44873269> Patch by Alex Christensen <achristensen@webkit.org> on 2019-03-11 Reviewed by Darin Adler. Source/WebKit: * NetworkProcess/NetworkContentRuleListManager.cpp: (WebKit::NetworkContentRuleListManager::addContentRuleLists): * NetworkProcess/NetworkContentRuleListManager.h: * NetworkProcess/cache/NetworkCacheFileSystem.cpp: (WebKit::NetworkCache::pathRegisteredAsUnsafeToMemoryMapForTesting): (WebKit::NetworkCache::registerPathAsUnsafeToMemoryMapForTesting): (WebKit::NetworkCache::isSafeToUseMemoryMapForPath): * NetworkProcess/cache/NetworkCacheFileSystem.h: * Shared/WebCompiledContentRuleList.cpp: (WebKit::WebCompiledContentRuleList::usesCopiedMemory const): (WebKit::WebCompiledContentRuleList::conditionsApplyOnlyToDomain const): (WebKit::WebCompiledContentRuleList::filtersWithoutConditionsBytecode const): (WebKit::WebCompiledContentRuleList::filtersWithConditionsBytecode const): (WebKit::WebCompiledContentRuleList::topURLFiltersBytecode const): (WebKit::WebCompiledContentRuleList::actions const): * Shared/WebCompiledContentRuleList.h: * Shared/WebCompiledContentRuleListData.cpp: (WebKit::WebCompiledContentRuleListData::size const): (WebKit::WebCompiledContentRuleListData::dataPointer const): (WebKit::WebCompiledContentRuleListData::encode const): (WebKit::WebCompiledContentRuleListData::decode): * Shared/WebCompiledContentRuleListData.h: (WebKit::WebCompiledContentRuleListData::WebCompiledContentRuleListData): * UIProcess/API/APIContentRuleList.cpp: (API::ContentRuleList::usesCopiedMemory const): * UIProcess/API/APIContentRuleList.h: * UIProcess/API/APIContentRuleListStore.cpp: (API::getData): (API::decodeContentRuleListMetaData): (API::ContentRuleListStore::readContentsOfFile): (API::MappedOrCopiedData::dataPointer const): (API::openAndMapOrCopyContentRuleList): (API::compiledToFile): (API::createExtension): (API::ContentRuleListStore::lookupContentRuleList): (API::ContentRuleListStore::compileContentRuleList): (API::ContentRuleListStore::getContentRuleListSource): (API::openAndMapContentRuleList): Deleted. * UIProcess/API/APIContentRuleListStore.h: * UIProcess/API/Cocoa/APIContentRuleListStoreCocoa.mm: (API::ContentRuleListStore::readContentsOfFile): * UIProcess/API/Cocoa/WKContentRuleListStore.mm: (+[WKContentRuleListStore _registerPathAsUnsafeToMemoryMapForTesting:]): * UIProcess/API/Cocoa/WKContentRuleListStorePrivate.h: * UIProcess/API/Cocoa/_WKUserContentFilter.mm: (-[_WKUserContentFilter usesCopiedMemory]): * UIProcess/API/Cocoa/_WKUserContentFilterPrivate.h: * WebProcess/UserContent/WebUserContentController.cpp: (WebKit::WebUserContentController::addContentRuleLists): * WebProcess/UserContent/WebUserContentController.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::m_hostFileDescriptor): Tools: * TestWebKitAPI/Tests/WebKitCocoa/WKContentExtensionStore.mm: (-[TestSchemeHandlerSubresourceShouldBeBlocked webView:startURLSchemeTask:]): (-[TestSchemeHandlerSubresourceShouldBeBlocked webView:stopURLSchemeTask:]): (TEST_F): Canonical link: https://commits.webkit.org/209867@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242735 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-03-11 20:21:39 +00:00
#include "SharedBufferDataReference.h"
[Content Extensions] Move compiling of content extensions to the UIProcess https://bugs.webkit.org/show_bug.cgi?id=142402 Reviewed by Benjamin Poulain. Source/WebCore: * contentextensions/CompiledContentExtension.cpp: (WebCore::ContentExtensions::CompiledContentExtension::~CompiledContentExtension): (WebCore::ContentExtensions::CompiledContentExtension::create): Deleted. (WebCore::ContentExtensions::CompiledContentExtension::CompiledContentExtension): Deleted. * contentextensions/CompiledContentExtension.h: (WebCore::ContentExtensions::CompiledContentExtension::bytecode): Deleted. (WebCore::ContentExtensions::CompiledContentExtension::actions): Deleted. Convert CompiledContentExtension to be an abstract base class so that we can back it however we like at the WebKit level. Since it doesn't necessarily use Vectors for its backing store any more, change the interface to use pointer/length. * contentextensions/ContentExtensionCompiler.cpp: (WebCore::ContentExtensions::compileRuleList): * contentextensions/ContentExtensionCompiler.h: Change compileRuleList to return compiled result as the raw Vectors rather than as a CompiledContentExtension, since that class is now abstract. It is up to the caller to copy the data into its final home. * contentextensions/ContentExtensionRule.cpp: (WebCore::ContentExtensions::Action::deserialize): * contentextensions/ContentExtensionRule.h: Switch Action::deserialize to take pointer/length rather than a Vector. * contentextensions/ContentExtensionsBackend.cpp: (WebCore::ContentExtensions::ContentExtensionsBackend::actionsForURL): Pull getting the serialized actions from the compiled extension out of the loop to avoid calling the virtual function multiple times. Pass the bytecode and actions as pointer/length pairs rather than Vectors. * contentextensions/DFABytecodeInterpreter.cpp: (WebCore::ContentExtensions::getBits): (WebCore::ContentExtensions::DFABytecodeInterpreter::interpret): * contentextensions/DFABytecodeInterpreter.h: (WebCore::ContentExtensions::DFABytecodeInterpreter::DFABytecodeInterpreter): Switch the interpreter to take pointer/length rather than a Vector. * page/UserContentController.cpp: (WebCore::UserContentController::addUserContentExtension): (WebCore::UserContentController::removeUserContentExtension): (WebCore::UserContentController::removeAllUserContentExtensions): (WebCore::UserContentController::addUserContentFilter): Deleted. (WebCore::UserContentController::removeUserContentFilter): Deleted. (WebCore::UserContentController::removeAllUserContentFilters): Deleted. * page/UserContentController.h: Unify terminology to use the term UserContentExtension rather than UserContentFilter. Source/WebKit2: * Shared/API/APIObject.h: Rename UserContentFilter type to UserContentExtension to match new unified naming. * Shared/WebCompiledContentExtension.cpp: Added. (WebKit::WebCompiledContentExtension::create): (WebKit::WebCompiledContentExtension::WebCompiledContentExtension): (WebKit::WebCompiledContentExtension::~WebCompiledContentExtension): (WebKit::WebCompiledContentExtension::bytecode): (WebKit::WebCompiledContentExtension::bytecodeLength): (WebKit::WebCompiledContentExtension::actions): (WebKit::WebCompiledContentExtension::actionsLength): * Shared/WebCompiledContentExtension.h: Added. Add new WebKit2 implementation of CompiledContentExtension. Right now it is the same as the old WebCore based CompiledContentExtension, but in subsequent patches, it will use shared/file backed memory. * Shared/WebCompiledContentExtensionData.cpp: Added. (WebKit::WebCompiledContentExtensionData::encode): (WebKit::WebCompiledContentExtensionData::decode): * Shared/WebCompiledContentExtensionData.h: Added. Add encodable/decodable holder for the compiled content extension data for use in IPC. Right now it is doing the naive thing and always copying the data, but in subsequent patches, it will use shared/file backed memory. * Shared/WebPageGroupData.cpp: (WebKit::WebPageGroupData::encode): (WebKit::WebPageGroupData::decode): * Shared/WebPageGroupData.h: Rename member to match new unification on the name userContentExtension. Change the value from the serialized JSON (as a String) to WebCompiledContentExtensionData. * UIProcess/API/APIUserContentExtension.cpp: Copied from Source/WebKit2/UIProcess/API/APIUserContentFilter.cpp. (API::UserContentExtension::UserContentExtension): (API::UserContentExtension::~UserContentExtension): (API::UserContentFilter::UserContentFilter): Deleted. (API::UserContentFilter::~UserContentFilter): Deleted. * UIProcess/API/APIUserContentExtension.h: Copied from Source/WebKit2/UIProcess/API/APIUserContentFilter.h. * UIProcess/API/APIUserContentFilter.cpp: Removed. * UIProcess/API/APIUserContentFilter.h: Removed. Renamed UserContentFilter to APIUserContentExtension. Updated to store the compiled extension (as a WebCompiledContentExtension) rather than the serialized JSON. * UIProcess/API/C/WKAPICast.h: * UIProcess/API/C/WKPageGroup.cpp: (WKPageGroupAddUserContentFilter): (WKPageGroupRemoveUserContentFilter): (WKPageGroupRemoveAllUserContentFilters): * UIProcess/API/C/WKUserContentControllerRef.cpp: (WKUserContentControllerAddUserContentFilter): (WKUserContentControllerRemoveAllUserContentFilters): * UIProcess/API/Cocoa/WKUserContentController.mm: (-[WKUserContentController _addUserContentFilter:]): (-[WKUserContentController _removeUserContentFilter:]): (-[WKUserContentController _removeAllUserContentFilters]): Update for rename of APIUserContentFilter -> UserContentExtension. * UIProcess/API/C/WKUserContentFilterRef.cpp: (WKUserContentFilterGetTypeID): (WKUserContentFilterCreate): Update for rename of APIUserContentFilter -> UserContentExtension. Also make WKUserContentFilterCreate eagerly compile rule list to a WebCompiledContentExtensionData. * UIProcess/API/Cocoa/_WKUserContentFilter.mm: (-[_WKUserContentFilter initWithName:serializedRules:]): (-[_WKUserContentFilter dealloc]): (-[_WKUserContentFilter _apiObject]): Update for rename of APIUserContentFilter -> UserContentExtension. Also make initWithName:serializedRules: eagerly compile rule list to a WebCompiledContentExtensionData. * UIProcess/API/Cocoa/_WKUserContentFilterInternal.h: (WebKit::wrapper): Update for rename of APIUserContentFilter -> UserContentExtension. * UIProcess/UserContent/WebUserContentControllerProxy.cpp: (WebKit::WebUserContentControllerProxy::addProcess): (WebKit::WebUserContentControllerProxy::addUserContentExtension): (WebKit::WebUserContentControllerProxy::removeUserContentExtension): (WebKit::WebUserContentControllerProxy::removeAllUserContentExtensions): (WebKit::WebUserContentControllerProxy::addUserContentFilter): Deleted. (WebKit::WebUserContentControllerProxy::removeUserContentFilter): Deleted. (WebKit::WebUserContentControllerProxy::removeAllUserContentFilters): Deleted. * UIProcess/UserContent/WebUserContentControllerProxy.h: * UIProcess/WebPageGroup.cpp: (WebKit::WebPageGroup::addUserContentExtension): (WebKit::WebPageGroup::removeUserContentExtension): (WebKit::WebPageGroup::removeAllUserContentExtensions): (WebKit::WebPageGroup::addUserContentFilter): Deleted. (WebKit::WebPageGroup::removeUserContentFilter): Deleted. (WebKit::WebPageGroup::removeAllUserContentFilters): Deleted. * UIProcess/WebPageGroup.h: * WebKit2.xcodeproj/project.pbxproj: * WebProcess/UserContent/WebUserContentController.cpp: (WebKit::WebUserContentController::addUserContentExtensions): (WebKit::WebUserContentController::removeUserContentExtension): (WebKit::WebUserContentController::removeAllUserContentExtensions): (WebKit::WebUserContentController::addUserContentFilters): Deleted. (WebKit::WebUserContentController::removeUserContentFilter): Deleted. (WebKit::WebUserContentController::removeAllUserContentFilters): Deleted. * WebProcess/UserContent/WebUserContentController.h: * WebProcess/UserContent/WebUserContentController.messages.in: * WebProcess/WebPage/WebPageGroupProxy.cpp: (WebKit::WebPageGroupProxy::WebPageGroupProxy): (WebKit::WebPageGroupProxy::addUserContentExtension): (WebKit::WebPageGroupProxy::removeUserContentExtension): (WebKit::WebPageGroupProxy::removeAllUserContentExtensions): (WebKit::WebPageGroupProxy::addUserContentFilter): Deleted. (WebKit::WebPageGroupProxy::removeUserContentFilter): Deleted. (WebKit::WebPageGroupProxy::removeAllUserContentFilters): Deleted. * WebProcess/WebPage/WebPageGroupProxy.h: * WebProcess/WebPage/WebPageGroupProxy.messages.in: Pipe the compiled extension from the UIProcess to the WebProcess. Tools: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp: Copied from Tools/TestWebKitAPI/Tests/WebCore/ContentFilter.cpp. (TestWebKitAPI::InMemoryCompiledContentExtension::create): (TestWebKitAPI::InMemoryCompiledContentExtension::~InMemoryCompiledContentExtension): (TestWebKitAPI::InMemoryCompiledContentExtension::InMemoryCompiledContentExtension): (TestWebKitAPI::TEST_F): * TestWebKitAPI/Tests/WebCore/ContentFilter.cpp: Removed. Update test for new name (ContentFilter -> ContentExtensions) and API (CompiledContentExtension is now abstract). Canonical link: https://commits.webkit.org/160480@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@181200 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-03-07 02:41:44 +00:00
namespace WebKit {
Rename WKContentExtension to WKContentRuleList https://bugs.webkit.org/show_bug.cgi?id=172053 <rdar://problem/32141005> Reviewed by Geoffrey Garen. Source/WebCore: Covered by existing API tests. * English.lproj/Localizable.strings: Source/WebKit2: * Shared/API/APIObject.h: * Shared/API/Cocoa/WebKit.h: * Shared/API/c/WKDeprecatedFunctions.cpp: (WKPageGroupAddUserContentFilter): (WKPageGroupRemoveUserContentFilter): * Shared/Cocoa/APIObject.mm: (API::Object::newObject): * Shared/WebCompiledContentExtension.cpp: Removed. * Shared/WebCompiledContentExtension.h: Removed. * Shared/WebCompiledContentExtensionData.cpp: Removed. * Shared/WebCompiledContentExtensionData.h: Removed. * Shared/WebCompiledContentRuleList.cpp: Copied from Source/WebKit2/Shared/WebCompiledContentExtension.cpp. (WebKit::WebCompiledContentRuleList::create): (WebKit::WebCompiledContentRuleList::WebCompiledContentRuleList): (WebKit::WebCompiledContentRuleList::~WebCompiledContentRuleList): (WebKit::WebCompiledContentRuleList::conditionsApplyOnlyToDomain): (WebKit::WebCompiledContentRuleList::filtersWithoutConditionsBytecode): (WebKit::WebCompiledContentRuleList::filtersWithoutConditionsBytecodeLength): (WebKit::WebCompiledContentRuleList::filtersWithConditionsBytecode): (WebKit::WebCompiledContentRuleList::filtersWithConditionsBytecodeLength): (WebKit::WebCompiledContentRuleList::topURLFiltersBytecode): (WebKit::WebCompiledContentRuleList::topURLFiltersBytecodeLength): (WebKit::WebCompiledContentRuleList::actions): (WebKit::WebCompiledContentRuleList::actionsLength): (WebKit::WebCompiledContentExtension::create): Deleted. (WebKit::WebCompiledContentExtension::WebCompiledContentExtension): Deleted. (WebKit::WebCompiledContentExtension::~WebCompiledContentExtension): Deleted. (WebKit::WebCompiledContentExtension::conditionsApplyOnlyToDomain): Deleted. (WebKit::WebCompiledContentExtension::filtersWithoutConditionsBytecode): Deleted. (WebKit::WebCompiledContentExtension::filtersWithoutConditionsBytecodeLength): Deleted. (WebKit::WebCompiledContentExtension::filtersWithConditionsBytecode): Deleted. (WebKit::WebCompiledContentExtension::filtersWithConditionsBytecodeLength): Deleted. (WebKit::WebCompiledContentExtension::topURLFiltersBytecode): Deleted. (WebKit::WebCompiledContentExtension::topURLFiltersBytecodeLength): Deleted. (WebKit::WebCompiledContentExtension::actions): Deleted. (WebKit::WebCompiledContentExtension::actionsLength): Deleted. * Shared/WebCompiledContentRuleList.h: Copied from Source/WebKit2/Shared/WebCompiledContentExtension.h. * Shared/WebCompiledContentRuleListData.cpp: Copied from Source/WebKit2/Shared/WebCompiledContentExtensionData.cpp. (WebKit::WebCompiledContentRuleListData::encode): (WebKit::WebCompiledContentRuleListData::decode): (WebKit::WebCompiledContentExtensionData::encode): Deleted. (WebKit::WebCompiledContentExtensionData::decode): Deleted. * Shared/WebCompiledContentRuleListData.h: Copied from Source/WebKit2/Shared/WebCompiledContentExtensionData.h. (WebKit::WebCompiledContentRuleListData::WebCompiledContentRuleListData): (WebKit::WebCompiledContentExtensionData::WebCompiledContentExtensionData): Deleted. * Shared/WebPageCreationParameters.cpp: (WebKit::WebPageCreationParameters::encode): (WebKit::WebPageCreationParameters::decode): * Shared/WebPageCreationParameters.h: * UIProcess/API/APIContentExtension.cpp: Removed. * UIProcess/API/APIContentExtension.h: Removed. * UIProcess/API/APIContentExtensionStore.cpp: Removed. * UIProcess/API/APIContentExtensionStore.h: Removed. * UIProcess/API/APIContentRuleList.cpp: Copied from Source/WebKit2/UIProcess/API/APIContentExtension.cpp. (API::ContentRuleList::ContentRuleList): (API::ContentRuleList::~ContentRuleList): (API::ContentExtension::ContentExtension): Deleted. (API::ContentExtension::~ContentExtension): Deleted. * UIProcess/API/APIContentRuleList.h: Copied from Source/WebKit2/UIProcess/API/APIContentExtension.h. * UIProcess/API/APIContentRuleListStore.cpp: Copied from Source/WebKit2/UIProcess/API/APIContentExtensionStore.cpp. (API::ContentRuleListStore::legacyDefaultStore): (API::ContentRuleListStore::nonLegacyDdefaultStore): (API::ContentRuleListStore::defaultStore): (API::ContentRuleListStore::storeWithPath): (API::ContentRuleListStore::ContentRuleListStore): (API::ContentRuleListStore::~ContentRuleListStore): (API::constructedPathPrefix): (API::ContentRuleListMetaData::fileSize): (API::encodeContentRuleListMetaData): (API::decodeContentRuleListMetaData): (API::openAndMapContentRuleList): (API::compiledToFile): (API::createExtension): (API::ContentRuleListStore::lookupContentRuleList): (API::ContentRuleListStore::getAvailableContentRuleListIdentifiers): (API::ContentRuleListStore::compileContentRuleList): (API::ContentRuleListStore::removeContentRuleList): (API::ContentRuleListStore::synchronousRemoveAllContentRuleLists): (API::ContentRuleListStore::invalidateContentRuleListVersion): (API::ContentRuleListStore::getContentRuleListSource): (API::contentRuleListStoreErrorCategory): (API::ContentExtensionStore::defaultStore): Deleted. (API::ContentExtensionStore::storeWithPath): Deleted. (API::ContentExtensionStore::ContentExtensionStore): Deleted. (API::ContentExtensionStore::~ContentExtensionStore): Deleted. (API::ContentExtensionMetaData::fileSize): Deleted. (API::encodeContentExtensionMetaData): Deleted. (API::decodeContentExtensionMetaData): Deleted. (API::openAndMapContentExtension): Deleted. (API::ContentExtensionStore::lookupContentExtension): Deleted. (API::ContentExtensionStore::getAvailableContentExtensionIdentifiers): Deleted. (API::ContentExtensionStore::compileContentExtension): Deleted. (API::ContentExtensionStore::removeContentExtension): Deleted. (API::ContentExtensionStore::synchronousRemoveAllContentExtensions): Deleted. (API::ContentExtensionStore::invalidateContentExtensionVersion): Deleted. (API::ContentExtensionStore::getContentExtensionSource): Deleted. (API::contentExtensionStoreErrorCategory): Deleted. * UIProcess/API/APIContentRuleListStore.h: Copied from Source/WebKit2/UIProcess/API/APIContentExtensionStore.h. (API::make_error_code): * UIProcess/API/C/WKAPICast.h: * UIProcess/API/C/WKPageGroup.cpp: * UIProcess/API/C/WKUserContentControllerRef.cpp: (WKUserContentControllerAddUserContentFilter): (WKUserContentControllerRemoveAllUserContentFilters): * UIProcess/API/C/WKUserContentExtensionStoreRef.cpp: (WKUserContentExtensionStoreGetTypeID): * UIProcess/API/Cocoa/APIUserContentExtensionStoreCocoa.mm: (API::ContentRuleListStore::defaultStorePath): (API::ContentExtensionStore::defaultStorePath): Deleted. * UIProcess/API/Cocoa/WKContentExtension.h: Removed. * UIProcess/API/Cocoa/WKContentExtension.mm: Removed. * UIProcess/API/Cocoa/WKContentExtensionInternal.h: Removed. * UIProcess/API/Cocoa/WKContentExtensionStore.h: Removed. * UIProcess/API/Cocoa/WKContentExtensionStore.mm: Removed. * UIProcess/API/Cocoa/WKContentExtensionStoreInternal.h: Removed. * UIProcess/API/Cocoa/WKContentExtensionStorePrivate.h: Removed. * UIProcess/API/Cocoa/WKContentRuleList.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKContentExtension.h. * UIProcess/API/Cocoa/WKContentRuleList.mm: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKContentExtension.mm. (-[WKContentRuleList dealloc]): (-[WKContentRuleList _apiObject]): (-[WKContentRuleList identifier]): (-[WKContentExtension dealloc]): Deleted. (-[WKContentExtension _apiObject]): Deleted. (-[WKContentExtension identifier]): Deleted. * UIProcess/API/Cocoa/WKContentRuleListInternal.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKContentExtensionInternal.h. (WebKit::wrapper): * UIProcess/API/Cocoa/WKContentRuleListStore.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKContentExtensionStore.h. * UIProcess/API/Cocoa/WKContentRuleListStore.mm: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKContentExtensionStore.mm. (toWKErrorCode): (-[WKContentRuleListStore dealloc]): (+[WKContentRuleListStore defaultStore]): (+[WKContentRuleListStore storeWithURL:]): (-[WKContentRuleListStore compileContentRuleListForIdentifier:encodedContentRuleList:completionHandler:]): (-[WKContentRuleListStore _compileContentRuleListForIdentifier:encodedContentRuleList:completionHandler:releasesArgument:]): (-[WKContentRuleListStore lookUpContentRuleListForIdentifier:completionHandler:]): (-[WKContentRuleListStore getAvailableContentRuleListIdentifiers:]): (-[WKContentRuleListStore removeContentRuleListForIdentifier:completionHandler:]): (-[WKContentRuleListStore _apiObject]): (-[WKContentRuleListStore _removeAllContentRuleLists]): (-[WKContentRuleListStore _invalidateContentRuleListVersionForIdentifier:]): (-[WKContentRuleListStore _getContentRuleListSourceForIdentifier:completionHandler:]): (-[WKContentRuleListStore _compileContentRuleListForIdentifier:encodedContentRuleList:completionHandler:]): (-[WKContentExtensionStore dealloc]): Deleted. (+[WKContentExtensionStore defaultStore]): Deleted. (+[WKContentExtensionStore storeWithURL:]): Deleted. (-[WKContentExtensionStore compileContentExtensionForIdentifier:encodedContentExtension:completionHandler:]): Deleted. (-[WKContentExtensionStore _compileContentExtensionForIdentifier:encodedContentExtension:completionHandler:releasesArgument:]): Deleted. (-[WKContentExtensionStore lookUpContentExtensionForIdentifier:completionHandler:]): Deleted. (-[WKContentExtensionStore getAvailableContentExtensionIdentifiers:]): Deleted. (-[WKContentExtensionStore removeContentExtensionForIdentifier:completionHandler:]): Deleted. (-[WKContentExtensionStore _apiObject]): Deleted. (-[WKContentExtensionStore _removeAllContentExtensions]): Deleted. (-[WKContentExtensionStore _invalidateContentExtensionVersionForIdentifier:]): Deleted. (-[WKContentExtensionStore _getContentExtensionSourceForIdentifier:completionHandler:]): Deleted. (-[WKContentExtensionStore _compileContentExtensionForIdentifier:encodedContentExtension:completionHandler:]): Deleted. * UIProcess/API/Cocoa/WKContentRuleListStoreInternal.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKContentExtensionStoreInternal.h. (WebKit::wrapper): * UIProcess/API/Cocoa/WKContentRuleListStorePrivate.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKContentExtensionStorePrivate.h. * UIProcess/API/Cocoa/WKError.h: * UIProcess/API/Cocoa/WKError.mm: (localizedDescriptionForErrorCode): * UIProcess/API/Cocoa/WKUserContentController.h: * UIProcess/API/Cocoa/WKUserContentController.mm: (-[WKUserContentController addContentRuleList:]): (-[WKUserContentController removeContentRuleList:]): (-[WKUserContentController removeAllContentRuleLists]): (-[WKUserContentController _addUserContentFilter:]): (-[WKUserContentController _removeUserContentFilter:]): (-[WKUserContentController _removeAllUserContentFilters]): (-[WKUserContentController addContentExtension:]): Deleted. (-[WKUserContentController removeContentExtension:]): Deleted. (-[WKUserContentController removeAllContentExtensions]): Deleted. * UIProcess/API/Cocoa/_WKUserContentExtensionStore.mm: (toUserContentRuleListStoreError): (+[_WKUserContentExtensionStore defaultStore]): (+[_WKUserContentExtensionStore storeWithURL:]): (-[_WKUserContentExtensionStore compileContentExtensionForIdentifier:encodedContentExtension:completionHandler:]): (-[_WKUserContentExtensionStore lookupContentExtensionForIdentifier:completionHandler:]): (-[_WKUserContentExtensionStore removeContentExtensionForIdentifier:completionHandler:]): (-[_WKUserContentExtensionStore _apiObject]): (-[_WKUserContentExtensionStore _removeAllContentExtensions]): (-[_WKUserContentExtensionStore _invalidateContentExtensionVersionForIdentifier:]): (-[_WKUserContentExtensionStore _initWithWKContentRuleListStore:]): (toUserContentExtensionStoreError): Deleted. (-[_WKUserContentExtensionStore _initWithWKContentExtensionStore:]): Deleted. * UIProcess/API/Cocoa/_WKUserContentExtensionStoreInternal.h: * UIProcess/API/Cocoa/_WKUserContentExtensionStorePrivate.h: * UIProcess/API/Cocoa/_WKUserContentFilter.mm: (-[_WKUserContentFilter _apiObject]): (-[_WKUserContentFilter _initWithWKContentRuleList:]): (-[_WKUserContentFilter _initWithWKContentExtension:]): Deleted. * UIProcess/API/Cocoa/_WKUserContentFilterInternal.h: * UIProcess/API/Cocoa/_WKUserContentFilterPrivate.h: * UIProcess/UserContent/WebUserContentControllerProxy.cpp: (WebKit::WebUserContentControllerProxy::addProcess): (WebKit::WebUserContentControllerProxy::addContentRuleList): (WebKit::WebUserContentControllerProxy::removeContentRuleList): (WebKit::WebUserContentControllerProxy::removeAllContentRuleLists): (WebKit::WebUserContentControllerProxy::addContentExtension): Deleted. (WebKit::WebUserContentControllerProxy::removeContentExtension): Deleted. (WebKit::WebUserContentControllerProxy::removeAllContentExtensions): Deleted. * UIProcess/UserContent/WebUserContentControllerProxy.h: * UIProcess/WebPageGroup.cpp: * WebKit2.xcodeproj/project.pbxproj: * WebProcess/UserContent/WebUserContentController.cpp: (WebKit::WebUserContentController::addContentRuleLists): (WebKit::WebUserContentController::removeContentRuleList): (WebKit::WebUserContentController::removeAllContentRuleLists): (WebKit::WebUserContentController::addContentExtensions): Deleted. (WebKit::WebUserContentController::removeContentExtension): Deleted. (WebKit::WebUserContentController::removeAllContentExtensions): Deleted. * WebProcess/UserContent/WebUserContentController.h: * WebProcess/UserContent/WebUserContentController.messages.in: * WebProcess/WebPage/WebPage.cpp: (WebKit::m_backgroundCPULimit): Tools: * TestWebKitAPI/Tests/WebKit2Cocoa/WKContentExtensionStore.mm: (WKContentRuleListStoreTest::SetUp): (TEST_F): (-[ContentRuleListDelegate webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:]): (WKContentExtensionStoreTest::SetUp): Deleted. (-[ContentExtensionDelegate webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:]): Deleted. Canonical link: https://commits.webkit.org/189003@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@216809 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-05-13 01:33:13 +00:00
void WebCompiledContentRuleListData::encode(IPC::Encoder& encoder) const
[WK2] Start a prototype for declarative site specific extensions https://bugs.webkit.org/show_bug.cgi?id=140160 Reviewed by Andreas Kling. Source/WebCore: Currently, clients have various ways to execute custom code for certain URLs. Each of those mechanism implies messaging the UIProcess, executing some code calling back to the WebProcess, then actually load the resource. All this back and forth introduces delays before we actually load resources. Since the set of actions is done per site is actually simple and limited, it may be possible to do everything in WebCore and shortcut the defered loading. This patch provides the starting point for this idea. The "rules" (currently just blocking) are be passed to WebCore in a JSON format. In WebCore, we create a state machine to match the rules and we execute the action when the state machine tells us to. * WebCore.exp.in: * WebCore.xcodeproj/project.pbxproj: * contentextensions/ContentExtensionRule.cpp: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. (WebCore::ContentExtensions::ContentExtensionRule::ContentExtensionRule): * contentextensions/ContentExtensionRule.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. (WebCore::ContentExtensions::ContentExtensionRule::trigger): (WebCore::ContentExtensions::ContentExtensionRule::action): * contentextensions/ContentExtensionsBackend.cpp: Added. (WebCore::ContentExtensions::ContentExtensionsBackend::sharedInstance): (WebCore::ContentExtensions::ContentExtensionsBackend::setRuleList): (WebCore::ContentExtensions::ContentExtensionsBackend::removeRuleList): (WebCore::ContentExtensions::ContentExtensionsBackend::shouldBlockURL): * contentextensions/ContentExtensionsBackend.h: Added. * contentextensions/ContentExtensionsInterface.cpp: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. (WebCore::ContentExtensions::shouldBlockURL): * contentextensions/ContentExtensionsInterface.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. * contentextensions/ContentExtensionsManager.cpp: Added. (WebCore::ContentExtensions::ExtensionsManager::loadTrigger): (WebCore::ContentExtensions::ExtensionsManager::loadAction): (WebCore::ContentExtensions::ExtensionsManager::loadRule): (WebCore::ContentExtensions::ExtensionsManager::loadExtension): * contentextensions/ContentExtensionsManager.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. * contentextensions/DFA.cpp: Added. (WebCore::ContentExtensions::DFA::DFA): (WebCore::ContentExtensions::DFA::operator=): (WebCore::ContentExtensions::DFA::nextState): (WebCore::ContentExtensions::DFA::actions): (WebCore::ContentExtensions::DFA::debugPrintDot): * contentextensions/DFA.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. (WebCore::ContentExtensions::DFA::root): * contentextensions/DFANode.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. * contentextensions/NFA.cpp: Added. (WebCore::ContentExtensions::NFA::NFA): (WebCore::ContentExtensions::NFA::createNode): (WebCore::ContentExtensions::NFA::addTransition): (WebCore::ContentExtensions::NFA::addEpsilonTransition): (WebCore::ContentExtensions::NFA::setFinal): (WebCore::ContentExtensions::NFA::debugPrintDot): * contentextensions/NFA.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. (WebCore::ContentExtensions::NFA::root): * contentextensions/NFANode.cpp: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. (WebCore::ContentExtensions::NFANode::NFANode): * contentextensions/NFANode.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. * contentextensions/NFAToDFA.cpp: Added. (WebCore::ContentExtensions::epsilonClosure): (WebCore::ContentExtensions::setTransitionsExcludingEpsilon): (WebCore::ContentExtensions::HashableNodeIdSet::HashableNodeIdSet): (WebCore::ContentExtensions::HashableNodeIdSet::operator=): (WebCore::ContentExtensions::HashableNodeIdSet::isEmptyValue): (WebCore::ContentExtensions::HashableNodeIdSet::isDeletedValue): (WebCore::ContentExtensions::HashableNodeIdSet::nodeIdSet): (WebCore::ContentExtensions::HashableNodeIdSetHash::hash): (WebCore::ContentExtensions::HashableNodeIdSetHash::equal): (WebCore::ContentExtensions::addDFAState): (WebCore::ContentExtensions::NFAToDFA::convert): * contentextensions/NFAToDFA.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. * loader/cache/CachedResourceLoader.cpp: (WebCore::CachedResourceLoader::requestResource): Source/WebKit2: Provide a small SPI for OS X. This will likely move to a better place. * UIProcess/API/Cocoa/WKProcessPool.mm: (-[WKProcessPool _loadContentExtensionWithIdentifier:serializedRules:successCompletionHandler:errorCompletionHandler:]): * UIProcess/API/Cocoa/WKProcessPoolPrivate.h: * UIProcess/WebProcessPool.cpp: (WebKit::WebProcessPool::processDidFinishLaunching): (WebKit::WebProcessPool::loadContentExtension): * UIProcess/WebProcessPool.h: * WebProcess/WebProcess.cpp: (WebKit::WebProcess::loadContentExtension): * WebProcess/WebProcess.h: * WebProcess/WebProcess.messages.in: Source/WTF: * wtf/FeatureDefines.h: Canonical link: https://commits.webkit.org/158244@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@178151 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-01-09 01:56:00 +00:00
{
WKContentRuleLists should have a maximum FileProtection of CompleteUnlessOpen https://bugs.webkit.org/show_bug.cgi?id=197078 <rdar://problem/49564348> Reviewed by Geoff Garen. Source/WebKit: r242735 was a fix for crashes when using mmap'd memory in apps with default FileProtection of NSFileProtectionComplete. It is more memory efficient and just as secure to reduce the FileProtection of these files to NSFileProtectionCompleteUnlessOpen. * NetworkProcess/cache/NetworkCacheFileSystem.cpp: (WebKit::NetworkCache::isSafeToUseMemoryMapForPath): (WebKit::NetworkCache::makeSafeToUseMemoryMapForPath): (WebKit::NetworkCache::pathRegisteredAsUnsafeToMemoryMapForTesting): Deleted. (WebKit::NetworkCache::registerPathAsUnsafeToMemoryMapForTesting): Deleted. * NetworkProcess/cache/NetworkCacheFileSystem.h: * NetworkProcess/cache/NetworkCacheFileSystemCocoa.mm: Added. (WebKit::NetworkCache::isSafeToUseMemoryMapForPath): (WebKit::NetworkCache::makeSafeToUseMemoryMapForPath): * Shared/WebCompiledContentRuleList.cpp: (WebKit::WebCompiledContentRuleList::conditionsApplyOnlyToDomain const): (WebKit::WebCompiledContentRuleList::filtersWithoutConditionsBytecode const): (WebKit::WebCompiledContentRuleList::filtersWithConditionsBytecode const): (WebKit::WebCompiledContentRuleList::topURLFiltersBytecode const): (WebKit::WebCompiledContentRuleList::actions const): (WebKit::WebCompiledContentRuleList::usesCopiedMemory const): Deleted. * Shared/WebCompiledContentRuleList.h: * Shared/WebCompiledContentRuleListData.cpp: (WebKit::WebCompiledContentRuleListData::encode const): (WebKit::WebCompiledContentRuleListData::decode): (WebKit::WebCompiledContentRuleListData::size const): Deleted. (WebKit::WebCompiledContentRuleListData::dataPointer const): Deleted. * Shared/WebCompiledContentRuleListData.h: (WebKit::WebCompiledContentRuleListData::WebCompiledContentRuleListData): * SourcesCocoa.txt: * UIProcess/API/APIContentRuleList.cpp: (API::ContentRuleList::usesCopiedMemory const): Deleted. * UIProcess/API/APIContentRuleList.h: * UIProcess/API/APIContentRuleListStore.cpp: (API::openAndMapOrCopyContentRuleList): (API::compiledToFile): (API::createExtension): (API::ContentRuleListStore::getContentRuleListSource): (API::ContentRuleListStore::readContentsOfFile): Deleted. (API::MappedOrCopiedData::dataPointer const): Deleted. * UIProcess/API/APIContentRuleListStore.h: * UIProcess/API/Cocoa/APIContentRuleListStoreCocoa.mm: (API::ContentRuleListStore::readContentsOfFile): Deleted. * UIProcess/API/Cocoa/WKContentRuleListStore.mm: (+[WKContentRuleListStore _registerPathAsUnsafeToMemoryMapForTesting:]): Deleted. * UIProcess/API/Cocoa/WKContentRuleListStorePrivate.h: * UIProcess/API/Cocoa/_WKUserContentFilter.mm: (-[_WKUserContentFilter usesCopiedMemory]): Deleted. * UIProcess/API/Cocoa/_WKUserContentFilterPrivate.h: * WebKit.xcodeproj/project.pbxproj: Tools: * TestWebKitAPI/Tests/WebKitCocoa/WKContentExtensionStore.mm: (TEST_F): (-[TestSchemeHandlerSubresourceShouldBeBlocked webView:startURLSchemeTask:]): Deleted. (-[TestSchemeHandlerSubresourceShouldBeBlocked webView:stopURLSchemeTask:]): Deleted. Unfortunately, setting the NSFileProtectionKey attribute is only supported on iOS devices. Canonical link: https://commits.webkit.org/211457@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@244597 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-04-24 17:46:28 +00:00
SharedMemory::Handle handle;
data->createHandle(handle, SharedMemory::Protection::ReadOnly);
Convert remaining SharedMemory::Handle to SharedMemory::IPCHandle https://bugs.webkit.org/show_bug.cgi?id=215471 <rdar://problem/67024177> Reviewed by David Kilzer. Use the new struct for sending SharedMemory::Handle objects via IPC, so we can include the exact size of data (SharedMemory::Handle::size() rounds up to the nearest page), and verify these sizes match when decoding. In many cases, the size is not sent as a separate argument via IPC, so we can initialize the IPCHandle object with SharedMemory::Handle::size(). We can remove the additional size parameter when it exists, because we are now passing IPCHandle which should include the size value. * GPUProcess/webrtc/RemoteAudioMediaStreamTrackRenderer.cpp: (WebKit::RemoteAudioMediaStreamTrackRenderer::audioSamplesStorageChanged): * GPUProcess/webrtc/RemoteAudioMediaStreamTrackRenderer.h: * GPUProcess/webrtc/RemoteAudioMediaStreamTrackRenderer.messages.in: * GPUProcess/webrtc/RemoteMediaRecorder.cpp: (WebKit::RemoteMediaRecorder::audioSamplesStorageChanged): * GPUProcess/webrtc/RemoteMediaRecorder.h: * GPUProcess/webrtc/RemoteMediaRecorder.messages.in: Send SharedMemory::IPCHandle object instead of SharedMemory::Handle over IPC. * NetworkProcess/ServiceWorker/WebSWOriginStore.cpp: (WebKit::WebSWOriginStore::sendStoreHandle): Since no additional size parameter is being sent in this function, we can use handle.size() as the IPCHandle::dataSize parameter. * Platform/SharedMemory.h: Remove encode/decode functions in SharedMemory::Handle. * Platform/cocoa/SharedMemoryCocoa.cpp: (WebKit::SharedMemory::Handle::encode const): Deleted. (WebKit::SharedMemory::Handle::decode): Deleted. * Platform/unix/SharedMemoryUnix.cpp: (WebKit::SharedMemory::IPCHandle::encode const): (WebKit::SharedMemory::IPCHandle::decode): * Platform/win/SharedMemoryWin.cpp: (WebKit::SharedMemory::IPCHandle::encode const): (WebKit::SharedMemory::IPCHandle::decode): (WebKit::SharedMemory::Handle::encode const): Deleted. (WebKit::SharedMemory::Handle::decode): Deleted. Remove SharedMemory::Handle encode/decode functions so we will not ever send a SharedMemory::Handle object over IPC accidentally in the future. * Shared/ShareableBitmap.cpp: (WebKit::ShareableBitmap::Handle::encode const): (WebKit::ShareableBitmap::Handle::decode): Keep m_size here because it is an IntSize object and is useful to check width/height parameters in the SharableBitmap object. * Shared/ShareableResource.cpp: (WebKit::ShareableResource::Handle::encode const): (WebKit::ShareableResource::Handle::decode): * Shared/WebCompiledContentRuleListData.cpp: (WebKit::WebCompiledContentRuleListData::encode const): (WebKit::WebCompiledContentRuleListData::decode): * Shared/WebCoreArgumentCoders.cpp: (IPC::encodeSharedBuffer): (IPC::decodeSharedBuffer): * Shared/WebHitTestResultData.cpp: (WebKit::WebHitTestResultData::encode const): (WebKit::WebHitTestResultData::decode): More cases of converting between SharedMemory::Handle and SharedMemory::IPCHandle when encoding/decoding. * UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp: * UIProcess/VisitedLinkStore.cpp: (WebKit::VisitedLinkStore::sendStoreHandleToProcess): * WebProcess/GPU/media/RemoteAudioBusData.h: (WebKit::RemoteAudioBusData::encode const): (WebKit::RemoteAudioBusData::decode): Since no additional size parameter is being sent in this function, we can use handle.size() as the IPCHandle::dataSize parameter. * WebProcess/GPU/webrtc/AudioMediaStreamTrackRenderer.cpp: (WebKit::AudioMediaStreamTrackRenderer::storageChanged): * WebProcess/GPU/webrtc/MediaRecorderPrivate.cpp: (WebKit::MediaRecorderPrivate::storageChanged): * WebProcess/Storage/WebSWClientConnection.cpp: (WebKit::WebSWClientConnection::setSWOriginTableSharedMemory): * WebProcess/Storage/WebSWClientConnection.h: * WebProcess/Storage/WebSWClientConnection.messages.in: * WebProcess/WebPage/VisitedLinkTableController.cpp: (WebKit::VisitedLinkTableController::setVisitedLinkTable): * WebProcess/WebPage/VisitedLinkTableController.h: * WebProcess/WebPage/VisitedLinkTableController.messages.in: * WebProcess/cocoa/RemoteCaptureSampleManager.cpp: (WebKit::RemoteCaptureSampleManager::audioStorageChanged): * WebProcess/cocoa/RemoteCaptureSampleManager.h: * WebProcess/cocoa/RemoteCaptureSampleManager.messages.in: More cases of converting between SharedMemory::Handle and SharedMemory::IPCHandle when encoding/decoding. Canonical link: https://commits.webkit.org/228303@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@265725 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-08-15 01:46:04 +00:00
#if OS(DARWIN) || OS(WINDOWS)
// Exact data size is the last bytecode offset plus its size.
uint64_t dataSize = topURLFiltersBytecodeOffset + topURLFiltersBytecodeSize;
Convert remaining SharedMemory::Handle to SharedMemory::IPCHandle https://bugs.webkit.org/show_bug.cgi?id=215471 <rdar://problem/67024177> Reviewed by David Kilzer. Use the new struct for sending SharedMemory::Handle objects via IPC, so we can include the exact size of data (SharedMemory::Handle::size() rounds up to the nearest page), and verify these sizes match when decoding. In many cases, the size is not sent as a separate argument via IPC, so we can initialize the IPCHandle object with SharedMemory::Handle::size(). We can remove the additional size parameter when it exists, because we are now passing IPCHandle which should include the size value. * GPUProcess/webrtc/RemoteAudioMediaStreamTrackRenderer.cpp: (WebKit::RemoteAudioMediaStreamTrackRenderer::audioSamplesStorageChanged): * GPUProcess/webrtc/RemoteAudioMediaStreamTrackRenderer.h: * GPUProcess/webrtc/RemoteAudioMediaStreamTrackRenderer.messages.in: * GPUProcess/webrtc/RemoteMediaRecorder.cpp: (WebKit::RemoteMediaRecorder::audioSamplesStorageChanged): * GPUProcess/webrtc/RemoteMediaRecorder.h: * GPUProcess/webrtc/RemoteMediaRecorder.messages.in: Send SharedMemory::IPCHandle object instead of SharedMemory::Handle over IPC. * NetworkProcess/ServiceWorker/WebSWOriginStore.cpp: (WebKit::WebSWOriginStore::sendStoreHandle): Since no additional size parameter is being sent in this function, we can use handle.size() as the IPCHandle::dataSize parameter. * Platform/SharedMemory.h: Remove encode/decode functions in SharedMemory::Handle. * Platform/cocoa/SharedMemoryCocoa.cpp: (WebKit::SharedMemory::Handle::encode const): Deleted. (WebKit::SharedMemory::Handle::decode): Deleted. * Platform/unix/SharedMemoryUnix.cpp: (WebKit::SharedMemory::IPCHandle::encode const): (WebKit::SharedMemory::IPCHandle::decode): * Platform/win/SharedMemoryWin.cpp: (WebKit::SharedMemory::IPCHandle::encode const): (WebKit::SharedMemory::IPCHandle::decode): (WebKit::SharedMemory::Handle::encode const): Deleted. (WebKit::SharedMemory::Handle::decode): Deleted. Remove SharedMemory::Handle encode/decode functions so we will not ever send a SharedMemory::Handle object over IPC accidentally in the future. * Shared/ShareableBitmap.cpp: (WebKit::ShareableBitmap::Handle::encode const): (WebKit::ShareableBitmap::Handle::decode): Keep m_size here because it is an IntSize object and is useful to check width/height parameters in the SharableBitmap object. * Shared/ShareableResource.cpp: (WebKit::ShareableResource::Handle::encode const): (WebKit::ShareableResource::Handle::decode): * Shared/WebCompiledContentRuleListData.cpp: (WebKit::WebCompiledContentRuleListData::encode const): (WebKit::WebCompiledContentRuleListData::decode): * Shared/WebCoreArgumentCoders.cpp: (IPC::encodeSharedBuffer): (IPC::decodeSharedBuffer): * Shared/WebHitTestResultData.cpp: (WebKit::WebHitTestResultData::encode const): (WebKit::WebHitTestResultData::decode): More cases of converting between SharedMemory::Handle and SharedMemory::IPCHandle when encoding/decoding. * UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp: * UIProcess/VisitedLinkStore.cpp: (WebKit::VisitedLinkStore::sendStoreHandleToProcess): * WebProcess/GPU/media/RemoteAudioBusData.h: (WebKit::RemoteAudioBusData::encode const): (WebKit::RemoteAudioBusData::decode): Since no additional size parameter is being sent in this function, we can use handle.size() as the IPCHandle::dataSize parameter. * WebProcess/GPU/webrtc/AudioMediaStreamTrackRenderer.cpp: (WebKit::AudioMediaStreamTrackRenderer::storageChanged): * WebProcess/GPU/webrtc/MediaRecorderPrivate.cpp: (WebKit::MediaRecorderPrivate::storageChanged): * WebProcess/Storage/WebSWClientConnection.cpp: (WebKit::WebSWClientConnection::setSWOriginTableSharedMemory): * WebProcess/Storage/WebSWClientConnection.h: * WebProcess/Storage/WebSWClientConnection.messages.in: * WebProcess/WebPage/VisitedLinkTableController.cpp: (WebKit::VisitedLinkTableController::setVisitedLinkTable): * WebProcess/WebPage/VisitedLinkTableController.h: * WebProcess/WebPage/VisitedLinkTableController.messages.in: * WebProcess/cocoa/RemoteCaptureSampleManager.cpp: (WebKit::RemoteCaptureSampleManager::audioStorageChanged): * WebProcess/cocoa/RemoteCaptureSampleManager.h: * WebProcess/cocoa/RemoteCaptureSampleManager.messages.in: More cases of converting between SharedMemory::Handle and SharedMemory::IPCHandle when encoding/decoding. Canonical link: https://commits.webkit.org/228303@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@265725 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-08-15 01:46:04 +00:00
#else
uint64_t dataSize = 0;
#endif
encoder << SharedMemory::IPCHandle { WTFMove(handle), dataSize };
Add a WKContentRuleList variant that uses copied memory instead of mmap'd shared memory for class A containerized apps https://bugs.webkit.org/show_bug.cgi?id=195511 <rdar://problem/44873269> Patch by Alex Christensen <achristensen@webkit.org> on 2019-03-11 Reviewed by Darin Adler. Source/WebKit: * NetworkProcess/NetworkContentRuleListManager.cpp: (WebKit::NetworkContentRuleListManager::addContentRuleLists): * NetworkProcess/NetworkContentRuleListManager.h: * NetworkProcess/cache/NetworkCacheFileSystem.cpp: (WebKit::NetworkCache::pathRegisteredAsUnsafeToMemoryMapForTesting): (WebKit::NetworkCache::registerPathAsUnsafeToMemoryMapForTesting): (WebKit::NetworkCache::isSafeToUseMemoryMapForPath): * NetworkProcess/cache/NetworkCacheFileSystem.h: * Shared/WebCompiledContentRuleList.cpp: (WebKit::WebCompiledContentRuleList::usesCopiedMemory const): (WebKit::WebCompiledContentRuleList::conditionsApplyOnlyToDomain const): (WebKit::WebCompiledContentRuleList::filtersWithoutConditionsBytecode const): (WebKit::WebCompiledContentRuleList::filtersWithConditionsBytecode const): (WebKit::WebCompiledContentRuleList::topURLFiltersBytecode const): (WebKit::WebCompiledContentRuleList::actions const): * Shared/WebCompiledContentRuleList.h: * Shared/WebCompiledContentRuleListData.cpp: (WebKit::WebCompiledContentRuleListData::size const): (WebKit::WebCompiledContentRuleListData::dataPointer const): (WebKit::WebCompiledContentRuleListData::encode const): (WebKit::WebCompiledContentRuleListData::decode): * Shared/WebCompiledContentRuleListData.h: (WebKit::WebCompiledContentRuleListData::WebCompiledContentRuleListData): * UIProcess/API/APIContentRuleList.cpp: (API::ContentRuleList::usesCopiedMemory const): * UIProcess/API/APIContentRuleList.h: * UIProcess/API/APIContentRuleListStore.cpp: (API::getData): (API::decodeContentRuleListMetaData): (API::ContentRuleListStore::readContentsOfFile): (API::MappedOrCopiedData::dataPointer const): (API::openAndMapOrCopyContentRuleList): (API::compiledToFile): (API::createExtension): (API::ContentRuleListStore::lookupContentRuleList): (API::ContentRuleListStore::compileContentRuleList): (API::ContentRuleListStore::getContentRuleListSource): (API::openAndMapContentRuleList): Deleted. * UIProcess/API/APIContentRuleListStore.h: * UIProcess/API/Cocoa/APIContentRuleListStoreCocoa.mm: (API::ContentRuleListStore::readContentsOfFile): * UIProcess/API/Cocoa/WKContentRuleListStore.mm: (+[WKContentRuleListStore _registerPathAsUnsafeToMemoryMapForTesting:]): * UIProcess/API/Cocoa/WKContentRuleListStorePrivate.h: * UIProcess/API/Cocoa/_WKUserContentFilter.mm: (-[_WKUserContentFilter usesCopiedMemory]): * UIProcess/API/Cocoa/_WKUserContentFilterPrivate.h: * WebProcess/UserContent/WebUserContentController.cpp: (WebKit::WebUserContentController::addContentRuleLists): * WebProcess/UserContent/WebUserContentController.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::m_hostFileDescriptor): Tools: * TestWebKitAPI/Tests/WebKitCocoa/WKContentExtensionStore.mm: (-[TestSchemeHandlerSubresourceShouldBeBlocked webView:startURLSchemeTask:]): (-[TestSchemeHandlerSubresourceShouldBeBlocked webView:stopURLSchemeTask:]): (TEST_F): Canonical link: https://commits.webkit.org/209867@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242735 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-03-11 20:21:39 +00:00
WKContentRuleLists with if-top-url or unless-top-url should run regex against entire top URL https://bugs.webkit.org/show_bug.cgi?id=173980 Reviewed by Tim Horton. Source/WebKit2: if-top-url and unless-top-url were broken inside WebKit2 apps. This fixes them and adds a test. ContentExtension::populateConditionCacheIfNeeded was calling WebCompiledContentRuleList::conditionsApplyOnlyToDomain but m_data.conditionsApplyOnlyToDomainOffset was always 0 instead of ConditionsApplyOnlyToDomainOffset because it wasn't being encoded and decoded when telling the WebProcess about the content rule list. This was causing us to use whatever was at offset 0 in the file instead of the correct value stored in the file to determine whether to run regular expressions against the entire top URL for if-top-url or unless-top-url or against just the domain for if-top-domain or unless-top-domain. Luckily, offset 0 in the file is always ContentRuleListStore::CurrentContentRuleListFileVersion, so it was deterministic and easy to debug. I should have added a LayoutTest with r213669 to verify correct behavior in an actual WKWebView, but I didn't because it wouldn't have caught regressions since the contentextension tests are marked as flaky since r206914, but once that is fixed the new test http/tests/contentextensions/top-url.html will verify that this feature is behaving correctly. It failed before this change and passes after. * Shared/WebCompiledContentRuleListData.cpp: (WebKit::WebCompiledContentRuleListData::encode): (WebKit::WebCompiledContentRuleListData::decode): LayoutTests: * http/tests/contentextensions/top-url-expected.txt: Added. * http/tests/contentextensions/top-url.html: Added. * http/tests/contentextensions/top-url.html.json: Added. Canonical link: https://commits.webkit.org/190818@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@218956 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-06-29 19:31:36 +00:00
encoder << conditionsApplyOnlyToDomainOffset;
[Content Extensions] Pass compiled content extensions as read-only shared memory rather than copying them https://bugs.webkit.org/show_bug.cgi?id=142458 Reviewed by Dan Bernstein. * Shared/WebCompiledContentExtensionData.cpp: (WebKit::WebCompiledContentExtensionData::encode): (WebKit::WebCompiledContentExtensionData::decode): * Shared/WebCompiledContentExtensionData.h: (WebKit::WebCompiledContentExtensionData::WebCompiledContentExtensionData): Store the compiled data as a SharedMemory block with offset/size pairs for the bytecode and actions. While the bytecode offset is currently always 0, this won't be the case when we map these in from files due to metadata that will be placed at the top of the files. * Shared/WebCompiledContentExtension.h: * Shared/WebCompiledContentExtension.cpp: (WebKit::WebCompiledContentExtension::createFromCompiledContentExtensionData): Temporary creation helper. In subsequent patches, this will be removed and replaced by always passing in shared/mapped data. (WebKit::WebCompiledContentExtension::create): (WebKit::WebCompiledContentExtension::WebCompiledContentExtension): (WebKit::WebCompiledContentExtension::bytecode): (WebKit::WebCompiledContentExtension::bytecodeLength): (WebKit::WebCompiledContentExtension::actions): (WebKit::WebCompiledContentExtension::actionsLength): Convert to work with the new WebCompiledContentExtension format. * UIProcess/API/C/WKUserContentFilterRef.cpp: (WKUserContentFilterCreate): * UIProcess/API/Cocoa/_WKUserContentFilter.mm: (-[_WKUserContentFilter initWithName:serializedRules:]): Switch to using WebCompiledContentExtension::createFromCompiledContentExtensionData(). * WebProcess/UserContent/WebUserContentController.cpp: (WebKit::WebUserContentController::addUserContentExtensions): * WebProcess/WebPage/WebPageGroupProxy.cpp: (WebKit::WebPageGroupProxy::addUserContentExtension): Update to pass the WebCompiledContentExtensionData directly to the WebCompiledContentExtension. Canonical link: https://commits.webkit.org/160504@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@181246 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-03-08 21:32:50 +00:00
encoder << actionsOffset;
encoder << actionsSize;
[Content Extensions] Rename "Domain" to "Condition" where appropriate https://bugs.webkit.org/show_bug.cgi?id=169297 Reviewed by Brady Eidson. Source/WebCore: In r184116 I added the ability for a content blocker author to add conditions to the triggers, if-domain and unless-domain which look at the domain of the main document URL. I plan to add more conditions soon to run regexes on the entire URL, but to make that patch more manageable, I took the non-behavior-changing parts and put them in this patch. No change in behavior except some error messages were made more generic. * contentextensions/CompiledContentExtension.h: * contentextensions/ContentExtension.cpp: (WebCore::ContentExtensions::ContentExtension::ContentExtension): (WebCore::ContentExtensions::ContentExtension::compileGlobalDisplayNoneStyleSheet): (WebCore::ContentExtensions::ContentExtension::populateConditionCacheIfNeeded): Pass the main document URL instead of just the domain. No change in behavior yet. (WebCore::ContentExtensions::ContentExtension::cachedConditionedActions): (WebCore::ContentExtensions::ContentExtension::universalActionsWithConditions): (WebCore::ContentExtensions::ContentExtension::populateDomainCacheIfNeeded): Deleted. (WebCore::ContentExtensions::ContentExtension::cachedDomainActions): Deleted. (WebCore::ContentExtensions::ContentExtension::universalActionsWithDomains): Deleted. * contentextensions/ContentExtension.h: (WebCore::ContentExtensions::ContentExtension::universalActionsWithoutConditions): (WebCore::ContentExtensions::ContentExtension::universalActionsWithoutDomains): Deleted. * contentextensions/ContentExtensionCompiler.cpp: (WebCore::ContentExtensions::serializeActions): (WebCore::ContentExtensions::compileRuleList): * contentextensions/ContentExtensionCompiler.h: * contentextensions/ContentExtensionError.cpp: (WebCore::ContentExtensions::contentExtensionErrorCategory): * contentextensions/ContentExtensionError.h: * contentextensions/ContentExtensionParser.cpp: (WebCore::ContentExtensions::getStringList): Don't pass the error type as a parameter. It's always JSONInvalidConditionList. (WebCore::ContentExtensions::getDomainList): (WebCore::ContentExtensions::loadTrigger): * contentextensions/ContentExtensionRule.h: (WebCore::ContentExtensions::Trigger::~Trigger): (WebCore::ContentExtensions::Trigger::isEmpty): (WebCore::ContentExtensions::Trigger::operator==): (WebCore::ContentExtensions::TriggerHash::hash): Use bitwise xor instead of bitwise or to have fewer hash collisions. Also, before we were accidentally doing the same hash operation here for IfDomain and UnlessDomain. This caused unnecessary hash collisions. This is fixed, but should not change any behavior. * 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::matchesCondition): (WebCore::ContentExtensions::DFABytecodeInterpreter::interpretAppendAction): (WebCore::ContentExtensions::DFABytecodeInterpreter::interpretTestFlagsAndAppendAction): (WebCore::ContentExtensions::DFABytecodeInterpreter::actionsMatchingEverything): (WebCore::ContentExtensions::DFABytecodeInterpreter::interpretWithConditions): (WebCore::ContentExtensions::DFABytecodeInterpreter::interpret): (WebCore::ContentExtensions::matchesDomain): Deleted. (WebCore::ContentExtensions::DFABytecodeInterpreter::interpretWithDomains): Deleted. * contentextensions/DFABytecodeInterpreter.h: * loader/ResourceLoadInfo.h: Source/WebKit2: * Shared/WebCompiledContentExtension.cpp: (WebKit::WebCompiledContentExtension::filtersWithoutConditionsBytecode): (WebKit::WebCompiledContentExtension::filtersWithoutConditionsBytecodeLength): (WebKit::WebCompiledContentExtension::filtersWithConditionsBytecode): (WebKit::WebCompiledContentExtension::filtersWithConditionsBytecodeLength): (WebKit::WebCompiledContentExtension::conditionedFiltersBytecode): (WebKit::WebCompiledContentExtension::conditionedFiltersBytecodeLength): (WebKit::WebCompiledContentExtension::filtersWithoutDomainsBytecode): Deleted. (WebKit::WebCompiledContentExtension::filtersWithoutDomainsBytecodeLength): Deleted. (WebKit::WebCompiledContentExtension::filtersWithDomainsBytecode): Deleted. (WebKit::WebCompiledContentExtension::filtersWithDomainsBytecodeLength): Deleted. (WebKit::WebCompiledContentExtension::domainFiltersBytecode): Deleted. (WebKit::WebCompiledContentExtension::domainFiltersBytecodeLength): Deleted. * Shared/WebCompiledContentExtension.h: * Shared/WebCompiledContentExtensionData.cpp: (WebKit::WebCompiledContentExtensionData::encode): (WebKit::WebCompiledContentExtensionData::decode): * Shared/WebCompiledContentExtensionData.h: (WebKit::WebCompiledContentExtensionData::WebCompiledContentExtensionData): * UIProcess/API/APIUserContentExtensionStore.cpp: (API::ContentExtensionMetaData::fileSize): (API::encodeContentExtensionMetaData): (API::decodeContentExtensionMetaData): (API::compiledToFile): (API::createExtension): (API::UserContentExtensionStore::lookupContentExtension): (API::UserContentExtensionStore::compileContentExtension): (API::UserContentExtensionStore::removeContentExtension): * UIProcess/API/APIUserContentExtensionStore.h: Tools: * TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp: (TestWebKitAPI::InMemoryCompiledContentExtension::create): (TestWebKitAPI::TEST_F): Canonical link: https://commits.webkit.org/186295@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@213533 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-03-07 20:54:09 +00:00
encoder << filtersWithoutConditionsBytecodeOffset;
encoder << filtersWithoutConditionsBytecodeSize;
encoder << filtersWithConditionsBytecodeOffset;
encoder << filtersWithConditionsBytecodeSize;
[Content Extensions] Introduce if-top-url and unless-top-url https://bugs.webkit.org/show_bug.cgi?id=169433 Reviewed by Brady Eidson. Source/WebCore: In r184116 I added if-domain and unless-domain to control whether a rule applies based on the domain of the main document URL. I'm expanding this by adding if-top-url and unless-top-url that run regular expressions on the entire main document URL so that example.com/user1content can be distinguished from example.com/user2content. To not add to the number of passes we make on the URLs for each load and to maintain JSON backwards compatibility, I've made it so that if-top-url and unless-top-url can be used instead of if-domain and unless-domain (which continue to work) but the two condition types cannot be used together since running regular expressions on the entire main document URL is strictly more powerful than checking the domain and subdomains. As a minor detail, content extension regexes are by default ASCII-case-insensitive, so I've done the same with top URL regexes, adding top-url-filter-is-case-sensitive to mirror the existing url-filter-is-case-sensitive if the JSON author decides to make regexes case sensitive. Covered by new API tests. * contentextensions/CompiledContentExtension.h: * contentextensions/ContentExtension.cpp: (WebCore::ContentExtensions::ContentExtension::populateConditionCacheIfNeeded): (WebCore::ContentExtensions::ContentExtension::topURLActions): (WebCore::ContentExtensions::ContentExtension::cachedConditionedActions): Deleted. * contentextensions/ContentExtension.h: * contentextensions/ContentExtensionCompiler.cpp: (WebCore::ContentExtensions::addUniversalActionsToDFA): (WebCore::ContentExtensions::compileToBytecode): We had three copies of compiling to bytecode that were almost the same and would've been made into three copies of the same code. I moved them to one helper function that is called three times. (WebCore::ContentExtensions::compileRuleList): * contentextensions/ContentExtensionCompiler.h: * contentextensions/ContentExtensionError.cpp: (WebCore::ContentExtensions::contentExtensionErrorCategory): Add the new error type for JSON that tries to use if-top-url and unless-top-url with if-domain and unless-domain. * contentextensions/ContentExtensionError.h: * contentextensions/ContentExtensionParser.cpp: (WebCore::ContentExtensions::loadTrigger): Parse the new values if-top-url, unless-top-url, and top-url-filter-is-case-sensitive. * contentextensions/ContentExtensionRule.h: (WebCore::ContentExtensions::Trigger::~Trigger): * contentextensions/ContentExtensionsBackend.cpp: (WebCore::ContentExtensions::ContentExtensionsBackend::actionsForResourceLoad): * contentextensions/DFABytecodeInterpreter.cpp: (WebCore::ContentExtensions::DFABytecodeInterpreter::interpretAppendAction): (WebCore::ContentExtensions::DFABytecodeInterpreter::interpretTestFlagsAndAppendAction): (WebCore::ContentExtensions::DFABytecodeInterpreter::interpretWithConditions): * contentextensions/DFABytecodeInterpreter.h: Source/WebKit2: Rename conditionedFilters to topURLFilters to reflect the fact that they are the filters that are run on the top URL, and possibly just the domain of the top url. I was a bit too aggressive when renaming domain* to condition* in r213533. * Shared/WebCompiledContentExtension.cpp: (WebKit::WebCompiledContentExtension::conditionsApplyOnlyToDomain): (WebKit::WebCompiledContentExtension::topURLFiltersBytecode): (WebKit::WebCompiledContentExtension::topURLFiltersBytecodeLength): (WebKit::WebCompiledContentExtension::conditionedFiltersBytecode): Deleted. (WebKit::WebCompiledContentExtension::conditionedFiltersBytecodeLength): Deleted. * Shared/WebCompiledContentExtension.h: * Shared/WebCompiledContentExtensionData.cpp: (WebKit::WebCompiledContentExtensionData::encode): (WebKit::WebCompiledContentExtensionData::decode): * Shared/WebCompiledContentExtensionData.h: (WebKit::WebCompiledContentExtensionData::WebCompiledContentExtensionData): * UIProcess/API/APIUserContentExtensionStore.cpp: (API::encodeContentExtensionMetaData): (API::decodeContentExtensionMetaData): (API::compiledToFile): (API::createExtension): (API::UserContentExtensionStore::invalidateContentExtensionVersion): (API::userContentExtensionStoreErrorCategory): * UIProcess/API/APIUserContentExtensionStore.h: Increment CurrentContentExtensionFileVersion because we have changed the format of the binary on disk. We only added 4 bytes, but that's binary incompatible and requires re-compiling any existing content extensions. Tools: * TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp: (TestWebKitAPI::TEST_F): Add tests for new functionality and new failure types. Canonical link: https://commits.webkit.org/186425@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@213669 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-03-09 22:17:13 +00:00
encoder << topURLFiltersBytecodeOffset;
encoder << topURLFiltersBytecodeSize;
[WK2] Start a prototype for declarative site specific extensions https://bugs.webkit.org/show_bug.cgi?id=140160 Reviewed by Andreas Kling. Source/WebCore: Currently, clients have various ways to execute custom code for certain URLs. Each of those mechanism implies messaging the UIProcess, executing some code calling back to the WebProcess, then actually load the resource. All this back and forth introduces delays before we actually load resources. Since the set of actions is done per site is actually simple and limited, it may be possible to do everything in WebCore and shortcut the defered loading. This patch provides the starting point for this idea. The "rules" (currently just blocking) are be passed to WebCore in a JSON format. In WebCore, we create a state machine to match the rules and we execute the action when the state machine tells us to. * WebCore.exp.in: * WebCore.xcodeproj/project.pbxproj: * contentextensions/ContentExtensionRule.cpp: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. (WebCore::ContentExtensions::ContentExtensionRule::ContentExtensionRule): * contentextensions/ContentExtensionRule.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. (WebCore::ContentExtensions::ContentExtensionRule::trigger): (WebCore::ContentExtensions::ContentExtensionRule::action): * contentextensions/ContentExtensionsBackend.cpp: Added. (WebCore::ContentExtensions::ContentExtensionsBackend::sharedInstance): (WebCore::ContentExtensions::ContentExtensionsBackend::setRuleList): (WebCore::ContentExtensions::ContentExtensionsBackend::removeRuleList): (WebCore::ContentExtensions::ContentExtensionsBackend::shouldBlockURL): * contentextensions/ContentExtensionsBackend.h: Added. * contentextensions/ContentExtensionsInterface.cpp: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. (WebCore::ContentExtensions::shouldBlockURL): * contentextensions/ContentExtensionsInterface.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. * contentextensions/ContentExtensionsManager.cpp: Added. (WebCore::ContentExtensions::ExtensionsManager::loadTrigger): (WebCore::ContentExtensions::ExtensionsManager::loadAction): (WebCore::ContentExtensions::ExtensionsManager::loadRule): (WebCore::ContentExtensions::ExtensionsManager::loadExtension): * contentextensions/ContentExtensionsManager.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. * contentextensions/DFA.cpp: Added. (WebCore::ContentExtensions::DFA::DFA): (WebCore::ContentExtensions::DFA::operator=): (WebCore::ContentExtensions::DFA::nextState): (WebCore::ContentExtensions::DFA::actions): (WebCore::ContentExtensions::DFA::debugPrintDot): * contentextensions/DFA.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. (WebCore::ContentExtensions::DFA::root): * contentextensions/DFANode.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. * contentextensions/NFA.cpp: Added. (WebCore::ContentExtensions::NFA::NFA): (WebCore::ContentExtensions::NFA::createNode): (WebCore::ContentExtensions::NFA::addTransition): (WebCore::ContentExtensions::NFA::addEpsilonTransition): (WebCore::ContentExtensions::NFA::setFinal): (WebCore::ContentExtensions::NFA::debugPrintDot): * contentextensions/NFA.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. (WebCore::ContentExtensions::NFA::root): * contentextensions/NFANode.cpp: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. (WebCore::ContentExtensions::NFANode::NFANode): * contentextensions/NFANode.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. * contentextensions/NFAToDFA.cpp: Added. (WebCore::ContentExtensions::epsilonClosure): (WebCore::ContentExtensions::setTransitionsExcludingEpsilon): (WebCore::ContentExtensions::HashableNodeIdSet::HashableNodeIdSet): (WebCore::ContentExtensions::HashableNodeIdSet::operator=): (WebCore::ContentExtensions::HashableNodeIdSet::isEmptyValue): (WebCore::ContentExtensions::HashableNodeIdSet::isDeletedValue): (WebCore::ContentExtensions::HashableNodeIdSet::nodeIdSet): (WebCore::ContentExtensions::HashableNodeIdSetHash::hash): (WebCore::ContentExtensions::HashableNodeIdSetHash::equal): (WebCore::ContentExtensions::addDFAState): (WebCore::ContentExtensions::NFAToDFA::convert): * contentextensions/NFAToDFA.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. * loader/cache/CachedResourceLoader.cpp: (WebCore::CachedResourceLoader::requestResource): Source/WebKit2: Provide a small SPI for OS X. This will likely move to a better place. * UIProcess/API/Cocoa/WKProcessPool.mm: (-[WKProcessPool _loadContentExtensionWithIdentifier:serializedRules:successCompletionHandler:errorCompletionHandler:]): * UIProcess/API/Cocoa/WKProcessPoolPrivate.h: * UIProcess/WebProcessPool.cpp: (WebKit::WebProcessPool::processDidFinishLaunching): (WebKit::WebProcessPool::loadContentExtension): * UIProcess/WebProcessPool.h: * WebProcess/WebProcess.cpp: (WebKit::WebProcess::loadContentExtension): * WebProcess/WebProcess.h: * WebProcess/WebProcess.messages.in: Source/WTF: * wtf/FeatureDefines.h: Canonical link: https://commits.webkit.org/158244@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@178151 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-01-09 01:56:00 +00:00
}
Remove WTF::Optional synonym for std::optional, using that class template directly instead https://bugs.webkit.org/show_bug.cgi?id=226433 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * inspector/scripts/codegen/generate_objc_protocol_types_implementation.py: (ObjCProtocolTypesImplementationGenerator._generate_init_method_for_payload): Use auto instead of Optional<>. Also use * instead of value() and nest the definition of the local inside an if statement in the case where it's an optional. * inspector/scripts/tests/expected/*: Regenerated these results. Source/WebCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebCore/PAL: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebDriver: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKit: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * Scripts/webkit/tests: Regenerated expected results, by running the command "python Scripts/webkit/messages_unittest.py -r". (How am I supposed to know to do that?) Source/WebKitLegacy/ios: * WebCoreSupport/WebChromeClientIOS.h: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/mac: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/win: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WTF: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * wtf/Optional.h: Remove WTF::Optional. Tools: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Canonical link: https://commits.webkit.org/238290@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278253 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-30 16:11:40 +00:00
std::optional<WebCompiledContentRuleListData> WebCompiledContentRuleListData::decode(IPC::Decoder& decoder)
Add initial experimental user content filtering API https://bugs.webkit.org/show_bug.cgi?id=140584 Reviewed by Benjamin Poulain. Source/WebCore: Change content extensions to be managed through the UserContentController. * WebCore.exp.in: Update exports. * WebCore.xcodeproj/project.pbxproj: Update for removed files. * contentextensions/ContentExtensionsBackend.cpp: (WebCore::ContentExtensions::ContentExtensionsBackend::removeAllRuleLists): (WebCore::ContentExtensions::ContentExtensionsBackend::sharedInstance): Deleted. * contentextensions/ContentExtensionsBackend.h: Remove concept of a shared instance and add a removeAllRuleLists() function. * contentextensions/ContentExtensionsInterface.cpp: Removed. * contentextensions/ContentExtensionsInterface.h: Removed. Since there is no shared instance anymore, checking if a URL should be blocked now has to go directly to the backend. * contentextensions/ContentExtensionsManager.cpp: (WebCore::ContentExtensions::ExtensionsManager::createRuleList): (WebCore::ContentExtensions::ExtensionsManager::loadExtension): Deleted. * contentextensions/ContentExtensionsManager.h: Update interface to accommodate the lack of a shared instance. Now, all this file does is take a serialized rule list and outputs the Vector of ContentExtensionRules * loader/cache/CachedResourceLoader.cpp: (WebCore::CachedResourceLoader::requestResource): Check with the UserContentController to see if the URL should be blocked. * page/UserContentController.cpp: (WebCore::UserContentController::addUserContentFilter): (WebCore::UserContentController::removeAllUserContentFilters): (WebCore::UserContentController::contentFilterBlocksURL): * page/UserContentController.h: Add single point of interaction for both the WebKit level to add and remove content filters and WebCore to check to see if URLs should be blocked. Source/WebKit2: Moves content filtering from being per-ProcessPool to per-UserContentController. * Shared/API/APIObject.h: * Shared/API/c/WKBase.h: * UIProcess/API/APIUserContentFilter.cpp: Added. (API::UserContentFilter::UserContentFilter): (API::UserContentFilter::~UserContentFilter): * UIProcess/API/APIUserContentFilter.h: Added. * UIProcess/API/C/WKAPICast.h: * UIProcess/API/C/WKUserContentFilterRef.cpp: Added. (WKUserContentFilterGetTypeID): (WKUserContentFilterCreate): * UIProcess/API/C/WKUserContentFilterRef.h: Added. * UIProcess/API/C/WebKit2_C.h: * UIProcess/API/Cocoa/_WKUserContentFilter.h: Added. * UIProcess/API/Cocoa/_WKUserContentFilter.mm: Added. (WKUserContentControllerAddUserContentFilter): (WKUserContentControllerRemoveAllUserContentFilters): (-[_WKUserContentFilter _initWithName:ruleList:]): * UIProcess/API/Cocoa/_WKUserContentFilterInternal.h: Added. Add a basic UserContentFilter type and expose it via both the Objective-C API (as _WKUserContentFilter) and via the C SPI (as WKUserContentFilterRef). * UIProcess/API/C/WKUserContentControllerRef.h: * UIProcess/API/C/WKUserContentControllerRef.cpp: Add C-SPI to set and remove WKUserContentFilterRefs. * UIProcess/API/Cocoa/WKProcessPool.mm: (-[WKProcessPool _loadContentExtensionWithIdentifier:serializedRules:successCompletionHandler:errorCompletionHandler:]): Deleted. * UIProcess/API/Cocoa/WKProcessPoolPrivate.h: * UIProcess/WebProcessPool.cpp: (WebKit::WebProcessPool::processDidFinishLaunching): (WebKit::WebProcessPool::loadContentExtension): Deleted. * UIProcess/WebProcessPool.h: * WebProcess/WebProcess.cpp: (WebKit::WebProcess::loadContentExtension): Deleted. * WebProcess/WebProcess.h: * WebProcess/WebProcess.messages.in: Remove the old SPI for loading content filters that was per-ProcessPool. Content filters now follow the same pattern as UserScripts and UserStyleSheets as being per-UserContentController. * UIProcess/API/Cocoa/WKUserContentController.mm: (-[WKUserContentController _addUserContentFilter:]): (-[WKUserContentController _removeAllUserContentFilters]): * UIProcess/API/Cocoa/WKUserContentControllerInternal.h: * UIProcess/API/Cocoa/WKUserContentControllerPrivate.h: Added. * UIProcess/UserContent/WebUserContentControllerProxy.cpp: (WebKit::WebUserContentControllerProxy::WebUserContentControllerProxy): (WebKit::WebUserContentControllerProxy::addProcess): (WebKit::WebUserContentControllerProxy::addUserContentFilter): (WebKit::WebUserContentControllerProxy::removeAllUserContentFilters): * UIProcess/UserContent/WebUserContentControllerProxy.h: * WebProcess/UserContent/WebUserContentController.cpp: (WebKit::WebUserContentController::addUserContentFilters): (WebKit::WebUserContentController::removeAllUserContentFilters): * WebProcess/UserContent/WebUserContentController.h: * WebProcess/UserContent/WebUserContentController.messages.in: Pipe user content filters over to all the WebProcesses that the UserContentController is connected to. * WebKit2.xcodeproj/project.pbxproj: Add new files. Canonical link: https://commits.webkit.org/158567@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@178634 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-01-18 21:54:12 +00:00
{
Convert remaining SharedMemory::Handle to SharedMemory::IPCHandle https://bugs.webkit.org/show_bug.cgi?id=215471 <rdar://problem/67024177> Reviewed by David Kilzer. Use the new struct for sending SharedMemory::Handle objects via IPC, so we can include the exact size of data (SharedMemory::Handle::size() rounds up to the nearest page), and verify these sizes match when decoding. In many cases, the size is not sent as a separate argument via IPC, so we can initialize the IPCHandle object with SharedMemory::Handle::size(). We can remove the additional size parameter when it exists, because we are now passing IPCHandle which should include the size value. * GPUProcess/webrtc/RemoteAudioMediaStreamTrackRenderer.cpp: (WebKit::RemoteAudioMediaStreamTrackRenderer::audioSamplesStorageChanged): * GPUProcess/webrtc/RemoteAudioMediaStreamTrackRenderer.h: * GPUProcess/webrtc/RemoteAudioMediaStreamTrackRenderer.messages.in: * GPUProcess/webrtc/RemoteMediaRecorder.cpp: (WebKit::RemoteMediaRecorder::audioSamplesStorageChanged): * GPUProcess/webrtc/RemoteMediaRecorder.h: * GPUProcess/webrtc/RemoteMediaRecorder.messages.in: Send SharedMemory::IPCHandle object instead of SharedMemory::Handle over IPC. * NetworkProcess/ServiceWorker/WebSWOriginStore.cpp: (WebKit::WebSWOriginStore::sendStoreHandle): Since no additional size parameter is being sent in this function, we can use handle.size() as the IPCHandle::dataSize parameter. * Platform/SharedMemory.h: Remove encode/decode functions in SharedMemory::Handle. * Platform/cocoa/SharedMemoryCocoa.cpp: (WebKit::SharedMemory::Handle::encode const): Deleted. (WebKit::SharedMemory::Handle::decode): Deleted. * Platform/unix/SharedMemoryUnix.cpp: (WebKit::SharedMemory::IPCHandle::encode const): (WebKit::SharedMemory::IPCHandle::decode): * Platform/win/SharedMemoryWin.cpp: (WebKit::SharedMemory::IPCHandle::encode const): (WebKit::SharedMemory::IPCHandle::decode): (WebKit::SharedMemory::Handle::encode const): Deleted. (WebKit::SharedMemory::Handle::decode): Deleted. Remove SharedMemory::Handle encode/decode functions so we will not ever send a SharedMemory::Handle object over IPC accidentally in the future. * Shared/ShareableBitmap.cpp: (WebKit::ShareableBitmap::Handle::encode const): (WebKit::ShareableBitmap::Handle::decode): Keep m_size here because it is an IntSize object and is useful to check width/height parameters in the SharableBitmap object. * Shared/ShareableResource.cpp: (WebKit::ShareableResource::Handle::encode const): (WebKit::ShareableResource::Handle::decode): * Shared/WebCompiledContentRuleListData.cpp: (WebKit::WebCompiledContentRuleListData::encode const): (WebKit::WebCompiledContentRuleListData::decode): * Shared/WebCoreArgumentCoders.cpp: (IPC::encodeSharedBuffer): (IPC::decodeSharedBuffer): * Shared/WebHitTestResultData.cpp: (WebKit::WebHitTestResultData::encode const): (WebKit::WebHitTestResultData::decode): More cases of converting between SharedMemory::Handle and SharedMemory::IPCHandle when encoding/decoding. * UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp: * UIProcess/VisitedLinkStore.cpp: (WebKit::VisitedLinkStore::sendStoreHandleToProcess): * WebProcess/GPU/media/RemoteAudioBusData.h: (WebKit::RemoteAudioBusData::encode const): (WebKit::RemoteAudioBusData::decode): Since no additional size parameter is being sent in this function, we can use handle.size() as the IPCHandle::dataSize parameter. * WebProcess/GPU/webrtc/AudioMediaStreamTrackRenderer.cpp: (WebKit::AudioMediaStreamTrackRenderer::storageChanged): * WebProcess/GPU/webrtc/MediaRecorderPrivate.cpp: (WebKit::MediaRecorderPrivate::storageChanged): * WebProcess/Storage/WebSWClientConnection.cpp: (WebKit::WebSWClientConnection::setSWOriginTableSharedMemory): * WebProcess/Storage/WebSWClientConnection.h: * WebProcess/Storage/WebSWClientConnection.messages.in: * WebProcess/WebPage/VisitedLinkTableController.cpp: (WebKit::VisitedLinkTableController::setVisitedLinkTable): * WebProcess/WebPage/VisitedLinkTableController.h: * WebProcess/WebPage/VisitedLinkTableController.messages.in: * WebProcess/cocoa/RemoteCaptureSampleManager.cpp: (WebKit::RemoteCaptureSampleManager::audioStorageChanged): * WebProcess/cocoa/RemoteCaptureSampleManager.h: * WebProcess/cocoa/RemoteCaptureSampleManager.messages.in: More cases of converting between SharedMemory::Handle and SharedMemory::IPCHandle when encoding/decoding. Canonical link: https://commits.webkit.org/228303@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@265725 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-08-15 01:46:04 +00:00
SharedMemory::IPCHandle ipcHandle;
if (!decoder.decode(ipcHandle))
Next step toward using std::optional directly instead of through WTF::Optional typedef https://bugs.webkit.org/show_bug.cgi?id=226280 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Accept the renaming done by do-webcore-rename. * yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file, tweaked style to make it happy after the renaming done by do-webcore-rename, and also hand-updated Optional to std::optional as long as we were touching it. Source/WebCore: * <many files>: Accept the renaming done by do-webcore-rename. * Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained about the names of some arguments, fixed them, and also hand-updated Optional to std::optional as long as we were touching it. * loader/EmptyClients.cpp: Since style checker complained about the mix of WEBCORE_EXPORT and inlined functions, moved them out of line, and also hand-updated Optional to std::optional as long as we were touching it. Also removed is<EmptyFrameLoaderClient>(). * loader/EmptyFrameLoaderClient.h: Ditto. Source/WebCore/PAL: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebDriver: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebKit: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebKitLegacy: * Storage/StorageTracker.cpp: (WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename. Source/WebKitLegacy/mac: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebKitLegacy/win: * <many files>: Accept the renaming done by do-webcore-rename. Source/WTF: * <many files>: Accept the renaming done by do-webcore-rename. * wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional. * wtf/URLHelpers.cpp: (WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt. Tools: * Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t, WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily be done by the script and so will be done in later passes. * <many files>: Accept the renaming done by do-webcore-rename. Canonical link: https://commits.webkit.org/238228@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
return std::nullopt;
Convert remaining SharedMemory::Handle to SharedMemory::IPCHandle https://bugs.webkit.org/show_bug.cgi?id=215471 <rdar://problem/67024177> Reviewed by David Kilzer. Use the new struct for sending SharedMemory::Handle objects via IPC, so we can include the exact size of data (SharedMemory::Handle::size() rounds up to the nearest page), and verify these sizes match when decoding. In many cases, the size is not sent as a separate argument via IPC, so we can initialize the IPCHandle object with SharedMemory::Handle::size(). We can remove the additional size parameter when it exists, because we are now passing IPCHandle which should include the size value. * GPUProcess/webrtc/RemoteAudioMediaStreamTrackRenderer.cpp: (WebKit::RemoteAudioMediaStreamTrackRenderer::audioSamplesStorageChanged): * GPUProcess/webrtc/RemoteAudioMediaStreamTrackRenderer.h: * GPUProcess/webrtc/RemoteAudioMediaStreamTrackRenderer.messages.in: * GPUProcess/webrtc/RemoteMediaRecorder.cpp: (WebKit::RemoteMediaRecorder::audioSamplesStorageChanged): * GPUProcess/webrtc/RemoteMediaRecorder.h: * GPUProcess/webrtc/RemoteMediaRecorder.messages.in: Send SharedMemory::IPCHandle object instead of SharedMemory::Handle over IPC. * NetworkProcess/ServiceWorker/WebSWOriginStore.cpp: (WebKit::WebSWOriginStore::sendStoreHandle): Since no additional size parameter is being sent in this function, we can use handle.size() as the IPCHandle::dataSize parameter. * Platform/SharedMemory.h: Remove encode/decode functions in SharedMemory::Handle. * Platform/cocoa/SharedMemoryCocoa.cpp: (WebKit::SharedMemory::Handle::encode const): Deleted. (WebKit::SharedMemory::Handle::decode): Deleted. * Platform/unix/SharedMemoryUnix.cpp: (WebKit::SharedMemory::IPCHandle::encode const): (WebKit::SharedMemory::IPCHandle::decode): * Platform/win/SharedMemoryWin.cpp: (WebKit::SharedMemory::IPCHandle::encode const): (WebKit::SharedMemory::IPCHandle::decode): (WebKit::SharedMemory::Handle::encode const): Deleted. (WebKit::SharedMemory::Handle::decode): Deleted. Remove SharedMemory::Handle encode/decode functions so we will not ever send a SharedMemory::Handle object over IPC accidentally in the future. * Shared/ShareableBitmap.cpp: (WebKit::ShareableBitmap::Handle::encode const): (WebKit::ShareableBitmap::Handle::decode): Keep m_size here because it is an IntSize object and is useful to check width/height parameters in the SharableBitmap object. * Shared/ShareableResource.cpp: (WebKit::ShareableResource::Handle::encode const): (WebKit::ShareableResource::Handle::decode): * Shared/WebCompiledContentRuleListData.cpp: (WebKit::WebCompiledContentRuleListData::encode const): (WebKit::WebCompiledContentRuleListData::decode): * Shared/WebCoreArgumentCoders.cpp: (IPC::encodeSharedBuffer): (IPC::decodeSharedBuffer): * Shared/WebHitTestResultData.cpp: (WebKit::WebHitTestResultData::encode const): (WebKit::WebHitTestResultData::decode): More cases of converting between SharedMemory::Handle and SharedMemory::IPCHandle when encoding/decoding. * UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp: * UIProcess/VisitedLinkStore.cpp: (WebKit::VisitedLinkStore::sendStoreHandleToProcess): * WebProcess/GPU/media/RemoteAudioBusData.h: (WebKit::RemoteAudioBusData::encode const): (WebKit::RemoteAudioBusData::decode): Since no additional size parameter is being sent in this function, we can use handle.size() as the IPCHandle::dataSize parameter. * WebProcess/GPU/webrtc/AudioMediaStreamTrackRenderer.cpp: (WebKit::AudioMediaStreamTrackRenderer::storageChanged): * WebProcess/GPU/webrtc/MediaRecorderPrivate.cpp: (WebKit::MediaRecorderPrivate::storageChanged): * WebProcess/Storage/WebSWClientConnection.cpp: (WebKit::WebSWClientConnection::setSWOriginTableSharedMemory): * WebProcess/Storage/WebSWClientConnection.h: * WebProcess/Storage/WebSWClientConnection.messages.in: * WebProcess/WebPage/VisitedLinkTableController.cpp: (WebKit::VisitedLinkTableController::setVisitedLinkTable): * WebProcess/WebPage/VisitedLinkTableController.h: * WebProcess/WebPage/VisitedLinkTableController.messages.in: * WebProcess/cocoa/RemoteCaptureSampleManager.cpp: (WebKit::RemoteCaptureSampleManager::audioStorageChanged): * WebProcess/cocoa/RemoteCaptureSampleManager.h: * WebProcess/cocoa/RemoteCaptureSampleManager.messages.in: More cases of converting between SharedMemory::Handle and SharedMemory::IPCHandle when encoding/decoding. Canonical link: https://commits.webkit.org/228303@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@265725 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-08-15 01:46:04 +00:00
RefPtr<SharedMemory> data = SharedMemory::map(ipcHandle.handle, SharedMemory::Protection::ReadOnly);
[Content Extensions] Pass compiled content extensions as read-only shared memory rather than copying them https://bugs.webkit.org/show_bug.cgi?id=142458 Reviewed by Dan Bernstein. * Shared/WebCompiledContentExtensionData.cpp: (WebKit::WebCompiledContentExtensionData::encode): (WebKit::WebCompiledContentExtensionData::decode): * Shared/WebCompiledContentExtensionData.h: (WebKit::WebCompiledContentExtensionData::WebCompiledContentExtensionData): Store the compiled data as a SharedMemory block with offset/size pairs for the bytecode and actions. While the bytecode offset is currently always 0, this won't be the case when we map these in from files due to metadata that will be placed at the top of the files. * Shared/WebCompiledContentExtension.h: * Shared/WebCompiledContentExtension.cpp: (WebKit::WebCompiledContentExtension::createFromCompiledContentExtensionData): Temporary creation helper. In subsequent patches, this will be removed and replaced by always passing in shared/mapped data. (WebKit::WebCompiledContentExtension::create): (WebKit::WebCompiledContentExtension::WebCompiledContentExtension): (WebKit::WebCompiledContentExtension::bytecode): (WebKit::WebCompiledContentExtension::bytecodeLength): (WebKit::WebCompiledContentExtension::actions): (WebKit::WebCompiledContentExtension::actionsLength): Convert to work with the new WebCompiledContentExtension format. * UIProcess/API/C/WKUserContentFilterRef.cpp: (WKUserContentFilterCreate): * UIProcess/API/Cocoa/_WKUserContentFilter.mm: (-[_WKUserContentFilter initWithName:serializedRules:]): Switch to using WebCompiledContentExtension::createFromCompiledContentExtensionData(). * WebProcess/UserContent/WebUserContentController.cpp: (WebKit::WebUserContentController::addUserContentExtensions): * WebProcess/WebPage/WebPageGroupProxy.cpp: (WebKit::WebPageGroupProxy::addUserContentExtension): Update to pass the WebCompiledContentExtensionData directly to the WebCompiledContentExtension. Canonical link: https://commits.webkit.org/160504@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@181246 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-03-08 21:32:50 +00:00
Remove WTF::Optional synonym for std::optional, using that class template directly instead https://bugs.webkit.org/show_bug.cgi?id=226433 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * inspector/scripts/codegen/generate_objc_protocol_types_implementation.py: (ObjCProtocolTypesImplementationGenerator._generate_init_method_for_payload): Use auto instead of Optional<>. Also use * instead of value() and nest the definition of the local inside an if statement in the case where it's an optional. * inspector/scripts/tests/expected/*: Regenerated these results. Source/WebCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebCore/PAL: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebDriver: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKit: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * Scripts/webkit/tests: Regenerated expected results, by running the command "python Scripts/webkit/messages_unittest.py -r". (How am I supposed to know to do that?) Source/WebKitLegacy/ios: * WebCoreSupport/WebChromeClientIOS.h: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/mac: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/win: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WTF: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * wtf/Optional.h: Remove WTF::Optional. Tools: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Canonical link: https://commits.webkit.org/238290@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278253 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-30 16:11:40 +00:00
std::optional<unsigned> conditionsApplyOnlyToDomainOffset;
decoder >> conditionsApplyOnlyToDomainOffset;
if (!conditionsApplyOnlyToDomainOffset)
Next step toward using std::optional directly instead of through WTF::Optional typedef https://bugs.webkit.org/show_bug.cgi?id=226280 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Accept the renaming done by do-webcore-rename. * yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file, tweaked style to make it happy after the renaming done by do-webcore-rename, and also hand-updated Optional to std::optional as long as we were touching it. Source/WebCore: * <many files>: Accept the renaming done by do-webcore-rename. * Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained about the names of some arguments, fixed them, and also hand-updated Optional to std::optional as long as we were touching it. * loader/EmptyClients.cpp: Since style checker complained about the mix of WEBCORE_EXPORT and inlined functions, moved them out of line, and also hand-updated Optional to std::optional as long as we were touching it. Also removed is<EmptyFrameLoaderClient>(). * loader/EmptyFrameLoaderClient.h: Ditto. Source/WebCore/PAL: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebDriver: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebKit: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebKitLegacy: * Storage/StorageTracker.cpp: (WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename. Source/WebKitLegacy/mac: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebKitLegacy/win: * <many files>: Accept the renaming done by do-webcore-rename. Source/WTF: * <many files>: Accept the renaming done by do-webcore-rename. * wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional. * wtf/URLHelpers.cpp: (WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt. Tools: * Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t, WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily be done by the script and so will be done in later passes. * <many files>: Accept the renaming done by do-webcore-rename. Canonical link: https://commits.webkit.org/238228@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
return std::nullopt;
Remove WTF::Optional synonym for std::optional, using that class template directly instead https://bugs.webkit.org/show_bug.cgi?id=226433 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * inspector/scripts/codegen/generate_objc_protocol_types_implementation.py: (ObjCProtocolTypesImplementationGenerator._generate_init_method_for_payload): Use auto instead of Optional<>. Also use * instead of value() and nest the definition of the local inside an if statement in the case where it's an optional. * inspector/scripts/tests/expected/*: Regenerated these results. Source/WebCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebCore/PAL: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebDriver: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKit: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * Scripts/webkit/tests: Regenerated expected results, by running the command "python Scripts/webkit/messages_unittest.py -r". (How am I supposed to know to do that?) Source/WebKitLegacy/ios: * WebCoreSupport/WebChromeClientIOS.h: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/mac: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/win: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WTF: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * wtf/Optional.h: Remove WTF::Optional. Tools: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Canonical link: https://commits.webkit.org/238290@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278253 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-30 16:11:40 +00:00
std::optional<unsigned> actionsOffset;
decoder >> actionsOffset;
if (!actionsOffset)
Next step toward using std::optional directly instead of through WTF::Optional typedef https://bugs.webkit.org/show_bug.cgi?id=226280 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Accept the renaming done by do-webcore-rename. * yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file, tweaked style to make it happy after the renaming done by do-webcore-rename, and also hand-updated Optional to std::optional as long as we were touching it. Source/WebCore: * <many files>: Accept the renaming done by do-webcore-rename. * Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained about the names of some arguments, fixed them, and also hand-updated Optional to std::optional as long as we were touching it. * loader/EmptyClients.cpp: Since style checker complained about the mix of WEBCORE_EXPORT and inlined functions, moved them out of line, and also hand-updated Optional to std::optional as long as we were touching it. Also removed is<EmptyFrameLoaderClient>(). * loader/EmptyFrameLoaderClient.h: Ditto. Source/WebCore/PAL: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebDriver: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebKit: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebKitLegacy: * Storage/StorageTracker.cpp: (WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename. Source/WebKitLegacy/mac: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebKitLegacy/win: * <many files>: Accept the renaming done by do-webcore-rename. Source/WTF: * <many files>: Accept the renaming done by do-webcore-rename. * wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional. * wtf/URLHelpers.cpp: (WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt. Tools: * Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t, WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily be done by the script and so will be done in later passes. * <many files>: Accept the renaming done by do-webcore-rename. Canonical link: https://commits.webkit.org/238228@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
return std::nullopt;
Remove WTF::Optional synonym for std::optional, using that class template directly instead https://bugs.webkit.org/show_bug.cgi?id=226433 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * inspector/scripts/codegen/generate_objc_protocol_types_implementation.py: (ObjCProtocolTypesImplementationGenerator._generate_init_method_for_payload): Use auto instead of Optional<>. Also use * instead of value() and nest the definition of the local inside an if statement in the case where it's an optional. * inspector/scripts/tests/expected/*: Regenerated these results. Source/WebCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebCore/PAL: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebDriver: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKit: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * Scripts/webkit/tests: Regenerated expected results, by running the command "python Scripts/webkit/messages_unittest.py -r". (How am I supposed to know to do that?) Source/WebKitLegacy/ios: * WebCoreSupport/WebChromeClientIOS.h: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/mac: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/win: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WTF: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * wtf/Optional.h: Remove WTF::Optional. Tools: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Canonical link: https://commits.webkit.org/238290@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278253 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-30 16:11:40 +00:00
std::optional<unsigned> actionsSize;
decoder >> actionsSize;
if (!actionsSize)
Next step toward using std::optional directly instead of through WTF::Optional typedef https://bugs.webkit.org/show_bug.cgi?id=226280 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Accept the renaming done by do-webcore-rename. * yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file, tweaked style to make it happy after the renaming done by do-webcore-rename, and also hand-updated Optional to std::optional as long as we were touching it. Source/WebCore: * <many files>: Accept the renaming done by do-webcore-rename. * Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained about the names of some arguments, fixed them, and also hand-updated Optional to std::optional as long as we were touching it. * loader/EmptyClients.cpp: Since style checker complained about the mix of WEBCORE_EXPORT and inlined functions, moved them out of line, and also hand-updated Optional to std::optional as long as we were touching it. Also removed is<EmptyFrameLoaderClient>(). * loader/EmptyFrameLoaderClient.h: Ditto. Source/WebCore/PAL: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebDriver: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebKit: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebKitLegacy: * Storage/StorageTracker.cpp: (WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename. Source/WebKitLegacy/mac: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebKitLegacy/win: * <many files>: Accept the renaming done by do-webcore-rename. Source/WTF: * <many files>: Accept the renaming done by do-webcore-rename. * wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional. * wtf/URLHelpers.cpp: (WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt. Tools: * Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t, WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily be done by the script and so will be done in later passes. * <many files>: Accept the renaming done by do-webcore-rename. Canonical link: https://commits.webkit.org/238228@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
return std::nullopt;
Remove WTF::Optional synonym for std::optional, using that class template directly instead https://bugs.webkit.org/show_bug.cgi?id=226433 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * inspector/scripts/codegen/generate_objc_protocol_types_implementation.py: (ObjCProtocolTypesImplementationGenerator._generate_init_method_for_payload): Use auto instead of Optional<>. Also use * instead of value() and nest the definition of the local inside an if statement in the case where it's an optional. * inspector/scripts/tests/expected/*: Regenerated these results. Source/WebCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebCore/PAL: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebDriver: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKit: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * Scripts/webkit/tests: Regenerated expected results, by running the command "python Scripts/webkit/messages_unittest.py -r". (How am I supposed to know to do that?) Source/WebKitLegacy/ios: * WebCoreSupport/WebChromeClientIOS.h: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/mac: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/win: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WTF: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * wtf/Optional.h: Remove WTF::Optional. Tools: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Canonical link: https://commits.webkit.org/238290@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278253 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-30 16:11:40 +00:00
std::optional<unsigned> filtersWithoutConditionsBytecodeOffset;
decoder >> filtersWithoutConditionsBytecodeOffset;
if (!filtersWithoutConditionsBytecodeOffset)
Next step toward using std::optional directly instead of through WTF::Optional typedef https://bugs.webkit.org/show_bug.cgi?id=226280 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Accept the renaming done by do-webcore-rename. * yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file, tweaked style to make it happy after the renaming done by do-webcore-rename, and also hand-updated Optional to std::optional as long as we were touching it. Source/WebCore: * <many files>: Accept the renaming done by do-webcore-rename. * Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained about the names of some arguments, fixed them, and also hand-updated Optional to std::optional as long as we were touching it. * loader/EmptyClients.cpp: Since style checker complained about the mix of WEBCORE_EXPORT and inlined functions, moved them out of line, and also hand-updated Optional to std::optional as long as we were touching it. Also removed is<EmptyFrameLoaderClient>(). * loader/EmptyFrameLoaderClient.h: Ditto. Source/WebCore/PAL: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebDriver: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebKit: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebKitLegacy: * Storage/StorageTracker.cpp: (WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename. Source/WebKitLegacy/mac: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebKitLegacy/win: * <many files>: Accept the renaming done by do-webcore-rename. Source/WTF: * <many files>: Accept the renaming done by do-webcore-rename. * wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional. * wtf/URLHelpers.cpp: (WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt. Tools: * Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t, WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily be done by the script and so will be done in later passes. * <many files>: Accept the renaming done by do-webcore-rename. Canonical link: https://commits.webkit.org/238228@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
return std::nullopt;
Remove WTF::Optional synonym for std::optional, using that class template directly instead https://bugs.webkit.org/show_bug.cgi?id=226433 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * inspector/scripts/codegen/generate_objc_protocol_types_implementation.py: (ObjCProtocolTypesImplementationGenerator._generate_init_method_for_payload): Use auto instead of Optional<>. Also use * instead of value() and nest the definition of the local inside an if statement in the case where it's an optional. * inspector/scripts/tests/expected/*: Regenerated these results. Source/WebCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebCore/PAL: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebDriver: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKit: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * Scripts/webkit/tests: Regenerated expected results, by running the command "python Scripts/webkit/messages_unittest.py -r". (How am I supposed to know to do that?) Source/WebKitLegacy/ios: * WebCoreSupport/WebChromeClientIOS.h: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/mac: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/win: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WTF: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * wtf/Optional.h: Remove WTF::Optional. Tools: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Canonical link: https://commits.webkit.org/238290@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278253 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-30 16:11:40 +00:00
std::optional<unsigned> filtersWithoutConditionsBytecodeSize;
decoder >> filtersWithoutConditionsBytecodeSize;
if (!filtersWithoutConditionsBytecodeSize)
Next step toward using std::optional directly instead of through WTF::Optional typedef https://bugs.webkit.org/show_bug.cgi?id=226280 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Accept the renaming done by do-webcore-rename. * yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file, tweaked style to make it happy after the renaming done by do-webcore-rename, and also hand-updated Optional to std::optional as long as we were touching it. Source/WebCore: * <many files>: Accept the renaming done by do-webcore-rename. * Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained about the names of some arguments, fixed them, and also hand-updated Optional to std::optional as long as we were touching it. * loader/EmptyClients.cpp: Since style checker complained about the mix of WEBCORE_EXPORT and inlined functions, moved them out of line, and also hand-updated Optional to std::optional as long as we were touching it. Also removed is<EmptyFrameLoaderClient>(). * loader/EmptyFrameLoaderClient.h: Ditto. Source/WebCore/PAL: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebDriver: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebKit: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebKitLegacy: * Storage/StorageTracker.cpp: (WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename. Source/WebKitLegacy/mac: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebKitLegacy/win: * <many files>: Accept the renaming done by do-webcore-rename. Source/WTF: * <many files>: Accept the renaming done by do-webcore-rename. * wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional. * wtf/URLHelpers.cpp: (WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt. Tools: * Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t, WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily be done by the script and so will be done in later passes. * <many files>: Accept the renaming done by do-webcore-rename. Canonical link: https://commits.webkit.org/238228@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
return std::nullopt;
Remove WTF::Optional synonym for std::optional, using that class template directly instead https://bugs.webkit.org/show_bug.cgi?id=226433 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * inspector/scripts/codegen/generate_objc_protocol_types_implementation.py: (ObjCProtocolTypesImplementationGenerator._generate_init_method_for_payload): Use auto instead of Optional<>. Also use * instead of value() and nest the definition of the local inside an if statement in the case where it's an optional. * inspector/scripts/tests/expected/*: Regenerated these results. Source/WebCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebCore/PAL: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebDriver: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKit: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * Scripts/webkit/tests: Regenerated expected results, by running the command "python Scripts/webkit/messages_unittest.py -r". (How am I supposed to know to do that?) Source/WebKitLegacy/ios: * WebCoreSupport/WebChromeClientIOS.h: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/mac: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/win: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WTF: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * wtf/Optional.h: Remove WTF::Optional. Tools: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Canonical link: https://commits.webkit.org/238290@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278253 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-30 16:11:40 +00:00
std::optional<unsigned> filtersWithConditionsBytecodeOffset;
decoder >> filtersWithConditionsBytecodeOffset;
if (!filtersWithConditionsBytecodeOffset)
Next step toward using std::optional directly instead of through WTF::Optional typedef https://bugs.webkit.org/show_bug.cgi?id=226280 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Accept the renaming done by do-webcore-rename. * yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file, tweaked style to make it happy after the renaming done by do-webcore-rename, and also hand-updated Optional to std::optional as long as we were touching it. Source/WebCore: * <many files>: Accept the renaming done by do-webcore-rename. * Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained about the names of some arguments, fixed them, and also hand-updated Optional to std::optional as long as we were touching it. * loader/EmptyClients.cpp: Since style checker complained about the mix of WEBCORE_EXPORT and inlined functions, moved them out of line, and also hand-updated Optional to std::optional as long as we were touching it. Also removed is<EmptyFrameLoaderClient>(). * loader/EmptyFrameLoaderClient.h: Ditto. Source/WebCore/PAL: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebDriver: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebKit: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebKitLegacy: * Storage/StorageTracker.cpp: (WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename. Source/WebKitLegacy/mac: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebKitLegacy/win: * <many files>: Accept the renaming done by do-webcore-rename. Source/WTF: * <many files>: Accept the renaming done by do-webcore-rename. * wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional. * wtf/URLHelpers.cpp: (WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt. Tools: * Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t, WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily be done by the script and so will be done in later passes. * <many files>: Accept the renaming done by do-webcore-rename. Canonical link: https://commits.webkit.org/238228@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
return std::nullopt;
Remove WTF::Optional synonym for std::optional, using that class template directly instead https://bugs.webkit.org/show_bug.cgi?id=226433 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * inspector/scripts/codegen/generate_objc_protocol_types_implementation.py: (ObjCProtocolTypesImplementationGenerator._generate_init_method_for_payload): Use auto instead of Optional<>. Also use * instead of value() and nest the definition of the local inside an if statement in the case where it's an optional. * inspector/scripts/tests/expected/*: Regenerated these results. Source/WebCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebCore/PAL: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebDriver: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKit: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * Scripts/webkit/tests: Regenerated expected results, by running the command "python Scripts/webkit/messages_unittest.py -r". (How am I supposed to know to do that?) Source/WebKitLegacy/ios: * WebCoreSupport/WebChromeClientIOS.h: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/mac: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/win: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WTF: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * wtf/Optional.h: Remove WTF::Optional. Tools: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Canonical link: https://commits.webkit.org/238290@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278253 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-30 16:11:40 +00:00
std::optional<unsigned> filtersWithConditionsBytecodeSize;
decoder >> filtersWithConditionsBytecodeSize;
if (!filtersWithConditionsBytecodeSize)
Next step toward using std::optional directly instead of through WTF::Optional typedef https://bugs.webkit.org/show_bug.cgi?id=226280 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Accept the renaming done by do-webcore-rename. * yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file, tweaked style to make it happy after the renaming done by do-webcore-rename, and also hand-updated Optional to std::optional as long as we were touching it. Source/WebCore: * <many files>: Accept the renaming done by do-webcore-rename. * Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained about the names of some arguments, fixed them, and also hand-updated Optional to std::optional as long as we were touching it. * loader/EmptyClients.cpp: Since style checker complained about the mix of WEBCORE_EXPORT and inlined functions, moved them out of line, and also hand-updated Optional to std::optional as long as we were touching it. Also removed is<EmptyFrameLoaderClient>(). * loader/EmptyFrameLoaderClient.h: Ditto. Source/WebCore/PAL: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebDriver: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebKit: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebKitLegacy: * Storage/StorageTracker.cpp: (WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename. Source/WebKitLegacy/mac: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebKitLegacy/win: * <many files>: Accept the renaming done by do-webcore-rename. Source/WTF: * <many files>: Accept the renaming done by do-webcore-rename. * wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional. * wtf/URLHelpers.cpp: (WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt. Tools: * Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t, WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily be done by the script and so will be done in later passes. * <many files>: Accept the renaming done by do-webcore-rename. Canonical link: https://commits.webkit.org/238228@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
return std::nullopt;
Remove WTF::Optional synonym for std::optional, using that class template directly instead https://bugs.webkit.org/show_bug.cgi?id=226433 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * inspector/scripts/codegen/generate_objc_protocol_types_implementation.py: (ObjCProtocolTypesImplementationGenerator._generate_init_method_for_payload): Use auto instead of Optional<>. Also use * instead of value() and nest the definition of the local inside an if statement in the case where it's an optional. * inspector/scripts/tests/expected/*: Regenerated these results. Source/WebCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebCore/PAL: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebDriver: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKit: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * Scripts/webkit/tests: Regenerated expected results, by running the command "python Scripts/webkit/messages_unittest.py -r". (How am I supposed to know to do that?) Source/WebKitLegacy/ios: * WebCoreSupport/WebChromeClientIOS.h: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/mac: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/win: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WTF: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * wtf/Optional.h: Remove WTF::Optional. Tools: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Canonical link: https://commits.webkit.org/238290@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278253 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-30 16:11:40 +00:00
std::optional<unsigned> topURLFiltersBytecodeOffset;
decoder >> topURLFiltersBytecodeOffset;
if (!topURLFiltersBytecodeOffset)
Next step toward using std::optional directly instead of through WTF::Optional typedef https://bugs.webkit.org/show_bug.cgi?id=226280 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Accept the renaming done by do-webcore-rename. * yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file, tweaked style to make it happy after the renaming done by do-webcore-rename, and also hand-updated Optional to std::optional as long as we were touching it. Source/WebCore: * <many files>: Accept the renaming done by do-webcore-rename. * Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained about the names of some arguments, fixed them, and also hand-updated Optional to std::optional as long as we were touching it. * loader/EmptyClients.cpp: Since style checker complained about the mix of WEBCORE_EXPORT and inlined functions, moved them out of line, and also hand-updated Optional to std::optional as long as we were touching it. Also removed is<EmptyFrameLoaderClient>(). * loader/EmptyFrameLoaderClient.h: Ditto. Source/WebCore/PAL: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebDriver: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebKit: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebKitLegacy: * Storage/StorageTracker.cpp: (WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename. Source/WebKitLegacy/mac: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebKitLegacy/win: * <many files>: Accept the renaming done by do-webcore-rename. Source/WTF: * <many files>: Accept the renaming done by do-webcore-rename. * wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional. * wtf/URLHelpers.cpp: (WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt. Tools: * Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t, WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily be done by the script and so will be done in later passes. * <many files>: Accept the renaming done by do-webcore-rename. Canonical link: https://commits.webkit.org/238228@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
return std::nullopt;
Remove WTF::Optional synonym for std::optional, using that class template directly instead https://bugs.webkit.org/show_bug.cgi?id=226433 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * inspector/scripts/codegen/generate_objc_protocol_types_implementation.py: (ObjCProtocolTypesImplementationGenerator._generate_init_method_for_payload): Use auto instead of Optional<>. Also use * instead of value() and nest the definition of the local inside an if statement in the case where it's an optional. * inspector/scripts/tests/expected/*: Regenerated these results. Source/WebCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebCore/PAL: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebDriver: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKit: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * Scripts/webkit/tests: Regenerated expected results, by running the command "python Scripts/webkit/messages_unittest.py -r". (How am I supposed to know to do that?) Source/WebKitLegacy/ios: * WebCoreSupport/WebChromeClientIOS.h: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/mac: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/win: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WTF: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * wtf/Optional.h: Remove WTF::Optional. Tools: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Canonical link: https://commits.webkit.org/238290@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278253 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-30 16:11:40 +00:00
std::optional<unsigned> topURLFiltersBytecodeSize;
decoder >> topURLFiltersBytecodeSize;
if (!topURLFiltersBytecodeSize)
Next step toward using std::optional directly instead of through WTF::Optional typedef https://bugs.webkit.org/show_bug.cgi?id=226280 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Accept the renaming done by do-webcore-rename. * yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file, tweaked style to make it happy after the renaming done by do-webcore-rename, and also hand-updated Optional to std::optional as long as we were touching it. Source/WebCore: * <many files>: Accept the renaming done by do-webcore-rename. * Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained about the names of some arguments, fixed them, and also hand-updated Optional to std::optional as long as we were touching it. * loader/EmptyClients.cpp: Since style checker complained about the mix of WEBCORE_EXPORT and inlined functions, moved them out of line, and also hand-updated Optional to std::optional as long as we were touching it. Also removed is<EmptyFrameLoaderClient>(). * loader/EmptyFrameLoaderClient.h: Ditto. Source/WebCore/PAL: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebDriver: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebKit: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebKitLegacy: * Storage/StorageTracker.cpp: (WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename. Source/WebKitLegacy/mac: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebKitLegacy/win: * <many files>: Accept the renaming done by do-webcore-rename. Source/WTF: * <many files>: Accept the renaming done by do-webcore-rename. * wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional. * wtf/URLHelpers.cpp: (WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt. Tools: * Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t, WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily be done by the script and so will be done in later passes. * <many files>: Accept the renaming done by do-webcore-rename. Canonical link: https://commits.webkit.org/238228@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
return std::nullopt;
[Content Extensions] Pass compiled content extensions as read-only shared memory rather than copying them https://bugs.webkit.org/show_bug.cgi?id=142458 Reviewed by Dan Bernstein. * Shared/WebCompiledContentExtensionData.cpp: (WebKit::WebCompiledContentExtensionData::encode): (WebKit::WebCompiledContentExtensionData::decode): * Shared/WebCompiledContentExtensionData.h: (WebKit::WebCompiledContentExtensionData::WebCompiledContentExtensionData): Store the compiled data as a SharedMemory block with offset/size pairs for the bytecode and actions. While the bytecode offset is currently always 0, this won't be the case when we map these in from files due to metadata that will be placed at the top of the files. * Shared/WebCompiledContentExtension.h: * Shared/WebCompiledContentExtension.cpp: (WebKit::WebCompiledContentExtension::createFromCompiledContentExtensionData): Temporary creation helper. In subsequent patches, this will be removed and replaced by always passing in shared/mapped data. (WebKit::WebCompiledContentExtension::create): (WebKit::WebCompiledContentExtension::WebCompiledContentExtension): (WebKit::WebCompiledContentExtension::bytecode): (WebKit::WebCompiledContentExtension::bytecodeLength): (WebKit::WebCompiledContentExtension::actions): (WebKit::WebCompiledContentExtension::actionsLength): Convert to work with the new WebCompiledContentExtension format. * UIProcess/API/C/WKUserContentFilterRef.cpp: (WKUserContentFilterCreate): * UIProcess/API/Cocoa/_WKUserContentFilter.mm: (-[_WKUserContentFilter initWithName:serializedRules:]): Switch to using WebCompiledContentExtension::createFromCompiledContentExtensionData(). * WebProcess/UserContent/WebUserContentController.cpp: (WebKit::WebUserContentController::addUserContentExtensions): * WebProcess/WebPage/WebPageGroupProxy.cpp: (WebKit::WebPageGroupProxy::addUserContentExtension): Update to pass the WebCompiledContentExtensionData directly to the WebCompiledContentExtension. Canonical link: https://commits.webkit.org/160504@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@181246 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-03-08 21:32:50 +00:00
return {{
WTFMove(data),
WTFMove(*conditionsApplyOnlyToDomainOffset),
WTFMove(*actionsOffset),
WTFMove(*actionsSize),
WTFMove(*filtersWithoutConditionsBytecodeOffset),
WTFMove(*filtersWithoutConditionsBytecodeSize),
WTFMove(*filtersWithConditionsBytecodeOffset),
WTFMove(*filtersWithConditionsBytecodeSize),
WTFMove(*topURLFiltersBytecodeOffset),
WTFMove(*topURLFiltersBytecodeSize)
}};
Add initial experimental user content filtering API https://bugs.webkit.org/show_bug.cgi?id=140584 Reviewed by Benjamin Poulain. Source/WebCore: Change content extensions to be managed through the UserContentController. * WebCore.exp.in: Update exports. * WebCore.xcodeproj/project.pbxproj: Update for removed files. * contentextensions/ContentExtensionsBackend.cpp: (WebCore::ContentExtensions::ContentExtensionsBackend::removeAllRuleLists): (WebCore::ContentExtensions::ContentExtensionsBackend::sharedInstance): Deleted. * contentextensions/ContentExtensionsBackend.h: Remove concept of a shared instance and add a removeAllRuleLists() function. * contentextensions/ContentExtensionsInterface.cpp: Removed. * contentextensions/ContentExtensionsInterface.h: Removed. Since there is no shared instance anymore, checking if a URL should be blocked now has to go directly to the backend. * contentextensions/ContentExtensionsManager.cpp: (WebCore::ContentExtensions::ExtensionsManager::createRuleList): (WebCore::ContentExtensions::ExtensionsManager::loadExtension): Deleted. * contentextensions/ContentExtensionsManager.h: Update interface to accommodate the lack of a shared instance. Now, all this file does is take a serialized rule list and outputs the Vector of ContentExtensionRules * loader/cache/CachedResourceLoader.cpp: (WebCore::CachedResourceLoader::requestResource): Check with the UserContentController to see if the URL should be blocked. * page/UserContentController.cpp: (WebCore::UserContentController::addUserContentFilter): (WebCore::UserContentController::removeAllUserContentFilters): (WebCore::UserContentController::contentFilterBlocksURL): * page/UserContentController.h: Add single point of interaction for both the WebKit level to add and remove content filters and WebCore to check to see if URLs should be blocked. Source/WebKit2: Moves content filtering from being per-ProcessPool to per-UserContentController. * Shared/API/APIObject.h: * Shared/API/c/WKBase.h: * UIProcess/API/APIUserContentFilter.cpp: Added. (API::UserContentFilter::UserContentFilter): (API::UserContentFilter::~UserContentFilter): * UIProcess/API/APIUserContentFilter.h: Added. * UIProcess/API/C/WKAPICast.h: * UIProcess/API/C/WKUserContentFilterRef.cpp: Added. (WKUserContentFilterGetTypeID): (WKUserContentFilterCreate): * UIProcess/API/C/WKUserContentFilterRef.h: Added. * UIProcess/API/C/WebKit2_C.h: * UIProcess/API/Cocoa/_WKUserContentFilter.h: Added. * UIProcess/API/Cocoa/_WKUserContentFilter.mm: Added. (WKUserContentControllerAddUserContentFilter): (WKUserContentControllerRemoveAllUserContentFilters): (-[_WKUserContentFilter _initWithName:ruleList:]): * UIProcess/API/Cocoa/_WKUserContentFilterInternal.h: Added. Add a basic UserContentFilter type and expose it via both the Objective-C API (as _WKUserContentFilter) and via the C SPI (as WKUserContentFilterRef). * UIProcess/API/C/WKUserContentControllerRef.h: * UIProcess/API/C/WKUserContentControllerRef.cpp: Add C-SPI to set and remove WKUserContentFilterRefs. * UIProcess/API/Cocoa/WKProcessPool.mm: (-[WKProcessPool _loadContentExtensionWithIdentifier:serializedRules:successCompletionHandler:errorCompletionHandler:]): Deleted. * UIProcess/API/Cocoa/WKProcessPoolPrivate.h: * UIProcess/WebProcessPool.cpp: (WebKit::WebProcessPool::processDidFinishLaunching): (WebKit::WebProcessPool::loadContentExtension): Deleted. * UIProcess/WebProcessPool.h: * WebProcess/WebProcess.cpp: (WebKit::WebProcess::loadContentExtension): Deleted. * WebProcess/WebProcess.h: * WebProcess/WebProcess.messages.in: Remove the old SPI for loading content filters that was per-ProcessPool. Content filters now follow the same pattern as UserScripts and UserStyleSheets as being per-UserContentController. * UIProcess/API/Cocoa/WKUserContentController.mm: (-[WKUserContentController _addUserContentFilter:]): (-[WKUserContentController _removeAllUserContentFilters]): * UIProcess/API/Cocoa/WKUserContentControllerInternal.h: * UIProcess/API/Cocoa/WKUserContentControllerPrivate.h: Added. * UIProcess/UserContent/WebUserContentControllerProxy.cpp: (WebKit::WebUserContentControllerProxy::WebUserContentControllerProxy): (WebKit::WebUserContentControllerProxy::addProcess): (WebKit::WebUserContentControllerProxy::addUserContentFilter): (WebKit::WebUserContentControllerProxy::removeAllUserContentFilters): * UIProcess/UserContent/WebUserContentControllerProxy.h: * WebProcess/UserContent/WebUserContentController.cpp: (WebKit::WebUserContentController::addUserContentFilters): (WebKit::WebUserContentController::removeAllUserContentFilters): * WebProcess/UserContent/WebUserContentController.h: * WebProcess/UserContent/WebUserContentController.messages.in: Pipe user content filters over to all the WebProcesses that the UserContentController is connected to. * WebKit2.xcodeproj/project.pbxproj: Add new files. Canonical link: https://commits.webkit.org/158567@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@178634 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-01-18 21:54:12 +00:00
}
[WK2] Start a prototype for declarative site specific extensions https://bugs.webkit.org/show_bug.cgi?id=140160 Reviewed by Andreas Kling. Source/WebCore: Currently, clients have various ways to execute custom code for certain URLs. Each of those mechanism implies messaging the UIProcess, executing some code calling back to the WebProcess, then actually load the resource. All this back and forth introduces delays before we actually load resources. Since the set of actions is done per site is actually simple and limited, it may be possible to do everything in WebCore and shortcut the defered loading. This patch provides the starting point for this idea. The "rules" (currently just blocking) are be passed to WebCore in a JSON format. In WebCore, we create a state machine to match the rules and we execute the action when the state machine tells us to. * WebCore.exp.in: * WebCore.xcodeproj/project.pbxproj: * contentextensions/ContentExtensionRule.cpp: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. (WebCore::ContentExtensions::ContentExtensionRule::ContentExtensionRule): * contentextensions/ContentExtensionRule.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. (WebCore::ContentExtensions::ContentExtensionRule::trigger): (WebCore::ContentExtensions::ContentExtensionRule::action): * contentextensions/ContentExtensionsBackend.cpp: Added. (WebCore::ContentExtensions::ContentExtensionsBackend::sharedInstance): (WebCore::ContentExtensions::ContentExtensionsBackend::setRuleList): (WebCore::ContentExtensions::ContentExtensionsBackend::removeRuleList): (WebCore::ContentExtensions::ContentExtensionsBackend::shouldBlockURL): * contentextensions/ContentExtensionsBackend.h: Added. * contentextensions/ContentExtensionsInterface.cpp: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. (WebCore::ContentExtensions::shouldBlockURL): * contentextensions/ContentExtensionsInterface.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. * contentextensions/ContentExtensionsManager.cpp: Added. (WebCore::ContentExtensions::ExtensionsManager::loadTrigger): (WebCore::ContentExtensions::ExtensionsManager::loadAction): (WebCore::ContentExtensions::ExtensionsManager::loadRule): (WebCore::ContentExtensions::ExtensionsManager::loadExtension): * contentextensions/ContentExtensionsManager.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. * contentextensions/DFA.cpp: Added. (WebCore::ContentExtensions::DFA::DFA): (WebCore::ContentExtensions::DFA::operator=): (WebCore::ContentExtensions::DFA::nextState): (WebCore::ContentExtensions::DFA::actions): (WebCore::ContentExtensions::DFA::debugPrintDot): * contentextensions/DFA.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. (WebCore::ContentExtensions::DFA::root): * contentextensions/DFANode.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. * contentextensions/NFA.cpp: Added. (WebCore::ContentExtensions::NFA::NFA): (WebCore::ContentExtensions::NFA::createNode): (WebCore::ContentExtensions::NFA::addTransition): (WebCore::ContentExtensions::NFA::addEpsilonTransition): (WebCore::ContentExtensions::NFA::setFinal): (WebCore::ContentExtensions::NFA::debugPrintDot): * contentextensions/NFA.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. (WebCore::ContentExtensions::NFA::root): * contentextensions/NFANode.cpp: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. (WebCore::ContentExtensions::NFANode::NFANode): * contentextensions/NFANode.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. * contentextensions/NFAToDFA.cpp: Added. (WebCore::ContentExtensions::epsilonClosure): (WebCore::ContentExtensions::setTransitionsExcludingEpsilon): (WebCore::ContentExtensions::HashableNodeIdSet::HashableNodeIdSet): (WebCore::ContentExtensions::HashableNodeIdSet::operator=): (WebCore::ContentExtensions::HashableNodeIdSet::isEmptyValue): (WebCore::ContentExtensions::HashableNodeIdSet::isDeletedValue): (WebCore::ContentExtensions::HashableNodeIdSet::nodeIdSet): (WebCore::ContentExtensions::HashableNodeIdSetHash::hash): (WebCore::ContentExtensions::HashableNodeIdSetHash::equal): (WebCore::ContentExtensions::addDFAState): (WebCore::ContentExtensions::NFAToDFA::convert): * contentextensions/NFAToDFA.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h. * loader/cache/CachedResourceLoader.cpp: (WebCore::CachedResourceLoader::requestResource): Source/WebKit2: Provide a small SPI for OS X. This will likely move to a better place. * UIProcess/API/Cocoa/WKProcessPool.mm: (-[WKProcessPool _loadContentExtensionWithIdentifier:serializedRules:successCompletionHandler:errorCompletionHandler:]): * UIProcess/API/Cocoa/WKProcessPoolPrivate.h: * UIProcess/WebProcessPool.cpp: (WebKit::WebProcessPool::processDidFinishLaunching): (WebKit::WebProcessPool::loadContentExtension): * UIProcess/WebProcessPool.h: * WebProcess/WebProcess.cpp: (WebKit::WebProcess::loadContentExtension): * WebProcess/WebProcess.h: * WebProcess/WebProcess.messages.in: Source/WTF: * wtf/FeatureDefines.h: Canonical link: https://commits.webkit.org/158244@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@178151 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-01-09 01:56:00 +00:00
[Content Extensions] Move compiling of content extensions to the UIProcess https://bugs.webkit.org/show_bug.cgi?id=142402 Reviewed by Benjamin Poulain. Source/WebCore: * contentextensions/CompiledContentExtension.cpp: (WebCore::ContentExtensions::CompiledContentExtension::~CompiledContentExtension): (WebCore::ContentExtensions::CompiledContentExtension::create): Deleted. (WebCore::ContentExtensions::CompiledContentExtension::CompiledContentExtension): Deleted. * contentextensions/CompiledContentExtension.h: (WebCore::ContentExtensions::CompiledContentExtension::bytecode): Deleted. (WebCore::ContentExtensions::CompiledContentExtension::actions): Deleted. Convert CompiledContentExtension to be an abstract base class so that we can back it however we like at the WebKit level. Since it doesn't necessarily use Vectors for its backing store any more, change the interface to use pointer/length. * contentextensions/ContentExtensionCompiler.cpp: (WebCore::ContentExtensions::compileRuleList): * contentextensions/ContentExtensionCompiler.h: Change compileRuleList to return compiled result as the raw Vectors rather than as a CompiledContentExtension, since that class is now abstract. It is up to the caller to copy the data into its final home. * contentextensions/ContentExtensionRule.cpp: (WebCore::ContentExtensions::Action::deserialize): * contentextensions/ContentExtensionRule.h: Switch Action::deserialize to take pointer/length rather than a Vector. * contentextensions/ContentExtensionsBackend.cpp: (WebCore::ContentExtensions::ContentExtensionsBackend::actionsForURL): Pull getting the serialized actions from the compiled extension out of the loop to avoid calling the virtual function multiple times. Pass the bytecode and actions as pointer/length pairs rather than Vectors. * contentextensions/DFABytecodeInterpreter.cpp: (WebCore::ContentExtensions::getBits): (WebCore::ContentExtensions::DFABytecodeInterpreter::interpret): * contentextensions/DFABytecodeInterpreter.h: (WebCore::ContentExtensions::DFABytecodeInterpreter::DFABytecodeInterpreter): Switch the interpreter to take pointer/length rather than a Vector. * page/UserContentController.cpp: (WebCore::UserContentController::addUserContentExtension): (WebCore::UserContentController::removeUserContentExtension): (WebCore::UserContentController::removeAllUserContentExtensions): (WebCore::UserContentController::addUserContentFilter): Deleted. (WebCore::UserContentController::removeUserContentFilter): Deleted. (WebCore::UserContentController::removeAllUserContentFilters): Deleted. * page/UserContentController.h: Unify terminology to use the term UserContentExtension rather than UserContentFilter. Source/WebKit2: * Shared/API/APIObject.h: Rename UserContentFilter type to UserContentExtension to match new unified naming. * Shared/WebCompiledContentExtension.cpp: Added. (WebKit::WebCompiledContentExtension::create): (WebKit::WebCompiledContentExtension::WebCompiledContentExtension): (WebKit::WebCompiledContentExtension::~WebCompiledContentExtension): (WebKit::WebCompiledContentExtension::bytecode): (WebKit::WebCompiledContentExtension::bytecodeLength): (WebKit::WebCompiledContentExtension::actions): (WebKit::WebCompiledContentExtension::actionsLength): * Shared/WebCompiledContentExtension.h: Added. Add new WebKit2 implementation of CompiledContentExtension. Right now it is the same as the old WebCore based CompiledContentExtension, but in subsequent patches, it will use shared/file backed memory. * Shared/WebCompiledContentExtensionData.cpp: Added. (WebKit::WebCompiledContentExtensionData::encode): (WebKit::WebCompiledContentExtensionData::decode): * Shared/WebCompiledContentExtensionData.h: Added. Add encodable/decodable holder for the compiled content extension data for use in IPC. Right now it is doing the naive thing and always copying the data, but in subsequent patches, it will use shared/file backed memory. * Shared/WebPageGroupData.cpp: (WebKit::WebPageGroupData::encode): (WebKit::WebPageGroupData::decode): * Shared/WebPageGroupData.h: Rename member to match new unification on the name userContentExtension. Change the value from the serialized JSON (as a String) to WebCompiledContentExtensionData. * UIProcess/API/APIUserContentExtension.cpp: Copied from Source/WebKit2/UIProcess/API/APIUserContentFilter.cpp. (API::UserContentExtension::UserContentExtension): (API::UserContentExtension::~UserContentExtension): (API::UserContentFilter::UserContentFilter): Deleted. (API::UserContentFilter::~UserContentFilter): Deleted. * UIProcess/API/APIUserContentExtension.h: Copied from Source/WebKit2/UIProcess/API/APIUserContentFilter.h. * UIProcess/API/APIUserContentFilter.cpp: Removed. * UIProcess/API/APIUserContentFilter.h: Removed. Renamed UserContentFilter to APIUserContentExtension. Updated to store the compiled extension (as a WebCompiledContentExtension) rather than the serialized JSON. * UIProcess/API/C/WKAPICast.h: * UIProcess/API/C/WKPageGroup.cpp: (WKPageGroupAddUserContentFilter): (WKPageGroupRemoveUserContentFilter): (WKPageGroupRemoveAllUserContentFilters): * UIProcess/API/C/WKUserContentControllerRef.cpp: (WKUserContentControllerAddUserContentFilter): (WKUserContentControllerRemoveAllUserContentFilters): * UIProcess/API/Cocoa/WKUserContentController.mm: (-[WKUserContentController _addUserContentFilter:]): (-[WKUserContentController _removeUserContentFilter:]): (-[WKUserContentController _removeAllUserContentFilters]): Update for rename of APIUserContentFilter -> UserContentExtension. * UIProcess/API/C/WKUserContentFilterRef.cpp: (WKUserContentFilterGetTypeID): (WKUserContentFilterCreate): Update for rename of APIUserContentFilter -> UserContentExtension. Also make WKUserContentFilterCreate eagerly compile rule list to a WebCompiledContentExtensionData. * UIProcess/API/Cocoa/_WKUserContentFilter.mm: (-[_WKUserContentFilter initWithName:serializedRules:]): (-[_WKUserContentFilter dealloc]): (-[_WKUserContentFilter _apiObject]): Update for rename of APIUserContentFilter -> UserContentExtension. Also make initWithName:serializedRules: eagerly compile rule list to a WebCompiledContentExtensionData. * UIProcess/API/Cocoa/_WKUserContentFilterInternal.h: (WebKit::wrapper): Update for rename of APIUserContentFilter -> UserContentExtension. * UIProcess/UserContent/WebUserContentControllerProxy.cpp: (WebKit::WebUserContentControllerProxy::addProcess): (WebKit::WebUserContentControllerProxy::addUserContentExtension): (WebKit::WebUserContentControllerProxy::removeUserContentExtension): (WebKit::WebUserContentControllerProxy::removeAllUserContentExtensions): (WebKit::WebUserContentControllerProxy::addUserContentFilter): Deleted. (WebKit::WebUserContentControllerProxy::removeUserContentFilter): Deleted. (WebKit::WebUserContentControllerProxy::removeAllUserContentFilters): Deleted. * UIProcess/UserContent/WebUserContentControllerProxy.h: * UIProcess/WebPageGroup.cpp: (WebKit::WebPageGroup::addUserContentExtension): (WebKit::WebPageGroup::removeUserContentExtension): (WebKit::WebPageGroup::removeAllUserContentExtensions): (WebKit::WebPageGroup::addUserContentFilter): Deleted. (WebKit::WebPageGroup::removeUserContentFilter): Deleted. (WebKit::WebPageGroup::removeAllUserContentFilters): Deleted. * UIProcess/WebPageGroup.h: * WebKit2.xcodeproj/project.pbxproj: * WebProcess/UserContent/WebUserContentController.cpp: (WebKit::WebUserContentController::addUserContentExtensions): (WebKit::WebUserContentController::removeUserContentExtension): (WebKit::WebUserContentController::removeAllUserContentExtensions): (WebKit::WebUserContentController::addUserContentFilters): Deleted. (WebKit::WebUserContentController::removeUserContentFilter): Deleted. (WebKit::WebUserContentController::removeAllUserContentFilters): Deleted. * WebProcess/UserContent/WebUserContentController.h: * WebProcess/UserContent/WebUserContentController.messages.in: * WebProcess/WebPage/WebPageGroupProxy.cpp: (WebKit::WebPageGroupProxy::WebPageGroupProxy): (WebKit::WebPageGroupProxy::addUserContentExtension): (WebKit::WebPageGroupProxy::removeUserContentExtension): (WebKit::WebPageGroupProxy::removeAllUserContentExtensions): (WebKit::WebPageGroupProxy::addUserContentFilter): Deleted. (WebKit::WebPageGroupProxy::removeUserContentFilter): Deleted. (WebKit::WebPageGroupProxy::removeAllUserContentFilters): Deleted. * WebProcess/WebPage/WebPageGroupProxy.h: * WebProcess/WebPage/WebPageGroupProxy.messages.in: Pipe the compiled extension from the UIProcess to the WebProcess. Tools: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp: Copied from Tools/TestWebKitAPI/Tests/WebCore/ContentFilter.cpp. (TestWebKitAPI::InMemoryCompiledContentExtension::create): (TestWebKitAPI::InMemoryCompiledContentExtension::~InMemoryCompiledContentExtension): (TestWebKitAPI::InMemoryCompiledContentExtension::InMemoryCompiledContentExtension): (TestWebKitAPI::TEST_F): * TestWebKitAPI/Tests/WebCore/ContentFilter.cpp: Removed. Update test for new name (ContentFilter -> ContentExtensions) and API (CompiledContentExtension is now abstract). Canonical link: https://commits.webkit.org/160480@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@181200 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-03-07 02:41:44 +00:00
} // namespace WebKit
#endif // ENABLE(CONTENT_EXTENSIONS)