-[WKWebView loadRequest:] should return a WKNavigation
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 30 Jan 2014 01:17:57 +0000 (01:17 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 30 Jan 2014 01:17:57 +0000 (01:17 +0000)
https://bugs.webkit.org/show_bug.cgi?id=127873

Reviewed by Dan Bernstein.

Source/WebKit2:

For now this just returns a dummy navigation.

* UIProcess/API/Cocoa/WKNavigation.h:
* UIProcess/API/Cocoa/WKNavigation.mm:
(-[WKNavigation initWithRequest:]):
(-[WKNavigation request]):
* UIProcess/API/Cocoa/WKNavigationInternal.h: Added.
* UIProcess/API/Cocoa/WKWebView.h:
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView loadRequest:]):
* WebKit2.xcodeproj/project.pbxproj:

Tools:

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2Cocoa/Navigation.mm: Added.
(TEST):

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

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/Cocoa/WKNavigation.h
Source/WebKit2/UIProcess/API/Cocoa/WKNavigation.mm
Source/WebKit2/UIProcess/API/Cocoa/WKNavigationInternal.h [new file with mode: 0644]
Source/WebKit2/UIProcess/API/Cocoa/WKWebView.h
Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Tools/ChangeLog
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebKit2Cocoa/Navigation.mm [new file with mode: 0644]

index 27228ad..1b2f4fa 100644 (file)
@@ -1,5 +1,24 @@
 2014-01-29  Anders Carlsson  <andersca@apple.com>
 
+        -[WKWebView loadRequest:] should return a WKNavigation
+        https://bugs.webkit.org/show_bug.cgi?id=127873
+
+        Reviewed by Dan Bernstein.
+
+        For now this just returns a dummy navigation.
+
+        * UIProcess/API/Cocoa/WKNavigation.h:
+        * UIProcess/API/Cocoa/WKNavigation.mm:
+        (-[WKNavigation initWithRequest:]):
+        (-[WKNavigation request]):
+        * UIProcess/API/Cocoa/WKNavigationInternal.h: Added.
+        * UIProcess/API/Cocoa/WKWebView.h:
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView loadRequest:]):
+        * WebKit2.xcodeproj/project.pbxproj:
+
+2014-01-29  Anders Carlsson  <andersca@apple.com>
+
         
 
         * UIProcess/API/C/WKPage.cpp:
index 1d00bcf..ad81a78 100644 (file)
@@ -31,6 +31,8 @@
 WK_API_CLASS
 @interface WKNavigation : NSObject
 
+@property (nonatomic, readonly) NSURLRequest *request;
+
 @end
 
 #endif
index f1a90e8..9071ce0 100644 (file)
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "config.h"
-#include "WKNavigation.h"
+#import "config.h"
+#import "WKNavigation.h"
+
+#import <wtf/RetainPtr.h>
 
 #if WK_API_ENABLED
 
-@implementation WKNavigation
+@implementation WKNavigation {
+    RetainPtr<NSURLRequest> _request;
+}
+
+- (instancetype)initWithRequest:(NSURLRequest *)request
+{
+    if (!(self = [super init]))
+        return nil;
+
+    _request = adoptNS([request copy]);
+
+    return self;
+}
+
+- (NSURLRequest *)request
+{
+    return _request.get();
+}
 
 @end
 
diff --git a/Source/WebKit2/UIProcess/API/Cocoa/WKNavigationInternal.h b/Source/WebKit2/UIProcess/API/Cocoa/WKNavigationInternal.h
new file mode 100644 (file)
index 0000000..e3f0762
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2014 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 "WKNavigation.h"
+
+#if WK_API_ENABLED
+
+@interface WKNavigation ()
+
+- (instancetype)initWithRequest:(NSURLRequest *)request;
+
+@end
+
+#endif
index 4f0e955..6bc3a87 100644 (file)
@@ -34,6 +34,7 @@
 #import <AppKit/AppKit.h>
 #endif
 
+@class WKNavigation;
 @class WKWebViewConfiguration;
 
 /*!
@@ -66,8 +67,7 @@ WK_API_CLASS
  */
 - (instancetype)initWithFrame:(CGRect)frame configuration:(WKWebViewConfiguration *)configuration WK_DESIGNATED_INITIALIZER;
 
-// FIXME: This should return a WKNavigation object.
-- (void)loadRequest:(NSURLRequest *)request;
+- (WKNavigation *)loadRequest:(NSURLRequest *)request;
 
 @end
 
index 90307ce..6b34273 100644 (file)
@@ -28,6 +28,7 @@
 
 #if WK_API_ENABLED
 
+#import "WKNavigationInternal.h"
 #import "WKProcessClass.h"
 #import "WKWebViewConfiguration.h"
 #import "WebPageProxy.h"
@@ -120,9 +121,11 @@ static _UIWebViewportConfiguration standardViewportConfiguration = { { UIWebView
     return [[_configuration copy] autorelease];
 }
 
-- (void)loadRequest:(NSURLRequest *)request
+- (WKNavigation *)loadRequest:(NSURLRequest *)request
 {
     _page->loadRequest(request);
+
+    return [[[WKNavigation alloc] initWithRequest:request] autorelease];
 }
 
 #pragma mark iOS-specific methods
index cbc0637..3352ea3 100644 (file)
                1AB8A1F418400B8F00E9AE69 /* WKPageFindClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AB8A1F318400B8F00E9AE69 /* WKPageFindClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
                1AB8A1F618400B9D00E9AE69 /* WKPageFindMatchesClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AB8A1F518400B9D00E9AE69 /* WKPageFindMatchesClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
                1AB8A1F818400BB800E9AE69 /* WKPageContextMenuClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AB8A1F718400BB800E9AE69 /* WKPageContextMenuClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               1ABC3DF11899C6B6004F0626 /* WKNavigationInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 1ABC3DF01899C6B6004F0626 /* WKNavigationInternal.h */; };
                1AC1336718565B5700F3EC05 /* UserData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AC1336518565B5700F3EC05 /* UserData.cpp */; };
                1AC1336818565B5700F3EC05 /* UserData.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AC1336618565B5700F3EC05 /* UserData.h */; };
                1AC1336C18565C7A00F3EC05 /* APIPageHandle.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AC1336B18565C7A00F3EC05 /* APIPageHandle.h */; };
                1AB8A1F318400B8F00E9AE69 /* WKPageFindClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKPageFindClient.h; sourceTree = "<group>"; };
                1AB8A1F518400B9D00E9AE69 /* WKPageFindMatchesClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKPageFindMatchesClient.h; sourceTree = "<group>"; };
                1AB8A1F718400BB800E9AE69 /* WKPageContextMenuClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKPageContextMenuClient.h; sourceTree = "<group>"; };
+               1ABC3DF01899C6B6004F0626 /* WKNavigationInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKNavigationInternal.h; sourceTree = "<group>"; };
                1AC1336518565B5700F3EC05 /* UserData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UserData.cpp; sourceTree = "<group>"; };
                1AC1336618565B5700F3EC05 /* UserData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserData.h; sourceTree = "<group>"; };
                1AC1336B18565C7A00F3EC05 /* APIPageHandle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIPageHandle.h; sourceTree = "<group>"; };
                                1A43E826188F38E2009E4D30 /* Deprecated */,
                                1A5B1C4F1898606F004FCF9B /* WKNavigation.h */,
                                1A5B1C4E1898606F004FCF9B /* WKNavigation.mm */,
+                               1ABC3DF01899C6B6004F0626 /* WKNavigationInternal.h */,
                                1AFDD3161891C94700153970 /* WKPreferences.h */,
                                1AFDD3181891CA1200153970 /* WKPreferences.mm */,
                                1A158418189044F50017616C /* WKProcessClass.h */,
                                293EBEAB1627D9C9005F89F1 /* WKDOMText.h in Headers */,
                                BC017D2116263308007054F5 /* WKDOMTextIterator.h in Headers */,
                                37DFA7001810BB92001F4A9F /* WKFoundation.h in Headers */,
+                               1ABC3DF11899C6B6004F0626 /* WKNavigationInternal.h in Headers */,
                                1F604BA81889FA7400EE0395 /* WKRenderingProgressEvents.h in Headers */,
                                BCBAACEB145225E30053F82F /* WKProcessGroup.h in Headers */,
                                377EAD4817E2C77B002D193D /* WKUserContentInjectedFrames.h in Headers */,
index 2d5cfdf..313e97c 100644 (file)
@@ -1,3 +1,14 @@
+2014-01-29  Anders Carlsson  <andersca@apple.com>
+
+        -[WKWebView loadRequest:] should return a WKNavigation
+        https://bugs.webkit.org/show_bug.cgi?id=127873
+
+        Reviewed by Dan Bernstein.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKit2Cocoa/Navigation.mm: Added.
+        (TEST):
+
 2014-01-29  Tim Horton  <timothy_horton@apple.com>
 
         WebKit2 View Gestures (Swipe): Update rubberBandsAt{Left,Right} when WebKit swipe is enabled
index 1e1e5f6..be41f8c 100644 (file)
@@ -26,6 +26,7 @@
                1A9E52C913E65EF4006917F5 /* 18-characters.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C045F9461385C2F800C0F3CD /* 18-characters.html */; };
                1AA9BAE418500450003B6BC6 /* WeakObjCPtr.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AA9BAE218500450003B6BC6 /* WeakObjCPtr.mm */; };
                1AA9E55914980A9900001A8A /* Functional.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AA9E55714980A9900001A8A /* Functional.cpp */; };
+               1ABC3DEF1899BE6D004F0626 /* Navigation.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1ABC3DED1899BE6D004F0626 /* Navigation.mm */; };
                1ADBEFAE130C689C00D61D19 /* ForceRepaint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1ADBEFAD130C689C00D61D19 /* ForceRepaint.cpp */; };
                1ADBEFE3130C6AA100D61D19 /* simple-accelerated-compositing.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 1ADBEFBC130C6A0100D61D19 /* simple-accelerated-compositing.html */; };
                1AE72F48173EB214006362F0 /* TerminateTwice.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AE72F47173EB214006362F0 /* TerminateTwice.cpp */; };
                1A7E8B351812093600AEB74A /* FragmentNavigation.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = FragmentNavigation.html; sourceTree = "<group>"; };
                1AA9BAE218500450003B6BC6 /* WeakObjCPtr.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WeakObjCPtr.mm; sourceTree = "<group>"; };
                1AA9E55714980A9900001A8A /* Functional.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Functional.cpp; sourceTree = "<group>"; };
+               1ABC3DED1899BE6D004F0626 /* Navigation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Navigation.mm; sourceTree = "<group>"; };
                1ADBEFAD130C689C00D61D19 /* ForceRepaint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ForceRepaint.cpp; sourceTree = "<group>"; };
                1ADBEFBC130C6A0100D61D19 /* simple-accelerated-compositing.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "simple-accelerated-compositing.html"; sourceTree = "<group>"; };
                1AE72F47173EB214006362F0 /* TerminateTwice.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TerminateTwice.cpp; sourceTree = "<group>"; };
                        name = Products;
                        sourceTree = "<group>";
                };
+               1ABC3DEC1899BE55004F0626 /* WebKit2 Cocoa */ = {
+                       isa = PBXGroup;
+                       children = (
+                               1ABC3DED1899BE6D004F0626 /* Navigation.mm */,
+                       );
+                       name = "WebKit2 Cocoa";
+                       path = WebKit2Cocoa;
+                       sourceTree = "<group>";
+               };
                2E9660DC16C07D7B00371B42 /* ios */ = {
                        isa = PBXGroup;
                        children = (
                                C08587F913FEC39B001EF4E5 /* TestWebKitAPI */,
                                440A1D3614A01000008A66F2 /* WebCore */,
                                BC9096411255616000083756 /* WebKit2 */,
+                               1ABC3DEC1899BE55004F0626 /* WebKit2 Cocoa */,
                                BC3C4C6F14575B1D0025FB62 /* WebKit2 Objective-C */,
                                BC9096461255618900083756 /* WTF */,
                        );
                                A7A966DB140ECCC8005EF9B4 /* CheckedArithmeticOperations.cpp in Sources */,
                                5142B2711517C88B00C32B19 /* ContextMenuCanCopyURL.mm in Sources */,
                                F6F3F29113342FEB00A6BF19 /* CookieManager.cpp in Sources */,
+                               1ABC3DEF1899BE6D004F0626 /* Navigation.mm in Sources */,
                                26A2C72F15E2E73C005B1A14 /* CString.cpp in Sources */,
                                29AB8AA1164C735800D49BEC /* CustomProtocolsTest.mm in Sources */,
                                3776BC63150946BC0043A66D /* DeviceScaleFactorInDashboardRegions.mm in Sources */,
diff --git a/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/Navigation.mm b/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/Navigation.mm
new file mode 100644 (file)
index 0000000..8121948
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2014 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"
+
+#import <WebKit2/WKNavigation.h>
+#import <WebKit2/WKWebView.h>
+#import <wtf/RetainPtr.h>
+#import "Test.h"
+
+#if WK_API_ENABLED
+
+TEST(WKNavigation, LoadRequest)
+{
+    RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
+
+    NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"simple" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];
+
+    WKNavigation *navigation = [webView loadRequest:request];
+    ASSERT_NOT_NULL(navigation);
+    ASSERT_TRUE([navigation.request isEqual:request]);
+}
+
+#endif