Diff
Modified: trunk/Source/WebKit2/ChangeLog (158412 => 158413)
--- trunk/Source/WebKit2/ChangeLog 2013-11-01 00:45:47 UTC (rev 158412)
+++ trunk/Source/WebKit2/ChangeLog 2013-11-01 00:48:49 UTC (rev 158413)
@@ -1,5 +1,49 @@
2013-10-31 Anders Carlsson <[email protected]>
+ Begin stubbing out the WKRemoteObjectCoder NSCoder subclass
+ https://bugs.webkit.org/show_bug.cgi?id=123596
+
+ Reviewed by Tim Horton.
+
+ * Shared/API/Cocoa/WKRemoteObject.mm:
+ (-[WKRemoteObject forwardInvocation:]):
+ Call through to the WKRemoteObjectRegistry.
+
+ * Shared/API/Cocoa/WKRemoteObjectCoder.h: Added.
+ * Shared/API/Cocoa/WKRemoteObjectCoder.mm: Added.
+ (-[WKRemoteObjectEncoder init]):
+ Create a root WKDictionary.
+
+ (-[WKRemoteObjectEncoder dealloc]):
+ Assert that the current dictionary is the root dictionary; that we're back where we started.
+
+ (-[WKRemoteObjectEncoder allowsKeyedCoding]):
+ Return YES.
+
+ (-[WKRemoteObjectEncoder encodeObject:forKey:]):
+ Check that the object is valid and then encode it.
+
+ (-[WKRemoteObjectEncoder _encodeInvocation:forKey:]):
+ Encode the method type string and invocation selector.
+
+ (-[WKRemoteObjectEncoder encodeBytes:length:forKey:]):
+ Create a WKDataRef and add it to the dictionary.
+
+ (-[WKRemoteObjectEncoder _encodeObjectForKey:usingBlock:]):
+ Create a new dictionary and call the block.
+
+ * Shared/API/Cocoa/WKRemoteObjectRegistry.mm:
+ (-[WKRemoteObjectRegistry _sendInvocation:interface:]):
+ Create an encoder and encode the invocation and interface.
+
+ * Shared/API/Cocoa/WKRemoteObjectRegistryInternal.h: Added.
+ Add IPI header.
+
+ * WebKit2.xcodeproj/project.pbxproj:
+ Add new files.
+
+2013-10-31 Anders Carlsson <[email protected]>
+
Address review comments.
* Shared/API/Cocoa/WKRemoteObject.h:
Modified: trunk/Source/WebKit2/Shared/API/Cocoa/WKRemoteObject.mm (158412 => 158413)
--- trunk/Source/WebKit2/Shared/API/Cocoa/WKRemoteObject.mm 2013-11-01 00:45:47 UTC (rev 158412)
+++ trunk/Source/WebKit2/Shared/API/Cocoa/WKRemoteObject.mm 2013-11-01 00:48:49 UTC (rev 158413)
@@ -29,6 +29,7 @@
#if WK_API_ENABLED
#import "WKRemoteObjectInterface.h"
+#import "WKRemoteObjectRegistryInternal.h"
#import <objc/runtime.h>
#import <wtf/RetainPtr.h>
@@ -86,7 +87,7 @@
- (void)forwardInvocation:(NSInvocation *)invocation
{
- // FIXME: Implement.
+ [_objectRegistry _sendInvocation:invocation interface:_interface.get()];
}
@end
Added: trunk/Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectCoder.h (0 => 158413)
--- trunk/Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectCoder.h (rev 0)
+++ trunk/Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectCoder.h 2013-11-01 00:48:49 UTC (rev 158413)
@@ -0,0 +1,33 @@
+/*
+ * 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 "WKFoundation.h"
+
+#if WK_API_ENABLED
+
+@interface WKRemoteObjectEncoder : NSCoder
+@end
+
+#endif // WK_API_ENABLED
Added: trunk/Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectCoder.mm (0 => 158413)
--- trunk/Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectCoder.mm (rev 0)
+++ trunk/Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectCoder.mm 2013-11-01 00:48:49 UTC (rev 158413)
@@ -0,0 +1,120 @@
+/*
+ * 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 "WKRemoteObjectCoder.h"
+
+#import "WKData.h"
+#import "WKMutableDictionary.h"
+#import "WKNumber.h"
+#import "WKRetainPtr.h"
+#import "WKStringCF.h"
+
+#if WK_API_ENABLED
+
+@interface NSMethodSignature (Details)
+- (NSString *)_typeString;
+@end
+
+@implementation WKRemoteObjectEncoder {
+ WKRetainPtr<WKMutableDictionaryRef> _rootDictionary;
+ WKMutableDictionaryRef _currentDictionary;
+}
+
+- (id)init
+{
+ if (!(self = [super init]))
+ return nil;
+
+ _rootDictionary = adoptWK(WKMutableDictionaryCreate());
+ _currentDictionary = _rootDictionary.get();
+
+ return self;
+}
+
+#if ASSERT_DISABLED
+- (void)dealloc
+{
+ ASSERT(_currentDictionary == _rootDictionary);
+
+ [super dealloc];
+}
+#endif
+
+- (BOOL)allowsKeyedCoding
+{
+ return YES;
+}
+
+- (void)encodeObject:(id)object forKey:(NSString *)key
+{
+ if ([object isKindOfClass:[NSInvocation class]]) {
+ // We have to special case NSInvocation since we don't want to encode the target.
+ [self _encodeInvocation:object forKey:key];
+ return;
+ }
+
+ if (![object conformsToProtocol:@protocol(NSSecureCoding)])
+ [NSException raise:NSInvalidArgumentException format:@"%@ does not conform to NSSecureCoding", object];
+
+ [self _encodeObjectForKey:key usingBlock:^{
+ [object encodeWithCoder:self];
+ }];
+}
+
+- (void)_encodeInvocation:(NSInvocation *)invocation forKey:(NSString *)key
+{
+ [self _encodeObjectForKey:key usingBlock:^{
+ NSMethodSignature *methodSignature = invocation.methodSignature;
+ [self encodeObject:methodSignature._typeString forKey:@"typeString"];
+ [self encodeObject:NSStringFromSelector(invocation.selector) forKey:@"selector"];
+
+ // FIXME: Encode arguments as well.
+ }];
+}
+
+- (void)encodeBytes:(const uint8_t *)bytes length:(NSUInteger)length forKey:(NSString *)key
+{
+ auto data = "" length));
+ auto keyString = adoptWK(WKStringCreateWithCFString((CFStringRef)key));
+
+ WKDictionarySetItem(_currentDictionary, keyString.get(), data.get());
+}
+
+- (void)_encodeObjectForKey:(NSString *)key usingBlock:(void (^)())block
+{
+ auto dictionary = adoptWK(WKMutableDictionaryCreate());
+ auto keyString = adoptWK(WKStringCreateWithCFString((CFStringRef)key));
+
+ WKDictionarySetItem(_currentDictionary, keyString.get(), dictionary.get());
+
+ WKMutableDictionaryRef previousDictionary = _currentDictionary;
+ block();
+ _currentDictionary = previousDictionary;
+}
+
+@end
+
+#endif // WK_API_ENABLED
Modified: trunk/Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectRegistry.mm (158412 => 158413)
--- trunk/Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectRegistry.mm 2013-11-01 00:45:47 UTC (rev 158412)
+++ trunk/Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectRegistry.mm 2013-11-01 00:48:49 UTC (rev 158413)
@@ -24,13 +24,13 @@
*/
#import "config.h"
-#import "WKRemoteObjectRegistry.h"
-#import "WKRemoteObjectRegistryPrivate.h"
+#import "WKRemoteObjectRegistryInternal.h"
#import "Connection.h"
#import "WKConnectionRef.h"
+#import "WKRemoteObject.h"
+#import "WKRemoteObjectCoder.h"
#import "WKRemoteObjectInterface.h"
-#import "WKRemoteObject.h"
#import "WKSharedAPICast.h"
#import "WebConnection.h"
@@ -68,6 +68,14 @@
return [remoteObject.leakRef() autorelease];
}
+- (void)_sendInvocation:(NSInvocation *)invocation interface:(WKRemoteObjectInterface *)interface
+{
+ RetainPtr<WKRemoteObjectEncoder> encoder = adoptNS([[WKRemoteObjectEncoder alloc] init]);
+
+ [encoder encodeObject:interface.identifier forKey:@"interfaceIdentifier"];
+ [encoder encodeObject:invocation forKey:@"invocation"];
+}
+
@end
@implementation WKRemoteObjectRegistry (WKPrivate)
Added: trunk/Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectRegistryInternal.h (0 => 158413)
--- trunk/Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectRegistryInternal.h (rev 0)
+++ trunk/Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectRegistryInternal.h 2013-11-01 00:48:49 UTC (rev 158413)
@@ -0,0 +1,36 @@
+/*
+ * 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 "WKRemoteObjectRegistryPrivate.h"
+
+#if WK_API_ENABLED
+
+@interface WKRemoteObjectRegistry ()
+
+- (void)_sendInvocation:(NSInvocation *)invocation interface:(WKRemoteObjectInterface *)interface;
+
+@end
+
+#endif // WK_API_ENABLED
Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (158412 => 158413)
--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj 2013-11-01 00:45:47 UTC (rev 158412)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj 2013-11-01 00:48:49 UTC (rev 158413)
@@ -207,6 +207,9 @@
1A9E329718219BEA00F5D04C /* WKRemoteObjectRegistryPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A9E329618219BEA00F5D04C /* WKRemoteObjectRegistryPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
1A9E329A1822E1CC00F5D04C /* WKRemoteObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A9E32981822E1CC00F5D04C /* WKRemoteObject.mm */; };
1A9E329B1822E1CC00F5D04C /* WKRemoteObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A9E32991822E1CC00F5D04C /* WKRemoteObject.h */; };
+ 1A9E329E1822FEDD00F5D04C /* WKRemoteObjectCoder.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A9E329C1822FEDD00F5D04C /* WKRemoteObjectCoder.mm */; };
+ 1A9E329F1822FEDD00F5D04C /* WKRemoteObjectCoder.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A9E329D1822FEDD00F5D04C /* WKRemoteObjectCoder.h */; };
+ 1A9E32A11823018900F5D04C /* WKRemoteObjectRegistryInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A9E32A01823018900F5D04C /* WKRemoteObjectRegistryInternal.h */; };
1A9FBA8D13FF04E600DEED67 /* PluginComplexTextInputState.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A9FBA8C13FF04E600DEED67 /* PluginComplexTextInputState.h */; };
1AA2E51D12E4C05E00BC4966 /* CGUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA2E51B12E4C05E00BC4966 /* CGUtilities.h */; };
1AA2E51E12E4C05E00BC4966 /* CGUtilities.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AA2E51C12E4C05E00BC4966 /* CGUtilities.cpp */; };
@@ -1664,6 +1667,9 @@
1A9E329618219BEA00F5D04C /* WKRemoteObjectRegistryPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKRemoteObjectRegistryPrivate.h; sourceTree = "<group>"; };
1A9E32981822E1CC00F5D04C /* WKRemoteObject.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKRemoteObject.mm; sourceTree = "<group>"; };
1A9E32991822E1CC00F5D04C /* WKRemoteObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKRemoteObject.h; sourceTree = "<group>"; };
+ 1A9E329C1822FEDD00F5D04C /* WKRemoteObjectCoder.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKRemoteObjectCoder.mm; sourceTree = "<group>"; };
+ 1A9E329D1822FEDD00F5D04C /* WKRemoteObjectCoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKRemoteObjectCoder.h; sourceTree = "<group>"; };
+ 1A9E32A01823018900F5D04C /* WKRemoteObjectRegistryInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKRemoteObjectRegistryInternal.h; sourceTree = "<group>"; };
1A9FBA8C13FF04E600DEED67 /* PluginComplexTextInputState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PluginComplexTextInputState.h; sourceTree = "<group>"; };
1AA1C79A100E7FC50078DEBC /* WebCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = WebCore.framework; sourceTree = BUILT_PRODUCTS_DIR; };
1AA1C7DE100E846E0078DEBC /* _javascript_Core.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = _javascript_Core.framework; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -3697,10 +3703,13 @@
37DFA6FF1810BB92001F4A9F /* WKFoundation.h */,
1A9E32991822E1CC00F5D04C /* WKRemoteObject.h */,
1A9E32981822E1CC00F5D04C /* WKRemoteObject.mm */,
+ 1A9E329D1822FEDD00F5D04C /* WKRemoteObjectCoder.h */,
+ 1A9E329C1822FEDD00F5D04C /* WKRemoteObjectCoder.mm */,
1A9E328B182165A900F5D04C /* WKRemoteObjectInterface.h */,
1A9E328C182165A900F5D04C /* WKRemoteObjectInterface.mm */,
1A9E32871821636900F5D04C /* WKRemoteObjectRegistry.h */,
1A9E32881821636900F5D04C /* WKRemoteObjectRegistry.mm */,
+ 1A9E32A01823018900F5D04C /* WKRemoteObjectRegistryInternal.h */,
1A9E329618219BEA00F5D04C /* WKRemoteObjectRegistryPrivate.h */,
);
path = Cocoa;
@@ -5537,6 +5546,7 @@
5179556A162876F300FA43B6 /* NetworkProcess.h in Headers */,
517CF0E4163A486C00C2950E /* NetworkProcessConnectionMessages.h in Headers */,
51795571162877D200FA43B6 /* NetworkProcessCreationParameters.h in Headers */,
+ 1A9E329F1822FEDD00F5D04C /* WKRemoteObjectCoder.h in Headers */,
5163199516289A6300E22F00 /* NetworkProcessMessages.h in Headers */,
E14A954A16E016A40068DE82 /* NetworkProcessPlatformStrategies.h in Headers */,
5179556E162877B300FA43B6 /* NetworkProcessProxy.h in Headers */,
@@ -5579,6 +5589,7 @@
1A9FBA8D13FF04E600DEED67 /* PluginComplexTextInputState.h in Headers */,
1AA56F2911E92BC80061B882 /* PluginController.h in Headers */,
1A8EF4CB1252403700F7067F /* PluginControllerProxy.h in Headers */,
+ 1A9E32A11823018900F5D04C /* WKRemoteObjectRegistryInternal.h in Headers */,
1A8EF96F1252AF6B00F7067F /* PluginControllerProxyMessages.h in Headers */,
1A179780137EE82C00F97D45 /* PluginCreationParameters.h in Headers */,
1A9E329B1822E1CC00F5D04C /* WKRemoteObject.h in Headers */,
@@ -6856,6 +6867,7 @@
1A2D82A8127F4EAB001EB962 /* NPRemoteObjectMap.cpp in Sources */,
1A2161B111F37664008AD0F5 /* NPRuntimeObjectMap.cpp in Sources */,
1A2162B011F38971008AD0F5 /* NPRuntimeUtilities.cpp in Sources */,
+ 1A9E329E1822FEDD00F5D04C /* WKRemoteObjectCoder.mm in Sources */,
1A2D84A4127F6AD1001EB962 /* NPVariantData.cpp in Sources */,
BC8ACA1416670D89004C1941 /* ObjCObjectGraph.mm in Sources */,
BC8ACA1616670D89004C1941 /* ObjCObjectGraphCoders.mm in Sources */,