Removed unused WKUserContentFilterRef.
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 16 Apr 2015 23:41:22 +0000 (23:41 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 16 Apr 2015 23:41:22 +0000 (23:41 +0000)
https://bugs.webkit.org/show_bug.cgi?id=143852

Reviewed by Sam Weinig.

Source/WebKit2:

* Shared/WebCompiledContentExtension.cpp:
(WebKit::LegacyContentExtensionCompilationClient::LegacyContentExtensionCompilationClient): Deleted.
(WebKit::LegacyContentExtensionCompilationClient::writeBytecode): Deleted.
(WebKit::LegacyContentExtensionCompilationClient::writeActions): Deleted.
(WebKit::WebCompiledContentExtension::createFromCompiledContentExtensionData): Deleted.
* Shared/WebCompiledContentExtension.h:
* UIProcess/API/C/WKUserContentFilterRef.cpp: Removed.
* UIProcess/API/C/WKUserContentFilterRef.h: Removed.
* UIProcess/API/C/WebKit2_C.h:
* UIProcess/API/Cocoa/_WKUserContentFilter.h:
* UIProcess/API/Cocoa/_WKUserContentFilter.mm:
(-[_WKUserContentFilter initWithName:serializedRules:]): Deleted.
* WebKit2.xcodeproj/project.pbxproj:

Tools:

* TestWebKitAPI/Tests/WebKit2Cocoa/_WKUserContentExtensionStore.mm:
* WebKitTestRunner/mac/TestControllerMac.mm:
(WTR::TestController::platformResetPreferencesToConsistentValues):
(WTR::TestController::platformConfigureViewForTest):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@182922 268f45cc-cd09-0410-ab3c-d52691b4dbfc

12 files changed:
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebCompiledContentExtension.cpp
Source/WebKit2/Shared/WebCompiledContentExtension.h
Source/WebKit2/UIProcess/API/C/WKUserContentFilterRef.cpp [deleted file]
Source/WebKit2/UIProcess/API/C/WKUserContentFilterRef.h [deleted file]
Source/WebKit2/UIProcess/API/C/WebKit2_C.h
Source/WebKit2/UIProcess/API/Cocoa/_WKUserContentFilter.h
Source/WebKit2/UIProcess/API/Cocoa/_WKUserContentFilter.mm
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebKit2Cocoa/_WKUserContentExtensionStore.mm
Tools/WebKitTestRunner/mac/TestControllerMac.mm

index 57da7c7..83d7cd6 100644 (file)
@@ -1,3 +1,24 @@
+2015-04-16  Alex Christensen  <achristensen@webkit.org>
+
+        Removed unused WKUserContentFilterRef.
+        https://bugs.webkit.org/show_bug.cgi?id=143852
+
+        Reviewed by Sam Weinig.
+
+        * Shared/WebCompiledContentExtension.cpp:
+        (WebKit::LegacyContentExtensionCompilationClient::LegacyContentExtensionCompilationClient): Deleted.
+        (WebKit::LegacyContentExtensionCompilationClient::writeBytecode): Deleted.
+        (WebKit::LegacyContentExtensionCompilationClient::writeActions): Deleted.
+        (WebKit::WebCompiledContentExtension::createFromCompiledContentExtensionData): Deleted.
+        * Shared/WebCompiledContentExtension.h:
+        * UIProcess/API/C/WKUserContentFilterRef.cpp: Removed.
+        * UIProcess/API/C/WKUserContentFilterRef.h: Removed.
+        * UIProcess/API/C/WebKit2_C.h:
+        * UIProcess/API/Cocoa/_WKUserContentFilter.h:
+        * UIProcess/API/Cocoa/_WKUserContentFilter.mm:
+        (-[_WKUserContentFilter initWithName:serializedRules:]): Deleted.
+        * WebKit2.xcodeproj/project.pbxproj:
+
 2015-04-16  Beth Dakin  <bdakin@apple.com>
 
         Rubber-stamped by Tim Horton.
index 5a60b04..031751b 100644 (file)
 
 namespace WebKit {
 
-LegacyContentExtensionCompilationClient::LegacyContentExtensionCompilationClient(WebCore::ContentExtensions::CompiledContentExtensionData& data)
-    : m_data(data)
-{
-}
-
-void LegacyContentExtensionCompilationClient::writeBytecode(Vector<WebCore::ContentExtensions::DFABytecode>&& bytecode)
-{
-    m_data.bytecode = WTF::move(bytecode);
-}
-
-void LegacyContentExtensionCompilationClient::writeActions(Vector<WebCore::ContentExtensions::SerializedActionByte>&& actions)
-{
-    m_data.actions = WTF::move(actions);
-}
-
-
-Ref<WebCompiledContentExtension> WebCompiledContentExtension::createFromCompiledContentExtensionData(const WebCore::ContentExtensions::CompiledContentExtensionData& compilerData)
-{
-    RefPtr<SharedMemory> sharedMemory = SharedMemory::allocate(compilerData.bytecode.size() + compilerData.actions.size());
-    memcpy(static_cast<char*>(sharedMemory->data()), compilerData.actions.data(), compilerData.actions.size());
-    memcpy(static_cast<char*>(sharedMemory->data()) + compilerData.actions.size(), compilerData.bytecode.data(), compilerData.bytecode.size());
-
-    NetworkCache::Data fileData; // We don't have an mmap'd file to keep alive here, so just use an empty Data object.
-    WebCompiledContentExtensionData data(WTF::move(sharedMemory), fileData, 0, compilerData.actions.size(), compilerData.actions.size(), compilerData.bytecode.size());
-
-    return create(WTF::move(data));
-}
-
 Ref<WebCompiledContentExtension> WebCompiledContentExtension::create(WebCompiledContentExtensionData&& data)
 {
     return adoptRef(*new WebCompiledContentExtension(WTF::move(data)));
index 29b8667..f7ab62a 100644 (file)
 
 namespace WebKit {
 
-// FIXME: Remove this once everyone is converted to using the UserContentExtensionStore.
-class LegacyContentExtensionCompilationClient final : public WebCore::ContentExtensions::ContentExtensionCompilationClient {
-public:
-    LegacyContentExtensionCompilationClient(WebCore::ContentExtensions::CompiledContentExtensionData&);
-
-    virtual void writeBytecode(Vector<WebCore::ContentExtensions::DFABytecode>&&) override;
-    virtual void writeActions(Vector<WebCore::ContentExtensions::SerializedActionByte>&&) override;
-
-private:
-    WebCore::ContentExtensions::CompiledContentExtensionData& m_data;
-};
-
-
 class WebCompiledContentExtension final : public WebCore::ContentExtensions::CompiledContentExtension {
 public:
-    // FIXME: Remove this once everyone is converted to using the UserContentExtensionStore.
-    static Ref<WebCompiledContentExtension> createFromCompiledContentExtensionData(const WebCore::ContentExtensions::CompiledContentExtensionData&);
-
     static Ref<WebCompiledContentExtension> create(WebCompiledContentExtensionData&&);
     virtual ~WebCompiledContentExtension();
 
diff --git a/Source/WebKit2/UIProcess/API/C/WKUserContentFilterRef.cpp b/Source/WebKit2/UIProcess/API/C/WKUserContentFilterRef.cpp
deleted file mode 100644 (file)
index a1f9ea8..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
- *
- * 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"
-#include "WKUserContentFilterRef.h"
-
-#include "APIUserContentExtension.h"
-#include "WKAPICast.h"
-#include "WebCompiledContentExtension.h"
-#include <WebCore/ContentExtensionCompiler.h>
-#include <WebCore/ContentExtensionError.h>
-
-using namespace WebKit;
-
-WKTypeID WKUserContentFilterGetTypeID()
-{
-    return toAPI(API::UserContentExtension::APIType);
-}
-
-WKUserContentFilterRef WKUserContentFilterCreate(WKStringRef nameRef, WKStringRef serializedRulesRef)
-{
-#if ENABLE(CONTENT_EXTENSIONS)
-    WebCore::ContentExtensions::CompiledContentExtensionData data;
-    LegacyContentExtensionCompilationClient client(data);
-
-    auto compilerError = WebCore::ContentExtensions::compileRuleList(client, toWTFString(serializedRulesRef));
-    if (compilerError)
-        return nullptr;
-
-    auto compiledContentExtension = WebKit::WebCompiledContentExtension::createFromCompiledContentExtensionData(data);
-
-    return toAPI(&API::UserContentExtension::create(toWTFString(nameRef), WTF::move(compiledContentExtension)).leakRef());
-#else
-    UNUSED_PARAM(nameRef);
-    UNUSED_PARAM(serializedRulesRef);
-    return nullptr;
-#endif
-}
diff --git a/Source/WebKit2/UIProcess/API/C/WKUserContentFilterRef.h b/Source/WebKit2/UIProcess/API/C/WKUserContentFilterRef.h
deleted file mode 100644 (file)
index 44816a9..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
- *
- * 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.
- */
-
-#ifndef WKUserContentFilterRef_h
-#define WKUserContentFilterRef_h
-
-#include <WebKit/WKBase.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-WK_EXPORT WKTypeID WKUserContentFilterGetTypeID();
-
-WK_EXPORT WKUserContentFilterRef WKUserContentFilterCreate(WKStringRef name, WKStringRef serializedRules);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* WKUserContentFilterRef_h */
index 5b30f2f..2e7aa3b 100644 (file)
@@ -59,7 +59,6 @@
 #include <WebKit/WKURLRequest.h>
 #include <WebKit/WKURLResponse.h>
 #include <WebKit/WKUserContentControllerRef.h>
-#include <WebKit/WKUserContentFilterRef.h>
 #include <WebKit/WKUserMediaPermissionRequest.h>
 #include <WebKit/WKUserScriptRef.h>
 
index bd83046..c93135c 100644 (file)
@@ -30,8 +30,6 @@
 WK_CLASS_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA)
 @interface _WKUserContentFilter : NSObject
 
-- (instancetype)initWithName:(NSString *)name serializedRules:(NSString *)serializedRules;
-
 @end
 
 #endif // WK_API_ENABLED
index 4719ee7..6423b7c 100644 (file)
 
 @implementation _WKUserContentFilter
 
-- (instancetype)initWithName:(NSString *)name serializedRules:(NSString *)serializedRules
-{
-    if (!(self = [super init]))
-        return nil;
-
-    WebCore::ContentExtensions::CompiledContentExtensionData data;
-    WebKit::LegacyContentExtensionCompilationClient client(data);
-
-    if (auto compilerError = WebCore::ContentExtensions::compileRuleList(client, String(serializedRules)))
-        [NSException raise:NSGenericException format:@"Failed to compile rules with error: %s", compilerError.message().c_str()];
-
-    auto compiledContentExtension = WebKit::WebCompiledContentExtension::createFromCompiledContentExtensionData(data);
-    API::Object::constructInWrapper<API::UserContentExtension>(self, String(name), WTF::move(compiledContentExtension));
-
-    return self;
-}
-
 - (void)dealloc
 {
     _userContentExtension->~UserContentExtension();
index 4d8ac92..e6b4a88 100644 (file)
                7C89D2B91A6B0F2C003A5FDE /* _WKUserContentFilter.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7C89D2B71A6B0F2C003A5FDE /* _WKUserContentFilter.mm */; };
                7C89D2BA1A6B0F2C003A5FDE /* _WKUserContentFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C89D2B81A6B0F2C003A5FDE /* _WKUserContentFilter.h */; settings = {ATTRIBUTES = (Private, ); }; };
                7C89D2BC1A6B0F5B003A5FDE /* _WKUserContentFilterInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C89D2BB1A6B0F5B003A5FDE /* _WKUserContentFilterInternal.h */; };
-               7C89D2BF1A6B11EF003A5FDE /* WKUserContentFilterRef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C89D2BD1A6B11EF003A5FDE /* WKUserContentFilterRef.cpp */; };
-               7C89D2C01A6B11EF003A5FDE /* WKUserContentFilterRef.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C89D2BE1A6B11EF003A5FDE /* WKUserContentFilterRef.h */; settings = {ATTRIBUTES = (Private, ); }; };
                7C89D2D71A6C6BE6003A5FDE /* _WKProcessPoolConfigurationInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C89D2D61A6C6BE6003A5FDE /* _WKProcessPoolConfigurationInternal.h */; };
                7C8EB11718DB6A19007917C2 /* WKPreferencesPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C8EB11618DB6A19007917C2 /* WKPreferencesPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
                7C9D1537184584DA009D3918 /* WKBrowsingContextGroupInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C9D1536184584DA009D3918 /* WKBrowsingContextGroupInternal.h */; };
                7C89D2B71A6B0F2C003A5FDE /* _WKUserContentFilter.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = _WKUserContentFilter.mm; sourceTree = "<group>"; };
                7C89D2B81A6B0F2C003A5FDE /* _WKUserContentFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKUserContentFilter.h; sourceTree = "<group>"; };
                7C89D2BB1A6B0F5B003A5FDE /* _WKUserContentFilterInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKUserContentFilterInternal.h; sourceTree = "<group>"; };
-               7C89D2BD1A6B11EF003A5FDE /* WKUserContentFilterRef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKUserContentFilterRef.cpp; sourceTree = "<group>"; };
-               7C89D2BE1A6B11EF003A5FDE /* WKUserContentFilterRef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKUserContentFilterRef.h; sourceTree = "<group>"; };
                7C89D2D61A6C6BE6003A5FDE /* _WKProcessPoolConfigurationInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKProcessPoolConfigurationInternal.h; sourceTree = "<group>"; };
                7C8EB11618DB6A19007917C2 /* WKPreferencesPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKPreferencesPrivate.h; sourceTree = "<group>"; };
                7C9D1536184584DA009D3918 /* WKBrowsingContextGroupInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKBrowsingContextGroupInternal.h; sourceTree = "<group>"; };
                                7C89D29E1A678554003A5FDE /* WKUserContentControllerRef.h */,
                                7C2413061AACFCB400A58C15 /* WKUserContentExtensionStoreRef.cpp */,
                                7C2413071AACFCB400A58C15 /* WKUserContentExtensionStoreRef.h */,
-                               7C89D2BD1A6B11EF003A5FDE /* WKUserContentFilterRef.cpp */,
-                               7C89D2BE1A6B11EF003A5FDE /* WKUserContentFilterRef.h */,
                                4A410F3519AF7AC3002EBAB5 /* WKUserMediaPermissionRequest.cpp */,
                                4A410F3619AF7AC3002EBAB5 /* WKUserMediaPermissionRequest.h */,
                                7C89D2A11A678875003A5FDE /* WKUserScriptRef.cpp */,
index 2e50372..95edfc1 100644 (file)
@@ -1,3 +1,15 @@
+2015-04-16  Alex Christensen  <achristensen@webkit.org>
+
+        Removed unused WKUserContentFilterRef.
+        https://bugs.webkit.org/show_bug.cgi?id=143852
+
+        Reviewed by Sam Weinig.
+
+        * TestWebKitAPI/Tests/WebKit2Cocoa/_WKUserContentExtensionStore.mm:
+        * WebKitTestRunner/mac/TestControllerMac.mm:
+        (WTR::TestController::platformResetPreferencesToConsistentValues):
+        (WTR::TestController::platformConfigureViewForTest):
+
 2015-04-16  Jake Nielsen  <jacob_nielsen@apple.com>
 
         Unreviewed. Adding myself as a commiter in contributers.json.
index 28ec5d5..5dc70fa 100644 (file)
@@ -31,7 +31,6 @@
 #import "PlatformUtilities.h"
 #import "Test.h"
 #import <WebKit/_WKUserContentExtensionStorePrivate.h>
-#import <WebKit/_WKUserContentFilter.h>
 #import <wtf/RetainPtr.h>
 
 class _WKUserContentExtensionStoreTest : public testing::Test {
index b71f396..40a49f8 100644 (file)
 #import "PoseAsClass.h"
 #import "TestInvocation.h"
 #import "WebKitTestRunnerPasteboard.h"
+#import <WebKit/WKPageGroup.h>
 #import <WebKit/WKStringCF.h>
 #import <WebKit/WKURLCF.h>
-#import <WebKit/WKUserContentFilterRef.h>
+#import <WebKit/_WKUserContentExtensionStore.h>
+#import <WebKit/_WKUserContentExtensionStorePrivate.h>
 #import <mach-o/dyld.h>
 
 @interface NSSound (Details)
@@ -82,6 +84,7 @@ static bool shouldUseThreadedScrolling(const TestInvocation& test)
 
 void TestController::platformResetPreferencesToConsistentValues()
 {
+    [[_WKUserContentExtensionStore defaultStore] _removeAllContentExtensions];
 }
 
 void TestController::platformConfigureViewForTest(const TestInvocation& test)
@@ -107,12 +110,15 @@ void TestController::platformConfigureViewForTest(const TestInvocation& test)
     NSString *contentExtensionString = [NSString stringWithContentsOfURL:filterURL usedEncoding:&encoding error:NULL];
     if (!contentExtensionString)
         return;
-
-    WKRetainPtr<WKStringRef> name = adoptWK(WKStringCreateWithUTF8CString("TestContentExtensions"));
-    WKRetainPtr<WKStringRef> contentExtensionStringWK = adoptWK(WKStringCreateWithCFString((CFStringRef)contentExtensionString));
-    WKRetainPtr<WKUserContentFilterRef> filter = adoptWK(WKUserContentFilterCreate(name.get(), contentExtensionStringWK.get()));
-
-    WKPageGroupAddUserContentFilter(WKPageGetPageGroup(TestController::singleton().mainWebView()->page()), filter.get());
+    
+    __block bool done = false;
+    [[_WKUserContentExtensionStore defaultStore] compileContentExtensionForIdentifier:@"TestContentExtensions" encodedContentExtension:contentExtensionString completionHandler:^(_WKUserContentFilter *filter, NSError *error)
+    {
+        if (!error)
+            WKPageGroupAddUserContentFilter(WKPageGetPageGroup(TestController::singleton().mainWebView()->page()), (__bridge WKUserContentFilterRef)filter);
+        done = true;
+    }];
+    platformRunUntil(done, 0);
 }
 
 void TestController::platformRunUntil(bool& done, double timeout)