<!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>[178997] 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/178997">178997</a></dd>
<dt>Author</dt> <dd>ddkilzer@apple.com</dd>
<dt>Date</dt> <dd>2015-01-23 02:04:43 -0800 (Fri, 23 Jan 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Merged <a href="http://trac.webkit.org/projects/webkit/changeset/174072">r174072</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="#branchessafari6001415branchSourceWebKit2UIProcessWebPageProxycpp">branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/WebPageProxy.cpp</a></li>
<li><a href="#branchessafari6001415branchSourceWebKit2UIProcessWebPageProxyh">branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/WebPageProxy.h</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>
<li><a href="#branchessafari6001415branchSourceWebKit2WebProcessWebPageWebPagecpp">branches/safari-600.1.4.15-branch/Source/WebKit2/WebProcess/WebPage/WebPage.cpp</a></li>
<li><a href="#branchessafari6001415branchSourceWebKit2WebProcessWebPageWebPageh">branches/safari-600.1.4.15-branch/Source/WebKit2/WebProcess/WebPage/WebPage.h</a></li>
<li><a href="#branchessafari6001415branchSourceWebKit2WebProcessWebPageWebPagemessagesin">branches/safari-600.1.4.15-branch/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in</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 (178996 => 178997)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/Source/WebKit2/ChangeLog        2015-01-23 10:04:40 UTC (rev 178996)
+++ branches/safari-600.1.4.15-branch/Source/WebKit2/ChangeLog        2015-01-23 10:04:43 UTC (rev 178997)
</span><span class="lines">@@ -1,5 +1,36 @@
</span><span class="cx"> 2015-01-22 David Kilzer <ddkilzer@apple.com>
</span><span class="cx">
</span><ins>+ Merge r174072.
+
+ 2014-09-27 Andy Estes <aestes@apple.com>
+
+ [iOS] Add basic support for link navigation in WKPDFView
+ https://bugs.webkit.org/show_bug.cgi?id=137182
+
+ Reviewed by Tim Horton.
+
+ Teach WKPDFView to navigate to URLs when PDF link annotations are tapped.
+
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::navigateToURLWithSimulatedClick): Sent Messages::WebPage::NavigateToURLWithSimulatedClick.
+ * UIProcess/WebPageProxy.h:
+ * UIProcess/ios/WKPDFView.h:
+ * UIProcess/ios/WKPDFView.mm:
+ (-[WKPDFView _clearPages]): Removed self as the UIPDFAnnotationControllerDelegate.
+ (-[WKPDFView _revalidateViews]): Added self as the UIPDFAnnotationControllerDelegate.
+ (-[WKPDFView annotation:wasTouchedAtPoint:controller:]): Retrieved the URL from the touched annotation,
+ computed the touched point relative to the WKPDFView and to the screen, and called
+ navigateToURLWithSimulatedClick() after a 200 ms delay in order to show a soon-to-be-added tap highlight
+ (this value matches the delay in UIWebPDFView).
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::navigateToURLWithSimulatedClick): Created a fake single-click MouseEvent and called
+ FrameLoader::urlSelected(). Creating a mouse event ensures that the navigation appears as a
+ NavigationTypeLinkClicked in navigation policy delegates.
+ * WebProcess/WebPage/WebPage.h:
+ * WebProcess/WebPage/WebPage.messages.in:
+
+2015-01-22 David Kilzer <ddkilzer@apple.com>
+
</ins><span class="cx"> Merge r172966.
</span><span class="cx">
</span><span class="cx"> 2014-08-26 Tim Horton <timothy_horton@apple.com>
</span></span></pre></div>
<a id="branchessafari6001415branchSourceWebKit2UIProcessWebPageProxycpp"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/WebPageProxy.cpp (178996 => 178997)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/WebPageProxy.cpp        2015-01-23 10:04:40 UTC (rev 178996)
+++ branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/WebPageProxy.cpp        2015-01-23 10:04:43 UTC (rev 178997)
</span><span class="lines">@@ -845,6 +845,18 @@
</span><span class="cx"> m_process->responsivenessTimer()->start();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void WebPageProxy::navigateToURLWithSimulatedClick(const String& url, IntPoint documentPoint, IntPoint screenPoint)
+{
+ if (m_isClosed)
+ return;
+
+ if (!isValid())
+ reattachToWebProcess();
+
+ m_process->send(Messages::WebPage::NavigateToURLWithSimulatedClick(url, documentPoint, screenPoint), m_pageID);
+ m_process->responsivenessTimer()->start();
+}
+
</ins><span class="cx"> void WebPageProxy::stopLoading()
</span><span class="cx"> {
</span><span class="cx"> if (!isValid())
</span></span></pre></div>
<a id="branchessafari6001415branchSourceWebKit2UIProcessWebPageProxyh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/WebPageProxy.h (178996 => 178997)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/WebPageProxy.h        2015-01-23 10:04:40 UTC (rev 178996)
+++ branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/WebPageProxy.h        2015-01-23 10:04:43 UTC (rev 178997)
</span><span class="lines">@@ -308,6 +308,7 @@
</span><span class="cx"> void loadAlternateHTMLString(const String& htmlString, const String& baseURL, const String& unreachableURL, API::Object* userData = nullptr);
</span><span class="cx"> void loadPlainTextString(const String&, API::Object* userData = nullptr);
</span><span class="cx"> void loadWebArchiveData(API::Data*, API::Object* userData = nullptr);
</span><ins>+ void navigateToURLWithSimulatedClick(const String& url, WebCore::IntPoint documentPoint, WebCore::IntPoint screenPoint);
</ins><span class="cx">
</span><span class="cx"> void stopLoading();
</span><span class="cx"> uint64_t reload(bool reloadFromOrigin);
</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 (178996 => 178997)</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:40 UTC (rev 178996)
+++ branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/WKPDFView.h        2015-01-23 10:04:43 UTC (rev 178997)
</span><span class="lines">@@ -26,10 +26,11 @@
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">
</span><span class="cx"> #import "WKWebViewContentProvider.h"
</span><ins>+#import <CorePDF/UIPDFAnnotationController.h>
</ins><span class="cx"> #import <CorePDF/UIPDFPageView.h>
</span><span class="cx"> #import <UIKit/UIView.h>
</span><span class="cx">
</span><del>-@interface WKPDFView : UIView <WKWebViewContentProvider, UIPDFPageViewDelegate>
</del><ins>+@interface WKPDFView : UIView <WKWebViewContentProvider, UIPDFPageViewDelegate, UIPDFAnnotationControllerDelegate>
</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 (178996 => 178997)</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:40 UTC (rev 178996)
+++ branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/WKPDFView.mm        2015-01-23 10:04:43 UTC (rev 178997)
</span><span class="lines">@@ -30,11 +30,14 @@
</span><span class="cx">
</span><span class="cx"> #import "WKPDFPageNumberIndicator.h"
</span><span class="cx"> #import "WKWebViewInternal.h"
</span><ins>+#import "WebPageProxy.h"
</ins><span class="cx"> #import <CorePDF/UIPDFDocument.h>
</span><ins>+#import <CorePDF/UIPDFLinkAnnotation.h>
</ins><span class="cx"> #import <CorePDF/UIPDFPage.h>
</span><span class="cx"> #import <CorePDF/UIPDFPageView.h>
</span><span class="cx"> #import <UIKit/UIScrollView_Private.h>
</span><span class="cx"> #import <WebCore/FloatRect.h>
</span><ins>+#import <chrono>
</ins><span class="cx"> #import <wtf/RetainPtr.h>
</span><span class="cx"> #import <wtf/Vector.h>
</span><span class="cx">
</span><span class="lines">@@ -110,6 +113,7 @@
</span><span class="cx"> for (auto& page : _pages) {
</span><span class="cx"> [page.view removeFromSuperview];
</span><span class="cx"> [page.view setDelegate:nil];
</span><ins>+ [[page.view annotationController] setDelegate:nil];
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> _pages.clear();
</span><span class="lines">@@ -179,6 +183,7 @@
</span><span class="cx"> pageInfo.view = adoptNS([[UIPDFPageView alloc] initWithPage:pageInfo.page.get() tiledContent:YES]);
</span><span class="cx"> [pageInfo.view setUseBackingLayer:YES];
</span><span class="cx"> [pageInfo.view setDelegate:self];
</span><ins>+ [[pageInfo.view annotationController] setDelegate:self];
</ins><span class="cx"> [self addSubview:pageInfo.view.get()];
</span><span class="cx">
</span><span class="cx"> [pageInfo.view setFrame:pageInfo.frame];
</span><span class="lines">@@ -259,6 +264,7 @@
</span><span class="cx"> [_scrollView setContentSize:newFrame.size];
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+#pragma mark UIPDFPageViewDelegate
</ins><span class="cx">
</span><span class="cx"> - (void)zoom:(UIPDFPageView *)pageView to:(CGRect)targetRect atPoint:(CGPoint)origin kind:(UIPDFObjectKind)kind
</span><span class="cx"> {
</span><span class="lines">@@ -288,6 +294,33 @@
</span><span class="cx"> _isStartingZoom = NO;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+#pragma mark UIPDFAnnotationControllerDelegate
+
+- (void)annotation:(UIPDFAnnotation *)annotation wasTouchedAtPoint:(CGPoint)point controller:(UIPDFAnnotationController *)controller
+{
+ ASSERT(isMainThread());
+
+ if (![annotation isKindOfClass:[UIPDFLinkAnnotation class]])
+ return;
+
+ UIPDFLinkAnnotation *linkAnnotation = (UIPDFLinkAnnotation *)annotation;
+ String urlString = linkAnnotation.url.absoluteString;
+ if (urlString.isEmpty())
+ return;
+
+ // FIXME: Support pageNumber navigations
+
+ CGPoint documentPoint = [controller.pageView convertPoint:point toView:self];
+ CGPoint screenPoint = [self.window convertPoint:[self convertPoint:documentPoint toView:nil] toWindow:nil];
+ static const int64_t dispatchOffset = std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::milliseconds(200)).count();
+ RetainPtr<WKWebView> retainedWebView = _webView;
+
+ // Call navigateToURLWithSimulatedClick() on a delay so that a tap highlight can be shown.
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, dispatchOffset), dispatch_get_main_queue(), ^ {
+ retainedWebView->_page->navigateToURLWithSimulatedClick(urlString, roundedIntPoint(documentPoint), roundedIntPoint(screenPoint));
+ });
+}
+
</ins><span class="cx"> @end
</span><span class="cx">
</span><span class="cx"> #endif /* PLATFORM(IOS) */
</span></span></pre></div>
<a id="branchessafari6001415branchSourceWebKit2WebProcessWebPageWebPagecpp"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.15-branch/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (178996 => 178997)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/Source/WebKit2/WebProcess/WebPage/WebPage.cpp        2015-01-23 10:04:40 UTC (rev 178996)
+++ branches/safari-600.1.4.15-branch/Source/WebKit2/WebProcess/WebPage/WebPage.cpp        2015-01-23 10:04:43 UTC (rev 178997)
</span><span class="lines">@@ -100,6 +100,7 @@
</span><span class="cx"> #include <WebCore/ArchiveResource.h>
</span><span class="cx"> #include <WebCore/Chrome.h>
</span><span class="cx"> #include <WebCore/ContextMenuController.h>
</span><ins>+#include <WebCore/DataTransfer.h>
</ins><span class="cx"> #include <WebCore/DatabaseManager.h>
</span><span class="cx"> #include <WebCore/DocumentFragment.h>
</span><span class="cx"> #include <WebCore/DocumentLoader.h>
</span><span class="lines">@@ -1095,6 +1096,18 @@
</span><span class="cx"> loadDataImpl(0, sharedBuffer, ASCIILiteral("application/x-webarchive"), ASCIILiteral("utf-16"), blankURL(), URL(), decoder);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void WebPage::navigateToURLWithSimulatedClick(const String& url, IntPoint documentPoint, IntPoint screenPoint)
+{
+ Frame* mainFrame = m_mainFrame->coreFrame();
+ Document* mainFrameDocument = mainFrame->document();
+ if (!mainFrameDocument)
+ return;
+
+ const int singleClick = 1;
+ RefPtr<MouseEvent> mouseEvent = MouseEvent::create(eventNames().clickEvent, true, true, currentTime(), nullptr, singleClick, screenPoint.x(), screenPoint.y(), documentPoint.x(), documentPoint.y(), false, false, false, false, 0, nullptr, nullptr);
+ mainFrame->loader().urlSelected(mainFrameDocument->completeURL(url), emptyString(), mouseEvent.release(), LockHistory::No, LockBackForwardList::No, ShouldSendReferrer::MaybeSendReferrer);
+}
+
</ins><span class="cx"> void WebPage::stopLoadingFrame(uint64_t frameID)
</span><span class="cx"> {
</span><span class="cx"> WebFrame* frame = WebProcess::shared().webFrame(frameID);
</span></span></pre></div>
<a id="branchessafari6001415branchSourceWebKit2WebProcessWebPageWebPageh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.15-branch/Source/WebKit2/WebProcess/WebPage/WebPage.h (178996 => 178997)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/Source/WebKit2/WebProcess/WebPage/WebPage.h        2015-01-23 10:04:40 UTC (rev 178996)
+++ branches/safari-600.1.4.15-branch/Source/WebKit2/WebProcess/WebPage/WebPage.h        2015-01-23 10:04:43 UTC (rev 178997)
</span><span class="lines">@@ -900,6 +900,7 @@
</span><span class="cx"> void loadAlternateHTMLString(const String& htmlString, const String& baseURL, const String& unreachableURL, IPC::MessageDecoder&);
</span><span class="cx"> void loadPlainTextString(const String&, IPC::MessageDecoder&);
</span><span class="cx"> void loadWebArchiveData(const IPC::DataReference&, IPC::MessageDecoder&);
</span><ins>+ void navigateToURLWithSimulatedClick(const String& url, WebCore::IntPoint documentPoint, WebCore::IntPoint screenPoint);
</ins><span class="cx"> void reload(uint64_t navigationID, bool reloadFromOrigin, const SandboxExtension::Handle&);
</span><span class="cx"> void goForward(uint64_t navigationID, uint64_t);
</span><span class="cx"> void goBack(uint64_t navigationID, uint64_t);
</span></span></pre></div>
<a id="branchessafari6001415branchSourceWebKit2WebProcessWebPageWebPagemessagesin"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.15-branch/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in (178996 => 178997)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in        2015-01-23 10:04:40 UTC (rev 178996)
+++ branches/safari-600.1.4.15-branch/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in        2015-01-23 10:04:43 UTC (rev 178997)
</span><span class="lines">@@ -125,6 +125,7 @@
</span><span class="cx"> LoadAlternateHTMLString(String htmlString, String baseURL, String unreachableURL, WebKit::WebContextUserMessageEncoder userData) Variadic
</span><span class="cx"> LoadPlainTextString(String string, WebKit::WebContextUserMessageEncoder userData) Variadic
</span><span class="cx"> LoadWebArchiveData(IPC::DataReference webArchiveData, WebKit::WebContextUserMessageEncoder userData) Variadic
</span><ins>+ NavigateToURLWithSimulatedClick(String url, WebCore::IntPoint documentPoint, WebCore::IntPoint screenPoint)
</ins><span class="cx">
</span><span class="cx"> Reload(uint64_t navigationID, bool reloadFromOrigin, WebKit::SandboxExtension::Handle sandboxExtensionHandle)
</span><span class="cx"> StopLoading()
</span></span></pre>
</div>
</div>
</body>
</html>