<!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>[197973] 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/197973">197973</a></dd>
<dt>Author</dt> <dd>bdakin@apple.com</dd>
<dt>Date</dt> <dd>2016-03-10 16:47:31 -0800 (Thu, 10 Mar 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>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 &lt;id &lt;WKPreviewActionItem&gt;&gt; *
* 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:</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="#trunkSourceWebKit2UIProcessiosWKContentViewInteractionh">trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosWKContentViewInteractionmm">trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm</a></li>
<li><a href="#trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj">trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKPreviewActionIdentifiersPrivateh">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKPreviewActionIdentifiersPrivate.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKPreviewActionIdentifiersPrivatemm">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKPreviewActionIdentifiersPrivate.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoa_WKPreviewActionh">trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKPreviewAction.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoa_WKPreviewActionmm">trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKPreviewAction.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (197972 => 197973)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1,3 +1,50 @@
</span><ins>+2016-03-10  Beth Dakin  &lt;bdakin@apple.com&gt;
+
+        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 &lt;id &lt;WKPreviewActionItem&gt;&gt; *
+        * 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:
+
</ins><span class="cx"> 2016-03-10  Jer Noble  &lt;jer.noble@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Add WebCore, WebKit, &amp; WebKit2 preference/setting to enable Main Content heuristic.
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKPreviewActionIdentifiersPrivateh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKPreviewActionIdentifiersPrivate.h (0 => 197973)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,39 @@
</span><ins>+/*
+ * 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 &lt;WebKit/WKFoundation.h&gt;
+
+#if WK_API_ENABLED
+
+#import &lt;Foundation/Foundation.h&gt;
+#import &lt;WebKit/WKDeclarationSpecifiers.h&gt;
+
+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
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKPreviewActionIdentifiersPrivatemm"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKPreviewActionIdentifiersPrivate.mm (0 => 197973)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,36 @@
</span><ins>+/*
+ * 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 &quot;config.h&quot;
+#include &quot;WKPreviewActionIdentifiersPrivate.h&quot;
+
+#if WK_API_ENABLED
+
+NSString * const _WKPreviewIdentifierOpen = @&quot;WKPreviewIdentifierOpen&quot;;
+NSString * const _WKPreviewIdentifierAddToReadingList = @&quot;WKPreviewIdentifierAddToReadingList&quot;;
+NSString * const _WKPreviewIdentifierCopy = @&quot;WKPreviewIdentifierCopy&quot;;
+NSString * const _WKPreviewIdentifierShare = @&quot;WKPreviewIdentifierShare&quot;;
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKUIDelegatePrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h (197972 => 197973)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -29,8 +29,8 @@
</span><span class="cx"> 
</span><span class="cx"> #import &lt;WebKit/WKSecurityOrigin.h&gt;
</span><span class="cx"> #import &lt;WebKit/_WKActivatedElementInfo.h&gt;
</span><ins>+#import &lt;WebKit/_WKPreviewAction.h&gt;
</ins><span class="cx"> 
</span><del>-@class UIPreviewActionItem;
</del><span class="cx"> @class UIScrollView;
</span><span class="cx"> @class UIViewController;
</span><span class="cx"> @class _WKContextMenuElementInfo;
</span><span class="lines">@@ -83,9 +83,10 @@
</span><span class="cx"> // shouldPreviewElement. Returning NO in shouldPreviewElement will prevent the other methods from being invoked.
</span><span class="cx"> // The client can provide a custom preview by returning their own UIViewController from
</span><span class="cx"> // previewingViewControllerForElement:defaultActions:. Returning nil will result in the default preview behavior
</span><del>-// for that element.
</del><ins>+// 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.
</ins><span class="cx"> - (BOOL)_webView:(WKWebView *)webView shouldPreviewElement:(_WKPreviewElementInfo *)elementInfo;
</span><del>-- (UIViewController *)_webView:(WKWebView *)webView previewingViewControllerForElement:(_WKPreviewElementInfo *)elementInfo defaultActions:(NSArray&lt;UIPreviewActionItem *&gt; *)previewActions WK_AVAILABLE(NA, WK_IOS_TBA);
</del><ins>+- (UIViewController *)_webView:(WKWebView *)webView previewingViewControllerForElement:(_WKPreviewElementInfo *)elementInfo defaultActions:(NSArray &lt;id &lt;_WKPreviewActionItem&gt;&gt; *)previewActions WK_AVAILABLE(NA, WK_IOS_TBA);
</ins><span class="cx"> - (void)_webView:(WKWebView *)webView commitPreviewingViewController:(UIViewController *)previewingViewController WK_AVAILABLE(NA, WK_IOS_TBA);
</span><span class="cx"> 
</span><span class="cx"> - (UIViewController *)_presentingViewControllerForWebView:(WKWebView *)webView WK_AVAILABLE(NA, WK_IOS_TBA);
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoa_WKPreviewActionh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKPreviewAction.h (0 => 197973)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,46 @@
</span><ins>+/*
+ * 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 &lt;WebKit/WKFoundation.h&gt;
+
+#if WK_API_ENABLED &amp;&amp; TARGET_OS_IPHONE
+
+#import &lt;UIKit/UIViewController.h&gt;
+
+WK_CLASS_AVAILABLE(NA, WK_IOS_TBA)
+@protocol _WKPreviewActionItem &lt;NSObject, UIPreviewActionItem&gt;
+
+@property(nonatomic, copy, readonly) NSString *identifier;
+
+@end
+WK_CLASS_AVAILABLE(NA, WK_IOS_TBA)
+
+@interface _WKPreviewAction : UIPreviewAction &lt;NSCopying, _WKPreviewActionItem&gt;
+
++ (instancetype)actionWithIdentifier:(NSString *)identifier title:(NSString *)title style:(UIPreviewActionStyle)style handler:(void (^)(UIPreviewAction *action, UIViewController *previewViewController))handler;
+
+@end
+
+#endif // WK_API_ENABLED &amp;&amp; TARGET_OS_IPHONE
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoa_WKPreviewActionmm"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKPreviewAction.mm (0 => 197973)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,43 @@
</span><ins>+/*
+ * 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 &quot;config.h&quot;
+#import &quot;_WKPreviewAction.h&quot;
+
+#if WK_API_ENABLED &amp;&amp; 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 = [self actionWithTitle:title style:style handler:handler];
+    action-&gt;_identifier = identifier;
+    return action;
+}
+
+@end
+
+#endif // WK_API_ENABLED &amp;&amp; TARGET_OS_IPHONE
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWKContentViewInteractionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h (197972 => 197973)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -123,6 +123,7 @@
</span><span class="cx">     RetainPtr&lt;UIGestureRecognizer&gt; _previewSecondaryGestureRecognizer;
</span><span class="cx"> #if HAVE(LINK_PREVIEW)
</span><span class="cx">     RetainPtr&lt;UIPreviewItemController&gt; _previewItemController;
</span><ins>+    BOOL _uiDelegateProvidedPreviewingViewController;
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     std::unique_ptr&lt;WebKit::SmartMagnificationController&gt; _smartMagnificationController;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWKContentViewInteractionmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (197972 => 197973)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -43,6 +43,7 @@
</span><span class="cx"> #import &quot;WKImagePreviewViewController.h&quot;
</span><span class="cx"> #import &quot;WKInspectorNodeSearchGestureRecognizer.h&quot;
</span><span class="cx"> #import &quot;WKNSURLExtras.h&quot;
</span><ins>+#import &quot;WKPreviewActionIdentifiersPrivate.h&quot;
</ins><span class="cx"> #import &quot;WKUIDelegatePrivate.h&quot;
</span><span class="cx"> #import &quot;WKWebViewConfiguration.h&quot;
</span><span class="cx"> #import &quot;WKWebViewInternal.h&quot;
</span><span class="lines">@@ -52,9 +53,11 @@
</span><span class="cx"> #import &quot;WebPageMessages.h&quot;
</span><span class="cx"> #import &quot;WebProcessProxy.h&quot;
</span><span class="cx"> #import &quot;_WKActivatedElementInfoInternal.h&quot;
</span><ins>+#import &quot;_WKElementAction.h&quot;
</ins><span class="cx"> #import &quot;_WKFocusedElementInfo.h&quot;
</span><span class="cx"> #import &quot;_WKFormInputSession.h&quot;
</span><span class="cx"> #import &quot;_WKInputDelegate.h&quot;
</span><ins>+#import &quot;_WKPreviewAction.h&quot;
</ins><span class="cx"> #import &quot;_WKPreviewElementInfoInternal.h&quot;
</span><span class="cx"> #import &lt;CoreText/CTFont.h&gt;
</span><span class="cx"> #import &lt;CoreText/CTFontDescriptor.h&gt;
</span><span class="lines">@@ -3748,6 +3751,7 @@
</span><span class="cx">     _previewGestureRecognizer = _previewItemController.get().presentationGestureRecognizer;
</span><span class="cx">     if ([_previewItemController respondsToSelector:@selector(presentationSecondaryGestureRecognizer)])
</span><span class="cx">         _previewSecondaryGestureRecognizer = _previewItemController.get().presentationSecondaryGestureRecognizer;
</span><ins>+    _uiDelegateProvidedPreviewingViewController = NO;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)_unregisterPreview
</span><span class="lines">@@ -3756,6 +3760,7 @@
</span><span class="cx">     _previewGestureRecognizer = nil;
</span><span class="cx">     _previewSecondaryGestureRecognizer = nil;
</span><span class="cx">     _previewItemController = nil;
</span><ins>+    _uiDelegateProvidedPreviewingViewController = NO;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (BOOL)_interactionShouldBeginFromPreviewItemController:(UIPreviewItemController *)controller forPosition:(CGPoint)position
</span><span class="lines">@@ -3867,6 +3872,26 @@
</span><span class="cx">     return _positionInformation.bounds;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+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;
+}
+
</ins><span class="cx"> - (UIViewController *)_presentedViewControllerForPreviewItemController:(UIPreviewItemController *)controller
</span><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="lines">@@ -3891,11 +3916,20 @@
</span><span class="cx"> 
</span><span class="cx">         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()]);
</span><span class="cx"> 
</span><del>-        RetainPtr&lt;NSArray&gt; actions = [_actionSheetAssistant defaultActionsForLinkSheet:elementInfo.get()];
</del><ins>+        auto actions = [_actionSheetAssistant defaultActionsForLinkSheet:elementInfo.get()];
</ins><span class="cx">         if ([uiDelegate respondsToSelector:@selector(_webView:previewingViewControllerForElement:defaultActions:)]) {
</span><ins>+            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];
+            }
</ins><span class="cx">             auto previewElementInfo = adoptNS([[_WKPreviewElementInfo alloc] _initWithLinkURL:targetURL]);
</span><del>-            if (UIViewController *controller = [uiDelegate _webView:_webView previewingViewControllerForElement:previewElementInfo.get() defaultActions:actions.get()])
</del><ins>+            if (UIViewController *controller = [uiDelegate _webView:_webView previewingViewControllerForElement:previewElementInfo.get() defaultActions:previewActions.get()]) {
+                _uiDelegateProvidedPreviewingViewController = YES;
</ins><span class="cx">                 return controller;
</span><ins>+            }
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         if ([uiDelegate respondsToSelector:@selector(_webView:previewViewControllerForURL:defaultActions:elementInfo:)])
</span><span class="lines">@@ -3940,7 +3974,7 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if ([uiDelegate respondsToSelector:@selector(_webView:commitPreviewedViewController:)]) {
</del><ins>+    if (_uiDelegateProvidedPreviewingViewController &amp;&amp; [uiDelegate respondsToSelector:@selector(_webView:commitPreviewedViewController:)]) {
</ins><span class="cx">         [uiDelegate _webView:_webView commitPreviewedViewController:viewController];
</span><span class="cx">         return;
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (197972 => 197973)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1202,6 +1202,10 @@
</span><span class="cx">                 9395E68E1BF410FD00F49BCE /* _WKElementInfoInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 9395E68D1BF410FD00F49BCE /* _WKElementInfoInternal.h */; };
</span><span class="cx">                 939AE7661316E99C00AE06A6 /* WebCoreArgumentCoders.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 939AE7651316E99C00AE06A6 /* WebCoreArgumentCoders.cpp */; };
</span><span class="cx">                 939F401C19FB0BBC002B2B42 /* WKActionMenuTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 939F401B19FB0BBC002B2B42 /* WKActionMenuTypes.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><ins>+                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 */; };
</ins><span class="cx">                 93A88B301BC6E99700ABA5C2 /* WebHitTestResultData.mm in Sources */ = {isa = PBXBuildFile; fileRef = 93A88B2E1BC6E98F00ABA5C2 /* WebHitTestResultData.mm */; };
</span><span class="cx">                 93A88B331BC6E9CD00ABA5C2 /* WebHitTestResultData.h in Headers */ = {isa = PBXBuildFile; fileRef = 93A88B311BC6E9C000ABA5C2 /* WebHitTestResultData.h */; };
</span><span class="cx">                 93A88B361BC6EAD500ABA5C2 /* WebHitTestResultData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93A88B341BC6EABA00ABA5C2 /* WebHitTestResultData.cpp */; };
</span><span class="lines">@@ -3218,6 +3222,10 @@
</span><span class="cx">                 9395E68D1BF410FD00F49BCE /* _WKElementInfoInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKElementInfoInternal.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 939AE7651316E99C00AE06A6 /* WebCoreArgumentCoders.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebCoreArgumentCoders.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 939F401B19FB0BBC002B2B42 /* WKActionMenuTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKActionMenuTypes.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                93A253EC1C922E1E00F9F68D /* _WKPreviewAction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKPreviewAction.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                93A253EE1C922E8E00F9F68D /* _WKPreviewAction.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = _WKPreviewAction.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
+                93A253F21C92411200F9F68D /* WKPreviewActionIdentifiersPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKPreviewActionIdentifiersPrivate.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                93A253F41C92413200F9F68D /* WKPreviewActionIdentifiersPrivate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKPreviewActionIdentifiersPrivate.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 93A88B2E1BC6E98F00ABA5C2 /* WebHitTestResultData.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebHitTestResultData.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 93A88B311BC6E9C000ABA5C2 /* WebHitTestResultData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebHitTestResultData.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 93A88B341BC6EABA00ABA5C2 /* WebHitTestResultData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebHitTestResultData.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -4970,6 +4978,8 @@
</span><span class="cx">                                 37A64E5418F38E3C00EB30F1 /* _WKInputDelegate.h */,
</span><span class="cx">                                 2D790A9C1AD7050D00AB90B3 /* _WKLayoutMode.h */,
</span><span class="cx">                                 9323611D1B015DA800FA9232 /* _WKOverlayScrollbarStyle.h */,
</span><ins>+                                93A253EC1C922E1E00F9F68D /* _WKPreviewAction.h */,
+                                93A253EE1C922E8E00F9F68D /* _WKPreviewAction.mm */,
</ins><span class="cx">                                 9395E6891BF2C33200F49BCE /* _WKPreviewElementInfo.h */,
</span><span class="cx">                                 9395E68B1BF2C35200F49BCE /* _WKPreviewElementInfo.mm */,
</span><span class="cx">                                 9391074E1BF6BC65008C17AD /* _WKPreviewElementInfoInternal.h */,
</span><span class="lines">@@ -5041,6 +5051,8 @@
</span><span class="cx">                                 1AFDD3181891CA1200153970 /* WKPreferences.mm */,
</span><span class="cx">                                 1A3C887F18A5ABAE00C4C962 /* WKPreferencesInternal.h */,
</span><span class="cx">                                 7C8EB11618DB6A19007917C2 /* WKPreferencesPrivate.h */,
</span><ins>+                                93A253F21C92411200F9F68D /* WKPreviewActionIdentifiersPrivate.h */,
+                                93A253F41C92413200F9F68D /* WKPreviewActionIdentifiersPrivate.mm */,
</ins><span class="cx">                                 1A158418189044F50017616C /* WKProcessPool.h */,
</span><span class="cx">                                 1A158417189044F50017616C /* WKProcessPool.mm */,
</span><span class="cx">                                 1A3CC16818907EB0001E6ED8 /* WKProcessPoolInternal.h */,
</span><span class="lines">@@ -7391,6 +7403,7 @@
</span><span class="cx">                                 5163199516289A6300E22F00 /* NetworkProcessMessages.h in Headers */,
</span><span class="cx">                                 E14A954A16E016A40068DE82 /* NetworkProcessPlatformStrategies.h in Headers */,
</span><span class="cx">                                 5179556E162877B300FA43B6 /* NetworkProcessProxy.h in Headers */,
</span><ins>+                                93A253ED1C922E1E00F9F68D /* _WKPreviewAction.h in Headers */,
</ins><span class="cx">                                 513A163D163088F6005D7D22 /* NetworkProcessProxyMessages.h in Headers */,
</span><span class="cx">                                 9955A6F51C7986E000EB6A93 /* InspectorBackendDispatchers.h in Headers */,
</span><span class="cx">                                 51FD18B61651FBAD00DBE1CE /* NetworkResourceLoader.h in Headers */,
</span><span class="lines">@@ -8017,6 +8030,7 @@
</span><span class="cx">                                 75A8D2C8187CCFAB00C39C9E /* WKWebsiteDataStore.h in Headers */,
</span><span class="cx">                                 75A8D2D6187D1C0E00C39C9E /* WKWebsiteDataStoreInternal.h in Headers */,
</span><span class="cx">                                 1A57109F1ABA0027002FABBE /* WKWebsiteDataStoreRef.h in Headers */,
</span><ins>+                                93A253F31C92411200F9F68D /* WKPreviewActionIdentifiersPrivate.h in Headers */,
</ins><span class="cx">                                 1A3CC16718906ACF001E6ED8 /* WKWebView.h in Headers */,
</span><span class="cx">                                 1ADF591B1890528E0043C145 /* WKWebViewConfiguration.h in Headers */,
</span><span class="cx">                                 2D7AAFD618C956AF00A7ACD4 /* WKWebViewConfigurationInternal.h in Headers */,
</span><span class="lines">@@ -8810,6 +8824,7 @@
</span><span class="cx">                                 E489D28B1A0A2DB80078C06A /* NetworkCacheCoders.cpp in Sources */,
</span><span class="cx">                                 E47D1E981B0649FB002676A8 /* NetworkCacheData.cpp in Sources */,
</span><span class="cx">                                 E42E06141AA75B7000B11699 /* NetworkCacheDataCocoa.mm in Sources */,
</span><ins>+                                93A253F51C92413200F9F68D /* WKPreviewActionIdentifiersPrivate.mm in Sources */,
</ins><span class="cx">                                 E489D28D1A0A2DB80078C06A /* NetworkCacheDecoder.cpp in Sources */,
</span><span class="cx">                                 E489D28F1A0A2DB80078C06A /* NetworkCacheEncoder.cpp in Sources */,
</span><span class="cx">                                 E413F59F1AC1AF9D00345360 /* NetworkCacheEntry.cpp in Sources */,
</span><span class="lines">@@ -9285,6 +9300,7 @@
</span><span class="cx">                                 CDCA85C8132ABA4E00E961DF /* WKFullScreenWindowController.mm in Sources */,
</span><span class="cx">                                 BC54CC1312D674EE005C67B0 /* WKGeolocationManager.cpp in Sources */,
</span><span class="cx">                                 BC06F44F12DBDF3F002D78DE /* WKGeolocationPermissionRequest.cpp in Sources */,
</span><ins>+                                93A253EF1C922E8E00F9F68D /* _WKPreviewAction.mm in Sources */,
</ins><span class="cx">                                 BC0E619912D6CD120012A72A /* WKGeolocationPosition.cpp in Sources */,
</span><span class="cx">                                 07297FA21C186ADB003F0735 /* WKUserMediaPermissionCheck.cpp in Sources */,
</span><span class="cx">                                 0FCB4E5018BBE044000FCFC9 /* WKGeolocationProviderIOS.mm in Sources */,
</span></span></pre>
</div>
</div>

</body>
</html>