<!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>[178998] 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/178998">178998</a></dd>
<dt>Author</dt> <dd>ddkilzer@apple.com</dd>
<dt>Date</dt> <dd>2015-01-23 02:04:46 -0800 (Fri, 23 Jan 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Merged <a href="http://trac.webkit.org/projects/webkit/changeset/174232">r174232</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="#branchessafari6001415branchSourceWebKit2UIProcessAPICocoaWKWebViewmm">branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm</a></li>
<li><a href="#branchessafari6001415branchSourceWebKit2UIProcessAPICocoaWKWebViewInternalh">branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h</a></li>
<li><a href="#branchessafari6001415branchSourceWebKit2UIProcessCocoaWKWebViewContentProviderh">branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/Cocoa/WKWebViewContentProvider.h</a></li>
<li><a href="#branchessafari6001415branchSourceWebKit2UIProcessiosPageClientImplIOSmm">branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm</a></li>
<li><a href="#branchessafari6001415branchSourceWebKit2UIProcessiosWKContentViewmm">branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/WKContentView.mm</a></li>
<li><a href="#branchessafari6001415branchSourceWebKit2UIProcessiosWKPDFPageNumberIndicatorh">branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/WKPDFPageNumberIndicator.h</a></li>
<li><a href="#branchessafari6001415branchSourceWebKit2UIProcessiosWKPDFPageNumberIndicatormm">branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/WKPDFPageNumberIndicator.mm</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 (178997 => 178998)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/Source/WebKit2/ChangeLog        2015-01-23 10:04:43 UTC (rev 178997)
+++ branches/safari-600.1.4.15-branch/Source/WebKit2/ChangeLog        2015-01-23 10:04:46 UTC (rev 178998)
</span><span class="lines">@@ -1,5 +1,50 @@
</span><span class="cx"> 2015-01-22  David Kilzer  &lt;ddkilzer@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Merge r174232.
+
+    2014-10-02  Andy Estes  &lt;aestes@apple.com&gt;
+
+        [iOS] Teach WKPDFView to navigate to pageNumber links
+        https://bugs.webkit.org/show_bug.cgi?id=137358
+
+        Reviewed by Tim Horton.
+
+        Treat PDF pageNumber annotations as if they were fragment navigations in an HTML document. For a given page
+        number N, create a fragment called &quot;#pageN&quot; and tell WebKit to navigate to it. By doing this we create history
+        entries for each pageNumber navigation and allow for proper back/forward. When navigating to a page, reset to
+        the initial scale factor and scroll to the beginning of the Nth page.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _zoomToPoint:atScale:animated:]): Added an animated parameter. If animated is NO, use a duration of 0.
+        (-[WKWebView _zoomToRect:atScale:origin:animated:]): Added an animated parameter and passed it to _zoomToPoint:atScale:animated:.
+        (-[WKWebView _zoomOutWithOrigin:animated:]): Ditto.
+        (-[WKWebView _zoomToRect:withOrigin:fitEntireRect:minimumScale:maximumScale:minimumScrollDistance:]): Called _zoomToRect:atScale:origin:animated:,
+        setting animated to YES.
+        (-[WKWebView _didSameDocumentNavigationForMainFrame:]): Called web_didSameDocumentNavigation: on _customContentView.
+        (-[WKWebView _zoomToPoint:atScale:]): Deleted.
+        (-[WKWebView _zoomToRect:atScale:origin:]): Deleted.
+        (-[WKWebView _zoomOutWithOrigin:]): Deleted.
+        * UIProcess/API/Cocoa/WKWebViewInternal.h:
+        * UIProcess/Cocoa/WKWebViewContentProvider.h:
+        * UIProcess/ios/PageClientImplIOS.mm:
+        (WebKit::PageClientImpl::didSameDocumentNavigationForMainFrame): Called _didSameDocumentNavigationForMainFrame on m_webView.
+        * UIProcess/ios/WKContentView.mm:
+        (-[WKContentView _zoomOutWithOrigin:]): Called _zoomOutWithOrigin:animated: on m_webView, setting animated to YES.
+        * UIProcess/ios/WKPDFPageNumberIndicator.h:
+        * UIProcess/ios/WKPDFPageNumberIndicator.mm:
+        (-[WKPDFPageNumberIndicator hide]): Added a method to hide the page number indicator.
+        * UIProcess/ios/WKPDFView.mm:
+        (-[WKPDFView web_setContentProviderData:suggestedFilename:]): Added a FIXME for restoring scroll position and page scale when loading from the back/forward list.
+        (-[WKPDFView scrollViewDidScroll:]): Stopped showing the page number indicator if a same-document navigation is occurring (to match UIWebPDFView).
+        (-[WKPDFView _updatePageNumberIndicator]): Ditto.
+        (-[WKPDFView web_didSameDocumentNavigation:]):
+        (-[WKPDFView _resetZoomAnimated:]): For same-document navigations of type kWKSameDocumentNavigationSessionStatePop, extracted the page index from the URL fragment
+        identifier, hid the page number indicator, reset the zoom (without an animation to match UIWebPDFView), and scrolled to the beginning of the given page.
+        (-[WKPDFView resetZoom:]): Called _resetZoomAnimated:, setting animated to YES.
+        (-[WKPDFView annotation:wasTouchedAtPoint:controller:]): If there is a non-zero pageNumber in the link annotation, construct a &quot;#pageN&quot; fragment and navigate to it.
+
+2015-01-22  David Kilzer  &lt;ddkilzer@apple.com&gt;
+
</ins><span class="cx">         Merge r174072.
</span><span class="cx"> 
</span><span class="cx">     2014-09-27  Andy Estes  &lt;aestes@apple.com&gt;
</span></span></pre></div>
<a id="branchessafari6001415branchSourceWebKit2UIProcessAPICocoaWKWebViewmm"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (178997 => 178998)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2015-01-23 10:04:43 UTC (rev 178997)
+++ branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2015-01-23 10:04:46 UTC (rev 178998)
</span><span class="lines">@@ -50,6 +50,7 @@
</span><span class="cx"> #import &quot;WKNavigationInternal.h&quot;
</span><span class="cx"> #import &quot;WKPreferencesInternal.h&quot;
</span><span class="cx"> #import &quot;WKProcessPoolInternal.h&quot;
</span><ins>+#import &quot;WKSharedAPICast.h&quot;
</ins><span class="cx"> #import &quot;WKUIDelegate.h&quot;
</span><span class="cx"> #import &quot;WKUIDelegatePrivate.h&quot;
</span><span class="cx"> #import &quot;WKUserContentControllerInternal.h&quot;
</span><span class="lines">@@ -956,22 +957,26 @@
</span><span class="cx">     return WebKit::ViewSnapshot::create(slotID, imageSize, imageSize.width() * imageSize.height() * 4);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)_zoomToPoint:(WebCore::FloatPoint)point atScale:(double)scale
</del><ins>+- (void)_zoomToPoint:(WebCore::FloatPoint)point atScale:(double)scale animated:(BOOL)animated
</ins><span class="cx"> {
</span><del>-    double maximumZoomDuration = 0.4;
-    double minimumZoomDuration = 0.1;
-    double zoomDurationFactor = 0.3;
-
</del><ins>+    CFTimeInterval duration = 0;
</ins><span class="cx">     CGFloat zoomScale = contentZoomScale(self);
</span><del>-    CFTimeInterval duration = std::min(fabs(log(zoomScale) - log(scale)) * zoomDurationFactor + minimumZoomDuration, maximumZoomDuration);
</del><span class="cx"> 
</span><ins>+    if (animated) {
+        const double maximumZoomDuration = 0.4;
+        const double minimumZoomDuration = 0.1;
+        const double zoomDurationFactor = 0.3;
+
+        duration = std::min(fabs(log(zoomScale) - log(scale)) * zoomDurationFactor + minimumZoomDuration, maximumZoomDuration);
+    }
+
</ins><span class="cx">     if (scale != zoomScale)
</span><span class="cx">         _page-&gt;willStartUserTriggeredZooming();
</span><span class="cx"> 
</span><span class="cx">     [_scrollView _zoomToCenter:point scale:scale duration:duration];
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)_zoomToRect:(WebCore::FloatRect)targetRect atScale:(double)scale origin:(WebCore::FloatPoint)origin
</del><ins>+- (void)_zoomToRect:(WebCore::FloatRect)targetRect atScale:(double)scale origin:(WebCore::FloatPoint)origin animated:(BOOL)animated
</ins><span class="cx"> {
</span><span class="cx">     // FIMXE: Some of this could be shared with _scrollToRect.
</span><span class="cx">     const double visibleRectScaleChange = contentZoomScale(self) / scale;
</span><span class="lines">@@ -997,7 +1002,7 @@
</span><span class="cx">     visibleRectAfterZoom.move(-topLeftObscuredInsetAfterZoom);
</span><span class="cx">     visibleRectAfterZoom.expand(topLeftObscuredInsetAfterZoom + bottomRightObscuredInsetAfterZoom);
</span><span class="cx"> 
</span><del>-    [self _zoomToPoint:visibleRectAfterZoom.center() atScale:scale];
</del><ins>+    [self _zoomToPoint:visibleRectAfterZoom.center() atScale:scale animated:animated];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static WebCore::FloatPoint constrainContentOffset(WebCore::FloatPoint contentOffset, WebCore::FloatSize contentSize, WebCore::FloatSize unobscuredContentSize)
</span><span class="lines">@@ -1070,9 +1075,9 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)_zoomOutWithOrigin:(WebCore::FloatPoint)origin
</del><ins>+- (void)_zoomOutWithOrigin:(WebCore::FloatPoint)origin animated:(BOOL)animated
</ins><span class="cx"> {
</span><del>-    [self _zoomToPoint:origin atScale:[_scrollView minimumZoomScale]];
</del><ins>+    [self _zoomToPoint:origin atScale:[_scrollView minimumZoomScale] animated:animated];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // focusedElementRect and selectionRect are both in document coordinates.
</span><span class="lines">@@ -1212,7 +1217,7 @@
</span><span class="cx">         if ([self _scrollToRect:targetRect origin:origin minimumScrollDistance:minimumScrollDistance])
</span><span class="cx">             return true;
</span><span class="cx">     } else if (targetScale != currentScale) {
</span><del>-        [self _zoomToRect:targetRect atScale:targetScale origin:origin];
</del><ins>+        [self _zoomToRect:targetRect atScale:targetScale origin:origin animated:YES];
</ins><span class="cx">         return true;
</span><span class="cx">     }
</span><span class="cx">     
</span><span class="lines">@@ -1407,6 +1412,11 @@
</span><span class="cx">         inStableState:isStableState isChangingObscuredInsetsInteractively:_isChangingObscuredInsetsInteractively];
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (void)_didSameDocumentNavigationForMainFrame:(WebKit::SameDocumentNavigationType)navigationType
+{
+    [_customContentView web_didSameDocumentNavigation:toAPI(navigationType)];
+}
+
</ins><span class="cx"> - (void)_keyboardChangedWithInfo:(NSDictionary *)keyboardInfo adjustScrollView:(BOOL)adjustScrollView
</span><span class="cx"> {
</span><span class="cx">     NSValue *endFrameValue = [keyboardInfo objectForKey:UIKeyboardFrameEndUserInfoKey];
</span></span></pre></div>
<a id="branchessafari6001415branchSourceWebKit2UIProcessAPICocoaWKWebViewInternalh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h (178997 => 178998)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h        2015-01-23 10:04:43 UTC (rev 178997)
+++ branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h        2015-01-23 10:04:46 UTC (rev 178998)
</span><span class="lines">@@ -27,6 +27,7 @@
</span><span class="cx"> 
</span><span class="cx"> #if WK_API_ENABLED
</span><span class="cx"> 
</span><ins>+#import &quot;SameDocumentNavigationType.h&quot;
</ins><span class="cx"> #import &lt;wtf/RefPtr.h&gt;
</span><span class="cx"> #import &lt;wtf/RetainPtr.h&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -84,7 +85,7 @@
</span><span class="cx"> - (BOOL)_scrollToRect:(WebCore::FloatRect)targetRect origin:(WebCore::FloatPoint)origin minimumScrollDistance:(float)minimumScrollDistance;
</span><span class="cx"> - (void)_zoomToFocusRect:(WebCore::FloatRect)focusedElementRect selectionRect:(WebCore::FloatRect)selectionRectInDocumentCoordinates fontSize:(float)fontSize minimumScale:(double)minimumScale maximumScale:(double)maximumScale allowScaling:(BOOL)allowScaling forceScroll:(BOOL)forceScroll;
</span><span class="cx"> - (BOOL)_zoomToRect:(WebCore::FloatRect)targetRect withOrigin:(WebCore::FloatPoint)origin fitEntireRect:(BOOL)fitEntireRect minimumScale:(double)minimumScale maximumScale:(double)maximumScale minimumScrollDistance:(float)minimumScrollDistance;
</span><del>-- (void)_zoomOutWithOrigin:(WebCore::FloatPoint)origin;
</del><ins>+- (void)_zoomOutWithOrigin:(WebCore::FloatPoint)origin animated:(BOOL)animated;
</ins><span class="cx"> 
</span><span class="cx"> - (void)_setHasCustomContentView:(BOOL)hasCustomContentView loadedMIMEType:(const WTF::String&amp;)mimeType;
</span><span class="cx"> - (void)_didFinishLoadingDataForCustomContentProviderWithSuggestedFilename:(const WTF::String&amp;)suggestedFilename data:(NSData *)data;
</span><span class="lines">@@ -95,6 +96,8 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_updateVisibleContentRects;
</span><span class="cx"> 
</span><ins>+- (void)_didSameDocumentNavigationForMainFrame:(WebKit::SameDocumentNavigationType)navigationType;
+
</ins><span class="cx"> @property (nonatomic, readonly) UIEdgeInsets _computedContentInset;
</span><span class="cx"> #endif
</span><span class="cx"> @end
</span></span></pre></div>
<a id="branchessafari6001415branchSourceWebKit2UIProcessCocoaWKWebViewContentProviderh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/Cocoa/WKWebViewContentProvider.h (178997 => 178998)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/Cocoa/WKWebViewContentProvider.h        2015-01-23 10:04:43 UTC (rev 178997)
+++ branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/Cocoa/WKWebViewContentProvider.h        2015-01-23 10:04:46 UTC (rev 178998)
</span><span class="lines">@@ -29,6 +29,8 @@
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx"> 
</span><ins>+#import &lt;WebKit/WKPageLoadTypes.h&gt;
+
</ins><span class="cx"> @class NSData;
</span><span class="cx"> @class UIScrollView;
</span><span class="cx"> @class UIView;
</span><span class="lines">@@ -47,6 +49,7 @@
</span><span class="cx"> - (void)web_setOverlaidAccessoryViewsInset:(CGSize)inset;
</span><span class="cx"> - (void)web_computedContentInsetDidChange;
</span><span class="cx"> - (void)web_setFixedOverlayView:(UIView *)fixedOverlayView;
</span><ins>+- (void)web_didSameDocumentNavigation:(WKSameDocumentNavigationType)navigationType;
</ins><span class="cx"> 
</span><span class="cx"> @end
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchessafari6001415branchSourceWebKit2UIProcessiosPageClientImplIOSmm"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm (178997 => 178998)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm        2015-01-23 10:04:43 UTC (rev 178997)
+++ branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm        2015-01-23 10:04:46 UTC (rev 178998)
</span><span class="lines">@@ -687,8 +687,9 @@
</span><span class="cx">     NavigationState::fromWebPage(*m_webView-&gt;_page).willRecordNavigationSnapshot(item);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void PageClientImpl::didSameDocumentNavigationForMainFrame(SameDocumentNavigationType)
</del><ins>+void PageClientImpl::didSameDocumentNavigationForMainFrame(SameDocumentNavigationType navigationType)
</ins><span class="cx"> {
</span><ins>+    [m_webView _didSameDocumentNavigationForMainFrame:navigationType];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="branchessafari6001415branchSourceWebKit2UIProcessiosWKContentViewmm"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/WKContentView.mm (178997 => 178998)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/WKContentView.mm        2015-01-23 10:04:43 UTC (rev 178997)
+++ branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/WKContentView.mm        2015-01-23 10:04:46 UTC (rev 178998)
</span><span class="lines">@@ -511,7 +511,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_zoomOutWithOrigin:(CGPoint)origin
</span><span class="cx"> {
</span><del>-    return [_webView _zoomOutWithOrigin:origin];
</del><ins>+    return [_webView _zoomOutWithOrigin:origin animated:YES];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)_applicationWillResignActive:(NSNotification*)notification
</span></span></pre></div>
<a id="branchessafari6001415branchSourceWebKit2UIProcessiosWKPDFPageNumberIndicatorh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/WKPDFPageNumberIndicator.h (178997 => 178998)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/WKPDFPageNumberIndicator.h        2015-01-23 10:04:43 UTC (rev 178997)
+++ branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/WKPDFPageNumberIndicator.h        2015-01-23 10:04:46 UTC (rev 178998)
</span><span class="lines">@@ -34,6 +34,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)moveToPoint:(CGPoint)point animated:(BOOL)animated;
</span><span class="cx"> - (void)show;
</span><ins>+- (void)hide;
</ins><span class="cx"> 
</span><span class="cx"> @end
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchessafari6001415branchSourceWebKit2UIProcessiosWKPDFPageNumberIndicatormm"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/WKPDFPageNumberIndicator.mm (178997 => 178998)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/WKPDFPageNumberIndicator.mm        2015-01-23 10:04:43 UTC (rev 178997)
+++ branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/WKPDFPageNumberIndicator.mm        2015-01-23 10:04:46 UTC (rev 178998)
</span><span class="lines">@@ -122,6 +122,11 @@
</span><span class="cx">         _timer = [NSTimer scheduledTimerWithTimeInterval:indicatorTimeout target:self selector:@selector(hide:) userInfo:nil repeats:NO];
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (void)hide
+{
+    [self hide:nil];
+}
+
</ins><span class="cx"> - (void)hide:(NSTimer *)timer
</span><span class="cx"> {
</span><span class="cx">     [UIView animateWithDuration:indicatorFadeDuration animations:^{
</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 (178997 => 178998)</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:43 UTC (rev 178997)
+++ branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/WKPDFView.mm        2015-01-23 10:04:46 UTC (rev 178998)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx"> 
</span><ins>+#import &quot;SessionState.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">@@ -57,6 +58,10 @@
</span><span class="cx">     RetainPtr&lt;UIPDFPage&gt; page;
</span><span class="cx"> } PDFPageInfo;
</span><span class="cx"> 
</span><ins>+@interface WKPDFView ()
+- (void)_resetZoomAnimated:(BOOL)animated;
+@end
+
</ins><span class="cx"> @implementation WKPDFView {
</span><span class="cx">     RetainPtr&lt;UIPDFDocument&gt; _pdfDocument;
</span><span class="cx">     RetainPtr&lt;NSString&gt; _suggestedFilename;
</span><span class="lines">@@ -72,6 +77,7 @@
</span><span class="cx">     UIView *_fixedOverlayView;
</span><span class="cx"> 
</span><span class="cx">     BOOL _isStartingZoom;
</span><ins>+    BOOL _isPerformingSameDocumentNavigation;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (instancetype)web_initWithFrame:(CGRect)frame webView:(WKWebView *)webView
</span><span class="lines">@@ -129,6 +135,8 @@
</span><span class="cx">     RetainPtr&lt;CGPDFDocumentRef&gt; cgPDFDocument = adoptCF(CGPDFDocumentCreateWithProvider(dataProvider.get()));
</span><span class="cx">     _pdfDocument = adoptNS([[UIPDFDocument alloc] initWithCGPDFDocument:cgPDFDocument.get()]);
</span><span class="cx"> 
</span><ins>+    // FIXME: restore the scroll position and page scale if navigating from the back/forward list.
+
</ins><span class="cx">     [self _computePageAndDocumentFrames];
</span><span class="cx">     [self _revalidateViews];
</span><span class="cx"> }
</span><span class="lines">@@ -147,7 +155,9 @@
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     [self _revalidateViews];
</span><del>-    [_pageNumberIndicator show];
</del><ins>+
+    if (!_isPerformingSameDocumentNavigation)
+        [_pageNumberIndicator show];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)_revalidateViews
</span><span class="lines">@@ -201,6 +211,9 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_updatePageNumberIndicator
</span><span class="cx"> {
</span><ins>+    if (_isPerformingSameDocumentNavigation)
+        return;
+
</ins><span class="cx">     if (!_pageNumberIndicator)
</span><span class="cx">         _pageNumberIndicator = adoptNS([[WKPDFPageNumberIndicator alloc] initWithFrame:CGRectZero]);
</span><span class="cx"> 
</span><span class="lines">@@ -229,6 +242,36 @@
</span><span class="cx">         [_fixedOverlayView addSubview:_pageNumberIndicator.get()];
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (void)web_didSameDocumentNavigation:(WKSameDocumentNavigationType)navigationType
+{
+    // Check for kWKSameDocumentNavigationSessionStatePop instead of kWKSameDocumentNavigationAnchorNavigation since the
+    // latter is only called once when navigating to the same anchor in succession. If the user navigates to a page
+    // then scrolls back and clicks on the same link a second time, we want to scroll again.
+    if (navigationType != kWKSameDocumentNavigationSessionStatePop)
+        return;
+
+    // FIXME: restore the scroll position and page scale if navigating back from a fragment.
+
+    NSString *fragment = _webView.URL.fragment;
+    if (![fragment hasPrefix:@&quot;page&quot;])
+        return;
+
+    NSInteger pageIndex = [[fragment substringFromIndex:4] integerValue] - 1;
+    if (pageIndex &lt; 0 || static_cast&lt;std::size_t&gt;(pageIndex) &gt;= _pages.size())
+        return;
+
+    _isPerformingSameDocumentNavigation = YES;
+
+    [_pageNumberIndicator hide];
+    [self _resetZoomAnimated:NO];
+
+    // Ensure that the page margin is visible below the content inset.
+    const CGFloat verticalOffset = _pages[pageIndex].frame.origin.y - _webView._computedContentInset.top - pdfPageMargin;
+    [_scrollView setContentOffset:CGPointMake(_scrollView.contentOffset.x, verticalOffset) animated:NO];
+
+    _isPerformingSameDocumentNavigation = NO;
+}
+
</ins><span class="cx"> - (void)_computePageAndDocumentFrames
</span><span class="cx"> {
</span><span class="cx">     NSUInteger pageCount = [_pdfDocument numberOfPages];
</span><span class="lines">@@ -264,6 +307,17 @@
</span><span class="cx">     [_scrollView setContentSize:newFrame.size];
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (void)_resetZoomAnimated:(BOOL)animated
+{
+    _isStartingZoom = YES;
+
+    CGRect scrollViewBounds = _scrollView.bounds;
+    CGPoint centerOfPageInDocumentCoordinates = [_scrollView convertPoint:CGPointMake(CGRectGetMidX(scrollViewBounds), CGRectGetMidY(scrollViewBounds)) toView:self];
+    [_webView _zoomOutWithOrigin:centerOfPageInDocumentCoordinates animated:animated];
+
+    _isStartingZoom = NO;
+}
+
</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">@@ -285,13 +339,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)resetZoom:(UIPDFPageView *)pageView
</span><span class="cx"> {
</span><del>-    _isStartingZoom = YES;
-    
-    CGRect scrollViewBounds = _scrollView.bounds;
-    CGPoint centerOfPageInDocumentCoordinates = [_scrollView convertPoint:CGPointMake(CGRectGetMidX(scrollViewBounds), CGRectGetMidY(scrollViewBounds)) toView:self];
-    [_webView _zoomOutWithOrigin:centerOfPageInDocumentCoordinates];
-
-    _isStartingZoom = NO;
</del><ins>+    [self _resetZoomAnimated:YES];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #pragma mark UIPDFAnnotationControllerDelegate
</span><span class="lines">@@ -304,12 +352,17 @@
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     UIPDFLinkAnnotation *linkAnnotation = (UIPDFLinkAnnotation *)annotation;
</span><del>-    String urlString = linkAnnotation.url.absoluteString;
</del><ins>+    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));
+    }
+
</ins><span class="cx">     if (urlString.isEmpty())
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    // FIXME: Support pageNumber navigations
-
</del><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><span class="cx">     static const int64_t dispatchOffset = std::chrono::duration_cast&lt;std::chrono::nanoseconds&gt;(std::chrono::milliseconds(200)).count();
</span></span></pre>
</div>
</div>

</body>
</html>