<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[174885] trunk/Source/WebKit2</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/174885">174885</a></dd>
<dt>Author</dt> <dd>aestes@apple.com</dd>
<dt>Date</dt> <dd>2014-10-20 09:26:51 -0700 (Mon, 20 Oct 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>[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.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoa_WKElementActionmm">trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKElementAction.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoa_WKElementActionInternalh">trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKElementActionInternal.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosWKActionSheeth">trunk/Source/WebKit2/UIProcess/ios/WKActionSheet.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosWKActionSheetmm">trunk/Source/WebKit2/UIProcess/ios/WKActionSheet.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosWKActionSheetAssistanth">trunk/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosWKActionSheetAssistantmm">trunk/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosWKContentViewInteractionh">trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosWKContentViewInteractionmm">trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (174884 => 174885)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-10-20 15:46:21 UTC (rev 174884)
+++ trunk/Source/WebKit2/ChangeLog        2014-10-20 16:26:51 UTC (rev 174885)
</span><span class="lines">@@ -1,3 +1,55 @@
</span><ins>+2014-10-16 Andy Estes <aestes@apple.com>
+
+ [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.
+
</ins><span class="cx"> 2014-10-20 Carlos Garnacho <carlosg@gnome.org>
</span><span class="cx">
</span><span class="cx"> [GTK] Improve zooming gesture positioning
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoa_WKElementActionmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKElementAction.mm (174884 => 174885)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKElementAction.mm        2014-10-20 15:46:21 UTC (rev 174884)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKElementAction.mm        2014-10-20 16:26:51 UTC (rev 174885)
</span><span class="lines">@@ -31,6 +31,7 @@
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">
</span><span class="cx"> #import "GestureTypes.h"
</span><ins>+#import "WKActionSheetAssistant.h"
</ins><span class="cx"> #import "WKContentViewInteraction.h"
</span><span class="cx"> #import "_WKActivatedElementInfoInternal.h"
</span><span class="cx"> #import <SafariServices/SSReadingList.h>
</span><span class="lines">@@ -42,7 +43,7 @@
</span><span class="cx"> SOFT_LINK_FRAMEWORK(SafariServices);
</span><span class="cx"> SOFT_LINK_CLASS(SafariServices, SSReadingList);
</span><span class="cx">
</span><del>-typedef void (^WKElementActionHandlerInternal)(WKContentView *, _WKActivatedElementInfo *);
</del><ins>+typedef void (^WKElementActionHandlerInternal)(id <WKActionSheetAssistantDelegate>, _WKActivatedElementInfo *);
</ins><span class="cx">
</span><span class="cx"> @implementation _WKElementAction {
</span><span class="cx"> RetainPtr<NSString> _title;
</span><span class="lines">@@ -71,20 +72,10 @@
</span><span class="cx">
</span><span class="cx"> + (instancetype)elementActionWithTitle:(NSString *)title actionHandler:(WKElementActionHandler)handler
</span><span class="cx"> {
</span><del>- return [[[self alloc] _initWithTitle:title actionHandler:^(WKContentView *view, _WKActivatedElementInfo *actionInfo) { handler(actionInfo); }
</del><ins>+ return [[[self alloc] _initWithTitle:title actionHandler:^(id <WKActionSheetAssistantDelegate>, _WKActivatedElementInfo *actionInfo) { handler(actionInfo); }
</ins><span class="cx"> type:_WKElementActionTypeCustom] autorelease];
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static void copyElement(WKContentView *view)
-{
- [view _performAction:WebKit::SheetAction::Copy];
-}
-
-static void saveImage(WKContentView *view)
-{
- [view _performAction:WebKit::SheetAction::SaveImage];
-}
-
</del><span class="cx"> static void addToReadingList(NSURL *targetURL, NSString *title)
</span><span class="cx"> {
</span><span class="cx"> if (!title || [title length] == 0)
</span><span class="lines">@@ -100,25 +91,25 @@
</span><span class="cx"> switch (type) {
</span><span class="cx"> case _WKElementActionTypeCopy:
</span><span class="cx"> title = WEB_UI_STRING_KEY("Copy", "Copy ActionSheet Link", "Title for Copy Link or Image action button");
</span><del>- handler = ^(WKContentView *view, _WKActivatedElementInfo *actionInfo) {
- copyElement(view);
</del><ins>+ handler = ^(id <WKActionSheetAssistantDelegate> delegate, _WKActivatedElementInfo *actionInfo) {
+ [delegate performAction:WebKit::SheetAction::Copy];
</ins><span class="cx"> };
</span><span class="cx"> break;
</span><span class="cx"> case _WKElementActionTypeOpen:
</span><span class="cx"> title = WEB_UI_STRING_KEY("Open", "Open ActionSheet Link", "Title for Open Link action button");
</span><del>- handler = ^(WKContentView *view, _WKActivatedElementInfo *actionInfo) {
- [view _attemptClickAtLocation:actionInfo._interactionLocation];
</del><ins>+ handler = ^(id <WKActionSheetAssistantDelegate> delegate, _WKActivatedElementInfo *actionInfo) {
+ [delegate openElementAtLocation:actionInfo._interactionLocation];
</ins><span class="cx"> };
</span><span class="cx"> break;
</span><span class="cx"> case _WKElementActionTypeSaveImage:
</span><span class="cx"> title = WEB_UI_STRING_KEY("Save Image", "Save Image", "Title for Save Image action button");
</span><del>- handler = ^(WKContentView *view, _WKActivatedElementInfo *actionInfo) {
- saveImage(view);
</del><ins>+ handler = ^(id <WKActionSheetAssistantDelegate> delegate, _WKActivatedElementInfo *actionInfo) {
+ [delegate performAction:WebKit::SheetAction::SaveImage];
</ins><span class="cx"> };
</span><span class="cx"> break;
</span><span class="cx"> case _WKElementActionTypeAddToReadingList:
</span><span class="cx"> title = WEB_UI_STRING("Add to Reading List", "Title for Add to Reading List action button");
</span><del>- handler = ^(WKContentView *view, _WKActivatedElementInfo *actionInfo) {
</del><ins>+ handler = ^(id <WKActionSheetAssistantDelegate>, _WKActivatedElementInfo *actionInfo) {
</ins><span class="cx"> addToReadingList(actionInfo.URL, actionInfo.title);
</span><span class="cx"> };
</span><span class="cx"> break;
</span><span class="lines">@@ -140,9 +131,9 @@
</span><span class="cx"> return _title.get();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-- (void)_runActionWithElementInfo:(_WKActivatedElementInfo *)info view:(WKContentView *)view
</del><ins>+- (void)_runActionWithElementInfo:(_WKActivatedElementInfo *)info delegate:(id <WKActionSheetAssistantDelegate>)delegate
</ins><span class="cx"> {
</span><del>- _actionHandler(view, info);
</del><ins>+ _actionHandler(delegate, info);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> @end
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoa_WKElementActionInternalh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKElementActionInternal.h (174884 => 174885)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKElementActionInternal.h        2014-10-20 15:46:21 UTC (rev 174884)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKElementActionInternal.h        2014-10-20 16:26:51 UTC (rev 174885)
</span><span class="lines">@@ -30,10 +30,11 @@
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">
</span><span class="cx"> @class WKContentView;
</span><ins>+@protocol WKActionSheetAssistantDelegate;
</ins><span class="cx">
</span><span class="cx"> @interface _WKElementAction ()
</span><span class="cx">
</span><del>-- (void)_runActionWithElementInfo:(_WKActivatedElementInfo *)info view:(WKContentView *)view;
</del><ins>+- (void)_runActionWithElementInfo:(_WKActivatedElementInfo *)info delegate:(id <WKActionSheetAssistantDelegate>)delegate;
</ins><span class="cx">
</span><span class="cx"> @end
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWKActionSheeth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/WKActionSheet.h (174884 => 174885)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/WKActionSheet.h        2014-10-20 15:46:21 UTC (rev 174884)
+++ trunk/Source/WebKit2/UIProcess/ios/WKActionSheet.h        2014-10-20 16:26:51 UTC (rev 174885)
</span><span class="lines">@@ -35,7 +35,6 @@
</span><span class="cx">
</span><span class="cx"> @property (nonatomic, assign) id <WKActionSheetDelegate> sheetDelegate;
</span><span class="cx"> @property (nonatomic) UIPopoverArrowDirection arrowDirections;
</span><del>-- (id)initWithView:(WKContentView *)view;
</del><span class="cx"> - (void)doneWithSheet;
</span><span class="cx"> - (BOOL)presentSheet;
</span><span class="cx"> - (BOOL)presentSheetFromRect:(CGRect)presentationRect;
</span><span class="lines">@@ -47,6 +46,7 @@
</span><span class="cx"> - (UIView *)hostViewForSheet;
</span><span class="cx"> - (CGRect)initialPresentationRectInHostViewForSheet;
</span><span class="cx"> - (CGRect)presentationRectInHostViewForSheet;
</span><ins>+- (void)updatePositionInformation;
</ins><span class="cx"> @end
</span><span class="cx">
</span><span class="cx"> #endif // PLATFORM(IOS)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWKActionSheetmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/WKActionSheet.mm (174884 => 174885)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/WKActionSheet.mm        2014-10-20 15:46:21 UTC (rev 174884)
+++ trunk/Source/WebKit2/UIProcess/ios/WKActionSheet.mm        2014-10-20 16:26:51 UTC (rev 174885)
</span><span class="lines">@@ -28,13 +28,12 @@
</span><span class="cx">
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">
</span><del>-#import "WKContentViewInteraction.h"
</del><span class="cx"> #import <UIKit/UIAlertController_Private.h>
</span><span class="cx"> #import <UIKit/UIWindow_Private.h>
</span><ins>+#import <wtf/RetainPtr.h>
</ins><span class="cx">
</span><span class="cx"> @implementation WKActionSheet {
</span><span class="cx"> id <WKActionSheetDelegate> _sheetDelegate;
</span><del>- WKContentView *_view;
</del><span class="cx"> UIPopoverArrowDirection _arrowDirections;
</span><span class="cx"> BOOL _isRotating;
</span><span class="cx"> BOOL _readyToPresentAfterRotation;
</span><span class="lines">@@ -43,14 +42,13 @@
</span><span class="cx"> RetainPtr<id <UIPopoverPresentationControllerDelegate>> _popoverPresentationControllerDelegateWhileRotating;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-- (id)initWithView:(WKContentView *)view
</del><ins>+- (id)init
</ins><span class="cx"> {
</span><span class="cx"> self = [super init];
</span><span class="cx"> if (!self)
</span><span class="cx"> return nil;
</span><span class="cx">
</span><span class="cx"> _arrowDirections = UIPopoverArrowDirectionAny;
</span><del>- _view = view;
</del><span class="cx">
</span><span class="cx"> if (UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPhone) {
</span><span class="cx"> // Only iPads support popovers that rotate. UIActionSheets actually block rotation on iPhone/iPod Touch
</span><span class="lines">@@ -213,7 +211,7 @@
</span><span class="cx"> {
</span><span class="cx"> _isRotating = NO;
</span><span class="cx"> _readyToPresentAfterRotation = YES;
</span><del>- [_view _updatePositionInformation];
</del><ins>+ [_sheetDelegate updatePositionInformation];
</ins><span class="cx"> [self updateSheetPosition];
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWKActionSheetAssistanth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.h (174884 => 174885)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.h        2014-10-20 15:46:21 UTC (rev 174884)
+++ trunk/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.h        2014-10-20 16:26:51 UTC (rev 174885)
</span><span class="lines">@@ -25,23 +25,34 @@
</span><span class="cx">
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">
</span><ins>+#import "GestureTypes.h"
</ins><span class="cx"> #import "WKActionSheet.h"
</span><del>-
</del><span class="cx"> #import <DataDetectorsUI/DDDetectionController.h>
</span><span class="cx"> #import <UIKit/UIPopoverController.h>
</span><del>-#import <WebKit/WKDeclarationSpecifiers.h>
</del><span class="cx"> #import <wtf/RetainPtr.h>
</span><span class="cx">
</span><del>-@protocol WKActionSheetDelegate;
-@class WKContentView;
-
</del><span class="cx"> namespace WebKit {
</span><span class="cx"> class WebPageProxy;
</span><ins>+struct InteractionInformationAtPosition;
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+@protocol WKActionSheetDelegate;
+@class _WKActivatedElementInfo;
+
+@protocol WKActionSheetAssistantDelegate
+@required
+@property (nonatomic, readonly) const WebKit::InteractionInformationAtPosition& positionInformation;
+- (void)updatePositionInformation;
+- (void)performAction:(WebKit::SheetAction)action;
+- (void)openElementAtLocation:(CGPoint)location;
+- (RetainPtr<NSArray>)actionsForElement:(_WKActivatedElementInfo *)element defaultActions:(RetainPtr<NSArray>)defaultActions;
+- (void)startInteractionWithElement:(_WKActivatedElementInfo *)element;
+- (void)stopInteraction;
+@end
+
</ins><span class="cx"> @interface WKActionSheetAssistant : NSObject <WKActionSheetDelegate, DDDetectionControllerInteractionDelegate>
</span><del>-
-- (id)initWithView:(WKContentView *)view;
</del><ins>+@property (nonatomic, weak) id <WKActionSheetAssistantDelegate> delegate;
+- (id)initWithView:(UIView *)view;
</ins><span class="cx"> - (void)showLinkSheet;
</span><span class="cx"> - (void)showImageSheet;
</span><span class="cx"> - (void)showDataDetectorsSheet;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWKActionSheetAssistantmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.mm (174884 => 174885)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.mm        2014-10-20 15:46:21 UTC (rev 174884)
+++ trunk/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.mm        2014-10-20 16:26:51 UTC (rev 174885)
</span><span class="lines">@@ -31,6 +31,7 @@
</span><span class="cx"> #import "APIUIClient.h"
</span><span class="cx"> #import "WKActionSheet.h"
</span><span class="cx"> #import "WKContentViewInteraction.h"
</span><ins>+#import "WeakObjCPtr.h"
</ins><span class="cx"> #import "WebPageProxy.h"
</span><span class="cx"> #import "_WKActivatedElementInfoInternal.h"
</span><span class="cx"> #import "_WKElementActionInternal.h"
</span><span class="lines">@@ -65,13 +66,24 @@
</span><span class="cx"> using namespace WebKit;
</span><span class="cx">
</span><span class="cx"> @implementation WKActionSheetAssistant {
</span><ins>+ WeakObjCPtr<id <WKActionSheetAssistantDelegate>> _delegate;
</ins><span class="cx"> RetainPtr<WKActionSheet> _interactionSheet;
</span><span class="cx"> RetainPtr<_WKActivatedElementInfo> _elementInfo;
</span><del>- WKContentView *_view;
</del><ins>+ UIView *_view;
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-- (id)initWithView:(WKContentView *)view
</del><ins>+- (id <WKActionSheetAssistantDelegate>)delegate
</ins><span class="cx"> {
</span><ins>+ return _delegate.getAutoreleased();
+}
+
+- (void)setDelegate:(id <WKActionSheetAssistantDelegate>)delegate
+{
+ _delegate = delegate;
+}
+
+- (id)initWithView:(UIView *)view
+{
</ins><span class="cx"> _view = view;
</span><span class="cx"> return self;
</span><span class="cx"> }
</span><span class="lines">@@ -121,22 +133,26 @@
</span><span class="cx"> - (CGRect)initialPresentationRectInHostViewForSheet
</span><span class="cx"> {
</span><span class="cx"> UIView *view = [self superviewForSheet];
</span><del>- if (!view)
</del><ins>+ auto delegate = _delegate.get();
+ if (!view || !delegate)
</ins><span class="cx"> return CGRectZero;
</span><span class="cx">
</span><del>- return [self _presentationRectForSheetGivenPoint:_view.positionInformation.point inHostView:view];
</del><ins>+ return [self _presentationRectForSheetGivenPoint:[delegate positionInformation].point inHostView:view];
</ins><span class="cx">
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (CGRect)presentationRectInHostViewForSheet
</span><span class="cx"> {
</span><span class="cx"> UIView *view = [self superviewForSheet];
</span><del>- if (!view)
</del><ins>+ auto delegate = _delegate.get();
+ if (!view || !delegate)
</ins><span class="cx"> return CGRectZero;
</span><span class="cx">
</span><del>- CGRect boundingRect = _view.positionInformation.bounds;
- CGPoint fromPoint = _view.positionInformation.point;
</del><ins>+ const auto& positionInformation = [delegate positionInformation];
</ins><span class="cx">
</span><ins>+ CGRect boundingRect = positionInformation.bounds;
+ CGPoint fromPoint = positionInformation.point;
+
</ins><span class="cx"> // FIXME: We must adjust our presentation point to take into account a change in document scale.
</span><span class="cx">
</span><span class="cx"> // Test to see if we are still within the target node as it may have moved after rotation.
</span><span class="lines">@@ -146,6 +162,11 @@
</span><span class="cx"> return [self _presentationRectForSheetGivenPoint:fromPoint inHostView:view];
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+- (void)updatePositionInformation
+{
+ [_delegate.get() updatePositionInformation];
+}
+
</ins><span class="cx"> - (BOOL)presentSheet
</span><span class="cx"> {
</span><span class="cx"> // Calculate the presentation rect just before showing.
</span><span class="lines">@@ -167,13 +188,18 @@
</span><span class="cx"> - (void)_createSheetWithElementActions:(NSArray *)actions showLinkTitle:(BOOL)showLinkTitle
</span><span class="cx"> {
</span><span class="cx"> ASSERT(!_interactionSheet);
</span><ins>+ auto delegate = _delegate.get();
+ if (!delegate)
+ return;
</ins><span class="cx">
</span><del>- NSURL *targetURL = [NSURL URLWithString:_view.positionInformation.url];
</del><ins>+ const auto& positionInformation = [delegate positionInformation];
+
+ NSURL *targetURL = [NSURL URLWithString:positionInformation.url];
</ins><span class="cx"> NSString *urlScheme = [targetURL scheme];
</span><span class="cx"> BOOL isJavaScriptURL = [urlScheme length] && [urlScheme caseInsensitiveCompare:@"javascript"] == NSOrderedSame;
</span><span class="cx"> // FIXME: We should check if Javascript is enabled in the preferences.
</span><span class="cx">
</span><del>- _interactionSheet = adoptNS([[WKActionSheet alloc] initWithView:_view]);
</del><ins>+ _interactionSheet = adoptNS([[WKActionSheet alloc] init]);
</ins><span class="cx"> _interactionSheet.get().sheetDelegate = self;
</span><span class="cx"> _interactionSheet.get().preferredStyle = UIAlertControllerStyleActionSheet;
</span><span class="cx">
</span><span class="lines">@@ -187,7 +213,7 @@
</span><span class="cx"> titleIsURL = YES;
</span><span class="cx"> }
</span><span class="cx"> } else
</span><del>- titleString = _view.positionInformation.title;
</del><ins>+ titleString = positionInformation.title;
</ins><span class="cx">
</span><span class="cx"> if ([titleString length]) {
</span><span class="cx"> [_interactionSheet setTitle:titleString];
</span><span class="lines">@@ -199,7 +225,7 @@
</span><span class="cx">
</span><span class="cx"> for (_WKElementAction *action in actions) {
</span><span class="cx"> [_interactionSheet _addActionWithTitle:[action title] style:UIAlertActionStyleDefault handler:^{
</span><del>- [action _runActionWithElementInfo:_elementInfo.get() view:_view];
</del><ins>+ [action _runActionWithElementInfo:_elementInfo.get() delegate:delegate.get()];
</ins><span class="cx"> [self cleanupSheet];
</span><span class="cx"> } shouldDismissHandler:^{
</span><span class="cx"> return (BOOL)(!action.dismissalHandler || action.dismissalHandler());
</span><span class="lines">@@ -211,7 +237,7 @@
</span><span class="cx"> handler:^(UIAlertAction *action) {
</span><span class="cx"> [self cleanupSheet];
</span><span class="cx"> }]];
</span><del>- _view.page->startInteractionWithElementAtPosition(_view.positionInformation.point);
</del><ins>+ [delegate startInteractionWithElement:_elementInfo.get()];
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (void)showImageSheet
</span><span class="lines">@@ -219,8 +245,12 @@
</span><span class="cx"> ASSERT(!_interactionSheet);
</span><span class="cx"> ASSERT(!_elementInfo);
</span><span class="cx">
</span><del>- const auto& positionInformation = _view.positionInformation;
</del><ins>+ auto delegate = _delegate.get();
+ if (!delegate)
+ return;
</ins><span class="cx">
</span><ins>+ const auto& positionInformation = [delegate positionInformation];
+
</ins><span class="cx"> NSURL *targetURL = [NSURL URLWithString:positionInformation.url];
</span><span class="cx"> auto defaultActions = adoptNS([[NSMutableArray alloc] init]);
</span><span class="cx"> if (!positionInformation.url.isEmpty())
</span><span class="lines">@@ -235,7 +265,7 @@
</span><span class="cx"> auto elementInfo = adoptNS([[_WKActivatedElementInfo alloc] _initWithType:_WKActivatedElementTypeImage
</span><span class="cx"> URL:targetURL location:positionInformation.point title:positionInformation.title rect:positionInformation.bounds image:positionInformation.image.get()]);
</span><span class="cx">
</span><del>- RetainPtr<NSArray> actions = _view.page->uiClient().actionsForElement(elementInfo.get(), WTF::move(defaultActions));
</del><ins>+ RetainPtr<NSArray> actions = [delegate actionsForElement:elementInfo.get() defaultActions:WTF::move(defaultActions)];
</ins><span class="cx">
</span><span class="cx"> if (![actions count])
</span><span class="cx"> return;
</span><span class="lines">@@ -255,8 +285,12 @@
</span><span class="cx"> ASSERT(!_interactionSheet);
</span><span class="cx"> ASSERT(!_elementInfo);
</span><span class="cx">
</span><del>- const auto& positionInformation = _view.positionInformation;
</del><ins>+ auto delegate = _delegate.get();
+ if (!delegate)
+ return;
</ins><span class="cx">
</span><ins>+ const auto& positionInformation = [delegate positionInformation];
+
</ins><span class="cx"> NSURL *targetURL = [NSURL URLWithString:positionInformation.url];
</span><span class="cx"> if (!targetURL)
</span><span class="cx"> return;
</span><span class="lines">@@ -271,7 +305,7 @@
</span><span class="cx"> RetainPtr<_WKActivatedElementInfo> elementInfo = adoptNS([[_WKActivatedElementInfo alloc] _initWithType:_WKActivatedElementTypeLink
</span><span class="cx"> URL:targetURL location:positionInformation.point title:positionInformation.title rect:positionInformation.bounds image:positionInformation.image.get()]);
</span><span class="cx">
</span><del>- RetainPtr<NSArray> actions = _view.page->uiClient().actionsForElement(elementInfo.get(), WTF::move(defaultActions));
</del><ins>+ RetainPtr<NSArray> actions = [delegate actionsForElement:elementInfo.get() defaultActions:WTF::move(defaultActions)];
</ins><span class="cx">
</span><span class="cx"> if (![actions count])
</span><span class="cx"> return;
</span><span class="lines">@@ -289,7 +323,12 @@
</span><span class="cx"> - (void)showDataDetectorsSheet
</span><span class="cx"> {
</span><span class="cx"> ASSERT(!_interactionSheet);
</span><del>- NSURL *targetURL = [NSURL URLWithString:_view.positionInformation.url];
</del><ins>+
+ auto delegate = _delegate.get();
+ if (!delegate)
+ return;
+
+ NSURL *targetURL = [NSURL URLWithString:[delegate positionInformation].url];
</ins><span class="cx"> if (!targetURL)
</span><span class="cx"> return;
</span><span class="cx">
</span><span class="lines">@@ -327,7 +366,7 @@
</span><span class="cx">
</span><span class="cx"> - (void)cleanupSheet
</span><span class="cx"> {
</span><del>- _view.page->stopInteraction();
</del><ins>+ [_delegate.get() stopInteraction];
</ins><span class="cx">
</span><span class="cx"> [_interactionSheet doneWithSheet];
</span><span class="cx"> [_interactionSheet setSheetDelegate:nil];
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWKContentViewInteractionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h (174884 => 174885)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h        2014-10-20 15:46:21 UTC (rev 174884)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h        2014-10-20 16:26:51 UTC (rev 174885)
</span><span class="lines">@@ -30,10 +30,11 @@
</span><span class="cx"> #import "AssistedNodeInformation.h"
</span><span class="cx"> #import "GestureTypes.h"
</span><span class="cx"> #import "InteractionInformationAtPosition.h"
</span><del>-#import "WKSyntheticClickTapGestureRecognizer.h"
</del><ins>+#import "WKActionSheetAssistant.h"
</ins><span class="cx"> #import "WKAirPlayRoutePicker.h"
</span><span class="cx"> #import "WKFileUploadPanel.h"
</span><span class="cx"> #import "WKFormPeripheral.h"
</span><ins>+#import "WKSyntheticClickTapGestureRecognizer.h"
</ins><span class="cx"> #import <UIKit/UITextInput_Private.h>
</span><span class="cx"> #import <UIKit/UIView.h>
</span><span class="cx"> #import <UIKit/UIWKSelectionAssistant.h>
</span><span class="lines">@@ -145,7 +146,7 @@
</span><span class="cx">
</span><span class="cx"> @end
</span><span class="cx">
</span><del>-@interface WKContentView (WKInteraction) <UIGestureRecognizerDelegate, UIWebTouchEventsGestureRecognizerDelegate, UITextInputPrivate, UIWebFormAccessoryDelegate, UIWKInteractionViewProtocol, WKFileUploadPanelDelegate>
</del><ins>+@interface WKContentView (WKInteraction) <UIGestureRecognizerDelegate, UIWebTouchEventsGestureRecognizerDelegate, UITextInputPrivate, UIWebFormAccessoryDelegate, UIWKInteractionViewProtocol, WKFileUploadPanelDelegate, WKActionSheetAssistantDelegate>
</ins><span class="cx">
</span><span class="cx"> @property (nonatomic, readonly) CGPoint lastInteractionLocation;
</span><span class="cx"> @property (nonatomic, readonly) BOOL isEditable;
</span><span class="lines">@@ -170,8 +171,6 @@
</span><span class="cx"> - (BOOL)_interpretKeyEvent:(WebIOSEvent *)theEvent isCharEvent:(BOOL)isCharEvent;
</span><span class="cx"> - (void)_positionInformationDidChange:(const WebKit::InteractionInformationAtPosition&)info;
</span><span class="cx"> - (void)_attemptClickAtLocation:(CGPoint)location;
</span><del>-- (void)_updatePositionInformation;
-- (void)_performAction:(WebKit::SheetAction)action;
</del><span class="cx"> - (void)_willStartScrollingOrZooming;
</span><span class="cx"> - (void)_didScroll;
</span><span class="cx"> - (void)_didEndScrollingOrZooming;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWKContentViewInteractionmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (174884 => 174885)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm        2014-10-20 15:46:21 UTC (rev 174884)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm        2014-10-20 16:26:51 UTC (rev 174885)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx">
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">
</span><ins>+#import "APIUIClient.h"
</ins><span class="cx"> #import "EditingRange.h"
</span><span class="cx"> #import "NativeWebKeyboardEvent.h"
</span><span class="cx"> #import "NativeWebTouchEvent.h"
</span><span class="lines">@@ -270,6 +271,7 @@
</span><span class="cx"> [self useSelectionAssistantWithMode:toUIWebSelectionMode([[_webView configuration] selectionGranularity])];
</span><span class="cx">
</span><span class="cx"> _actionSheetAssistant = adoptNS([[WKActionSheetAssistant alloc] initWithView:self]);
</span><ins>+ [_actionSheetAssistant setDelegate:self];
</ins><span class="cx"> _smartMagnificationController = std::make_unique<SmartMagnificationController>(self);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -804,12 +806,6 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-- (void)_updatePositionInformation
-{
- _hasValidPositionInformation = NO;
- _page->requestPositionInformation(_positionInformation.point);
-}
-
</del><span class="cx"> - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
</span><span class="cx"> {
</span><span class="cx"> CGPoint point = [gestureRecognizer locationInView:self];
</span><span class="lines">@@ -1370,11 +1366,6 @@
</span><span class="cx"> [_textSelectionAssistant hideTextStyleOptions];
</span><span class="cx"> }
</span><span class="cx">
</span><del>-- (void)_performAction:(SheetAction)action
-{
- _page->performActionOnElement((uint32_t)action);
-}
-
</del><span class="cx"> - (void)copy:(id)sender
</span><span class="cx"> {
</span><span class="cx"> _page->executeEditCommand(ASCIILiteral("copy"));
</span><span class="lines">@@ -2695,6 +2686,39 @@
</span><span class="cx"> return YES;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+#pragma mark - Implementation of WKActionSheetAssistantDelegate.
+
+- (void)updatePositionInformation
+{
+ _hasValidPositionInformation = NO;
+ _page->requestPositionInformation(_positionInformation.point);
+}
+
+- (void)performAction:(WebKit::SheetAction)action
+{
+ _page->performActionOnElement((uint32_t)action);
+}
+
+- (void)openElementAtLocation:(CGPoint)location
+{
+ [self _attemptClickAtLocation:location];
+}
+
+- (RetainPtr<NSArray>)actionsForElement:(_WKActivatedElementInfo *)element defaultActions:(RetainPtr<NSArray>)defaultActions
+{
+ return _page->uiClient().actionsForElement(element, WTF::move(defaultActions));
+}
+
+- (void)startInteractionWithElement:(_WKActivatedElementInfo *)element
+{
+ _page->startInteractionWithElementAtPosition(_positionInformation.point);
+}
+
+- (void)stopInteraction
+{
+ _page->stopInteraction();
+}
+
</ins><span class="cx"> @end
</span><span class="cx">
</span><span class="cx"> // UITextRange, UITextPosition and UITextSelectionRect implementations for WK2
</span></span></pre>
</div>
</div>
</body>
</html>