[iOS] Teach WKPDFView to navigate to pageNumber links
authoraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 Oct 2014 21:51:14 +0000 (21:51 +0000)
committeraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 Oct 2014 21:51:14 +0000 (21:51 +0000)
commit4b8fdcfb7bf8894c485c0288b516ea2cfe1a62d1
tree4cb4237e3a87886a5667aae084aa0a515763cb4a
parent2e189e88ced8995c2e41fcc0d2817efaeb517929
[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 "#pageN" 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 "#pageN" fragment and navigate to it.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@174232 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h
Source/WebKit2/UIProcess/Cocoa/WKWebViewContentProvider.h
Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm
Source/WebKit2/UIProcess/ios/WKContentView.mm
Source/WebKit2/UIProcess/ios/WKPDFPageNumberIndicator.h
Source/WebKit2/UIProcess/ios/WKPDFPageNumberIndicator.mm
Source/WebKit2/UIProcess/ios/WKPDFView.mm