[iOS] Capture WKActionSheetAssistant's interaction with WKContentView in a @protocol
authoraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 20 Oct 2014 16:26:51 +0000 (16:26 +0000)
committeraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 20 Oct 2014 16:26:51 +0000 (16:26 +0000)
commit4c654a1a5f20ceedd1928f6cf77e14fe7d063f89
tree42c98a21a0fbc6337ad41aeb4669081ff66e7781
parent37fe24f39c22e8f086c2da05ad99c48f5156c315
[iOS] Capture WKActionSheetAssistant's interaction with WKContentView in a @protocol
https://bugs.webkit.org/show_bug.cgi?id=137792

Reviewed by Tim Horton.

WKPDFView would like to use WKActionSheetAssistant to show an action sheet when long-pressing a link, but it
can't so long as WKActionSheetAssistant is tightly coupled to WKContentView. Resolve this by factoring
WKActionSheetAssistant's interaction with WKContentView into a new protocol called
WKActionSheetAssistantDelegate and having WKContentView conform to this protocol.

* UIProcess/API/Cocoa/_WKElementAction.mm:
(+[_WKElementAction elementActionWithTitle:actionHandler:]): Changed instances of WKContentView * to id <WKActionSheetAssistantDelegate>.
(+[_WKElementAction elementActionWithType:customTitle:]): Ditto.
(-[_WKElementAction _runActionWithElementInfo:delegate:]): Ditto.
(copyElement): Deleted.
(saveImage): Deleted.
(-[_WKElementAction _runActionWithElementInfo:view:]): Deleted.
* UIProcess/API/Cocoa/_WKElementActionInternal.h:
* UIProcess/ios/WKActionSheet.h:
* UIProcess/ios/WKActionSheet.mm:
(-[WKActionSheet init]): Renamed from initWithView: since WKActionSheet no longer needs to know about a view.
(-[WKActionSheet _didRotateAndLayout]): Called -[WKActionSheetDelegate updatePositionInformation].
(-[WKActionSheet initWithView:]): Deleted.
* UIProcess/ios/WKActionSheetAssistant.h:
* UIProcess/ios/WKActionSheetAssistant.mm:
(-[WKActionSheetAssistant delegate]): Added a getter for the delegate property.
(-[WKActionSheetAssistant setDelegate:]): Added a setter for the delegate property.
(-[WKActionSheetAssistant initWithView:]): Changed argument type from WKContentView * to UIView *.
(-[WKActionSheetAssistant initialPresentationRectInHostViewForSheet]): Returned CGRectZero if there is no delegate.
Otherwise, retrieved positionInformation from the delegate.
(-[WKActionSheetAssistant presentationRectInHostViewForSheet]): Ditto.
(-[WKActionSheetAssistant updatePositionInformation]): Called -[WKActionSheetAssistantDelegate updatePositionInformation].
(-[WKActionSheetAssistant _createSheetWithElementActions:showLinkTitle:]): Returned early if there is no delegate.
Otherwise, retrieved positionInformation from the delegate.
(-[WKActionSheetAssistant showImageSheet]): Ditto.
(-[WKActionSheetAssistant showLinkSheet]): Ditto.
(-[WKActionSheetAssistant showDataDetectorsSheet]): Ditto.
(-[WKActionSheetAssistant cleanupSheet]):
* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView setupInteraction]): Installed self as WKActionSheetAssistant's delegate.
(-[WKContentView updatePositionInformation]): Renamed from _updatePositionInformation.
(-[WKContentView performAction:]): Renamed from _performAction:.
(-[WKContentView openElementAtLocation:]): Called _attemptClickAtLocation:.
(-[WKContentView actionsForElement:defaultActions:]): Called API::UIClient::actionsForElement().
(-[WKContentView startInteractionWithElement:]): Called WebPageProxy::startInteractionWithElementAtPosition().
(-[WKContentView stopInteraction]): Called WebPageProxy::stopInteraction().
(-[WKContentView _updatePositionInformation]): Deleted.
(-[WKContentView _performAction:]): Deleted.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@174885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/Cocoa/_WKElementAction.mm
Source/WebKit2/UIProcess/API/Cocoa/_WKElementActionInternal.h
Source/WebKit2/UIProcess/ios/WKActionSheet.h
Source/WebKit2/UIProcess/ios/WKActionSheet.mm
Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.h
Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.mm
Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h
Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm