Changeset 175608 in webkit
- Timestamp:
- Nov 4, 2014 9:36:08 PM (9 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r175607 r175608 1 2014-11-04 Andy Estes <aestes@apple.com> 2 3 [iOS] WKPDFView should scroll to a fragment when loading a PDF 4 https://bugs.webkit.org/show_bug.cgi?id=138404 5 6 Reviewed by Tim Horton. 7 8 WKPDFView already knew how to scroll to a page number fragment during a same-document navigation, but it didn't 9 know to do so when loading a PDF whose URL already contained a page number fragment. This could happen if the 10 user long-presses a page number link and taps 'Open in New Tab'. 11 12 * UIProcess/ios/WKPDFView.mm: 13 (-[WKPDFView web_setContentProviderData:suggestedFilename:]): Called _scrollToFragment:. 14 (-[WKPDFView _scrollToFragment:]): Moved fragment scrolling code to here from web_didSameDocumentNavigation:. 15 (-[WKPDFView web_didSameDocumentNavigation:]): Called _scrollToFragment. 16 1 17 2014-11-04 Andy Estes <aestes@apple.com> 2 18 -
trunk/Source/WebKit2/UIProcess/ios/WKPDFView.mm
r175607 r175608 148 148 [self _computePageAndDocumentFrames]; 149 149 [self _revalidateViews]; 150 [self _scrollToFragment:_webView.URL.fragment]; 150 151 } 151 152 … … 251 252 } 252 253 254 - (void)_scrollToFragment:(NSString *)fragment 255 { 256 if (![fragment hasPrefix:@"page"]) 257 return; 258 259 NSInteger pageIndex = [[fragment substringFromIndex:4] integerValue] - 1; 260 if (pageIndex < 0 || static_cast<std::size_t>(pageIndex) >= _pages.size()) 261 return; 262 263 _isPerformingSameDocumentNavigation = YES; 264 265 [_pageNumberIndicator hide]; 266 [self _resetZoomAnimated:NO]; 267 268 // Ensure that the page margin is visible below the content inset. 269 const CGFloat verticalOffset = _pages[pageIndex].frame.origin.y - _webView._computedContentInset.top - pdfPageMargin; 270 [_scrollView setContentOffset:CGPointMake(_scrollView.contentOffset.x, verticalOffset) animated:NO]; 271 272 _isPerformingSameDocumentNavigation = NO; 273 } 274 253 275 - (void)web_didSameDocumentNavigation:(WKSameDocumentNavigationType)navigationType 254 276 { … … 261 283 // FIXME: restore the scroll position and page scale if navigating back from a fragment. 262 284 263 NSString *fragment = _webView.URL.fragment; 264 if (![fragment hasPrefix:@"page"]) 265 return; 266 267 NSInteger pageIndex = [[fragment substringFromIndex:4] integerValue] - 1; 268 if (pageIndex < 0 || static_cast<std::size_t>(pageIndex) >= _pages.size()) 269 return; 270 271 _isPerformingSameDocumentNavigation = YES; 272 273 [_pageNumberIndicator hide]; 274 [self _resetZoomAnimated:NO]; 275 276 // Ensure that the page margin is visible below the content inset. 277 const CGFloat verticalOffset = _pages[pageIndex].frame.origin.y - _webView._computedContentInset.top - pdfPageMargin; 278 [_scrollView setContentOffset:CGPointMake(_scrollView.contentOffset.x, verticalOffset) animated:NO]; 279 280 _isPerformingSameDocumentNavigation = NO; 285 [self _scrollToFragment:_webView.URL.fragment]; 281 286 } 282 287
Note: See TracChangeset
for help on using the changeset viewer.