[iOS] Frame snapshots don't factor in page scale
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Jul 2015 00:19:58 +0000 (00:19 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Jul 2015 00:19:58 +0000 (00:19 +0000)
https://bugs.webkit.org/show_bug.cgi?id=147239
<rdar://problem/21905756>

Reviewed by Simon Fraser.

* page/FrameSnapshotting.cpp:
(WebCore::snapshotFrameRect):
Apply page scale when determining the backing store size and setting up the context.

* page/TextIndicator.cpp:
(WebCore::TextIndicator::createWithSelectionInFrame):
Don't assume snapshotFrameRect gave us an image with scale=deviceScale, because it
will factor in the pageScale too.

* platform/graphics/ImageBuffer.h:
(WebCore::ImageBuffer::resolutionScale):
Expose resolutionScale.

* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::addToOverlapMap):
This has been true for a long time.

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

Source/WebCore/ChangeLog
Source/WebCore/page/FrameSnapshotting.cpp
Source/WebCore/page/TextIndicator.cpp
Source/WebCore/platform/graphics/ImageBuffer.h
Source/WebCore/rendering/RenderLayerCompositor.cpp

index 720231b..9edb066 100644 (file)
@@ -1,3 +1,28 @@
+2015-07-23  Timothy Horton  <timothy_horton@apple.com>
+
+        [iOS] Frame snapshots don't factor in page scale
+        https://bugs.webkit.org/show_bug.cgi?id=147239
+        <rdar://problem/21905756>
+
+        Reviewed by Simon Fraser.
+
+        * page/FrameSnapshotting.cpp:
+        (WebCore::snapshotFrameRect):
+        Apply page scale when determining the backing store size and setting up the context.
+
+        * page/TextIndicator.cpp:
+        (WebCore::TextIndicator::createWithSelectionInFrame):
+        Don't assume snapshotFrameRect gave us an image with scale=deviceScale, because it
+        will factor in the pageScale too.
+
+        * platform/graphics/ImageBuffer.h:
+        (WebCore::ImageBuffer::resolutionScale):
+        Expose resolutionScale.
+
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::addToOverlapMap):
+        This has been true for a long time.
+
 2015-07-23  Jon Davis  <jond@apple.com>
 
         Adding Web Components to feature status page.
index 0c308da..6bfce12 100644 (file)
@@ -39,6 +39,7 @@
 #include "ImageBuffer.h"
 #include "Page.h"
 #include "RenderObject.h"
+#include "Settings.h"
 
 namespace WebCore {
 
@@ -93,7 +94,12 @@ std::unique_ptr<ImageBuffer> snapshotFrameRect(Frame& frame, const IntRect& imag
     // Other paint behaviors are set by paintContentsForSnapshot.
     frame.view()->setPaintBehavior(paintBehavior);
 
-    std::unique_ptr<ImageBuffer> buffer = ImageBuffer::create(imageRect.size(), frame.page()->deviceScaleFactor(), ColorSpaceDeviceRGB);
+    float scaleFactor = frame.page()->deviceScaleFactor();
+
+    if (frame.settings().delegatesPageScaling())
+        scaleFactor *= frame.page()->pageScaleFactor();
+
+    std::unique_ptr<ImageBuffer> buffer = ImageBuffer::create(imageRect.size(), scaleFactor, ColorSpaceDeviceRGB);
     if (!buffer)
         return nullptr;
     buffer->context()->translate(-imageRect.x(), -imageRect.y());
index ccefc2b..4c0ec6a 100644 (file)
@@ -163,7 +163,7 @@ RefPtr<TextIndicator> TextIndicator::createWithSelectionInFrame(Frame& frame, Te
     data.selectionRectInRootViewCoordinates = frame.view()->contentsToRootView(enclosingIntRect(frame.selection().selectionBounds()));
     data.textBoundingRectInRootViewCoordinates = textBoundingRectInRootViewCoordinates;
     data.textRectsInBoundingRectCoordinates = textRectsInBoundingRectCoordinates;
-    data.contentImageScaleFactor = frame.page()->deviceScaleFactor();
+    data.contentImageScaleFactor = indicatorBuffer->resolutionScale();
     data.contentImage = indicatorBitmap;
     data.contentImageWithHighlight = indicatorBitmapWithHighlight;
     data.presentationTransition = presentationTransition;
index 66c1d8f..605c45c 100644 (file)
@@ -92,6 +92,8 @@ public:
     const IntSize& internalSize() const { return m_size; }
     const IntSize& logicalSize() const { return m_logicalSize; }
 
+    float resolutionScale() const { return m_resolutionScale; }
+
     WEBCORE_EXPORT GraphicsContext* context() const;
 
     WEBCORE_EXPORT RefPtr<Image> copyImage(BackingStoreCopy = CopyBackingStore, ScaleBehavior = Scaled) const;
index 19fbbb3..ea278cc 100644 (file)
@@ -1233,12 +1233,9 @@ void RenderLayerCompositor::addToOverlapMap(OverlapMap& overlapMap, const Render
     LayoutRect clipRect = layer.backgroundClipRect(RenderLayer::ClipRectsContext(&rootRenderLayer(), AbsoluteClipRects)).rect(); // FIXME: Incorrect for CSS regions.
 
     // On iOS, pageScaleFactor() is not applied by RenderView, so we should not scale here.
-    // FIXME: Set Settings::delegatesPageScaling to true for iOS.
-#if !PLATFORM(IOS)
     const Settings& settings = m_renderView.frameView().frame().settings();
     if (!settings.delegatesPageScaling())
         clipRect.scale(pageScaleFactor());
-#endif
     clipRect.intersect(extent.bounds);
     overlapMap.add(clipRect);
 }