- Revision
- 213272
- Author
- wenson_hs...@apple.com
- Date
- 2017-03-01 23:43:41 -0800 (Wed, 01 Mar 2017)
Log Message
Replace -[WKWebView adjustedDataInteractionItemProviders:] with a UI delegate method
https://bugs.webkit.org/show_bug.cgi?id=169013
Reviewed by Dan Bernstein.
Source/WebKit2:
Rather than introduce new SPI on WKWebView directly, we should follow convention and add the hook to the private
version of the UI delegate.
* UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _adjustedDataInteractionItemProviders:]): Deleted.
* UIProcess/API/Cocoa/WKWebViewPrivate.h:
Tools:
Adjusts TestWebKitAPI for changes in WebKit2. See Source/WebKit2/ChangeLog for more details.
* TestWebKitAPI/Tests/ios/DataInteractionTests.mm:
(TestWebKitAPI::TEST):
(-[CustomItemProviderWebView _adjustedDataInteractionItemProviders:]): Deleted.
* TestWebKitAPI/ios/DataInteractionSimulator.h:
* TestWebKitAPI/ios/DataInteractionSimulator.mm:
(-[DataInteractionSimulator initWithWebView:]):
(-[DataInteractionSimulator dealloc]):
(-[DataInteractionSimulator _webView:adjustedDataInteractionItemProviders:]):
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (213271 => 213272)
--- trunk/Source/WebKit2/ChangeLog 2017-03-02 07:32:40 UTC (rev 213271)
+++ trunk/Source/WebKit2/ChangeLog 2017-03-02 07:43:41 UTC (rev 213272)
@@ -1,3 +1,18 @@
+2017-03-01 Wenson Hsieh <wenson_hs...@apple.com>
+
+ Replace -[WKWebView adjustedDataInteractionItemProviders:] with a UI delegate method
+ https://bugs.webkit.org/show_bug.cgi?id=169013
+
+ Reviewed by Dan Bernstein.
+
+ Rather than introduce new SPI on WKWebView directly, we should follow convention and add the hook to the private
+ version of the UI delegate.
+
+ * UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (-[WKWebView _adjustedDataInteractionItemProviders:]): Deleted.
+ * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+
2017-03-01 Alex Christensen <achristen...@webkit.org>
Unreviewed, rolling out r213259.
Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h (213271 => 213272)
--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h 2017-03-02 07:32:40 UTC (rev 213271)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h 2017-03-02 07:43:41 UTC (rev 213272)
@@ -30,6 +30,7 @@
#import <WebKit/WKSecurityOrigin.h>
#import <WebKit/_WKActivatedElementInfo.h>
+@class UIItemProvider;
@class UIScrollView;
@class UIViewController;
@class _WKContextMenuElementInfo;
@@ -86,6 +87,7 @@
- (UIViewController *)_presentingViewControllerForWebView:(WKWebView *)webView WK_API_AVAILABLE(ios(10.0));
- (void)_webView:(WKWebView *)webView getAlternateURLFromImage:(UIImage *)image completionHandler:(void (^)(NSURL *alternateURL, NSDictionary *userInfo))completionHandler WK_API_AVAILABLE(ios(WK_IOS_TBA));
- (NSURL *)_webView:(WKWebView *)webView alternateURLFromImage:(UIImage *)image userInfo:(NSDictionary **)userInfo WK_API_AVAILABLE(ios(WK_IOS_TBA));
+- (NSArray<UIItemProvider *> *)_webView:(WKWebView *)webView adjustedDataInteractionItemProviders:(NSArray<UIItemProvider *> *)originalItemProviders WK_API_AVAILABLE(ios(WK_IOS_TBA));
#else
- (NSMenu *)_webView:(WKWebView *)webView contextMenu:(NSMenu *)menu forElement:(_WKContextMenuElementInfo *)element WK_API_AVAILABLE(macosx(10.12));
- (NSMenu *)_webView:(WKWebView *)webView contextMenu:(NSMenu *)menu forElement:(_WKContextMenuElementInfo *)element userInfo:(id <NSSecureCoding>)userInfo WK_API_AVAILABLE(macosx(10.12));
Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (213271 => 213272)
--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm 2017-03-02 07:32:40 UTC (rev 213271)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm 2017-03-02 07:43:41 UTC (rev 213272)
@@ -3726,11 +3726,6 @@
{
}
-- (NSArray *)_adjustedDataInteractionItemProviders:(NSArray *)originalItemProviders
-{
- return originalItemProviders;
-}
-
#endif
- (void)_didRelaunchProcess
Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h (213271 => 213272)
--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h 2017-03-02 07:32:40 UTC (rev 213271)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h 2017-03-02 07:43:41 UTC (rev 213272)
@@ -188,8 +188,6 @@
- (void)_accessibilityRetrieveSpeakSelectionContent;
- (void)_accessibilityDidGetSpeakSelectionContent:(NSString *)content;
-- (NSArray *)_adjustedDataInteractionItemProviders:(NSArray *)originalItemProviders WK_API_AVAILABLE(ios(WK_IOS_TBA));
-
#else
@property (readonly) NSColor *_pageExtendedBackgroundColor;
@property (nonatomic, setter=_setDrawsBackground:) BOOL _drawsBackground;
Modified: trunk/Tools/ChangeLog (213271 => 213272)
--- trunk/Tools/ChangeLog 2017-03-02 07:32:40 UTC (rev 213271)
+++ trunk/Tools/ChangeLog 2017-03-02 07:43:41 UTC (rev 213272)
@@ -1,3 +1,21 @@
+2017-03-01 Wenson Hsieh <wenson_hs...@apple.com>
+
+ Replace -[WKWebView adjustedDataInteractionItemProviders:] with a UI delegate method
+ https://bugs.webkit.org/show_bug.cgi?id=169013
+
+ Reviewed by Dan Bernstein.
+
+ Adjusts TestWebKitAPI for changes in WebKit2. See Source/WebKit2/ChangeLog for more details.
+
+ * TestWebKitAPI/Tests/ios/DataInteractionTests.mm:
+ (TestWebKitAPI::TEST):
+ (-[CustomItemProviderWebView _adjustedDataInteractionItemProviders:]): Deleted.
+ * TestWebKitAPI/ios/DataInteractionSimulator.h:
+ * TestWebKitAPI/ios/DataInteractionSimulator.mm:
+ (-[DataInteractionSimulator initWithWebView:]):
+ (-[DataInteractionSimulator dealloc]):
+ (-[DataInteractionSimulator _webView:adjustedDataInteractionItemProviders:]):
+
2017-03-01 Per Arne Vollan <pvol...@apple.com>
[Win] DRT should not dispatch messages after test is done.
Modified: trunk/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm (213271 => 213272)
--- trunk/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm 2017-03-02 07:32:40 UTC (rev 213271)
+++ trunk/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm 2017-03-02 07:43:41 UTC (rev 213272)
@@ -34,7 +34,6 @@
#import <MobileCoreServices/MobileCoreServices.h>
#import <UIKit/UIItemProvider_Private.h>
#import <WebKit/WKWebViewConfigurationPrivate.h>
-#import <WebKit/WKWebViewPrivate.h>
@implementation TestWKWebView (DataInteractionTests)
@@ -50,22 +49,6 @@
@end
-@interface CustomItemProviderWebView : TestWKWebView
-@property (nonatomic) BlockPtr<NSArray *(NSArray *)> convertItemProvidersBlock;
-@end
-
-@implementation CustomItemProviderWebView
-
-- (NSArray *)_adjustedDataInteractionItemProviders:(NSArray *)originalItemProviders
-{
- if (!self.convertItemProvidersBlock)
- return [super _adjustedDataInteractionItemProviders:originalItemProviders];
-
- return self.convertItemProvidersBlock(originalItemProviders);
-}
-
-@end
-
static NSValue *makeCGRectValue(CGFloat x, CGFloat y, CGFloat width, CGFloat height)
{
return [NSValue valueWithCGRect:CGRectMake(x, y, width, height)];
@@ -272,12 +255,13 @@
{
RetainPtr<WKWebViewConfiguration> configuration = [WKWebViewConfiguration testwebkitapi_configurationWithTestPlugInClassName:@"BundleEditingDelegatePlugIn"];
[configuration _setAttachmentElementEnabled:YES];
- auto webView = adoptNS([[CustomItemProviderWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500) configuration:configuration.get()]);
+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500) configuration:configuration.get()]);
+ auto dataInteractionSimulator = adoptNS([[DataInteractionSimulator alloc] initWithWebView:webView.get()]);
[webView synchronouslyLoadTestPageNamed:@"attachment-element"];
NSString *injectedTypeIdentifier = @"org.webkit.data";
__block RetainPtr<NSString> injectedString;
- [webView setConvertItemProvidersBlock:^NSArray *(NSArray *originalItemProviders)
+ [dataInteractionSimulator setConvertItemProvidersBlock:^NSArray *(NSArray *originalItemProviders)
{
for (UIItemProvider *provider in originalItemProviders) {
NSData *injectedData = [provider copyDataRepresentationForTypeIdentifier:injectedTypeIdentifier error:nil];
@@ -289,7 +273,6 @@
return originalItemProviders;
}];
- auto dataInteractionSimulator = adoptNS([[DataInteractionSimulator alloc] initWithWebView:webView.get()]);
[dataInteractionSimulator runFrom:CGPointMake(50, 50) to:CGPointMake(50, 400)];
EXPECT_WK_STREQ("hello", [injectedString UTF8String]);
Modified: trunk/Tools/TestWebKitAPI/ios/DataInteractionSimulator.h (213271 => 213272)
--- trunk/Tools/TestWebKitAPI/ios/DataInteractionSimulator.h 2017-03-02 07:32:40 UTC (rev 213271)
+++ trunk/Tools/TestWebKitAPI/ios/DataInteractionSimulator.h 2017-03-02 07:43:41 UTC (rev 213272)
@@ -28,6 +28,7 @@
#import "TestWKWebView.h"
#import <UIKit/UIItemProvider.h>
#import <UIKit/UIKit.h>
+#import <WebKit/WKUIDelegatePrivate.h>
#import <WebKit/_WKTestingDelegate.h>
#import <wtf/BlockPtr.h>
@@ -48,7 +49,7 @@
DataInteractionPerforming = 4
};
-@interface DataInteractionSimulator : NSObject<_WKTestingDelegate> {
+@interface DataInteractionSimulator : NSObject<_WKTestingDelegate, WKUIDelegatePrivate> {
RetainPtr<TestWKWebView> _webView;
RetainPtr<MockDataInteractionSession> _dataInteractionSession;
RetainPtr<MockDataInteractionInfo> _dataInteractionInfo;
@@ -66,6 +67,7 @@
- (instancetype)initWithWebView:(TestWKWebView *)webView;
- (void)runFrom:(CGPoint)startLocation to:(CGPoint)endLocation;
+@property (nonatomic) BlockPtr<NSArray *(NSArray *)> convertItemProvidersBlock;
@property (nonatomic, strong) UIItemProvider *externalItemProvider;
@property (nonatomic, readonly) NSArray *observedEventNames;
@property (nonatomic, readonly) NSArray *finalSelectionRects;
Modified: trunk/Tools/TestWebKitAPI/ios/DataInteractionSimulator.mm (213271 => 213272)
--- trunk/Tools/TestWebKitAPI/ios/DataInteractionSimulator.mm 2017-03-02 07:32:40 UTC (rev 213271)
+++ trunk/Tools/TestWebKitAPI/ios/DataInteractionSimulator.mm 2017-03-02 07:43:41 UTC (rev 213272)
@@ -59,6 +59,7 @@
if (self = [super init]) {
_webView = webView;
[_webView _setTestingDelegate:self];
+ [_webView setUIDelegate:self];
}
return self;
}
@@ -68,6 +69,9 @@
if ([_webView _testingDelegate] == self)
[_webView _setTestingDelegate:nil];
+ if ([_webView UIDelegate] == self)
+ [_webView setUIDelegate:nil];
+
[super dealloc];
}
@@ -212,6 +216,13 @@
_isDoneWithCurrentRun = true;
}
+#pragma mark - WKUIDelegatePrivate
+
+- (NSArray<UIItemProvider *>*)_webView:(WKWebView *)webView adjustedDataInteractionItemProviders:(NSArray<UIItemProvider *>*)originalItemProviders
+{
+ return self.convertItemProvidersBlock ? self.convertItemProvidersBlock(originalItemProviders) : originalItemProviders;
+}
+
@end
#endif // ENABLE(DATA_INTERACTION)