Skip to content
Permalink
Browse files
Add sourceFrame to WKNavigationAction
https://bugs.webkit.org/show_bug.cgi?id=128280

Reviewed by Dan Bernstein.

* UIProcess/API/Cocoa/WKFrameInfo.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKNavigationActionInternal.h.
* UIProcess/API/Cocoa/WKFrameInfo.mm: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKNavigationActionInternal.h.
(-[WKFrameInfo request]):
(-[WKFrameInfo setRequest:]):
* UIProcess/API/Cocoa/WKFrameInfoInternal.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKNavigationActionInternal.h.
* UIProcess/API/Cocoa/WKNavigationAction.h:
* UIProcess/API/Cocoa/WKNavigationAction.mm:
(-[WKNavigationAction sourceFrame]):
(-[WKNavigationAction setSourceFrame:]):
* UIProcess/API/Cocoa/WKNavigationActionInternal.h:
* UIProcess/Cocoa/NavigationState.mm:
(WebKit::frameInfoFromWebFrameProxy):
(WebKit::NavigationState::PolicyClient::decidePolicyForNavigationAction):
* WebKit2.xcodeproj/project.pbxproj:

Canonical link: https://commits.webkit.org/146286@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@163501 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Anders Carlsson committed Feb 6, 2014
1 parent e7703dc commit 87a1a613133360c104d31fe820130cee61dec597
@@ -1,3 +1,25 @@
2014-02-05 Anders Carlsson <andersca@apple.com>

Add sourceFrame to WKNavigationAction
https://bugs.webkit.org/show_bug.cgi?id=128280

Reviewed by Dan Bernstein.

* UIProcess/API/Cocoa/WKFrameInfo.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKNavigationActionInternal.h.
* UIProcess/API/Cocoa/WKFrameInfo.mm: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKNavigationActionInternal.h.
(-[WKFrameInfo request]):
(-[WKFrameInfo setRequest:]):
* UIProcess/API/Cocoa/WKFrameInfoInternal.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKNavigationActionInternal.h.
* UIProcess/API/Cocoa/WKNavigationAction.h:
* UIProcess/API/Cocoa/WKNavigationAction.mm:
(-[WKNavigationAction sourceFrame]):
(-[WKNavigationAction setSourceFrame:]):
* UIProcess/API/Cocoa/WKNavigationActionInternal.h:
* UIProcess/Cocoa/NavigationState.mm:
(WebKit::frameInfoFromWebFrameProxy):
(WebKit::NavigationState::PolicyClient::decidePolicyForNavigationAction):
* WebKit2.xcodeproj/project.pbxproj:

2014-02-05 Enrica Casucci <enrica@apple.com>

WK2: Tap highlight is positioned incorrectly in iframes.
@@ -0,0 +1,39 @@
/*
* 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 <Foundation/Foundation.h>
#import <WebKit2/WKFoundation.h>

#if WK_API_ENABLED

WK_API_CLASS
@interface WKFrameInfo : NSObject

@property (nonatomic, readonly, getter=isMainFrame) BOOL mainFrame;
@property (nonatomic, readonly) NSURLRequest *request;

@end

#endif
@@ -0,0 +1,50 @@
/*
* 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 "config.h"
#import "WKFrameInfoInternal.h"

#if WK_API_ENABLED

#import <wtf/RetainPtr.h>

@implementation WKFrameInfo {
RetainPtr<NSURLRequest> _request;
}

- (NSURLRequest *)request
{
return _request.get();
}

- (void)setRequest:(NSURLRequest *)request
{
_request = adoptNS([request copy]);
}

@end

#endif

@@ -0,0 +1,37 @@
/*
* 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 "WKFrameInfo.h"

#if WK_API_ENABLED

@interface WKFrameInfo ()

@property (nonatomic, readwrite, getter=isMainFrame) BOOL mainFrame;
@property (nonatomic, readwrite, copy) NSURLRequest *request;

@end

#endif
@@ -28,6 +28,8 @@

#if WK_API_ENABLED

@class WKFrameInfo;

typedef NS_ENUM(NSInteger, WKNavigationType) {
WKNavigationTypeLinkActivated,
WKNavigationTypeFormSubmitted,
@@ -40,6 +42,8 @@ typedef NS_ENUM(NSInteger, WKNavigationType) {
WK_API_CLASS
@interface WKNavigationAction : NSObject

@property (nonatomic, readonly) WKFrameInfo *sourceFrame;

@property (nonatomic, readonly) WKNavigationType navigationType;

@end
@@ -23,12 +23,26 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/

#include "config.h"
#include "WKNavigationAction.h"
#import "config.h"
#import "WKNavigationActionInternal.h"

#if WK_API_ENABLED

@implementation WKNavigationAction
#import <wtf/RetainPtr.h>

@implementation WKNavigationAction {
RetainPtr<WKFrameInfo> _sourceFrame;
}

- (WKFrameInfo *)sourceFrame
{
return _sourceFrame.get();
}

- (void)setSourceFrame:(WKFrameInfo *)sourceFrame
{
_sourceFrame = sourceFrame;
}

@end

@@ -29,6 +29,8 @@

@interface WKNavigationAction ()

@property (nonatomic, readwrite, strong) WKFrameInfo *sourceFrame;

@property (nonatomic, readwrite) WKNavigationType navigationType;

@end
@@ -30,6 +30,7 @@

#import "NavigationActionData.h"
#import "PageLoadState.h"
#import "WKFrameInfoInternal.h"
#import "WKNavigationActionInternal.h"
#import "WKNavigationDelegate.h"
#import "WKNavigationInternal.h"
@@ -126,6 +127,15 @@ static WKNavigationType toWKNavigationType(WebCore::NavigationType navigationTyp
return WKNavigationTypeOther;
}

static RetainPtr<WKFrameInfo> frameInfoFromWebFrameProxy(WebFrameProxy& webFrameProxy)
{
auto frameInfo = adoptNS([[WKFrameInfo alloc] init]);

[frameInfo setMainFrame:webFrameProxy.isMainFrame()];

return frameInfo;
}

void NavigationState::PolicyClient::decidePolicyForNavigationAction(WebPageProxy*, WebFrameProxy* destinationFrame, const NavigationActionData& navigationActionData, WebFrameProxy* sourceFrame, const WebCore::ResourceRequest& originalRequest, const WebCore::ResourceRequest&, RefPtr<WebFramePolicyListenerProxy> listener, API::Object* userData)
{
if (!m_navigationState.m_navigationDelegateMethods.webViewDecidePolicyForNavigationActionDecisionHandler) {
@@ -141,6 +151,12 @@ static WKNavigationType toWKNavigationType(WebCore::NavigationType navigationTyp
// FIXME: Set up the navigation action object.
auto navigationAction = adoptNS([[WKNavigationAction alloc] init]);

if (sourceFrame) {
auto sourceFrameInfo = frameInfoFromWebFrameProxy(*sourceFrame);
[sourceFrameInfo setRequest:originalRequest.nsURLRequest(WebCore::DoNotUpdateHTTPBody)];
[navigationAction setSourceFrame:sourceFrameInfo.get()];
}

[navigationAction setNavigationType:toWKNavigationType(navigationActionData.navigationType)];

[navigationDelegate webView:m_navigationState.m_webView decidePolicyForNavigationAction:navigationAction.get() decisionHandler:[listener](WKNavigationPolicyDecision policyDecision) {
@@ -118,7 +118,7 @@
1A24BED5120894D100FBB059 /* SharedMemory.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A24BED3120894D100FBB059 /* SharedMemory.h */; };
1A24BF3A120896A600FBB059 /* SharedMemoryMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A24BF39120896A600FBB059 /* SharedMemoryMac.cpp */; };
1A256E3718A1A788006FB922 /* WKNavigationAction.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A256E3518A1A788006FB922 /* WKNavigationAction.mm */; };
1A256E3818A1A788006FB922 /* WKNavigationAction.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A256E3618A1A788006FB922 /* WKNavigationAction.h */; };
1A256E3818A1A788006FB922 /* WKNavigationAction.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A256E3618A1A788006FB922 /* WKNavigationAction.h */; settings = {ATTRIBUTES = (Public, ); }; };
1A256E3A18A1A7DF006FB922 /* WKNavigationActionInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A256E3918A1A7DF006FB922 /* WKNavigationActionInternal.h */; };
1A2A4B0E1586A2240090C9E9 /* ColorSpaceData.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A2A4AFD158693920090C9E9 /* ColorSpaceData.mm */; };
1A2BB6D014117B4D000F35D4 /* PluginProcessConnectionMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2BB6CE14117B4D000F35D4 /* PluginProcessConnectionMessageReceiver.cpp */; };
@@ -178,6 +178,9 @@
1A4A9C9A12B821CD008FE984 /* NetscapePluginModuleMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A4A9C9912B821CD008FE984 /* NetscapePluginModuleMac.mm */; };
1A4A9F3312B844E2008FE984 /* PluginQuirks.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A4A9F3112B844E2008FE984 /* PluginQuirks.h */; };
1A4D664818A2D91A00D82E21 /* APIUIClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A4D664718A2D91A00D82E21 /* APIUIClient.h */; };
1A4D664B18A3030E00D82E21 /* WKFrameInfo.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A4D664918A3030E00D82E21 /* WKFrameInfo.mm */; };
1A4D664C18A3030E00D82E21 /* WKFrameInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A4D664A18A3030E00D82E21 /* WKFrameInfo.h */; settings = {ATTRIBUTES = (Public, ); }; };
1A4D664E18A3031B00D82E21 /* WKFrameInfoInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A4D664D18A3031B00D82E21 /* WKFrameInfoInternal.h */; };
1A50DB66110A3D57000D3FE5 /* WebProcess.app in Copy Files */ = {isa = PBXBuildFile; fileRef = 1A50DB1E110A3BDC000D3FE5 /* WebProcess.app */; };
1A5B1C501898606F004FCF9B /* WKNavigation.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A5B1C4E1898606F004FCF9B /* WKNavigation.mm */; };
1A5B1C511898606F004FCF9B /* WKNavigation.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A5B1C4F1898606F004FCF9B /* WKNavigation.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -1822,6 +1825,9 @@
1A4A9C9912B821CD008FE984 /* NetscapePluginModuleMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NetscapePluginModuleMac.mm; sourceTree = "<group>"; };
1A4A9F3112B844E2008FE984 /* PluginQuirks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PluginQuirks.h; sourceTree = "<group>"; };
1A4D664718A2D91A00D82E21 /* APIUIClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIUIClient.h; sourceTree = "<group>"; };
1A4D664918A3030E00D82E21 /* WKFrameInfo.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKFrameInfo.mm; sourceTree = "<group>"; };
1A4D664A18A3030E00D82E21 /* WKFrameInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKFrameInfo.h; sourceTree = "<group>"; };
1A4D664D18A3031B00D82E21 /* WKFrameInfoInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKFrameInfoInternal.h; sourceTree = "<group>"; };
1A4F976A100E7B6600637A18 /* Base.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Base.xcconfig; sourceTree = "<group>"; };
1A4F976B100E7B6600637A18 /* DebugRelease.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = DebugRelease.xcconfig; sourceTree = "<group>"; };
1A4F976C100E7B6600637A18 /* FeatureDefines.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = FeatureDefines.xcconfig; sourceTree = "<group>"; };
@@ -4287,6 +4293,9 @@
isa = PBXGroup;
children = (
1A43E826188F38E2009E4D30 /* Deprecated */,
1A4D664A18A3030E00D82E21 /* WKFrameInfo.h */,
1A4D664918A3030E00D82E21 /* WKFrameInfo.mm */,
1A4D664D18A3031B00D82E21 /* WKFrameInfoInternal.h */,
1A5B1C4F1898606F004FCF9B /* WKNavigation.h */,
1A5B1C4E1898606F004FCF9B /* WKNavigation.mm */,
1A256E3618A1A788006FB922 /* WKNavigationAction.h */,
@@ -6418,6 +6427,7 @@
514BDED316C98EDD00E4E25E /* StatisticsRequest.h in Headers */,
2DA944871884E3B500ED86DB /* PageClientImplIOS.h in Headers */,
1AD3306F16B1D991004F60E7 /* StorageAreaImpl.h in Headers */,
1A4D664E18A3031B00D82E21 /* WKFrameInfoInternal.h in Headers */,
1ACECD2517162DB1001FC9EF /* StorageAreaMap.h in Headers */,
1A334DEE16DE8F88006A8E38 /* StorageAreaMapMessages.h in Headers */,
1A44B95C16B73F9F00B7BBD8 /* StorageManager.h in Headers */,
@@ -6730,6 +6740,7 @@
BCC8B374125FB69000DE46A4 /* WKGeometry.h in Headers */,
B62E7312143047B00069EC35 /* WKHitTestResult.h in Headers */,
5110AE0D133C16CB0072717A /* WKIconDatabase.h in Headers */,
1A4D664C18A3030E00D82E21 /* WKFrameInfo.h in Headers */,
5123CF1C133D260A0056F800 /* WKIconDatabaseCG.h in Headers */,
37C4C0941814B3AF003688B9 /* WKNSArray.h in Headers */,
BCCF6AC312C91F34008F9C35 /* WKImage.h in Headers */,
@@ -7609,6 +7620,7 @@
93FC67BF12D3CCF200A60610 /* EncoderAdapter.cpp in Sources */,
2DA944AD1884E9BA00ED86DB /* TextCheckerIOS.mm in Sources */,
2DA944A21884E4F000ED86DB /* WebPlatformTouchPointIOS.cpp in Sources */,
1A4D664B18A3030E00D82E21 /* WKFrameInfo.mm in Sources */,
2D28F3E51885CCC1004B9EAE /* WebDatabaseManagerIOS.mm in Sources */,
51B15A8413843A3900321AD8 /* EnvironmentUtilities.cpp in Sources */,
1A43E829188F3CDC009E4D30 /* WKProcessClassConfiguration.mm in Sources */,
@@ -43,6 +43,7 @@ - (void)awakeFromNib
[_webView setFrameLoadDelegate:self];
[_webView setUIDelegate:self];
[_webView setResourceLoadDelegate:self];
[_webView setPolicyDelegate:self];

[containerView addSubview:_webView];
}
@@ -257,6 +258,13 @@ - (IBAction)dumpSourceToConsole:(id)sender
{
}

- (void)webView:(WebView *)webView decidePolicyForNavigationAction:(NSDictionary *)actionInformation request:(NSURLRequest *)request frame:(WebFrame *)frame decisionListener:(id<WebPolicyDecisionListener>)listener
{
NSLog(@"request %@ actionInformation %@", request, actionInformation);

[listener use];
}

// WebFrameLoadDelegate Methods
- (void)webView:(WebView *)sender didStartProvisionalLoadForFrame:(WebFrame *)frame
{
@@ -672,6 +672,7 @@ - (void)browsingContextController:(WKBrowsingContextController *)sender didRecei
- (void)browsingContextController:(WKBrowsingContextController *)browsingContext decidePolicyForNavigationAction:(NSDictionary *)actionInformation decisionHandler:(WKPolicyDecisionHandler)decisionHandler
{
LOG(@"decidePolicyForNavigationAction");
NSLog(@"action information %@", actionInformation);
decisionHandler(WKPolicyDecisionAllow);
}

0 comments on commit 87a1a61

Please sign in to comment.