Diff
Modified: trunk/Source/WebKit2/ChangeLog (150342 => 150343)
--- trunk/Source/WebKit2/ChangeLog 2013-05-18 22:11:11 UTC (rev 150342)
+++ trunk/Source/WebKit2/ChangeLog 2013-05-18 22:41:42 UTC (rev 150343)
@@ -1,3 +1,26 @@
+2013-05-17 Sam Weinig <[email protected]>
+
+ Add a way to pass WebKit2 WKTypeRefs in Objective-C style user data messages
+ https://bugs.webkit.org/show_bug.cgi?id=116345
+
+ Reviewed by Anders Carlsson.
+
+ In order to efficiently send a WKImageRef to another process when using the
+ Objective-C WKConnection (or other user data messages), we need a way to encode
+ WKTypeRefs in the objective-c object graph. Thus was born WKTypeRefWrapper.
+
+ * Shared/mac/ObjCObjectGraphCoders.mm:
+ (WebKit::typeFromObject):
+ (WebKit::WebContextObjCObjectGraphEncoderImpl::encode):
+ (WebKit::WebContextObjCObjectGraphDecoderImpl::decode):
+ (WebKit::InjectedBundleObjCObjectGraphEncoderImpl::encode):
+ (WebKit::InjectedBundleObjCObjectGraphDecoderImpl::decode):
+ * UIProcess/API/mac/WKTypeRefWrapper.h: Added.
+ * UIProcess/API/mac/WKTypeRefWrapper.mm: Added.
+ (-[WKTypeRefWrapper initWithObject:]):
+ (-[WKTypeRefWrapper object]):
+ * WebKit2.xcodeproj/project.pbxproj:
+
2013-05-18 Anders Carlsson <[email protected]>
Simplify StorageArea getter functions
Modified: trunk/Source/WebKit2/Shared/mac/ObjCObjectGraphCoders.mm (150342 => 150343)
--- trunk/Source/WebKit2/Shared/mac/ObjCObjectGraphCoders.mm 2013-05-18 22:11:11 UTC (rev 150342)
+++ trunk/Source/WebKit2/Shared/mac/ObjCObjectGraphCoders.mm 2013-05-18 22:41:42 UTC (rev 150343)
@@ -23,19 +23,22 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "config.h"
-#include "ObjCObjectGraphCoders.h"
+#import "config.h"
+#import "ObjCObjectGraphCoders.h"
#import "ArgumentCodersMac.h"
+#import "WKTypeRefWrapper.h"
// For UIProcess side encoding/decoding
#import "WKAPICast.h"
#import "WKBrowsingContextControllerInternal.h"
#import "WKBrowsingContextControllerPrivate.h"
+#import "WebContextUserMessageCoders.h"
#import "WebPageProxy.h"
#import "WebProcessProxy.h"
// For WebProcess side encoding/decoding
+#import "InjectedBundleUserMessageCoders.h"
#import "WKBundleAPICast.h"
#import "WKWebProcessPlugInBrowserContextControllerInternal.h"
#import "WKWebProcessPlugInBrowserContextControllerPrivate.h"
@@ -55,6 +58,7 @@
NSDataType,
#if defined(__LP64__) && defined(__clang__)
WKBrowsingContextControllerType,
+ WKTypeRefWrapperType,
#endif
UnknownType,
};
@@ -78,6 +82,8 @@
#if defined(__LP64__) && defined(__clang__)
if ([object isKindOfClass:[WKBrowsingContextController class]] || [object isKindOfClass:[WKWebProcessPlugInBrowserContextController class]])
return WKBrowsingContextControllerType;
+ if ([object isKindOfClass:[WKTypeRefWrapper class]])
+ return WKTypeRefWrapperType;
#endif
return UnknownType;
@@ -282,6 +288,11 @@
encoder << toImpl(browsingContextController._pageRef)->pageID();
break;
}
+ case WKTypeRefWrapperType: {
+ WKTypeRefWrapper *wrapper = static_cast<WKTypeRefWrapper *>(m_root);
+ encoder << WebContextUserMessageEncoder(toImpl(wrapper.object));
+ break;
+ }
#endif
default:
ASSERT_NOT_REACHED();
@@ -335,6 +346,14 @@
coder.m_root = [WKBrowsingContextController _browsingContextControllerForPageRef:toAPI(webPage)];
break;
}
+ case WKTypeRefWrapperType: {
+ RefPtr<APIObject> object;
+ WebContextUserMessageDecoder objectDecoder(object, coder.m_process);
+ if (!decoder.decode(objectDecoder))
+ return false;
+ coder.m_root = adoptNS([[WKTypeRefWrapper alloc] initWithObject:toAPI(object.get())]);
+ break;
+ }
#endif
default:
return false;
@@ -368,12 +387,15 @@
switch (type) {
#if defined(__LP64__) && defined(__clang__)
case WKBrowsingContextControllerType: {
-
WKWebProcessPlugInBrowserContextController *browserContextController = static_cast<WKWebProcessPlugInBrowserContextController *>(m_root);
encoder << toImpl(browserContextController._bundlePageRef)->pageID();
break;
}
+ case WKTypeRefWrapperType: {
+ WKTypeRefWrapper *wrapper = static_cast<WKTypeRefWrapper *>(m_root);
+ encoder << InjectedBundleUserMessageEncoder(toImpl(wrapper.object));
+ }
#endif
default:
ASSERT_NOT_REACHED();
@@ -426,6 +448,14 @@
coder.m_root = [[WKWebProcessPlugInController _shared] _browserContextControllerForBundlePageRef:toAPI(webPage)];
break;
}
+ case WKTypeRefWrapperType: {
+ RefPtr<APIObject> object;
+ InjectedBundleUserMessageDecoder objectDecoder(object);
+ if (!decoder.decode(objectDecoder))
+ return false;
+ coder.m_root = adoptNS([[WKTypeRefWrapper alloc] initWithObject:toAPI(object.get())]);
+ break;
+ }
#endif
default:
return false;
Added: trunk/Source/WebKit2/UIProcess/API/mac/WKTypeRefWrapper.h (0 => 150343)
--- trunk/Source/WebKit2/UIProcess/API/mac/WKTypeRefWrapper.h (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKTypeRefWrapper.h 2013-05-18 22:41:42 UTC (rev 150343)
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2013 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.
+ */
+
+#if defined(__LP64__) && defined(__clang__)
+
+#import <Foundation/Foundation.h>
+#import <WebKit2/WKBase.h>
+
+WK_EXPORT
+@interface WKTypeRefWrapper : NSObject
+
+- (id)initWithObject:(WKTypeRef)object;
+
+@property(readonly) WKTypeRef object;
+
+@end
+
+#endif
Added: trunk/Source/WebKit2/UIProcess/API/mac/WKTypeRefWrapper.mm (0 => 150343)
--- trunk/Source/WebKit2/UIProcess/API/mac/WKTypeRefWrapper.mm (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKTypeRefWrapper.mm 2013-05-18 22:41:42 UTC (rev 150343)
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2013 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.
+ */
+
+#import "config.h"
+#import "WKTypeRefWrapper.h"
+
+#import "WKRetainPtr.h"
+
+@interface WKTypeRefWrapper () {
+ // Underlying WKTypeRef.
+ WKRetainPtr<WKTypeRef> _object;
+}
+@end
+
+@implementation WKTypeRefWrapper
+
+- (id)initWithObject:(WKTypeRef)object
+{
+ self = [super init];
+ if (!self)
+ return nil;
+
+ _object = object;
+
+ return self;
+}
+
+- (WKTypeRef)object
+{
+ return _object.get();
+}
+
+@end
Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (150342 => 150343)
--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj 2013-05-18 22:11:11 UTC (rev 150342)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj 2013-05-18 22:41:42 UTC (rev 150343)
@@ -584,6 +584,8 @@
7CD5EBB81746A15B000C1C45 /* WKObjCTypeWrapperRef.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7CD5EBB61746A15B000C1C45 /* WKObjCTypeWrapperRef.mm */; };
7CD5EBB91746A15B000C1C45 /* WKObjCTypeWrapperRef.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CD5EBB71746A15B000C1C45 /* WKObjCTypeWrapperRef.h */; settings = {ATTRIBUTES = (Private, ); }; };
7CD5EBBB1746A83E000C1C45 /* WKBaseMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CD5EBBA1746A83E000C1C45 /* WKBaseMac.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 7CD5EBBE1746B04C000C1C45 /* WKTypeRefWrapper.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7CD5EBBC1746B04C000C1C45 /* WKTypeRefWrapper.mm */; };
+ 7CD5EBBF1746B04C000C1C45 /* WKTypeRefWrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CD5EBBD1746B04C000C1C45 /* WKTypeRefWrapper.h */; settings = {ATTRIBUTES = (Private, ); }; };
7CD622771739D863005BD7FF /* PluginSandboxProfile.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7CD622751739D863005BD7FF /* PluginSandboxProfile.mm */; };
7CD622781739D863005BD7FF /* PluginSandboxProfile.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CD622761739D863005BD7FF /* PluginSandboxProfile.h */; };
7CF47FF617275B71008ACB91 /* WKBundlePageBanner.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CF47FF417275B71008ACB91 /* WKBundlePageBanner.cpp */; };
@@ -2060,6 +2062,8 @@
7CD5EBB61746A15B000C1C45 /* WKObjCTypeWrapperRef.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKObjCTypeWrapperRef.mm; sourceTree = "<group>"; };
7CD5EBB71746A15B000C1C45 /* WKObjCTypeWrapperRef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKObjCTypeWrapperRef.h; sourceTree = "<group>"; };
7CD5EBBA1746A83E000C1C45 /* WKBaseMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKBaseMac.h; sourceTree = "<group>"; };
+ 7CD5EBBC1746B04C000C1C45 /* WKTypeRefWrapper.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKTypeRefWrapper.mm; sourceTree = "<group>"; };
+ 7CD5EBBD1746B04C000C1C45 /* WKTypeRefWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKTypeRefWrapper.h; sourceTree = "<group>"; };
7CD622751739D863005BD7FF /* PluginSandboxProfile.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PluginSandboxProfile.mm; sourceTree = "<group>"; };
7CD622761739D863005BD7FF /* PluginSandboxProfile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PluginSandboxProfile.h; sourceTree = "<group>"; };
7CF47FF417275B71008ACB91 /* WKBundlePageBanner.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKBundlePageBanner.cpp; sourceTree = "<group>"; };
@@ -4284,6 +4288,8 @@
BCBAACE5145225C90053F82F /* WKProcessGroup.h */,
BCBAACE6145225CA0053F82F /* WKProcessGroup.mm */,
BCBAACE7145225CB0053F82F /* WKProcessGroupPrivate.h */,
+ 7CD5EBBD1746B04C000C1C45 /* WKTypeRefWrapper.h */,
+ 7CD5EBBC1746B04C000C1C45 /* WKTypeRefWrapper.mm */,
BC8699B2116AADAA002A925B /* WKView.h */,
BC8699B3116AADAA002A925B /* WKView.mm */,
BC8699B4116AADAA002A925B /* WKViewInternal.h */,
@@ -5323,6 +5329,7 @@
1A91010A1268C8CA001842F5 /* FindIndicatorWindow.h in Headers */,
BCE81D8D1319F7EF00241910 /* FontInfo.h in Headers */,
BC17753F118BABF0007D9E9A /* GenericCallback.h in Headers */,
+ 7CD5EBBF1746B04C000C1C45 /* WKTypeRefWrapper.h in Headers */,
BC06F42F12DBB9B6002D78DE /* GeolocationPermissionRequestManager.h in Headers */,
BC06F44A12DBD1F5002D78DE /* GeolocationPermissionRequestManagerProxy.h in Headers */,
BC06F43A12DBCCFB002D78DE /* GeolocationPermissionRequestProxy.h in Headers */,
@@ -6620,6 +6627,7 @@
1A4A9C5512B816CF008FE984 /* NetscapePluginModule.cpp in Sources */,
1A4A9C9A12B821CD008FE984 /* NetscapePluginModuleMac.mm in Sources */,
1AA5889311EE70400061B882 /* NetscapePluginStream.cpp in Sources */,
+ 7CD5EBBE1746B04C000C1C45 /* WKTypeRefWrapper.mm in Sources */,
513A164C1630A9BF005D7D22 /* NetworkConnectionToWebProcess.cpp in Sources */,
51DD9F2816367DA2001578E9 /* NetworkConnectionToWebProcessMessageReceiver.cpp in Sources */,
51795568162876CF00FA43B6 /* NetworkProcess.cpp in Sources */,