Title: [197973] trunk/Source/WebKit2
Revision
197973
Author
[email protected]
Date
2016-03-10 16:47:31 -0800 (Thu, 10 Mar 2016)

Log Message

defaultActions in UIDelegate method 
_webView:previewingViewControllerForElement:defaultActions: need to be 
use-able by a client
https://bugs.webkit.org/show_bug.cgi?id=155304
-and corresponding-
rdar://problem/24269296

Reviewed by Anders Carlsson.

This patch adds a new protocol, WKPreviewActionItem, which is a sub-protocol 
of UIPreviewActionItem. The new protocol adds an identifier so that clients 
can identify which of our default actions they want to use. In order for a 
client to use our default action items, they need to return those actions in 
their UIViewController's implementation of previewActionItems.

Change the defaultActions to NSArray <id <WKPreviewActionItem>> *
* UIProcess/API/Cocoa/WKUIDelegatePrivate.h:

This new file defines our sub-protocol and sub-class for WKPreviewActions.
* UIProcess/API/Cocoa/_WKPreviewAction.h: Added.
* UIProcess/API/Cocoa/_WKPreviewAction.mm: Added.
(+[_WKPreviewAction actionWithIdentifier:title:style:handler:]):

New BOOL _uiDelegateProvidedPreviewingViewController keeps track of whether 
the client returned a view controller from 
_webView:previewingViewControllerForElement:defaultActions:. If they did 
return a view controller, then we should invoke 
_webView:commitPreviewingViewController: at commit time. If they returned 
nil, then they indicated that WebKit should continue with default previewing 
behavior, so we will not invoke the UIDelegate’s commit method.
* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _registerPreview]):
(-[WKContentView _unregisterPreview]):
(-[WKContentView _interactionShouldBeginFromPreviewItemController:forPosition:]):

In order for our default actions to be useful, we have to create 
_WKPreviewActions.
(-[WKContentView _presentedViewControllerForPreviewItemController:]):

Only invoke _webView:commitPreviewedViewController: if 
_uiDelegateProvidedPreviewingViewController is YES.
(-[WKContentView _previewItemController:commitPreview:]):
* WebKit2.xcodeproj/project.pbxproj:

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (197972 => 197973)


--- trunk/Source/WebKit2/ChangeLog	2016-03-11 00:45:13 UTC (rev 197972)
+++ trunk/Source/WebKit2/ChangeLog	2016-03-11 00:47:31 UTC (rev 197973)
@@ -1,3 +1,50 @@
+2016-03-10  Beth Dakin  <[email protected]>
+
+        defaultActions in UIDelegate method 
+        _webView:previewingViewControllerForElement:defaultActions: need to be 
+        use-able by a client
+        https://bugs.webkit.org/show_bug.cgi?id=155304
+        -and corresponding-
+        rdar://problem/24269296
+
+        Reviewed by Anders Carlsson.
+
+        This patch adds a new protocol, WKPreviewActionItem, which is a sub-protocol 
+        of UIPreviewActionItem. The new protocol adds an identifier so that clients 
+        can identify which of our default actions they want to use. In order for a 
+        client to use our default action items, they need to return those actions in 
+        their UIViewController's implementation of previewActionItems.
+
+        Change the defaultActions to NSArray <id <WKPreviewActionItem>> *
+        * UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
+
+        This new file defines our sub-protocol and sub-class for WKPreviewActions.
+        * UIProcess/API/Cocoa/_WKPreviewAction.h: Added.
+        * UIProcess/API/Cocoa/_WKPreviewAction.mm: Added.
+        (+[_WKPreviewAction actionWithIdentifier:title:style:handler:]):
+
+        New BOOL _uiDelegateProvidedPreviewingViewController keeps track of whether 
+        the client returned a view controller from 
+        _webView:previewingViewControllerForElement:defaultActions:. If they did 
+        return a view controller, then we should invoke 
+        _webView:commitPreviewingViewController: at commit time. If they returned 
+        nil, then they indicated that WebKit should continue with default previewing 
+        behavior, so we will not invoke the UIDelegate’s commit method.
+        * UIProcess/ios/WKContentViewInteraction.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView _registerPreview]):
+        (-[WKContentView _unregisterPreview]):
+        (-[WKContentView _interactionShouldBeginFromPreviewItemController:forPosition:]):
+
+        In order for our default actions to be useful, we have to create 
+        _WKPreviewActions.
+        (-[WKContentView _presentedViewControllerForPreviewItemController:]):
+
+        Only invoke _webView:commitPreviewedViewController: if 
+        _uiDelegateProvidedPreviewingViewController is YES.
+        (-[WKContentView _previewItemController:commitPreview:]):
+        * WebKit2.xcodeproj/project.pbxproj:
+
 2016-03-10  Jer Noble  <[email protected]>
 
         Add WebCore, WebKit, & WebKit2 preference/setting to enable Main Content heuristic.

Added: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKPreviewActionIdentifiersPrivate.h (0 => 197973)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKPreviewActionIdentifiersPrivate.h	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKPreviewActionIdentifiersPrivate.h	2016-03-11 00:47:31 UTC (rev 197973)
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2016 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 <WebKit/WKFoundation.h>
+
+#if WK_API_ENABLED
+
+#import <Foundation/Foundation.h>
+#import <WebKit/WKDeclarationSpecifiers.h>
+
+WK_EXPORT extern NSString * const _WKPreviewIdentifierOpen WK_AVAILABLE(NA, WK_IOS_TBA);
+WK_EXPORT extern NSString * const _WKPreviewIdentifierAddToReadingList WK_AVAILABLE(NA, WK_IOS_TBA);
+WK_EXPORT extern NSString * const _WKPreviewIdentifierCopy WK_AVAILABLE(NA, WK_IOS_TBA);
+WK_EXPORT extern NSString * const _WKPreviewIdentifierShare WK_AVAILABLE(NA, WK_IOS_TBA);
+
+#endif

Added: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKPreviewActionIdentifiersPrivate.mm (0 => 197973)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKPreviewActionIdentifiersPrivate.mm	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKPreviewActionIdentifiersPrivate.mm	2016-03-11 00:47:31 UTC (rev 197973)
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2016 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"
+#include "WKPreviewActionIdentifiersPrivate.h"
+
+#if WK_API_ENABLED
+
+NSString * const _WKPreviewIdentifierOpen = @"WKPreviewIdentifierOpen";
+NSString * const _WKPreviewIdentifierAddToReadingList = @"WKPreviewIdentifierAddToReadingList";
+NSString * const _WKPreviewIdentifierCopy = @"WKPreviewIdentifierCopy";
+NSString * const _WKPreviewIdentifierShare = @"WKPreviewIdentifierShare";
+
+#endif

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h (197972 => 197973)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h	2016-03-11 00:45:13 UTC (rev 197972)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h	2016-03-11 00:47:31 UTC (rev 197973)
@@ -29,8 +29,8 @@
 
 #import <WebKit/WKSecurityOrigin.h>
 #import <WebKit/_WKActivatedElementInfo.h>
+#import <WebKit/_WKPreviewAction.h>
 
-@class UIPreviewActionItem;
 @class UIScrollView;
 @class UIViewController;
 @class _WKContextMenuElementInfo;
@@ -83,9 +83,10 @@
 // shouldPreviewElement. Returning NO in shouldPreviewElement will prevent the other methods from being invoked.
 // The client can provide a custom preview by returning their own UIViewController from
 // previewingViewControllerForElement:defaultActions:. Returning nil will result in the default preview behavior
-// for that element.
+// for that element. If the client want to use the defaultActions, then the client is responsible for
+// returning those actions in their UIViewController's implementation of previewActionItems.
 - (BOOL)_webView:(WKWebView *)webView shouldPreviewElement:(_WKPreviewElementInfo *)elementInfo;
-- (UIViewController *)_webView:(WKWebView *)webView previewingViewControllerForElement:(_WKPreviewElementInfo *)elementInfo defaultActions:(NSArray<UIPreviewActionItem *> *)previewActions WK_AVAILABLE(NA, WK_IOS_TBA);
+- (UIViewController *)_webView:(WKWebView *)webView previewingViewControllerForElement:(_WKPreviewElementInfo *)elementInfo defaultActions:(NSArray <id <_WKPreviewActionItem>> *)previewActions WK_AVAILABLE(NA, WK_IOS_TBA);
 - (void)_webView:(WKWebView *)webView commitPreviewingViewController:(UIViewController *)previewingViewController WK_AVAILABLE(NA, WK_IOS_TBA);
 
 - (UIViewController *)_presentingViewControllerForWebView:(WKWebView *)webView WK_AVAILABLE(NA, WK_IOS_TBA);

Added: trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKPreviewAction.h (0 => 197973)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKPreviewAction.h	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKPreviewAction.h	2016-03-11 00:47:31 UTC (rev 197973)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2016 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 <WebKit/WKFoundation.h>
+
+#if WK_API_ENABLED && TARGET_OS_IPHONE
+
+#import <UIKit/UIViewController.h>
+
+WK_CLASS_AVAILABLE(NA, WK_IOS_TBA)
+@protocol _WKPreviewActionItem <NSObject, UIPreviewActionItem>
+
+@property(nonatomic, copy, readonly) NSString *identifier;
+
+@end
+WK_CLASS_AVAILABLE(NA, WK_IOS_TBA)
+
+@interface _WKPreviewAction : UIPreviewAction <NSCopying, _WKPreviewActionItem>
+
++ (instancetype)actionWithIdentifier:(NSString *)identifier title:(NSString *)title style:(UIPreviewActionStyle)style handler:(void (^)(UIPreviewAction *action, UIViewController *previewViewController))handler;
+
+@end
+
+#endif // WK_API_ENABLED && TARGET_OS_IPHONE

Added: trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKPreviewAction.mm (0 => 197973)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKPreviewAction.mm	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKPreviewAction.mm	2016-03-11 00:47:31 UTC (rev 197973)
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2016 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 "_WKPreviewAction.h"
+
+#if WK_API_ENABLED && TARGET_OS_IPHONE
+
+@implementation _WKPreviewAction
+@synthesize identifier=_identifier;
+
++ (instancetype)actionWithIdentifier:(NSString *)identifier title:(NSString *)title style:(UIPreviewActionStyle)style handler:(void (^)(UIPreviewAction *action, UIViewController *previewViewController))handler
+{
+    _WKPreviewAction *action = "" actionWithTitle:title style:style handler:handler];
+    action->_identifier = identifier;
+    return action;
+}
+
+@end
+
+#endif // WK_API_ENABLED && TARGET_OS_IPHONE

Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h (197972 => 197973)


--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h	2016-03-11 00:45:13 UTC (rev 197972)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h	2016-03-11 00:47:31 UTC (rev 197973)
@@ -123,6 +123,7 @@
     RetainPtr<UIGestureRecognizer> _previewSecondaryGestureRecognizer;
 #if HAVE(LINK_PREVIEW)
     RetainPtr<UIPreviewItemController> _previewItemController;
+    BOOL _uiDelegateProvidedPreviewingViewController;
 #endif
 
     std::unique_ptr<WebKit::SmartMagnificationController> _smartMagnificationController;

Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (197972 => 197973)


--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2016-03-11 00:45:13 UTC (rev 197972)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2016-03-11 00:47:31 UTC (rev 197973)
@@ -43,6 +43,7 @@
 #import "WKImagePreviewViewController.h"
 #import "WKInspectorNodeSearchGestureRecognizer.h"
 #import "WKNSURLExtras.h"
+#import "WKPreviewActionIdentifiersPrivate.h"
 #import "WKUIDelegatePrivate.h"
 #import "WKWebViewConfiguration.h"
 #import "WKWebViewInternal.h"
@@ -52,9 +53,11 @@
 #import "WebPageMessages.h"
 #import "WebProcessProxy.h"
 #import "_WKActivatedElementInfoInternal.h"
+#import "_WKElementAction.h"
 #import "_WKFocusedElementInfo.h"
 #import "_WKFormInputSession.h"
 #import "_WKInputDelegate.h"
+#import "_WKPreviewAction.h"
 #import "_WKPreviewElementInfoInternal.h"
 #import <CoreText/CTFont.h>
 #import <CoreText/CTFontDescriptor.h>
@@ -3748,6 +3751,7 @@
     _previewGestureRecognizer = _previewItemController.get().presentationGestureRecognizer;
     if ([_previewItemController respondsToSelector:@selector(presentationSecondaryGestureRecognizer)])
         _previewSecondaryGestureRecognizer = _previewItemController.get().presentationSecondaryGestureRecognizer;
+    _uiDelegateProvidedPreviewingViewController = NO;
 }
 
 - (void)_unregisterPreview
@@ -3756,6 +3760,7 @@
     _previewGestureRecognizer = nil;
     _previewSecondaryGestureRecognizer = nil;
     _previewItemController = nil;
+    _uiDelegateProvidedPreviewingViewController = NO;
 }
 
 - (BOOL)_interactionShouldBeginFromPreviewItemController:(UIPreviewItemController *)controller forPosition:(CGPoint)position
@@ -3867,6 +3872,26 @@
     return _positionInformation.bounds;
 }
 
+static NSString *previewIdentifierForElementAction(_WKElementAction *action)
+{
+    switch (action.type) {
+    case _WKElementActionTypeOpen:
+        return _WKPreviewIdentifierOpen;
+    case _WKElementActionTypeCopy:
+        return _WKPreviewIdentifierCopy;
+#if !defined(TARGET_OS_IOS) || TARGET_OS_IOS
+    case _WKElementActionTypeAddToReadingList:
+        return _WKPreviewIdentifierAddToReadingList;
+#endif
+    case _WKElementActionTypeShare:
+        return _WKPreviewIdentifierShare;
+    default:
+        return nil;
+    }
+    ASSERT_NOT_REACHED();
+    return nil;
+}
+
 - (UIViewController *)_presentedViewControllerForPreviewItemController:(UIPreviewItemController *)controller
 {
     id <WKUIDelegatePrivate> uiDelegate = static_cast<id <WKUIDelegatePrivate>>([_webView UIDelegate]);
@@ -3891,11 +3916,20 @@
 
         RetainPtr<_WKActivatedElementInfo> elementInfo = adoptNS([[_WKActivatedElementInfo alloc] _initWithType:_WKActivatedElementTypeLink URL:targetURL location:_positionInformation.point title:_positionInformation.title rect:_positionInformation.bounds image:_positionInformation.image.get()]);
 
-        RetainPtr<NSArray> actions = [_actionSheetAssistant defaultActionsForLinkSheet:elementInfo.get()];
+        auto actions = [_actionSheetAssistant defaultActionsForLinkSheet:elementInfo.get()];
         if ([uiDelegate respondsToSelector:@selector(_webView:previewingViewControllerForElement:defaultActions:)]) {
+            auto previewActions = adoptNS([[NSMutableArray alloc] init]);
+            for (_WKElementAction *elementAction in actions.get()) {
+                _WKPreviewAction *previewAction = [_WKPreviewAction actionWithIdentifier:previewIdentifierForElementAction(elementAction) title:[elementAction title] style:UIPreviewActionStyleDefault handler:^(UIPreviewAction *, UIViewController *) {
+                    [elementAction runActionWithElementInfo:elementInfo.get()];
+                }];
+                [previewActions addObject:previewAction];
+            }
             auto previewElementInfo = adoptNS([[_WKPreviewElementInfo alloc] _initWithLinkURL:targetURL]);
-            if (UIViewController *controller = [uiDelegate _webView:_webView previewingViewControllerForElement:previewElementInfo.get() defaultActions:actions.get()])
+            if (UIViewController *controller = [uiDelegate _webView:_webView previewingViewControllerForElement:previewElementInfo.get() defaultActions:previewActions.get()]) {
+                _uiDelegateProvidedPreviewingViewController = YES;
                 return controller;
+            }
         }
 
         if ([uiDelegate respondsToSelector:@selector(_webView:previewViewControllerForURL:defaultActions:elementInfo:)])
@@ -3940,7 +3974,7 @@
         return;
     }
 
-    if ([uiDelegate respondsToSelector:@selector(_webView:commitPreviewedViewController:)]) {
+    if (_uiDelegateProvidedPreviewingViewController && [uiDelegate respondsToSelector:@selector(_webView:commitPreviewedViewController:)]) {
         [uiDelegate _webView:_webView commitPreviewedViewController:viewController];
         return;
     }

Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (197972 => 197973)


--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2016-03-11 00:45:13 UTC (rev 197972)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2016-03-11 00:47:31 UTC (rev 197973)
@@ -1202,6 +1202,10 @@
 		9395E68E1BF410FD00F49BCE /* _WKElementInfoInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 9395E68D1BF410FD00F49BCE /* _WKElementInfoInternal.h */; };
 		939AE7661316E99C00AE06A6 /* WebCoreArgumentCoders.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 939AE7651316E99C00AE06A6 /* WebCoreArgumentCoders.cpp */; };
 		939F401C19FB0BBC002B2B42 /* WKActionMenuTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 939F401B19FB0BBC002B2B42 /* WKActionMenuTypes.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		93A253ED1C922E1E00F9F68D /* _WKPreviewAction.h in Headers */ = {isa = PBXBuildFile; fileRef = 93A253EC1C922E1E00F9F68D /* _WKPreviewAction.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		93A253EF1C922E8E00F9F68D /* _WKPreviewAction.mm in Sources */ = {isa = PBXBuildFile; fileRef = 93A253EE1C922E8E00F9F68D /* _WKPreviewAction.mm */; };
+		93A253F31C92411200F9F68D /* WKPreviewActionIdentifiersPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 93A253F21C92411200F9F68D /* WKPreviewActionIdentifiersPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		93A253F51C92413200F9F68D /* WKPreviewActionIdentifiersPrivate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 93A253F41C92413200F9F68D /* WKPreviewActionIdentifiersPrivate.mm */; };
 		93A88B301BC6E99700ABA5C2 /* WebHitTestResultData.mm in Sources */ = {isa = PBXBuildFile; fileRef = 93A88B2E1BC6E98F00ABA5C2 /* WebHitTestResultData.mm */; };
 		93A88B331BC6E9CD00ABA5C2 /* WebHitTestResultData.h in Headers */ = {isa = PBXBuildFile; fileRef = 93A88B311BC6E9C000ABA5C2 /* WebHitTestResultData.h */; };
 		93A88B361BC6EAD500ABA5C2 /* WebHitTestResultData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93A88B341BC6EABA00ABA5C2 /* WebHitTestResultData.cpp */; };
@@ -3218,6 +3222,10 @@
 		9395E68D1BF410FD00F49BCE /* _WKElementInfoInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKElementInfoInternal.h; sourceTree = "<group>"; };
 		939AE7651316E99C00AE06A6 /* WebCoreArgumentCoders.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebCoreArgumentCoders.cpp; sourceTree = "<group>"; };
 		939F401B19FB0BBC002B2B42 /* WKActionMenuTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKActionMenuTypes.h; sourceTree = "<group>"; };
+		93A253EC1C922E1E00F9F68D /* _WKPreviewAction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKPreviewAction.h; sourceTree = "<group>"; };
+		93A253EE1C922E8E00F9F68D /* _WKPreviewAction.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = _WKPreviewAction.mm; sourceTree = "<group>"; };
+		93A253F21C92411200F9F68D /* WKPreviewActionIdentifiersPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKPreviewActionIdentifiersPrivate.h; sourceTree = "<group>"; };
+		93A253F41C92413200F9F68D /* WKPreviewActionIdentifiersPrivate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKPreviewActionIdentifiersPrivate.mm; sourceTree = "<group>"; };
 		93A88B2E1BC6E98F00ABA5C2 /* WebHitTestResultData.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebHitTestResultData.mm; sourceTree = "<group>"; };
 		93A88B311BC6E9C000ABA5C2 /* WebHitTestResultData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebHitTestResultData.h; sourceTree = "<group>"; };
 		93A88B341BC6EABA00ABA5C2 /* WebHitTestResultData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebHitTestResultData.cpp; sourceTree = "<group>"; };
@@ -4970,6 +4978,8 @@
 				37A64E5418F38E3C00EB30F1 /* _WKInputDelegate.h */,
 				2D790A9C1AD7050D00AB90B3 /* _WKLayoutMode.h */,
 				9323611D1B015DA800FA9232 /* _WKOverlayScrollbarStyle.h */,
+				93A253EC1C922E1E00F9F68D /* _WKPreviewAction.h */,
+				93A253EE1C922E8E00F9F68D /* _WKPreviewAction.mm */,
 				9395E6891BF2C33200F49BCE /* _WKPreviewElementInfo.h */,
 				9395E68B1BF2C35200F49BCE /* _WKPreviewElementInfo.mm */,
 				9391074E1BF6BC65008C17AD /* _WKPreviewElementInfoInternal.h */,
@@ -5041,6 +5051,8 @@
 				1AFDD3181891CA1200153970 /* WKPreferences.mm */,
 				1A3C887F18A5ABAE00C4C962 /* WKPreferencesInternal.h */,
 				7C8EB11618DB6A19007917C2 /* WKPreferencesPrivate.h */,
+				93A253F21C92411200F9F68D /* WKPreviewActionIdentifiersPrivate.h */,
+				93A253F41C92413200F9F68D /* WKPreviewActionIdentifiersPrivate.mm */,
 				1A158418189044F50017616C /* WKProcessPool.h */,
 				1A158417189044F50017616C /* WKProcessPool.mm */,
 				1A3CC16818907EB0001E6ED8 /* WKProcessPoolInternal.h */,
@@ -7391,6 +7403,7 @@
 				5163199516289A6300E22F00 /* NetworkProcessMessages.h in Headers */,
 				E14A954A16E016A40068DE82 /* NetworkProcessPlatformStrategies.h in Headers */,
 				5179556E162877B300FA43B6 /* NetworkProcessProxy.h in Headers */,
+				93A253ED1C922E1E00F9F68D /* _WKPreviewAction.h in Headers */,
 				513A163D163088F6005D7D22 /* NetworkProcessProxyMessages.h in Headers */,
 				9955A6F51C7986E000EB6A93 /* InspectorBackendDispatchers.h in Headers */,
 				51FD18B61651FBAD00DBE1CE /* NetworkResourceLoader.h in Headers */,
@@ -8017,6 +8030,7 @@
 				75A8D2C8187CCFAB00C39C9E /* WKWebsiteDataStore.h in Headers */,
 				75A8D2D6187D1C0E00C39C9E /* WKWebsiteDataStoreInternal.h in Headers */,
 				1A57109F1ABA0027002FABBE /* WKWebsiteDataStoreRef.h in Headers */,
+				93A253F31C92411200F9F68D /* WKPreviewActionIdentifiersPrivate.h in Headers */,
 				1A3CC16718906ACF001E6ED8 /* WKWebView.h in Headers */,
 				1ADF591B1890528E0043C145 /* WKWebViewConfiguration.h in Headers */,
 				2D7AAFD618C956AF00A7ACD4 /* WKWebViewConfigurationInternal.h in Headers */,
@@ -8810,6 +8824,7 @@
 				E489D28B1A0A2DB80078C06A /* NetworkCacheCoders.cpp in Sources */,
 				E47D1E981B0649FB002676A8 /* NetworkCacheData.cpp in Sources */,
 				E42E06141AA75B7000B11699 /* NetworkCacheDataCocoa.mm in Sources */,
+				93A253F51C92413200F9F68D /* WKPreviewActionIdentifiersPrivate.mm in Sources */,
 				E489D28D1A0A2DB80078C06A /* NetworkCacheDecoder.cpp in Sources */,
 				E489D28F1A0A2DB80078C06A /* NetworkCacheEncoder.cpp in Sources */,
 				E413F59F1AC1AF9D00345360 /* NetworkCacheEntry.cpp in Sources */,
@@ -9285,6 +9300,7 @@
 				CDCA85C8132ABA4E00E961DF /* WKFullScreenWindowController.mm in Sources */,
 				BC54CC1312D674EE005C67B0 /* WKGeolocationManager.cpp in Sources */,
 				BC06F44F12DBDF3F002D78DE /* WKGeolocationPermissionRequest.cpp in Sources */,
+				93A253EF1C922E8E00F9F68D /* _WKPreviewAction.mm in Sources */,
 				BC0E619912D6CD120012A72A /* WKGeolocationPosition.cpp in Sources */,
 				07297FA21C186ADB003F0735 /* WKUserMediaPermissionCheck.cpp in Sources */,
 				0FCB4E5018BBE044000FCFC9 /* WKGeolocationProviderIOS.mm in Sources */,
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to