Diff
Modified: trunk/Source/WebKit2/ChangeLog (160277 => 160278)
--- trunk/Source/WebKit2/ChangeLog 2013-12-08 05:22:02 UTC (rev 160277)
+++ trunk/Source/WebKit2/ChangeLog 2013-12-08 05:23:29 UTC (rev 160278)
@@ -1,3 +1,24 @@
+2013-12-07 Dan Bernstein <m...@apple.com>
+
+ [Cocoa] WebData has a generic wrapper
+ https://bugs.webkit.org/show_bug.cgi?id=125402
+
+ Reviewed by Sam Weinig.
+
+ Added WKNSData, an NSData subclass that confroms to WKObject and wraps a WebData.
+
+ * Shared/Cocoa/APIObject.mm:
+ (API::Object::newObject): Allocate a WKNSData if the API::Object is data.
+ * Shared/Cocoa/WKNSData.h: Added.
+ (WebKit::wrapper): Added. Returns a WebData’s wrapper as an NSData.
+ * Shared/Cocoa/WKNSData.mm: Added.
+ (-[WKNSData dealloc]): Calls the WebData destructor.
+ (-[WKNSData length]): Added.
+ (-[WKNSData bytes]): Added.
+ (-[WKNSData copyWithZone:]): Retains self.
+ (-[WKNSData _apiObject]): Returns the wrapped WebData.
+ * WebKit2.xcodeproj/project.pbxproj: Added references to new files.
+
2013-12-07 Sam Weinig <s...@webkit.org>
[Cocoa] Make WKWebProcessPlugInBrowserContextController work with WKObject wrapping
Modified: trunk/Source/WebKit2/Shared/Cocoa/APIObject.mm (160277 => 160278)
--- trunk/Source/WebKit2/Shared/Cocoa/APIObject.mm 2013-12-08 05:22:02 UTC (rev 160277)
+++ trunk/Source/WebKit2/Shared/Cocoa/APIObject.mm 2013-12-08 05:23:29 UTC (rev 160278)
@@ -34,6 +34,7 @@
#import "WKBrowsingContextGroupInternal.h"
#import "WKConnectionInternal.h"
#import "WKNSArray.h"
+#import "WKNSData.h"
#import "WKNSDictionary.h"
#import "WKNSError.h"
#import "WKNSString.h"
@@ -93,6 +94,10 @@
wrapper = [WKProcessGroup alloc];
break;
+ case Type::Data:
+ wrapper = [WKNSData alloc];
+ break;
+
case Type::Dictionary:
wrapper = [WKNSDictionary alloc];
break;
Added: trunk/Source/WebKit2/Shared/Cocoa/WKNSData.h (0 => 160278)
--- trunk/Source/WebKit2/Shared/Cocoa/WKNSData.h (rev 0)
+++ trunk/Source/WebKit2/Shared/Cocoa/WKNSData.h 2013-12-08 05:23:29 UTC (rev 160278)
@@ -0,0 +1,46 @@
+/*
+ * 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
+
+#import "WKObject.h"
+#import "WebData.h"
+
+namespace WebKit {
+
+inline NSData *wrapper(WebData& data)
+{
+ ASSERT([data.wrapper() isKindOfClass:[NSData self]]);
+ return (NSData *)data.wrapper();
+}
+
+}
+
+@interface WKNSData : NSData <WKObject>
+@end
+
+#endif // WK_API_ENABLED
Added: trunk/Source/WebKit2/Shared/Cocoa/WKNSData.mm (0 => 160278)
--- trunk/Source/WebKit2/Shared/Cocoa/WKNSData.mm (rev 0)
+++ trunk/Source/WebKit2/Shared/Cocoa/WKNSData.mm 2013-12-08 05:23:29 UTC (rev 160278)
@@ -0,0 +1,72 @@
+/*
+ * 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.
+ */
+
+#include "config.h"
+#include "WKNSData.h"
+
+#if WK_API_ENABLED
+
+using namespace WebKit;
+
+@implementation WKNSData {
+ API::ObjectStorage<WebData> _data;
+}
+
+- (void)dealloc
+{
+ _data->~WebData();
+
+ [super dealloc];
+}
+
+#pragma mark NSData primitive methods
+
+- (NSUInteger)length
+{
+ return _data->size();
+}
+
+- (const void*)bytes
+{
+ return _data->bytes();
+}
+
+#pragma mark NSCopying protocol implementation
+
+- (id)copyWithZone:(NSZone *)zone
+{
+ return [self retain];
+}
+
+#pragma mark WKObject protocol implementation
+
+- (API::Object&)_apiObject
+{
+ return *_data;
+}
+
+@end
+
+#endif // WK_API_ENABLED
Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (160277 => 160278)
--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj 2013-12-08 05:22:02 UTC (rev 160277)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj 2013-12-08 05:23:29 UTC (rev 160278)
@@ -441,6 +441,8 @@
371B32DE184D67490013E2B2 /* WKNSURLProtectionSpace.h in Headers */ = {isa = PBXBuildFile; fileRef = 371B32DC184D67490013E2B2 /* WKNSURLProtectionSpace.h */; };
372CAF0B1833FD910040AC27 /* WKNSError.h in Headers */ = {isa = PBXBuildFile; fileRef = 372CAF091833FD910040AC27 /* WKNSError.h */; };
372CAF0C1833FD910040AC27 /* WKNSError.mm in Sources */ = {isa = PBXBuildFile; fileRef = 372CAF0A1833FD910040AC27 /* WKNSError.mm */; };
+ 373CEAD5185417AE008C363D /* WKNSData.mm in Sources */ = {isa = PBXBuildFile; fileRef = 373CEAD3185417AE008C363D /* WKNSData.mm */; };
+ 373CEAD6185417AE008C363D /* WKNSData.h in Headers */ = {isa = PBXBuildFile; fileRef = 373CEAD4185417AE008C363D /* WKNSData.h */; };
374436881820E7240049579F /* WKObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 374436871820E7240049579F /* WKObject.mm */; };
3760881E150413E900FC82C7 /* WebRenderObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3760881C150413E900FC82C7 /* WebRenderObject.cpp */; };
3760881F150413E900FC82C7 /* WebRenderObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 3760881D150413E900FC82C7 /* WebRenderObject.h */; };
@@ -1989,6 +1991,8 @@
371B32DC184D67490013E2B2 /* WKNSURLProtectionSpace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKNSURLProtectionSpace.h; sourceTree = "<group>"; };
372CAF091833FD910040AC27 /* WKNSError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKNSError.h; sourceTree = "<group>"; };
372CAF0A1833FD910040AC27 /* WKNSError.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKNSError.mm; sourceTree = "<group>"; };
+ 373CEAD3185417AE008C363D /* WKNSData.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKNSData.mm; sourceTree = "<group>"; };
+ 373CEAD4185417AE008C363D /* WKNSData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKNSData.h; sourceTree = "<group>"; };
374436871820E7240049579F /* WKObject.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKObject.mm; sourceTree = "<group>"; };
3760881C150413E900FC82C7 /* WebRenderObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebRenderObject.cpp; sourceTree = "<group>"; };
3760881D150413E900FC82C7 /* WebRenderObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebRenderObject.h; sourceTree = "<group>"; };
@@ -3829,6 +3833,8 @@
378E1A3B181ED6FF0031007A /* APIObject.mm */,
37C4C0921814B3AF003688B9 /* WKNSArray.h */,
37C4C0911814B3AF003688B9 /* WKNSArray.mm */,
+ 373CEAD4185417AE008C363D /* WKNSData.h */,
+ 373CEAD3185417AE008C363D /* WKNSData.mm */,
371A19401824D29300F32A5E /* WKNSDictionary.h */,
371A193F1824D29300F32A5E /* WKNSDictionary.mm */,
372CAF091833FD910040AC27 /* WKNSError.h */,
@@ -6195,6 +6201,7 @@
BC8F2F2B16273A2C005FACB5 /* WKWebProcessPlugInBrowserContextController.h in Headers */,
BC8F2F2E16273ACC005FACB5 /* WKWebProcessPlugInBrowserContextControllerInternal.h in Headers */,
29501724162A4504004A9D71 /* WKWebProcessPlugInBrowserContextControllerPrivate.h in Headers */,
+ 373CEAD6185417AE008C363D /* WKNSData.h in Headers */,
1AB8A1F018400B0000E9AE69 /* WKPageFormClient.h in Headers */,
BC989D85161A9890000D46D3 /* WKWebProcessPlugInInternal.h in Headers */,
BC04EFFC16E65AFB00E336F0 /* WKWebProcessPlugInPrivate.h in Headers */,
@@ -7489,6 +7496,7 @@
BC8699B6116AADAA002A925B /* WKView.mm in Sources */,
C5E1AFE816B20B67006CC1F2 /* WKWebArchive.cpp in Sources */,
C5E1AFEA16B20B7B006CC1F2 /* WKWebArchiveResource.cpp in Sources */,
+ 373CEAD5185417AE008C363D /* WKNSData.mm in Sources */,
BC989D81161A7E5D000D46D3 /* WKWebProcessPlugIn.mm in Sources */,
BC8F2F2A16273A2C005FACB5 /* WKWebProcessPlugInBrowserContextController.mm in Sources */,
BC2E6E8D1141971500A63B1E /* WorkQueue.cpp in Sources */,