Skip to content

Commit 77fdb88

Browse files
Add WKBundleFrameCreateFrameHandle
https://bugs.webkit.org/show_bug.cgi?id=181232 <rdar://problem/35926696> Reviewed by Tim Horton. Source/WebKit: InjectedBundle clients wanting to sent a _WKFrameHandle cannot without this function. Before, they would just send the WKBundleFrameRef which would be changed into a WKFrameRef in the UIProcess by WebProcessProxy::transformHandlesToObjects, but there is no ObjC equivalent of WKFrameRef, so we were just getting a WKObject when we wanted a _WKFrameHandle. We can't change WebProcessProxy::transformHandlesToObjects without being incompatible with the existing C API, so let's add a way for clients to say "I want a _WKFrameHandle". * WebProcess/InjectedBundle/API/c/WKBundlePage.cpp: (WKBundleFrameCreateFrameHandle): * WebProcess/InjectedBundle/API/c/WKBundlePage.h: Tools: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WebKitCocoa/FrameHandleSerialization.mm: Added. (mouseDidMoveOverElement): (-[FrameHandleSerialization webProcessPlugIn:didCreateBrowserContextController:]): * TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm: (-[MouseMoveOverElementDelegate _webView:mouseDidMoveOverElement:withFlags:userInfo:]): (TEST): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@226471 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent a8a7a71 commit 77fdb88

File tree

7 files changed

+105
-1
lines changed

7 files changed

+105
-1
lines changed

Source/WebKit/ChangeLog

+19
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
2018-01-05 Alex Christensen <[email protected]>
2+
3+
Add WKBundleFrameCreateFrameHandle
4+
https://bugs.webkit.org/show_bug.cgi?id=181232
5+
<rdar://problem/35926696>
6+
7+
Reviewed by Tim Horton.
8+
9+
InjectedBundle clients wanting to sent a _WKFrameHandle cannot without this function.
10+
Before, they would just send the WKBundleFrameRef which would be changed into a WKFrameRef
11+
in the UIProcess by WebProcessProxy::transformHandlesToObjects, but there is no ObjC equivalent
12+
of WKFrameRef, so we were just getting a WKObject when we wanted a _WKFrameHandle.
13+
We can't change WebProcessProxy::transformHandlesToObjects without being incompatible with the
14+
existing C API, so let's add a way for clients to say "I want a _WKFrameHandle".
15+
16+
* WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
17+
(WKBundleFrameCreateFrameHandle):
18+
* WebProcess/InjectedBundle/API/c/WKBundlePage.h:
19+
120
2018-01-05 Wenson Hsieh <[email protected]>
221

322
[Attachment Support] Add a way to write blob data to a file URL from the UI process

Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "WKBundlePagePrivate.h"
2929

3030
#include "APIArray.h"
31+
#include "APIFrameHandle.h"
3132
#include "APIString.h"
3233
#include "APIURL.h"
3334
#include "APIURLRequest.h"
@@ -170,6 +171,11 @@ WKBundleFrameRef WKBundlePageGetMainFrame(WKBundlePageRef pageRef)
170171
return toAPI(toImpl(pageRef)->mainWebFrame());
171172
}
172173

174+
WKFrameHandleRef WKBundleFrameCreateFrameHandle(WKBundleFrameRef bundleFrameRef)
175+
{
176+
return toAPI(&API::FrameHandle::create(toImpl(bundleFrameRef)->frameID()).leakRef());
177+
}
178+
173179
void WKBundlePageClickMenuItem(WKBundlePageRef pageRef, WKContextMenuItemRef item)
174180
{
175181
#if ENABLE(CONTEXT_MENUS)

Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePage.h

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ WK_EXPORT void WKBundlePageSetFullScreenClient(WKBundlePageRef page, WKBundlePag
6767

6868
WK_EXPORT WKBundlePageGroupRef WKBundlePageGetPageGroup(WKBundlePageRef page);
6969
WK_EXPORT WKBundleFrameRef WKBundlePageGetMainFrame(WKBundlePageRef page);
70+
WK_EXPORT WKFrameHandleRef WKBundleFrameCreateFrameHandle(WKBundleFrameRef);
7071

7172
WK_EXPORT WKBundleBackForwardListRef WKBundlePageGetBackForwardList(WKBundlePageRef page);
7273

Tools/ChangeLog

+16
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
2018-01-05 Alex Christensen <[email protected]>
2+
3+
Add WKBundleFrameCreateFrameHandle
4+
https://bugs.webkit.org/show_bug.cgi?id=181232
5+
<rdar://problem/35926696>
6+
7+
Reviewed by Tim Horton.
8+
9+
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
10+
* TestWebKitAPI/Tests/WebKitCocoa/FrameHandleSerialization.mm: Added.
11+
(mouseDidMoveOverElement):
12+
(-[FrameHandleSerialization webProcessPlugIn:didCreateBrowserContextController:]):
13+
* TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm:
14+
(-[MouseMoveOverElementDelegate _webView:mouseDidMoveOverElement:withFlags:userInfo:]):
15+
(TEST):
16+
117
2018-01-05 Chris Fleizach <[email protected]>
218

319
iOS: Build fix after r226432.

Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj

+4
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@
256256
5CB18BA81F5645E300EE23C4 /* ClickAutoFillButton.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5CB18BA71F5645B200EE23C4 /* ClickAutoFillButton.mm */; };
257257
5CB3CE391FA1697F00C3A2D6 /* WKWebViewConfiguration.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5CB3CE381FA1691700C3A2D6 /* WKWebViewConfiguration.mm */; };
258258
5CB40B4E1F4B98D3007DC7B9 /* UIDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5CB40B4D1F4B98BE007DC7B9 /* UIDelegate.mm */; };
259+
5CB5B3C21FFC55CF00C27BB0 /* FrameHandleSerialization.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5CB5B3BD1FFC517E00C27BB0 /* FrameHandleSerialization.mm */; };
259260
5CE354D91E70DA5C00BEFE3B /* WKContentExtensionStore.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5CE354D81E70D9C300BEFE3B /* WKContentExtensionStore.mm */; };
260261
5CEAB5E11FA939F400A77FAA /* _WKInputDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5CEAB5DF1FA937CB00A77FAA /* _WKInputDelegate.mm */; };
261262
5E4B1D2E1D404C6100053621 /* WKScrollViewDelegateCrash.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5E4B1D2C1D404C6100053621 /* WKScrollViewDelegateCrash.mm */; };
@@ -1417,6 +1418,7 @@
14171418
5CB18BA71F5645B200EE23C4 /* ClickAutoFillButton.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ClickAutoFillButton.mm; sourceTree = "<group>"; };
14181419
5CB3CE381FA1691700C3A2D6 /* WKWebViewConfiguration.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebViewConfiguration.mm; sourceTree = "<group>"; };
14191420
5CB40B4D1F4B98BE007DC7B9 /* UIDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = UIDelegate.mm; sourceTree = "<group>"; };
1421+
5CB5B3BD1FFC517E00C27BB0 /* FrameHandleSerialization.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = FrameHandleSerialization.mm; sourceTree = "<group>"; };
14201422
5CE354D81E70D9C300BEFE3B /* WKContentExtensionStore.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKContentExtensionStore.mm; sourceTree = "<group>"; };
14211423
5CEAB5DF1FA937CB00A77FAA /* _WKInputDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = _WKInputDelegate.mm; sourceTree = "<group>"; };
14221424
5E4B1D2C1D404C6100053621 /* WKScrollViewDelegateCrash.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKScrollViewDelegateCrash.mm; path = ../ios/WKScrollViewDelegateCrash.mm; sourceTree = "<group>"; };
@@ -2069,6 +2071,7 @@
20692071
F44D06461F395C4D001A0E29 /* EditorStateTests.mm */,
20702072
2D8104CB1BEC13E70020DA46 /* FindInPage.mm */,
20712073
2D1FE0AF1AD465C1006CD9E6 /* FixedLayoutSize.mm */,
2074+
5CB5B3BD1FFC517E00C27BB0 /* FrameHandleSerialization.mm */,
20722075
CD78E11A1DB7EA360014A2DE /* FullscreenDelegate.mm */,
20732076
3F1B52681D3D7129008D60C4 /* FullscreenLayoutConstraints.mm */,
20742077
CDE195B31CFE0ADE0053D256 /* FullscreenTopContentInset.mm */,
@@ -3694,6 +3697,7 @@
36943697
1C2B81831C891F0900A5529F /* CancelFontSubresourcePlugIn.mm in Sources */,
36953698
5CB18BA81F5645E300EE23C4 /* ClickAutoFillButton.mm in Sources */,
36963699
A14FC58B1B89927100D107EB /* ContentFilteringPlugIn.mm in Sources */,
3700+
5CB5B3C21FFC55CF00C27BB0 /* FrameHandleSerialization.mm in Sources */,
36973701
A13EBBAB1B87434600097110 /* PlatformUtilitiesCocoa.mm in Sources */,
36983702
1A4F81CF1BDFFD53004E672E /* RemoteObjectRegistryPlugIn.mm in Sources */,
36993703
A12DDC021E837C2400CF6CAE /* RenderedImageWithOptionsPlugIn.mm in Sources */,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Copyright (C) 2018 Apple Inc. All rights reserved.
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions
6+
* are met:
7+
* 1. Redistributions of source code must retain the above copyright
8+
* notice, this list of conditions and the following disclaimer.
9+
* 2. Redistributions in binary form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
*
13+
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15+
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17+
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23+
* THE POSSIBILITY OF SUCH DAMAGE.
24+
*/
25+
26+
#import "config.h"
27+
28+
#if WK_API_ENABLED
29+
30+
#import <WebKit/WKBundlePage.h>
31+
#import <WebKit/WKBundlePageUIClient.h>
32+
#import <WebKit/WKWebProcessPlugIn.h>
33+
#import <WebKit/WKWebProcessPlugInBrowserContextControllerPrivate.h>
34+
35+
void mouseDidMoveOverElement(WKBundlePageRef page, WKBundleHitTestResultRef hitTestResult, WKEventModifiers modifiers, WKTypeRef* userData, const void* clientInfo)
36+
{
37+
*userData = WKBundleFrameCreateFrameHandle(WKBundlePageGetMainFrame(page));
38+
}
39+
40+
@interface FrameHandleSerialization : NSObject <WKWebProcessPlugIn>
41+
@end
42+
43+
@implementation FrameHandleSerialization
44+
45+
- (void)webProcessPlugIn:(WKWebProcessPlugInController *)plugInController didCreateBrowserContextController:(WKWebProcessPlugInBrowserContextController *)browserContextController
46+
{
47+
WKBundlePageUIClientV0 client;
48+
memset(&client, 0, sizeof(client));
49+
client.mouseDidMoveOverElement = mouseDidMoveOverElement;
50+
WKBundlePageSetUIClient([browserContextController _bundlePageRef], &client.base);
51+
}
52+
53+
@end
54+
55+
#endif // WK_API_ENABLED
56+

Tools/TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm

+3-1
Original file line numberDiff line numberDiff line change
@@ -474,14 +474,16 @@ - (void)_webView:(WKWebView *)webview mouseDidMoveOverElement:(_WKHitTestResult
474474
EXPECT_STREQ(hitTestResult.linkLabel.UTF8String, "link label");
475475
EXPECT_STREQ(hitTestResult.linkTitle.UTF8String, "link title");
476476
EXPECT_EQ(flags, NSEventModifierFlagShift);
477+
EXPECT_STREQ(NSStringFromClass([(NSObject *)userInfo class]).UTF8String, "_WKFrameHandle");
477478
done = true;
478479
}
479480

480481
@end
481482

482483
TEST(WebKit, MouseMoveOverElement)
483484
{
484-
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 800, 600)]);
485+
WKWebViewConfiguration *configuration = [WKWebViewConfiguration _test_configurationWithTestPlugInClassName:@"FrameHandleSerialization"];
486+
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 800, 600) configuration:configuration]);
485487
[webView setUIDelegate:[[[MouseMoveOverElementDelegate alloc] init] autorelease]];
486488
[webView synchronouslyLoadHTMLString:@"<a href='http://example.com/path' title='link title'>link label</a>"];
487489
[webView mouseMoveToPoint:NSMakePoint(20, 600 - 20) withFlags:NSEventModifierFlagShift];

0 commit comments

Comments
 (0)