Title: [148238] trunk/Source/WebKit2
Revision
148238
Author
[email protected]
Date
2013-04-11 14:50:03 -0700 (Thu, 11 Apr 2013)

Log Message

InjectedBundleNodeHandle::imageForRect doesn't respect device scale factor or highlighting option
https://bugs.webkit.org/show_bug.cgi?id=114466
<rdar://problem/13508513>

Reviewed by Simon Fraser.

Respect the device scale factor when creating the snapshot image.
Clear the snapshot image before drawing into it.
Respect SnapshotOptionsExcludeSelectionHighlighting.

* WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp:
(WebKit::imageForRect):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (148237 => 148238)


--- trunk/Source/WebKit2/ChangeLog	2013-04-11 21:42:44 UTC (rev 148237)
+++ trunk/Source/WebKit2/ChangeLog	2013-04-11 21:50:03 UTC (rev 148238)
@@ -1,3 +1,18 @@
+2013-04-11  Tim Horton  <[email protected]>
+
+        InjectedBundleNodeHandle::imageForRect doesn't respect device scale factor or highlighting option
+        https://bugs.webkit.org/show_bug.cgi?id=114466
+        <rdar://problem/13508513>
+
+        Reviewed by Simon Fraser.
+
+        Respect the device scale factor when creating the snapshot image.
+        Clear the snapshot image before drawing into it.
+        Respect SnapshotOptionsExcludeSelectionHighlighting.
+
+        * WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp:
+        (WebKit::imageForRect):
+
 2013-04-11  Commit Queue  <[email protected]>
 
         Unreviewed, rolling out r148034, r148052, r148097, and

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp (148237 => 148238)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp	2013-04-11 21:42:44 UTC (rev 148237)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp	2013-04-11 21:50:03 UTC (rev 148238)
@@ -45,6 +45,7 @@
 #include <WebCore/IntRect.h>
 #include <WebCore/JSNode.h>
 #include <WebCore/Node.h>
+#include <WebCore/Page.h>
 #include <WebCore/RenderObject.h>
 #include <wtf/HashMap.h>
 #include <wtf/text/WTFString.h>
@@ -125,15 +126,25 @@
 
 static PassRefPtr<WebImage> imageForRect(FrameView* frameView, const IntRect& rect, SnapshotOptions options)
 {
-    RefPtr<WebImage> snapshot = WebImage::create(rect.size(), snapshotOptionsToImageOptions(options));
+    IntSize bitmapSize = rect.size();
+    float scaleFactor = frameView->frame()->page()->deviceScaleFactor();
+    bitmapSize.scale(scaleFactor);
+
+    RefPtr<WebImage> snapshot = WebImage::create(bitmapSize, snapshotOptionsToImageOptions(options));
     if (!snapshot->bitmap())
         return 0;
 
     OwnPtr<GraphicsContext> graphicsContext = snapshot->bitmap()->createGraphicsContext();
+    graphicsContext->clearRect(IntRect(IntPoint(), bitmapSize));
+    graphicsContext->applyDeviceScaleFactor(scaleFactor);
     graphicsContext->translate(-rect.x(), -rect.y());
 
-    frameView->paintContentsForSnapshot(graphicsContext.get(), rect, FrameView::IncludeSelection, FrameView::DocumentCoordinates);
+    FrameView::SelectionInSnaphot shouldPaintSelection = FrameView::IncludeSelection;
+    if (options & SnapshotOptionsExcludeSelectionHighlighting)
+        shouldPaintSelection = FrameView::ExcludeSelection;
 
+    frameView->paintContentsForSnapshot(graphicsContext.get(), rect, shouldPaintSelection, FrameView::DocumentCoordinates);
+
     return snapshot.release();
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to