<!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>[186377] 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/186377">186377</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2015-07-06 14:31:06 -0700 (Mon, 06 Jul 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Allow UIDelegate to customize link actions in preview.
https://bugs.webkit.org/show_bug.cgi?id=146567

Add a new UIDelegate method to pass the defaultActions and elementInfo to client to allow
the client customize the actions based on the element. Also add a new SPI runActionWithElementInfo:
to _WKElementAction and make it aware of the WKActionSheetAssistant that creates it, so that
the client can run the action without knowing WKActionSheetAssistant.

Patch by Yongjun Zhang &lt;yongjun_zhang@apple.com&gt; on 2015-07-06
Reviewed by Beth Dakin.

* UIProcess/API/Cocoa/WKUIDelegatePrivate.h: Add delegate method _webView:previewViewControllerForURL:defaultActions:elementInfo:.
* UIProcess/API/Cocoa/_WKElementAction.h: Add a SPI runActionWithElementInfo:.
* UIProcess/API/Cocoa/_WKElementAction.mm:
(-[_WKElementAction _initWithTitle:actionHandler:type:assistant:]): Modified initializer, also initialize _defaultActionSheetAssistant
    iVar if the caller provides that.
(+[_WKElementAction elementActionWithTitle:actionHandler:]): Use the new initializer.
(+[_WKElementAction _elementActionWithType:customTitle:assistant:]): A new helper method to create _WKElementAction with assistant.
(+[_WKElementAction _elementActionWithType:assistant:]):
(+[_WKElementAction elementActionWithType:customTitle:]):
(-[_WKElementAction runActionWithElementInfo:]):
* UIProcess/API/Cocoa/_WKElementActionInternal.h:
* UIProcess/ios/WKActionSheetAssistant.h: Add a method defaultActionsForLinkSheet.
* UIProcess/ios/WKActionSheetAssistant.mm:
(-[WKActionSheetAssistant defaultActionsForLinkSheet]): Get default actions for current link that is activated.
(-[WKActionSheetAssistant showLinkSheet]): Use defaultActionsForLinkSheet.
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView previewViewControllerForPosition:inSourceView:]): Pass defaultActions and elementInfo to UIDelegate when querying
    for preview view controller.
(-[WKContentView didDismissPreviewViewController:committing:]):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKUIDelegatePrivateh">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoa_WKElementActionh">trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKElementAction.h</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="#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="#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 (186376 => 186377)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2015-07-06 21:11:17 UTC (rev 186376)
+++ trunk/Source/WebKit2/ChangeLog        2015-07-06 21:31:06 UTC (rev 186377)
</span><span class="lines">@@ -1,3 +1,35 @@
</span><ins>+2015-07-06  Yongjun Zhang  &lt;yongjun_zhang@apple.com&gt;
+
+        Allow UIDelegate to customize link actions in preview.
+        https://bugs.webkit.org/show_bug.cgi?id=146567
+
+        Add a new UIDelegate method to pass the defaultActions and elementInfo to client to allow
+        the client customize the actions based on the element. Also add a new SPI runActionWithElementInfo:
+        to _WKElementAction and make it aware of the WKActionSheetAssistant that creates it, so that
+        the client can run the action without knowing WKActionSheetAssistant.
+
+        Reviewed by Beth Dakin.
+
+        * UIProcess/API/Cocoa/WKUIDelegatePrivate.h: Add delegate method _webView:previewViewControllerForURL:defaultActions:elementInfo:.
+        * UIProcess/API/Cocoa/_WKElementAction.h: Add a SPI runActionWithElementInfo:.
+        * UIProcess/API/Cocoa/_WKElementAction.mm:
+        (-[_WKElementAction _initWithTitle:actionHandler:type:assistant:]): Modified initializer, also initialize _defaultActionSheetAssistant
+            iVar if the caller provides that.
+        (+[_WKElementAction elementActionWithTitle:actionHandler:]): Use the new initializer.
+        (+[_WKElementAction _elementActionWithType:customTitle:assistant:]): A new helper method to create _WKElementAction with assistant.
+        (+[_WKElementAction _elementActionWithType:assistant:]):
+        (+[_WKElementAction elementActionWithType:customTitle:]):
+        (-[_WKElementAction runActionWithElementInfo:]):
+        * UIProcess/API/Cocoa/_WKElementActionInternal.h:
+        * UIProcess/ios/WKActionSheetAssistant.h: Add a method defaultActionsForLinkSheet.
+        * UIProcess/ios/WKActionSheetAssistant.mm:
+        (-[WKActionSheetAssistant defaultActionsForLinkSheet]): Get default actions for current link that is activated.
+        (-[WKActionSheetAssistant showLinkSheet]): Use defaultActionsForLinkSheet.
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView previewViewControllerForPosition:inSourceView:]): Pass defaultActions and elementInfo to UIDelegate when querying
+            for preview view controller.
+        (-[WKContentView didDismissPreviewViewController:committing:]):
+
</ins><span class="cx"> 2015-07-06  Brady Eidson  &lt;beidson@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         ShouldOpenExternalURLsPolicy should default to &quot;Allow&quot; for WK2 API loads.
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKUIDelegatePrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h (186376 => 186377)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h        2015-07-06 21:11:17 UTC (rev 186376)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h        2015-07-06 21:31:06 UTC (rev 186377)
</span><span class="lines">@@ -32,6 +32,7 @@
</span><span class="cx"> 
</span><span class="cx"> @class UIScrollView;
</span><span class="cx"> @class UIViewController;
</span><ins>+@class _WKActivatedElementInfo;
</ins><span class="cx"> @class _WKFrameHandle;
</span><span class="cx"> 
</span><span class="cx"> @protocol WKUIDelegatePrivate &lt;WKUIDelegate&gt;
</span><span class="lines">@@ -63,6 +64,7 @@
</span><span class="cx"> - (void)_webView:(WKWebView *)webView commitPreviewedImageWithURL:(NSURL *)imageURL WK_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);
</span><span class="cx"> - (void)_webView:(WKWebView *)webView didDismissPreviewViewController:(UIViewController *)previewedViewController;
</span><span class="cx"> - (UIEdgeInsets)_webView:(WKWebView *)webView finalObscuredInsetsForScrollView:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset;
</span><ins>+- (UIViewController *)_webView:(WKWebView *)webView previewViewControllerForURL:(NSURL *)url defaultActions:(NSArray *)actions elementInfo:(_WKActivatedElementInfo *)elementInfo WK_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> @end
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoa_WKElementActionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKElementAction.h (186376 => 186377)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKElementAction.h        2015-07-06 21:11:17 UTC (rev 186376)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKElementAction.h        2015-07-06 21:31:06 UTC (rev 186377)
</span><span class="lines">@@ -52,6 +52,8 @@
</span><span class="cx"> 
</span><span class="cx"> + (instancetype)elementActionWithTitle:(NSString *)title actionHandler:(WKElementActionHandler)handler;
</span><span class="cx"> 
</span><ins>+- (void)runActionWithElementInfo:(_WKActivatedElementInfo *)info WK_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);
+
</ins><span class="cx"> @property (nonatomic, readonly) _WKElementActionType type;
</span><span class="cx"> @property (nonatomic, readonly) NSString* title;
</span><span class="cx"> @property (nonatomic, copy) WKElementActionDismissalHandler dismissalHandler;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoa_WKElementActionmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKElementAction.mm (186376 => 186377)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKElementAction.mm        2015-07-06 21:11:17 UTC (rev 186376)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKElementAction.mm        2015-07-06 21:31:06 UTC (rev 186377)
</span><span class="lines">@@ -51,9 +51,10 @@
</span><span class="cx">     RetainPtr&lt;NSString&gt; _title;
</span><span class="cx">     WKElementActionHandlerInternal _actionHandler;
</span><span class="cx">     WKElementActionDismissalHandler _dismissalHandler;
</span><ins>+    __weak WKActionSheetAssistant *_defaultActionSheetAssistant;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (id)_initWithTitle:(NSString *)title actionHandler:(WKElementActionHandlerInternal)handler type:(_WKElementActionType)type
</del><ins>+- (id)_initWithTitle:(NSString *)title actionHandler:(WKElementActionHandlerInternal)handler type:(_WKElementActionType)type assistant:(WKActionSheetAssistant *)assistant
</ins><span class="cx"> {
</span><span class="cx">     if (!(self = [super init]))
</span><span class="cx">         return nil;
</span><span class="lines">@@ -61,6 +62,7 @@
</span><span class="cx">     _title = adoptNS([title copy]);
</span><span class="cx">     _type = type;
</span><span class="cx">     _actionHandler = [handler copy];
</span><ins>+    _defaultActionSheetAssistant = assistant;
</ins><span class="cx">     return self;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -75,7 +77,7 @@
</span><span class="cx"> + (instancetype)elementActionWithTitle:(NSString *)title actionHandler:(WKElementActionHandler)handler
</span><span class="cx"> {
</span><span class="cx">     return [[[self alloc] _initWithTitle:title actionHandler:^(WKActionSheetAssistant *, _WKActivatedElementInfo *actionInfo) { handler(actionInfo); }
</span><del>-       type:_WKElementActionTypeCustom] autorelease];
</del><ins>+        type:_WKElementActionTypeCustom assistant:nil] autorelease];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if HAVE(SAFARI_SERVICES_FRAMEWORK)
</span><span class="lines">@@ -88,7 +90,7 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-+ (instancetype)elementActionWithType:(_WKElementActionType)type customTitle:(NSString *)customTitle
</del><ins>++ (instancetype)_elementActionWithType:(_WKElementActionType)type customTitle:(NSString *)customTitle assistant:(WKActionSheetAssistant *)assistant
</ins><span class="cx"> {
</span><span class="cx">     NSString *title;
</span><span class="cx">     WKElementActionHandlerInternal handler;
</span><span class="lines">@@ -124,9 +126,19 @@
</span><span class="cx">         return nil;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    return [[[self alloc] _initWithTitle:(customTitle ? customTitle : title) actionHandler:handler type:type] autorelease];
</del><ins>+    return [[[self alloc] _initWithTitle:(customTitle ? customTitle : title) actionHandler:handler type:type assistant:assistant] autorelease];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>++ (instancetype)_elementActionWithType:(_WKElementActionType)type assistant:(WKActionSheetAssistant *)assistant
+{
+    return [self _elementActionWithType:type customTitle:nil assistant:assistant];
+}
+
++ (instancetype)elementActionWithType:(_WKElementActionType)type customTitle:(NSString *)customTitle
+{
+    return [self _elementActionWithType:type customTitle:customTitle assistant:nil];
+}
+
</ins><span class="cx"> + (instancetype)elementActionWithType:(_WKElementActionType)type
</span><span class="cx"> {
</span><span class="cx">     return [self elementActionWithType:type customTitle:nil];
</span><span class="lines">@@ -142,6 +154,11 @@
</span><span class="cx">     _actionHandler(assistant, info);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (void)runActionWithElementInfo:(_WKActivatedElementInfo *)info
+{
+    [self _runActionWithElementInfo:info forActionSheetAssistant:_defaultActionSheetAssistant];
+}
+
</ins><span class="cx"> @end
</span><span class="cx"> 
</span><span class="cx"> #endif // PLATFORM(IOS)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoa_WKElementActionInternalh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKElementActionInternal.h (186376 => 186377)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKElementActionInternal.h        2015-07-06 21:11:17 UTC (rev 186376)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKElementActionInternal.h        2015-07-06 21:31:06 UTC (rev 186377)
</span><span class="lines">@@ -34,6 +34,7 @@
</span><span class="cx"> 
</span><span class="cx"> @interface _WKElementAction ()
</span><span class="cx"> 
</span><ins>++ (instancetype)_elementActionWithType:(_WKElementActionType)type assistant:(WKActionSheetAssistant *)assistant;
</ins><span class="cx"> - (void)_runActionWithElementInfo:(_WKActivatedElementInfo *)info forActionSheetAssistant:(WKActionSheetAssistant *)assistant;
</span><span class="cx"> 
</span><span class="cx"> @end
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWKActionSheetAssistanth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.h (186376 => 186377)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.h        2015-07-06 21:11:17 UTC (rev 186376)
+++ trunk/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.h        2015-07-06 21:31:06 UTC (rev 186377)
</span><span class="lines">@@ -62,6 +62,7 @@
</span><span class="cx"> - (void)showDataDetectorsSheet;
</span><span class="cx"> - (void)cleanupSheet;
</span><span class="cx"> - (void)updateSheetPosition;
</span><ins>+- (RetainPtr&lt;NSArray&gt;)defaultActionsForLinkSheet;
</ins><span class="cx"> @end
</span><span class="cx"> 
</span><span class="cx"> #endif // PLATFORM(IOS)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWKActionSheetAssistantmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.mm (186376 => 186377)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.mm        2015-07-06 21:11:17 UTC (rev 186376)
+++ trunk/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.mm        2015-07-06 21:31:06 UTC (rev 186377)
</span><span class="lines">@@ -35,6 +35,7 @@
</span><span class="cx"> #import &quot;WKContentViewInteraction.h&quot;
</span><span class="cx"> #import &quot;WeakObjCPtr.h&quot;
</span><span class="cx"> #import &quot;WebPageProxy.h&quot;
</span><ins>+#import &quot;WKNSURLExtras.h&quot;
</ins><span class="cx"> #import &quot;_WKActivatedElementInfoInternal.h&quot;
</span><span class="cx"> #import &quot;_WKElementActionInternal.h&quot;
</span><span class="cx"> #import &lt;UIKit/UIView.h&gt;
</span><span class="lines">@@ -275,30 +276,46 @@
</span><span class="cx">         [self cleanupSheet];
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)showLinkSheet
</del><ins>+- (RetainPtr&lt;NSArray&gt;)defaultActionsForLinkSheet
</ins><span class="cx"> {
</span><del>-    ASSERT(!_interactionSheet);
-    ASSERT(!_elementInfo);
-
</del><span class="cx">     auto delegate = _delegate.get();
</span><span class="cx">     if (!delegate)
</span><del>-        return;
</del><ins>+        return nil;
</ins><span class="cx"> 
</span><span class="cx">     const auto&amp; positionInformation = [delegate positionInformationForActionSheetAssistant:self];
</span><span class="cx"> 
</span><span class="cx">     NSURL *targetURL = [NSURL URLWithString:positionInformation.url];
</span><span class="cx">     if (!targetURL)
</span><del>-        return;
</del><ins>+        return nil;
</ins><span class="cx"> 
</span><span class="cx">     auto defaultActions = adoptNS([[NSMutableArray alloc] init]);
</span><del>-    [defaultActions addObject:[_WKElementAction elementActionWithType:_WKElementActionTypeOpen]];
</del><ins>+    [defaultActions addObject:[_WKElementAction _elementActionWithType:_WKElementActionTypeOpen assistant:self]];
</ins><span class="cx"> #if HAVE(SAFARI_SERVICES_FRAMEWORK)
</span><span class="cx">     if ([getSSReadingListClass() supportsURL:targetURL])
</span><del>-        [defaultActions addObject:[_WKElementAction elementActionWithType:_WKElementActionTypeAddToReadingList]];
</del><ins>+        [defaultActions addObject:[_WKElementAction _elementActionWithType:_WKElementActionTypeAddToReadingList assistant:self]];
</ins><span class="cx"> #endif
</span><span class="cx">     if (![[targetURL scheme] length] || [[targetURL scheme] caseInsensitiveCompare:@&quot;javascript&quot;] != NSOrderedSame)
</span><del>-        [defaultActions addObject:[_WKElementAction elementActionWithType:_WKElementActionTypeCopy]];
</del><ins>+        [defaultActions addObject:[_WKElementAction _elementActionWithType:_WKElementActionTypeCopy assistant:self]];
</ins><span class="cx"> 
</span><ins>+    return defaultActions;
+}
+
+- (void)showLinkSheet
+{
+    ASSERT(!_interactionSheet);
+    ASSERT(!_elementInfo);
+
+    auto delegate = _delegate.get();
+    if (!delegate)
+        return;
+
+    const auto&amp; positionInformation = [delegate positionInformationForActionSheetAssistant:self];
+
+    NSURL *targetURL = [NSURL _web_URLWithWTFString:positionInformation.url];
+    if (!targetURL)
+        return;
+
+    auto defaultActions = [self defaultActionsForLinkSheet];
</ins><span class="cx">     RetainPtr&lt;_WKActivatedElementInfo&gt; 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></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWKContentViewInteractionmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (186376 => 186377)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm        2015-07-06 21:11:17 UTC (rev 186376)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm        2015-07-06 21:31:06 UTC (rev 186377)
</span><span class="lines">@@ -52,6 +52,7 @@
</span><span class="cx"> #import &quot;WebIOSEventFactory.h&quot;
</span><span class="cx"> #import &quot;WebPageMessages.h&quot;
</span><span class="cx"> #import &quot;WebProcessProxy.h&quot;
</span><ins>+#import &quot;_WKActivatedElementInfoInternal.h&quot;
</ins><span class="cx"> #import &quot;_WKFormDelegate.h&quot;
</span><span class="cx"> #import &quot;_WKFormInputSession.h&quot;
</span><span class="cx"> #import &lt;CoreText/CTFont.h&gt;
</span><span class="lines">@@ -3218,6 +3219,13 @@
</span><span class="cx">     if (canShowLinkPreview) {
</span><span class="cx">         _previewType = PreviewElementType::Link;
</span><span class="cx">         NSURL *targetURL = [NSURL _web_URLWithWTFString:_positionInformation.url];
</span><ins>+        if ([uiDelegate respondsToSelector:@selector(_webView:previewViewControllerForURL:defaultActions:elementInfo:)]) {
+            _highlightLongPressCanClick = NO;
+            RetainPtr&lt;_WKActivatedElementInfo&gt; elementInfo = adoptNS([[_WKActivatedElementInfo alloc] _initWithType:_WKActivatedElementTypeLink URL:targetURL location:_positionInformation.point title:_positionInformation.title rect:_positionInformation.bounds image:_positionInformation.image.get()]);
+            _page-&gt;startInteractionWithElementAtPosition(_positionInformation.point);
+            return [uiDelegate _webView:_webView previewViewControllerForURL:targetURL defaultActions:[_actionSheetAssistant defaultActionsForLinkSheet].get() elementInfo:elementInfo.get()];
+        }
+
</ins><span class="cx">         if ([uiDelegate respondsToSelector:@selector(_webView:previewViewControllerForURL:)]) {
</span><span class="cx">             _highlightLongPressCanClick = NO;
</span><span class="cx">             return [uiDelegate _webView:_webView previewViewControllerForURL:targetURL];
</span><span class="lines">@@ -3290,6 +3298,7 @@
</span><span class="cx"> - (void)didDismissPreviewViewController:(UIViewController *)viewController committing:(BOOL)committing
</span><span class="cx"> {
</span><span class="cx">     [self _addDefaultGestureRecognizers];
</span><ins>+    _page-&gt;stopInteraction();
</ins><span class="cx"> 
</span><span class="cx">     id&lt;WKUIDelegatePrivate&gt; uiDelegate = static_cast&lt;id &lt;WKUIDelegatePrivate&gt;&gt;([_webView UIDelegate]);
</span><span class="cx">     if ([uiDelegate respondsToSelector:@selector(_webView:didDismissPreviewViewController:)])
</span></span></pre>
</div>
</div>

</body>
</html>