<!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>[179003] branches/safari-600.1.4.15-branch/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/179003">179003</a></dd>
<dt>Author</dt> <dd>ddkilzer@apple.com</dd>
<dt>Date</dt> <dd>2015-01-23 02:05:01 -0800 (Fri, 23 Jan 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Merged <a href="http://trac.webkit.org/projects/webkit/changeset/175595">r175595</a>.  rdar://problem/19395075</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari6001415branchSourceWebKit2ChangeLog">branches/safari-600.1.4.15-branch/Source/WebKit2/ChangeLog</a></li>
<li><a href="#branchessafari6001415branchSourceWebKit2UIProcessiosWKActionSheetAssistanth">branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.h</a></li>
<li><a href="#branchessafari6001415branchSourceWebKit2UIProcessiosWKActionSheetAssistantmm">branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.mm</a></li>
<li><a href="#branchessafari6001415branchSourceWebKit2UIProcessiosWKPDFViewh">branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/WKPDFView.h</a></li>
<li><a href="#branchessafari6001415branchSourceWebKit2UIProcessiosWKPDFViewmm">branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/WKPDFView.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari6001415branchSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.15-branch/Source/WebKit2/ChangeLog (179002 => 179003)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/Source/WebKit2/ChangeLog        2015-01-23 10:04:58 UTC (rev 179002)
+++ branches/safari-600.1.4.15-branch/Source/WebKit2/ChangeLog        2015-01-23 10:05:01 UTC (rev 179003)
</span><span class="lines">@@ -1,5 +1,46 @@
</span><span class="cx"> 2015-01-22  David Kilzer  &lt;ddkilzer@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Merge r175595.
+
+    2014-11-04  Andy Estes  &lt;aestes@apple.com&gt;
+
+        [iOS] Add long press support for links in WKPDFView
+        https://bugs.webkit.org/show_bug.cgi?id=138357
+
+        Reviewed by Dan Bernstein.
+
+        Use WKActionSheetAssistant to show a link action sheet in response to long-pressing on a link. Have WKPDFView
+        conform to WKActionSheetAssistantDelegate in order to respond to the open and copy actions as well as to
+        provide the link's URL and position information to WKActionSheetAssistant. The long-pressed link is highlighted
+        for .75 seconds before the sheet is displayed in order to match UIWebPDFView.
+
+        * UIProcess/ios/WKActionSheetAssistant.h: Made protocol methods that WKPDFView doesn't implement optional.
+        * UIProcess/ios/WKActionSheetAssistant.mm:
+        (-[WKActionSheetAssistant updatePositionInformation]): Checked if delegate responds to
+        updatePositionInformationForActionSheetAssistant: before calling.
+        (-[WKActionSheetAssistant _createSheetWithElementActions:showLinkTitle:]): Checked if delegate responds to
+        actionSheetAssistant:willStartInteractionWithElement: before calling.
+        (-[WKActionSheetAssistant cleanupSheet]): Checked if delegate responds to actionSheetAssistantDidStopInteraction:
+        before calling.
+        * UIProcess/ios/WKPDFView.h: Conformed to WKActionSheetAssistantDelegate.
+        * UIProcess/ios/WKPDFView.mm:
+        (-[WKPDFView web_initWithFrame:webView:]): Instantiated a WKActionSheetAssistant and set self as its delegate.
+        (-[WKPDFView _highlightLinkAnnotation:forDuration:completionHandler:]): Moved highlight drawing to here from
+        annotation:wasTouchedAtPoint:controller: in order to be reused for long-press.
+        (-[WKPDFView _URLForLinkAnnotation:]): Moved URL creation to here from annotation:wasTouchedAtPoint:controller:
+        in order to be reused for long-press. Generated an absolute URL since this URL might go into the pasteboard.
+        (-[WKPDFView annotation:wasTouchedAtPoint:controller:]): Changed to call
+        _highlightLinkAnnotation:forDuration:completionHandler: and _URLForLinkAnnotation:.
+        (-[WKPDFView annotation:isBeingPressedAtPoint:controller:]): Set values on _positionInformation and called
+        -[WKActionSheetAssistant showLinkSheet] after showing a highlight for .75 seconds.
+        (-[WKPDFView positionInformation]): Returned _positionInformation.
+        (-[WKPDFView performAction:]): Added a UTF-8 text and URL representation of the pressed URL to the pasteboard.
+        (-[WKPDFView openElementAtLocation:]): Called WebPage::navigateToURLWithSimulatedClick().
+        (-[WKPDFView actionsForElement:defaultActions:]): Returned actions from UIClient::actionsForElement().
+        (-[WKPDFView _createHighlightViewWithFrame:]): Deleted.
+
+2015-01-22  David Kilzer  &lt;ddkilzer@apple.com&gt;
+
</ins><span class="cx">         Merge r175577.
</span><span class="cx"> 
</span><span class="cx">     2014-11-04  Andy Estes  &lt;aestes@apple.com&gt;
</span></span></pre></div>
<a id="branchessafari6001415branchSourceWebKit2UIProcessiosWKActionSheetAssistanth"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.h (179002 => 179003)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.h        2015-01-23 10:04:58 UTC (rev 179002)
+++ branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.h        2015-01-23 10:05:01 UTC (rev 179003)
</span><span class="lines">@@ -40,15 +40,18 @@
</span><span class="cx"> @class _WKActivatedElementInfo;
</span><span class="cx"> @protocol WKActionSheetDelegate;
</span><span class="cx"> 
</span><del>-@protocol WKActionSheetAssistantDelegate
</del><ins>+@protocol WKActionSheetAssistantDelegate &lt;NSObject&gt;
</ins><span class="cx"> @required
</span><span class="cx"> - (const WebKit::InteractionInformationAtPosition&amp;)positionInformationForActionSheetAssistant:(WKActionSheetAssistant *)assistant;
</span><del>-- (void)updatePositionInformationForActionSheetAssistant:(WKActionSheetAssistant *)assistant;
</del><span class="cx"> - (void)actionSheetAssistant:(WKActionSheetAssistant *)assistant performAction:(WebKit::SheetAction)action;
</span><span class="cx"> - (void)actionSheetAssistant:(WKActionSheetAssistant *)assistant openElementAtLocation:(CGPoint)location;
</span><span class="cx"> - (RetainPtr&lt;NSArray&gt;)actionSheetAssistant:(WKActionSheetAssistant *)assistant decideActionsForElement:(_WKActivatedElementInfo *)element defaultActions:(RetainPtr&lt;NSArray&gt;)defaultActions;
</span><ins>+
+@optional
+- (void)updatePositionInformationForActionSheetAssistant:(WKActionSheetAssistant *)assistant;
</ins><span class="cx"> - (void)actionSheetAssistant:(WKActionSheetAssistant *)assistant willStartInteractionWithElement:(_WKActivatedElementInfo *)element;
</span><span class="cx"> - (void)actionSheetAssistantDidStopInteraction:(WKActionSheetAssistant *)assistant;
</span><ins>+
</ins><span class="cx"> @end
</span><span class="cx"> 
</span><span class="cx"> @interface WKActionSheetAssistant : NSObject &lt;WKActionSheetDelegate, DDDetectionControllerInteractionDelegate&gt;
</span></span></pre></div>
<a id="branchessafari6001415branchSourceWebKit2UIProcessiosWKActionSheetAssistantmm"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.mm (179002 => 179003)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.mm        2015-01-23 10:04:58 UTC (rev 179002)
+++ branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.mm        2015-01-23 10:05:01 UTC (rev 179003)
</span><span class="lines">@@ -163,7 +163,9 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)updatePositionInformation
</span><span class="cx"> {
</span><del>-    [_delegate.get() updatePositionInformationForActionSheetAssistant:self];
</del><ins>+    auto delegate = _delegate.get();
+    if ([delegate respondsToSelector:@selector(updatePositionInformationForActionSheetAssistant:)])
+        [delegate updatePositionInformationForActionSheetAssistant:self];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (BOOL)presentSheet
</span><span class="lines">@@ -236,7 +238,9 @@
</span><span class="cx">                                                         handler:^(UIAlertAction *action) {
</span><span class="cx">                                                             [self cleanupSheet];
</span><span class="cx">                                                         }]];
</span><del>-    [delegate actionSheetAssistant:self willStartInteractionWithElement:_elementInfo.get()];
</del><ins>+
+    if ([delegate respondsToSelector:@selector(actionSheetAssistant:willStartInteractionWithElement:)])
+        [delegate actionSheetAssistant:self willStartInteractionWithElement:_elementInfo.get()];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)showImageSheet
</span><span class="lines">@@ -365,7 +369,9 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)cleanupSheet
</span><span class="cx"> {
</span><del>-    [_delegate.get() actionSheetAssistantDidStopInteraction:self];
</del><ins>+    auto delegate = _delegate.get();
+    if ([delegate respondsToSelector:@selector(actionSheetAssistantDidStopInteraction:)])
+        [delegate actionSheetAssistantDidStopInteraction:self];
</ins><span class="cx"> 
</span><span class="cx">     [_interactionSheet doneWithSheet];
</span><span class="cx">     [_interactionSheet setSheetDelegate:nil];
</span></span></pre></div>
<a id="branchessafari6001415branchSourceWebKit2UIProcessiosWKPDFViewh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/WKPDFView.h (179002 => 179003)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/WKPDFView.h        2015-01-23 10:04:58 UTC (rev 179002)
+++ branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/WKPDFView.h        2015-01-23 10:05:01 UTC (rev 179003)
</span><span class="lines">@@ -25,12 +25,13 @@
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx"> 
</span><ins>+#import &quot;WKActionSheetAssistant.h&quot;
</ins><span class="cx"> #import &quot;WKWebViewContentProvider.h&quot;
</span><span class="cx"> #import &lt;CorePDF/UIPDFAnnotationController.h&gt;
</span><span class="cx"> #import &lt;CorePDF/UIPDFPageView.h&gt;
</span><span class="cx"> #import &lt;UIKit/UIView.h&gt;
</span><span class="cx"> 
</span><del>-@interface WKPDFView : UIView &lt;WKWebViewContentProvider, UIPDFPageViewDelegate, UIPDFAnnotationControllerDelegate&gt;
</del><ins>+@interface WKPDFView : UIView &lt;WKWebViewContentProvider, UIPDFPageViewDelegate, UIPDFAnnotationControllerDelegate, WKActionSheetAssistantDelegate&gt;
</ins><span class="cx"> 
</span><span class="cx"> @property (nonatomic, readonly) NSString *suggestedFilename;
</span><span class="cx"> @property (nonatomic, readonly) CGPDFDocumentRef pdfDocument;
</span></span></pre></div>
<a id="branchessafari6001415branchSourceWebKit2UIProcessiosWKPDFViewmm"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/WKPDFView.mm (179002 => 179003)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/WKPDFView.mm        2015-01-23 10:04:58 UTC (rev 179002)
+++ branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/WKPDFView.mm        2015-01-23 10:05:01 UTC (rev 179003)
</span><span class="lines">@@ -28,7 +28,9 @@
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx"> 
</span><ins>+#import &quot;APIUIClient.h&quot;
</ins><span class="cx"> #import &quot;SessionState.h&quot;
</span><ins>+#import &quot;WKNSURLExtras.h&quot;
</ins><span class="cx"> #import &quot;WKPDFPageNumberIndicator.h&quot;
</span><span class="cx"> #import &quot;WKWebViewInternal.h&quot;
</span><span class="cx"> #import &quot;WebPageProxy.h&quot;
</span><span class="lines">@@ -36,10 +38,10 @@
</span><span class="cx"> #import &lt;CorePDF/UIPDFLinkAnnotation.h&gt;
</span><span class="cx"> #import &lt;CorePDF/UIPDFPage.h&gt;
</span><span class="cx"> #import &lt;CorePDF/UIPDFPageView.h&gt;
</span><ins>+#import &lt;MobileCoreServices/UTCoreTypes.h&gt;
</ins><span class="cx"> #import &lt;UIKit/UIScrollView_Private.h&gt;
</span><span class="cx"> #import &lt;WebCore/FloatRect.h&gt;
</span><span class="cx"> #import &lt;WebCore/_UIHighlightViewSPI.h&gt;
</span><del>-#import &lt;chrono&gt;
</del><span class="cx"> #import &lt;wtf/RetainPtr.h&gt;
</span><span class="cx"> #import &lt;wtf/Vector.h&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -79,6 +81,9 @@
</span><span class="cx"> 
</span><span class="cx">     BOOL _isStartingZoom;
</span><span class="cx">     BOOL _isPerformingSameDocumentNavigation;
</span><ins>+
+    RetainPtr&lt;WKActionSheetAssistant&gt; _actionSheetAssistant;
+    WebKit::InteractionInformationAtPosition _positionInformation;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (instancetype)web_initWithFrame:(CGRect)frame webView:(WKWebView *)webView
</span><span class="lines">@@ -95,6 +100,9 @@
</span><span class="cx">     [_scrollView setMaximumZoomScale:pdfMaximumZoomScale];
</span><span class="cx">     [_scrollView setBackgroundColor:[UIColor grayColor]];
</span><span class="cx"> 
</span><ins>+    _actionSheetAssistant = adoptNS([[WKActionSheetAssistant alloc] initWithView:self]);
+    [_actionSheetAssistant setDelegate:self];
+
</ins><span class="cx">     return self;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -319,19 +327,43 @@
</span><span class="cx">     _isStartingZoom = NO;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (RetainPtr&lt;_UIHighlightView&gt;)_createHighlightViewWithFrame:(CGRect)frame
</del><ins>+- (void)_highlightLinkAnnotation:(UIPDFLinkAnnotation *)linkAnnotation forDuration:(NSTimeInterval)duration completionHandler:(void (^)())completionHandler
</ins><span class="cx"> {
</span><span class="cx">     static const CGFloat highlightBorderRadius = 3;
</span><span class="cx">     static const CGFloat highlightColorComponent = 26.0 / 255;
</span><span class="cx">     static UIColor *highlightColor = [[UIColor alloc] initWithRed:highlightColorComponent green:highlightColorComponent blue:highlightColorComponent alpha:0.3];
</span><span class="cx"> 
</span><del>-    RetainPtr&lt;_UIHighlightView&gt; highlightView = adoptNS([[_UIHighlightView alloc] initWithFrame:CGRectInset(frame, -highlightBorderRadius, -highlightBorderRadius)]);
</del><ins>+    UIPDFPageView *pageView = linkAnnotation.annotationController.pageView;
+    CGRect highlightViewFrame = [self convertRect:[pageView convertRectFromPDFPageSpace:linkAnnotation.Rect] fromView:pageView];
+    RetainPtr&lt;_UIHighlightView&gt; highlightView = adoptNS([[_UIHighlightView alloc] initWithFrame:CGRectInset(highlightViewFrame, -highlightBorderRadius, -highlightBorderRadius)]);
</ins><span class="cx">     [highlightView setOpaque:NO];
</span><span class="cx">     [highlightView setCornerRadius:highlightBorderRadius];
</span><span class="cx">     [highlightView setColor:highlightColor];
</span><del>-    return highlightView;
</del><ins>+
+    ASSERT(isMainThread());
+    [self addSubview:highlightView.get()];
+    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, duration * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
+        [highlightView removeFromSuperview];
+        completionHandler();
+    });
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (NSURL *)_URLForLinkAnnotation:(UIPDFLinkAnnotation *)linkAnnotation
+{
+    NSURL *documentURL = _webView.URL;
+
+    if (NSURL *url = linkAnnotation.url)
+        return [NSURL URLWithString:url.relativeString relativeToURL:documentURL];
+
+    if (NSUInteger pageNumber = linkAnnotation.pageNumber) {
+        String anchorString = ASCIILiteral(&quot;#page&quot;);
+        anchorString.append(String::number(pageNumber));
+        return [NSURL _web_URLWithWTFString:anchorString relativeToURL:documentURL];
+    }
+
+    return nil;
+}
+
</ins><span class="cx"> #pragma mark UIPDFPageViewDelegate
</span><span class="cx"> 
</span><span class="cx"> - (void)zoom:(UIPDFPageView *)pageView to:(CGRect)targetRect atPoint:(CGPoint)origin kind:(UIPDFObjectKind)kind
</span><span class="lines">@@ -360,37 +392,73 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)annotation:(UIPDFAnnotation *)annotation wasTouchedAtPoint:(CGPoint)point controller:(UIPDFAnnotationController *)controller
</span><span class="cx"> {
</span><del>-    ASSERT(isMainThread());
-
</del><span class="cx">     if (![annotation isKindOfClass:[UIPDFLinkAnnotation class]])
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     UIPDFLinkAnnotation *linkAnnotation = (UIPDFLinkAnnotation *)annotation;
</span><del>-    String urlString;
-    if (NSURL *url = linkAnnotation.url)
-        urlString = url.absoluteString;
-    else if (NSUInteger pageNumber = linkAnnotation.pageNumber) {
-        urlString = ASCIILiteral(&quot;#page&quot;);
-        urlString.append(String::number(pageNumber));
-    }
-
-    if (urlString.isEmpty())
</del><ins>+    RetainPtr&lt;NSURL&gt; url = [self _URLForLinkAnnotation:linkAnnotation];
+    if (!url)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     CGPoint documentPoint = [controller.pageView convertPoint:point toView:self];
</span><span class="cx">     CGPoint screenPoint = [self.window convertPoint:[self convertPoint:documentPoint toView:nil] toWindow:nil];
</span><del>-    static const int64_t dispatchOffset = std::chrono::duration_cast&lt;std::chrono::nanoseconds&gt;(std::chrono::milliseconds(200)).count();
</del><span class="cx">     RetainPtr&lt;WKWebView&gt; retainedWebView = _webView;
</span><span class="cx"> 
</span><del>-    CGRect highlightViewFrame = [self convertRect:[controller.pageView convertRectFromPDFPageSpace:annotation.Rect] fromView:controller.pageView];
-    RetainPtr&lt;_UIHighlightView&gt; highlightView = [self _createHighlightViewWithFrame:highlightViewFrame];
-    [self addSubview:highlightView.get()];
-    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, dispatchOffset), dispatch_get_main_queue(), ^ {
-        retainedWebView-&gt;_page-&gt;navigateToURLWithSimulatedClick(urlString, roundedIntPoint(documentPoint), roundedIntPoint(screenPoint));
-        [highlightView removeFromSuperview];
-    });
</del><ins>+    [self _highlightLinkAnnotation:linkAnnotation forDuration:.2 completionHandler:^{
+        retainedWebView-&gt;_page-&gt;navigateToURLWithSimulatedClick([url absoluteString], roundedIntPoint(documentPoint), roundedIntPoint(screenPoint));
+    }];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (void)annotation:(UIPDFAnnotation *)annotation isBeingPressedAtPoint:(CGPoint)point controller:(UIPDFAnnotationController *)controller
+{
+    if (![annotation isKindOfClass:[UIPDFLinkAnnotation class]])
+        return;
+
+    UIPDFLinkAnnotation *linkAnnotation = (UIPDFLinkAnnotation *)annotation;
+    NSURL *url = [self _URLForLinkAnnotation:linkAnnotation];
+    if (!url)
+        return;
+
+    _positionInformation.url = url.absoluteString;
+    _positionInformation.point = roundedIntPoint([controller.pageView convertPoint:point toView:self]);
+    _positionInformation.bounds = roundedIntRect([self convertRect:[controller.pageView convertRectFromPDFPageSpace:annotation.Rect] fromView:controller.pageView]);
+
+    [self _highlightLinkAnnotation:linkAnnotation forDuration:.75 completionHandler:^{
+        [_actionSheetAssistant showLinkSheet];
+    }];
+}
+
+#pragma mark WKActionSheetAssistantDelegate
+
+- (const WebKit::InteractionInformationAtPosition&amp;)positionInformationForActionSheetAssistant:(WKActionSheetAssistant *)assistant
+{
+    return _positionInformation;
+}
+
+- (void)actionSheetAssistant:(WKActionSheetAssistant *)assistant performAction:(WebKit::SheetAction)action
+{
+    if (action != WebKit::SheetAction::Copy)
+        return;
+
+    NSDictionary *representations = @{
+        (NSString *)kUTTypeUTF8PlainText : _positionInformation.url,
+        (NSString *)kUTTypeURL : [NSURL URLWithString:_positionInformation.url]
+    };
+
+    [UIPasteboard generalPasteboard].items = @[ representations ];
+}
+
+- (void)actionSheetAssistant:(WKActionSheetAssistant *)assistant openElementAtLocation:(CGPoint)location
+{
+    CGPoint screenPoint = [self.window convertPoint:[self convertPoint:location toView:nil] toWindow:nil];
+    _webView-&gt;_page-&gt;navigateToURLWithSimulatedClick(_positionInformation.url, roundedIntPoint(location), roundedIntPoint(screenPoint));
+}
+
+- (RetainPtr&lt;NSArray&gt;)actionSheetAssistant:(WKActionSheetAssistant *)assistant decideActionsForElement:(_WKActivatedElementInfo *)element defaultActions:(RetainPtr&lt;NSArray&gt;)defaultActions
+{
+    return _webView-&gt;_page-&gt;uiClient().actionsForElement(element, WTF::move(defaultActions));
+}
+
</ins><span class="cx"> @end
</span><span class="cx"> 
</span><span class="cx"> #endif /* PLATFORM(IOS) */
</span></span></pre>
</div>
</div>

</body>
</html>