Title: [134315] trunk/Source/WebKit2
Revision
134315
Author
[email protected]
Date
2012-11-12 14:57:54 -0800 (Mon, 12 Nov 2012)

Log Message

PDFPlugin should support non-1 device scale factor
https://bugs.webkit.org/show_bug.cgi?id=101923

Reviewed by Alexey Proskuryakov.

Do the appropriate plumbing to ensure that PDFPlugin handles device scale factor > 1
(it's called contentsScaleFactor in plugins), both for normal drawing and for snapshotting.

* WebProcess/Plugins/PDF/PDFLayerControllerDetails.h: Add deviceScaleFactor setter/getter to PDFLayerController.
* WebProcess/Plugins/PDF/PDFPlugin.h:
(PDFPlugin): Override contentsScaleFactorChanged.
* WebProcess/Plugins/PDF/PDFPlugin.mm:
(WebKit::PDFPlugin::pdfDocumentDidLoad): Plumb device scale factor through to PDFLayerController.
(WebKit::PDFPlugin::contentsScaleFactorChanged): Plumb device scale factor through to PDFLayerController
when we're notified that it has changed.
(WebKit::PDFPlugin::snapshot): Create snapshots with the device scale factor applied.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (134314 => 134315)


--- trunk/Source/WebKit2/ChangeLog	2012-11-12 22:54:42 UTC (rev 134314)
+++ trunk/Source/WebKit2/ChangeLog	2012-11-12 22:57:54 UTC (rev 134315)
@@ -1,3 +1,22 @@
+2012-11-12  Tim Horton  <[email protected]>
+
+        PDFPlugin should support non-1 device scale factor
+        https://bugs.webkit.org/show_bug.cgi?id=101923
+
+        Reviewed by Alexey Proskuryakov.
+
+        Do the appropriate plumbing to ensure that PDFPlugin handles device scale factor > 1
+        (it's called contentsScaleFactor in plugins), both for normal drawing and for snapshotting.
+
+        * WebProcess/Plugins/PDF/PDFLayerControllerDetails.h: Add deviceScaleFactor setter/getter to PDFLayerController.
+        * WebProcess/Plugins/PDF/PDFPlugin.h:
+        (PDFPlugin): Override contentsScaleFactorChanged.
+        * WebProcess/Plugins/PDF/PDFPlugin.mm:
+        (WebKit::PDFPlugin::pdfDocumentDidLoad): Plumb device scale factor through to PDFLayerController.
+        (WebKit::PDFPlugin::contentsScaleFactorChanged): Plumb device scale factor through to PDFLayerController
+        when we're notified that it has changed.
+        (WebKit::PDFPlugin::snapshot): Create snapshots with the device scale factor applied.
+
 2012-11-12  Anders Carlsson  <[email protected]>
 
         Rename RemoteLayerTreeController to RemoteLayerTreeContext

Modified: trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFLayerControllerDetails.h (134314 => 134315)


--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFLayerControllerDetails.h	2012-11-12 22:54:42 UTC (rev 134314)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFLayerControllerDetails.h	2012-11-12 22:57:54 UTC (rev 134315)
@@ -56,6 +56,9 @@
 - (CGFloat)tileScaleFactor;
 - (void)setTileScaleFactor:(CGFloat)scaleFactor;
 
+- (CGFloat)deviceScaleFactor;
+- (void)setDeviceScaleFactor:(CGFloat)scaleFactor;
+
 - (CGSize)contentSize;
 - (CGSize)contentSizeRespectingZoom;
 

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


--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.h	2012-11-12 22:54:42 UTC (rev 134314)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.h	2012-11-12 22:57:54 UTC (rev 134315)
@@ -80,6 +80,7 @@
     virtual PassRefPtr<ShareableBitmap> snapshot() OVERRIDE;
     virtual PlatformLayer* pluginLayer() OVERRIDE;
     virtual void geometryDidChange(const WebCore::IntSize& pluginSize, const WebCore::IntRect& clipRect, const WebCore::AffineTransform& pluginToRootViewTransform) OVERRIDE;
+    virtual void contentsScaleFactorChanged(float) OVERRIDE;
     virtual bool handleMouseEvent(const WebMouseEvent&) OVERRIDE;
     virtual bool handleKeyboardEvent(const WebKeyboardEvent&) OVERRIDE;
     virtual bool handleEditingCommand(const String& commandName, const String& argument) OVERRIDE;

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


--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm	2012-11-12 22:54:42 UTC (rev 134314)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm	2012-11-12 22:57:54 UTC (rev 134315)
@@ -292,6 +292,8 @@
 
     [m_pdfLayerController.get() setFrameSize:size()];
     m_pdfLayerController.get().document = document.get();
+
+    [m_pdfLayerController.get() setDeviceScaleFactor:controller()->contentsScaleFactor()];
     
     if (handlesPageScaleFactor())
         pluginView()->setPageScaleFactor([m_pdfLayerController.get() tileScaleFactor], IntPoint());
@@ -301,11 +303,14 @@
     calculateSizes();
     updateScrollbars();
 
-    controller()->invalidate(IntRect(IntPoint(), size()));
-    
     runScriptsInPDFDocument();
 }
 
+void PDFPlugin::contentsScaleFactorChanged(float contentsScaleFactor)
+{
+    [m_pdfLayerController.get() setDeviceScaleFactor:contentsScaleFactor];
+}
+
 void PDFPlugin::calculateSizes()
 {
     // FIXME: This should come straight from PDFKit.
@@ -369,14 +374,15 @@
 {
     if (size().isEmpty())
         return 0;
-    
-    // FIXME: Support non-1 page/deviceScaleFactor.
+
+    float contentsScaleFactor = controller()->contentsScaleFactor();
     IntSize backingStoreSize = size();
+    backingStoreSize.scale(contentsScaleFactor);
 
     RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(backingStoreSize, ShareableBitmap::SupportsAlpha);
     OwnPtr<GraphicsContext> context = bitmap->createGraphicsContext();
 
-    context->scale(FloatSize(1, -1));
+    context->scale(FloatSize(contentsScaleFactor, -contentsScaleFactor));
     context->translate(0, -size().height());
 
     [m_pdfLayerController.get() snapshotInContext:context->platformContext()];
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to