Title: [159263] trunk/Source/WebKit2
Revision
159263
Author
[email protected]
Date
2013-11-13 16:49:43 -0800 (Wed, 13 Nov 2013)

Log Message

[Cocoa] Add WKNSError
https://bugs.webkit.org/show_bug.cgi?id=124295

Reviewed by Anders Carlsson.

* Shared/Cocoa/APIObject.mm:
(API::Object::newObject): Allocate a WKNSError if the object is a WebError.
* Shared/Cocoa/WKNSError.h: Added.
(WebKit::wrapper): Added. Returns a WebError’s wrapper as an NSError.
* Shared/Cocoa/WKNSError.mm: Added.
(-[WKNSError _web_createTarget]): Override this WKObject method to return a copy of the
underlying CFError.
(-[WKNSError copyWithZone:]): Retains self.
* WebKit2.xcodeproj/project.pbxproj: Added new files.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (159262 => 159263)


--- trunk/Source/WebKit2/ChangeLog	2013-11-14 00:46:41 UTC (rev 159262)
+++ trunk/Source/WebKit2/ChangeLog	2013-11-14 00:49:43 UTC (rev 159263)
@@ -1,3 +1,20 @@
+2013-11-13  Dan Bernstein  <[email protected]>
+
+        [Cocoa] Add WKNSError
+        https://bugs.webkit.org/show_bug.cgi?id=124295
+
+        Reviewed by Anders Carlsson.
+
+        * Shared/Cocoa/APIObject.mm:
+        (API::Object::newObject): Allocate a WKNSError if the object is a WebError.
+        * Shared/Cocoa/WKNSError.h: Added.
+        (WebKit::wrapper): Added. Returns a WebError’s wrapper as an NSError.
+        * Shared/Cocoa/WKNSError.mm: Added.
+        (-[WKNSError _web_createTarget]): Override this WKObject method to return a copy of the
+        underlying CFError.
+        (-[WKNSError copyWithZone:]): Retains self.
+        * WebKit2.xcodeproj/project.pbxproj: Added new files.
+
 2013-11-13  Simon Fraser  <[email protected]>
 
         Tweak the property syntax after https://bugs.webkit.org/show_bug.cgi?id=124317

Modified: trunk/Source/WebKit2/Shared/Cocoa/APIObject.mm (159262 => 159263)


--- trunk/Source/WebKit2/Shared/Cocoa/APIObject.mm	2013-11-14 00:46:41 UTC (rev 159262)
+++ trunk/Source/WebKit2/Shared/Cocoa/APIObject.mm	2013-11-14 00:49:43 UTC (rev 159263)
@@ -32,6 +32,7 @@
 #import "WKBackForwardListItemInternal.h"
 #import "WKNSArray.h"
 #import "WKNSDictionary.h"
+#import "WKNSError.h"
 #import "WKNSString.h"
 #import "WKNSURL.h"
 #import "WKNavigationDataInternal.h"
@@ -73,6 +74,10 @@
         wrapper = [WKNSDictionary alloc];
         break;
 
+    case Type::Error:
+        wrapper = [WKNSError alloc];
+        break;
+
     case Type::NavigationData:
         wrapper = [WKNavigationData alloc];
         break;

Added: trunk/Source/WebKit2/Shared/Cocoa/WKNSError.h (0 => 159263)


--- trunk/Source/WebKit2/Shared/Cocoa/WKNSError.h	                        (rev 0)
+++ trunk/Source/WebKit2/Shared/Cocoa/WKNSError.h	2013-11-14 00:49:43 UTC (rev 159263)
@@ -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.
+ */
+
+#import "WKFoundation.h"
+
+#if WK_API_ENABLED
+
+#import "WKObject.h"
+#import "WebError.h"
+
+namespace WebKit {
+inline NSError *wrapper(WebError& error) { ASSERT([error.wrapper() isKindOfClass:[NSError self]]); return (NSError *)error.wrapper(); }
+}
+
+@interface WKNSError : WKObject <NSCopying>
+@end
+
+#endif // WK_API_ENABLED

Added: trunk/Source/WebKit2/Shared/Cocoa/WKNSError.mm (0 => 159263)


--- trunk/Source/WebKit2/Shared/Cocoa/WKNSError.mm	                        (rev 0)
+++ trunk/Source/WebKit2/Shared/Cocoa/WKNSError.mm	2013-11-14 00:49:43 UTC (rev 159263)
@@ -0,0 +1,51 @@
+/*
+ * 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 "WKNSError.h"
+
+#if WK_API_ENABLED
+
+#import "WebError.h"
+
+using namespace WebKit;
+
+@implementation WKNSError
+
+- (NSObject *)_web_createTarget
+{
+    return [(NSError *)static_cast<WebError*>(&self._apiObject)->platformError().cfError() copy];
+}
+
+#pragma mark NSCopying protocol implementation
+
+- (id)copyWithZone:(NSZone *)zone
+{
+    return [self retain];
+}
+
+@end
+
+#endif // WK_API_ENABLED

Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (159262 => 159263)


--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2013-11-14 00:46:41 UTC (rev 159262)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2013-11-14 00:49:43 UTC (rev 159263)
@@ -414,6 +414,8 @@
 		37183D57182F4E700080C811 /* WKNSURLExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = 37183D55182F4E700080C811 /* WKNSURLExtras.h */; };
 		371A19411824D29300F32A5E /* WKNSDictionary.mm in Sources */ = {isa = PBXBuildFile; fileRef = 371A193F1824D29300F32A5E /* WKNSDictionary.mm */; };
 		371A19421824D29300F32A5E /* WKNSDictionary.h in Headers */ = {isa = PBXBuildFile; fileRef = 371A19401824D29300F32A5E /* WKNSDictionary.h */; };
+		372CAF0B1833FD910040AC27 /* WKNSError.h in Headers */ = {isa = PBXBuildFile; fileRef = 372CAF091833FD910040AC27 /* WKNSError.h */; };
+		372CAF0C1833FD910040AC27 /* WKNSError.mm in Sources */ = {isa = PBXBuildFile; fileRef = 372CAF0A1833FD910040AC27 /* WKNSError.mm */; };
 		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 */; };
@@ -1916,6 +1918,8 @@
 		37183D55182F4E700080C811 /* WKNSURLExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKNSURLExtras.h; sourceTree = "<group>"; };
 		371A193F1824D29300F32A5E /* WKNSDictionary.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKNSDictionary.mm; sourceTree = "<group>"; };
 		371A19401824D29300F32A5E /* WKNSDictionary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKNSDictionary.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>"; };
 		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>"; };
@@ -3710,6 +3714,8 @@
 				37C4C0911814B3AF003688B9 /* WKNSArray.mm */,
 				371A19401824D29300F32A5E /* WKNSDictionary.h */,
 				371A193F1824D29300F32A5E /* WKNSDictionary.mm */,
+				372CAF091833FD910040AC27 /* WKNSError.h */,
+				372CAF0A1833FD910040AC27 /* WKNSError.mm */,
 				378E1A4818208CD60031007A /* WKNSString.h */,
 				378E1A4718208CD60031007A /* WKNSString.mm */,
 				378E1A4C18208D700031007A /* WKNSURL.h */,
@@ -5904,6 +5910,7 @@
 				BC4075F6124FF0270068F20A /* WKCertificateInfo.h in Headers */,
 				BC407627124FF0400068F20A /* WKCertificateInfoMac.h in Headers */,
 				F036978615F4BE6B00C3A80E /* WKColorPickerResultListener.h in Headers */,
+				372CAF0B1833FD910040AC27 /* WKNSError.h in Headers */,
 				BCA284D71492F2C7001F9042 /* WKConnection.h in Headers */,
 				BC5C75C814954DA600BC4775 /* WKConnectionInternal.h in Headers */,
 				BC4A6297147313A0006C681A /* WKConnectionRef.h in Headers */,
@@ -7045,6 +7052,7 @@
 				51ACBBA1127A8F2C00D203B9 /* WebContextMenuProxyMac.mm in Sources */,
 				BCEE7D0D12846F69009827DA /* WebContextMessageReceiver.cpp in Sources */,
 				3309344F1315B94D0097A7BC /* WebCookieManager.cpp in Sources */,
+				372CAF0C1833FD910040AC27 /* WKNSError.mm in Sources */,
 				1A9E329A1822E1CC00F5D04C /* WKRemoteObject.mm in Sources */,
 				51E35210180F63FB00E53BE9 /* DatabaseProcessIDBDatabaseBackendMessageReceiver.cpp in Sources */,
 				F6A90813133C20510082C3F4 /* WebCookieManagerMac.mm in Sources */,
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to