defaultActions in UIDelegate method
authorbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 Mar 2016 00:47:31 +0000 (00:47 +0000)
committerbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 Mar 2016 00:47:31 +0000 (00:47 +0000)
commit45aae2fd1dfdb335af5994dbd3b30fde5575e778
tree297373ea815fdb8e045cce612919c366482606aa
parent2f8696ccd70b81f813320ef96ccda86e7d57a4a1
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:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@197973 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/Cocoa/WKPreviewActionIdentifiersPrivate.h [new file with mode: 0644]
Source/WebKit2/UIProcess/API/Cocoa/WKPreviewActionIdentifiersPrivate.mm [new file with mode: 0644]
Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h
Source/WebKit2/UIProcess/API/Cocoa/_WKPreviewAction.h [new file with mode: 0644]
Source/WebKit2/UIProcess/API/Cocoa/_WKPreviewAction.mm [new file with mode: 0644]
Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h
Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj