Title: [135925] trunk/Source/WebKit2
Revision
135925
Author
timothy_hor...@apple.com
Date
2012-11-27 14:45:49 -0800 (Tue, 27 Nov 2012)

Log Message

PDFPlugin: Page scale factor should affect subframe PDFs
https://bugs.webkit.org/show_bug.cgi?id=103291
<rdar://problem/12555249>

Reviewed by Darin Adler.

For subframe PDFs, hand PDFKit the pageScaleFactor for the parent page
so it can scale its drawing appropriately.

* WebProcess/Plugins/PDF/PDFPlugin.h: Add updatePageAndDeviceScaleFactors.
* WebProcess/Plugins/PDF/PDFPlugin.mm:
(WebKit::PDFPlugin::pdfDocumentDidLoad): Call updatePageAndDeviceScaleFactors
instead of manually updating PDFLayerController's device scale factor.
(WebKit::PDFPlugin::updatePageAndDeviceScaleFactors): Hand PDFLayerController
the "underlying" (non-zoom) content scale, which is the product of the
device scale and the page scale.
(WebKit::PDFPlugin::contentsScaleFactorChanged): Use updatePageAndDeviceScaleFactors.
(WebKit::PDFPlugin::geometryDidChange): Use updatePageAndDeviceScaleFactors to keep
PDFLayerController's notion of the page scale up to date when the plugin's
geometry changes.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (135924 => 135925)


--- trunk/Source/WebKit2/ChangeLog	2012-11-27 22:42:14 UTC (rev 135924)
+++ trunk/Source/WebKit2/ChangeLog	2012-11-27 22:45:49 UTC (rev 135925)
@@ -1,5 +1,28 @@
 2012-11-27  Tim Horton  <timothy_hor...@apple.com>
 
+        PDFPlugin: Page scale factor should affect subframe PDFs
+        https://bugs.webkit.org/show_bug.cgi?id=103291
+        <rdar://problem/12555249>
+
+        Reviewed by Darin Adler.
+
+        For subframe PDFs, hand PDFKit the pageScaleFactor for the parent page
+        so it can scale its drawing appropriately.
+
+        * WebProcess/Plugins/PDF/PDFPlugin.h: Add updatePageAndDeviceScaleFactors.
+        * WebProcess/Plugins/PDF/PDFPlugin.mm:
+        (WebKit::PDFPlugin::pdfDocumentDidLoad): Call updatePageAndDeviceScaleFactors
+        instead of manually updating PDFLayerController's device scale factor.
+        (WebKit::PDFPlugin::updatePageAndDeviceScaleFactors): Hand PDFLayerController
+        the "underlying" (non-zoom) content scale, which is the product of the
+        device scale and the page scale.
+        (WebKit::PDFPlugin::contentsScaleFactorChanged): Use updatePageAndDeviceScaleFactors.
+        (WebKit::PDFPlugin::geometryDidChange): Use updatePageAndDeviceScaleFactors to keep
+        PDFLayerController's notion of the page scale up to date when the plugin's
+        geometry changes.
+
+2012-11-27  Tim Horton  <timothy_hor...@apple.com>
+
         PDFPlugin: Scroll bars do not grow on hover
         https://bugs.webkit.org/show_bug.cgi?id=103382
         <rdar://problem/12555262>

Modified: trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.h (135924 => 135925)


--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.h	2012-11-27 22:42:14 UTC (rev 135924)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.h	2012-11-27 22:45:49 UTC (rev 135925)
@@ -102,6 +102,8 @@
     
     bool supportsForms();
 
+    void updatePageAndDeviceScaleFactors();
+
     RetainPtr<CALayer> m_containerLayer;
     RetainPtr<CALayer> m_contentLayer;
     RetainPtr<CALayer> m_horizontalScrollbarLayer;

Modified: trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm (135924 => 135925)


--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm	2012-11-27 22:42:14 UTC (rev 135924)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm	2012-11-27 22:45:49 UTC (rev 135925)
@@ -303,7 +303,7 @@
     [m_pdfLayerController.get() setFrameSize:size()];
     m_pdfLayerController.get().document = document.get();
 
-    [m_pdfLayerController.get() setDeviceScaleFactor:controller()->contentsScaleFactor()];
+    updatePageAndDeviceScaleFactors();
     
     if (handlesPageScaleFactor())
         pluginView()->setPageScaleFactor([m_pdfLayerController.get() contentScaleFactor], IntPoint());
@@ -316,11 +316,20 @@
     runScriptsInPDFDocument();
 }
 
-void PDFPlugin::contentsScaleFactorChanged(float contentsScaleFactor)
+void PDFPlugin::updatePageAndDeviceScaleFactors()
 {
-    [m_pdfLayerController.get() setDeviceScaleFactor:contentsScaleFactor];
+    double newScaleFactor = controller()->contentsScaleFactor();
+    if (!handlesPageScaleFactor())
+        newScaleFactor *= webFrame()->page()->pageScaleFactor();
+
+    [m_pdfLayerController.get() setDeviceScaleFactor:newScaleFactor];
 }
 
+void PDFPlugin::contentsScaleFactorChanged(float)
+{
+    updatePageAndDeviceScaleFactors();
+}
+
 void PDFPlugin::calculateSizes()
 {
     // FIXME: This should come straight from PDFKit.
@@ -435,7 +444,11 @@
         // FIXME: Instead of m_lastMousePositionInPluginCoordinates, we should use the zoom origin from PluginView::setPageScaleFactor.
         if (magnification)
             [m_pdfLayerController.get() magnifyWithMagnification:magnification atPoint:convertFromPluginToPDFView(m_lastMousePositionInPluginCoordinates) immediately:NO];
-    }
+    } else {
+        // If we don't handle page scale ourselves, we need to respect our parent page's
+        // scale, which may have changed.
+        updatePageAndDeviceScaleFactors();
+    } 
 
     calculateSizes();
     updateScrollbars();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to