Changeset 230497 in webkit
- Timestamp:
- Apr 10, 2018 3:35:46 PM (6 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r230496 r230497 1 2018-04-10 Andy Estes <aestes@apple.com> 2 3 [iOS] Navigate to URL and page number annotations in WKPDFView 4 https://bugs.webkit.org/show_bug.cgi?id=184410 5 6 Reviewed by Timothy Hatcher. 7 8 Implemented navigation to URL and page number (same-document) link annotations in PDFs. 9 10 * UIProcess/ios/WKPDFView.mm: 11 (-[WKPDFView _scrollToURLFragment:]): 12 (-[WKPDFView web_didSameDocumentNavigation:]): 13 (-[WKPDFView pdfHostViewController:updatePageCount:]): 14 (-[WKPDFView pdfHostViewController:goToURL:]): 15 (-[WKPDFView pdfHostViewController:goToPageIndex:withViewFrustum:]): 16 1 17 2018-04-10 Andy Estes <aestes@apple.com> 2 18 -
trunk/Source/WebKit/UIProcess/ios/WKPDFView.mm
r230496 r230497 163 163 } 164 164 165 - (void)_scrollToURLFragment:(NSString *)fragment 166 { 167 NSInteger pageIndex = 0; 168 if ([fragment hasPrefix:@"page"]) 169 pageIndex = [[fragment substringFromIndex:4] integerValue] - 1; 170 171 if (pageIndex >= 0 && pageIndex < [_hostViewController pageCount] && pageIndex != [_hostViewController currentPageIndex]) 172 [_hostViewController goToPageIndex:pageIndex]; 173 } 174 165 175 - (void)web_didSameDocumentNavigation:(WKSameDocumentNavigationType)navigationType 166 176 { 167 // FIXME: Implement page number navigations. 177 if (navigationType == kWKSameDocumentNavigationSessionStatePop) 178 [self _scrollToURLFragment:[_webView URL].fragment]; 168 179 } 169 180 … … 221 232 { 222 233 return self.isBackground; 234 } 235 236 #pragma mark PDFHostViewControllerDelegate 237 238 - (void)pdfHostViewController:(PDFHostViewController *)controller updatePageCount:(NSInteger)pageCount 239 { 240 [self _scrollToURLFragment:[_webView URL].fragment]; 241 } 242 243 - (void)pdfHostViewController:(PDFHostViewController *)controller goToURL:(NSURL *)url 244 { 245 WKWebView *webView = _webView.getAutoreleased(); 246 if (!webView) 247 return; 248 249 // FIXME: We'd use the real tap location if we knew it. 250 WebCore::IntPoint point; 251 webView->_page->navigateToPDFLinkWithSimulatedClick(url.absoluteString, point, point); 252 } 253 254 - (void)pdfHostViewController:(PDFHostViewController *)controller goToPageIndex:(NSInteger)pageIndex withViewFrustum:(CGRect)documentViewRect 255 { 256 WKWebView *webView = _webView.getAutoreleased(); 257 if (!webView) 258 return; 259 260 NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"#page%ld", (long)pageIndex + 1] relativeToURL:webView.URL]; 261 CGPoint documentPoint = documentViewRect.origin; 262 CGPoint screenPoint = [self.window convertPoint:[self convertPoint:documentPoint toView:nil] toWindow:nil]; 263 webView->_page->navigateToPDFLinkWithSimulatedClick(url.absoluteString, WebCore::roundedIntPoint(documentPoint), WebCore::roundedIntPoint(screenPoint)); 223 264 } 224 265
Note: See TracChangeset
for help on using the changeset viewer.