[iOS][WK2] Rotating a zoomed PDF leads to weird scrolling behavior
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 Jun 2014 21:43:14 +0000 (21:43 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 Jun 2014 21:43:14 +0000 (21:43 +0000)
https://bugs.webkit.org/show_bug.cgi?id=134286

Reviewed by Benjamin Poulain.

* UIProcess/ios/WKPDFView.mm:
(-[WKPDFView _computePageAndDocumentFrames]):
The WKPDFView frame and scroll view content size need to be scaled.

(-[WKPDFView web_setScrollView:]): Deleted.

(-[WKPDFView web_initWithFrame:webView:]):
Get rid of _documentFrame, and don't set it at initWithFrame: time (it's not useful yet).

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@170439 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/ios/WKPDFView.mm

index a437821..d90f937 100644 (file)
@@ -1,3 +1,19 @@
+2014-06-25  Timothy Horton  <timothy_horton@apple.com>
+
+        [iOS][WK2] Rotating a zoomed PDF leads to weird scrolling behavior
+        https://bugs.webkit.org/show_bug.cgi?id=134286
+
+        Reviewed by Benjamin Poulain.
+
+        * UIProcess/ios/WKPDFView.mm:
+        (-[WKPDFView _computePageAndDocumentFrames]):
+        The WKPDFView frame and scroll view content size need to be scaled.
+
+        (-[WKPDFView web_setScrollView:]): Deleted.
+
+        (-[WKPDFView web_initWithFrame:webView:]):
+        Get rid of _documentFrame, and don't set it at initWithFrame: time (it's not useful yet).
+
 2014-06-25  Laszlo Gombos  <l.gombos@samsung.com>
 
         Remove build guard for progress element
index de2836f..7c7ea6f 100644 (file)
@@ -57,7 +57,6 @@ typedef struct {
     RetainPtr<WKPDFPageNumberIndicator> _pageNumberIndicator;
 
     Vector<PDFPageInfo> _pages;
-    CGRect _documentFrame;
     unsigned _centerPageNumber;
 
     CGSize _minimumSize;
@@ -79,7 +78,6 @@ typedef struct {
     _scrollView = webView.scrollView;
     [_scrollView setMinimumZoomScale:pdfMinimumZoomScale];
     [_scrollView setMaximumZoomScale:pdfMaximumZoomScale];
-    [_scrollView setContentSize:_documentFrame.size];
     [_scrollView setBackgroundColor:[UIColor grayColor]];
 
     return self;
@@ -126,16 +124,6 @@ typedef struct {
     [self _revalidateViews];
 }
 
-- (void)web_setScrollView:(UIScrollView *)scrollView
-{
-    _scrollView = scrollView;
-
-    [_scrollView setMinimumZoomScale:pdfMinimumZoomScale];
-    [_scrollView setMaximumZoomScale:pdfMaximumZoomScale];
-    [_scrollView setContentSize:_documentFrame.size];
-    [_scrollView setBackgroundColor:[UIColor grayColor]];
-}
-
 - (void)scrollViewDidScroll:(UIScrollView *)scrollView
 {
     if (scrollView.isZoomBouncing)
@@ -247,12 +235,13 @@ typedef struct {
         pageFrame.origin.y += pageFrame.size.height - pdfPageMargin;
     }
 
-    _documentFrame = [self frame];
-    _documentFrame.size.width = _minimumSize.width;
-    _documentFrame.size.height = std::max(pageFrame.origin.y + pdfPageMargin, _minimumSize.height);
+    CGFloat scale = _scrollView.zoomScale;
+    CGRect newFrame = [self frame];
+    newFrame.size.width = _minimumSize.width * scale;
+    newFrame.size.height = std::max(pageFrame.origin.y + pdfPageMargin, _minimumSize.height) * scale;
 
-    [self setFrame:_documentFrame];
-    [_scrollView setContentSize:_documentFrame.size];
+    [self setFrame:newFrame];
+    [_scrollView setContentSize:newFrame.size];
 }
 
 @end