Title: [120876] trunk
Revision
120876
Author
[email protected]
Date
2012-06-20 15:49:13 -0700 (Wed, 20 Jun 2012)

Log Message

Account for device scale factor when creating image for dragging.
https://bugs.webkit.org/show_bug.cgi?id=89489

Patch by Varun Jain <[email protected]> on 2012-06-20
Reviewed by Adam Barth.

.:

* ManualTests/chromium/drag-image-accounts-for-device-scale.html: Added.

Source/WebCore:

Manual Test: ManualTests/chromium/drag-image-accounts-for-device-scale.html

* page/Frame.cpp:
(WebCore::Frame::nodeImage):
(WebCore::Frame::dragImageForSelection):

Modified Paths

Added Paths

Diff

Modified: trunk/ChangeLog (120875 => 120876)


--- trunk/ChangeLog	2012-06-20 22:36:50 UTC (rev 120875)
+++ trunk/ChangeLog	2012-06-20 22:49:13 UTC (rev 120876)
@@ -1,3 +1,12 @@
+2012-06-20  Varun Jain  <[email protected]>
+
+        Account for device scale factor when creating image for dragging.
+        https://bugs.webkit.org/show_bug.cgi?id=89489
+
+        Reviewed by Adam Barth.
+
+        * ManualTests/chromium/drag-image-accounts-for-device-scale.html: Added.
+
 2012-06-18  Philippe Normand  <[email protected]>
 
         [GStreamer] 0.11 video-sink

Added: trunk/ManualTests/chromium/drag-image-accounts-for-device-scale.html (0 => 120876)


--- trunk/ManualTests/chromium/drag-image-accounts-for-device-scale.html	                        (rev 0)
+++ trunk/ManualTests/chromium/drag-image-accounts-for-device-scale.html	2012-06-20 22:49:13 UTC (rev 120876)
@@ -0,0 +1,10 @@
+<html>
+<body>
+    <p>To test device scale, run chrome with --force-device-scale-factor=2 (or run chrome on a device with > 1 device scale, such as a macbook running in high dpi mode)</p>
+    <p>Select some text and start dragging. If the text in the drag image is rendered at the same size as the text on the page and is not blurry (due to scaling), 1st part of this test passes.</p>
+    <p>For 2nd part, try dragging "Drag me" below. Again, if the text in the drag image is rendered at the same size as the text on the page is not blurry, the test passes.</p>
+    <div draggable='true' id='dragme'>
+        Drag me
+    </div>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (120875 => 120876)


--- trunk/Source/WebCore/ChangeLog	2012-06-20 22:36:50 UTC (rev 120875)
+++ trunk/Source/WebCore/ChangeLog	2012-06-20 22:49:13 UTC (rev 120876)
@@ -1,3 +1,16 @@
+2012-06-20  Varun Jain  <[email protected]>
+
+        Account for device scale factor when creating image for dragging.
+        https://bugs.webkit.org/show_bug.cgi?id=89489
+
+        Reviewed by Adam Barth.
+
+        Manual Test: ManualTests/chromium/drag-image-accounts-for-device-scale.html
+
+        * page/Frame.cpp:
+        (WebCore::Frame::nodeImage):
+        (WebCore::Frame::dragImageForSelection):
+
 2012-06-20  Jacky Jiang  <[email protected]>
 
         Add a != operator to ViewportArguments

Modified: trunk/Source/WebCore/page/Frame.cpp (120875 => 120876)


--- trunk/Source/WebCore/page/Frame.cpp	2012-06-20 22:36:50 UTC (rev 120875)
+++ trunk/Source/WebCore/page/Frame.cpp	2012-06-20 22:49:13 UTC (rev 120876)
@@ -1089,9 +1089,16 @@
     LayoutRect topLevelRect;
     IntRect paintingRect = pixelSnappedIntRect(renderer->paintingRootRect(topLevelRect));
 
+    float deviceScaleFactor = 1;
+    if (m_page)
+        deviceScaleFactor = m_page->deviceScaleFactor();
+    paintingRect.setWidth(paintingRect.width() * deviceScaleFactor);
+    paintingRect.setHeight(paintingRect.height() * deviceScaleFactor);
+
     OwnPtr<ImageBuffer> buffer(ImageBuffer::create(paintingRect.size(), 1, ColorSpaceDeviceRGB));
     if (!buffer)
         return 0;
+    buffer->context()->scale(FloatSize(deviceScaleFactor, deviceScaleFactor));
     buffer->context()->translate(-paintingRect.x(), -paintingRect.y());
     buffer->context()->clip(FloatRect(0, 0, paintingRect.maxX(), paintingRect.maxY()));
 
@@ -1112,9 +1119,16 @@
 
     IntRect paintingRect = enclosingIntRect(selection()->bounds());
 
+    float deviceScaleFactor = 1;
+    if (m_page)
+        deviceScaleFactor = m_page->deviceScaleFactor();
+    paintingRect.setWidth(paintingRect.width() * deviceScaleFactor);
+    paintingRect.setHeight(paintingRect.height() * deviceScaleFactor);
+
     OwnPtr<ImageBuffer> buffer(ImageBuffer::create(paintingRect.size(), 1, ColorSpaceDeviceRGB));
     if (!buffer)
         return 0;
+    buffer->context()->scale(FloatSize(deviceScaleFactor, deviceScaleFactor));
     buffer->context()->translate(-paintingRect.x(), -paintingRect.y());
     buffer->context()->clip(FloatRect(0, 0, paintingRect.maxX(), paintingRect.maxY()));
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to