diff options
Diffstat (limited to 'Source/WebCore/page/FrameSnapshotting.cpp')
| -rw-r--r-- | Source/WebCore/page/FrameSnapshotting.cpp | 27 |
1 files changed, 5 insertions, 22 deletions
diff --git a/Source/WebCore/page/FrameSnapshotting.cpp b/Source/WebCore/page/FrameSnapshotting.cpp index 4714dc666..495406b82 100644 --- a/Source/WebCore/page/FrameSnapshotting.cpp +++ b/Source/WebCore/page/FrameSnapshotting.cpp @@ -35,11 +35,9 @@ #include "Frame.h" #include "FrameSelection.h" #include "FrameView.h" -#include "GraphicsContext.h" #include "ImageBuffer.h" #include "Page.h" #include "RenderObject.h" -#include "Settings.h" namespace WebCore { @@ -88,21 +86,14 @@ std::unique_ptr<ImageBuffer> snapshotFrameRect(Frame& frame, const IntRect& imag paintBehavior |= PaintBehaviorForceBlackText; if (options & SnapshotOptionsPaintSelectionOnly) paintBehavior |= PaintBehaviorSelectionOnly; - if (options & SnapshotOptionsPaintSelectionAndBackgroundsOnly) - paintBehavior |= PaintBehaviorSelectionAndBackgroundsOnly; // Other paint behaviors are set by paintContentsForSnapshot. frame.view()->setPaintBehavior(paintBehavior); - float scaleFactor = frame.page()->deviceScaleFactor(); - - if (frame.settings().delegatesPageScaling()) - scaleFactor *= frame.page()->pageScaleFactor(); - - std::unique_ptr<ImageBuffer> buffer = ImageBuffer::create(imageRect.size(), Unaccelerated, scaleFactor); + std::unique_ptr<ImageBuffer> buffer = ImageBuffer::create(imageRect.size(), frame.page()->deviceScaleFactor(), ColorSpaceDeviceRGB); if (!buffer) return nullptr; - buffer->context().translate(-imageRect.x(), -imageRect.y()); + buffer->context()->translate(-imageRect.x(), -imageRect.y()); frame.view()->paintContentsForSnapshot(buffer->context(), imageRect, shouldIncludeSelection, coordinateSpace); return buffer; @@ -110,19 +101,11 @@ std::unique_ptr<ImageBuffer> snapshotFrameRect(Frame& frame, const IntRect& imag std::unique_ptr<ImageBuffer> snapshotSelection(Frame& frame, SnapshotOptions options) { - auto& selection = frame.selection(); - - if (!selection.isRange()) - return nullptr; - - FloatRect selectionBounds = selection.selectionBounds(); - - // It is possible for the selection bounds to be empty; see https://bugs.webkit.org/show_bug.cgi?id=56645. - if (selectionBounds.isEmpty()) + if (!frame.selection().isRange()) return nullptr; options |= SnapshotOptionsPaintSelectionOnly; - return snapshotFrameRect(frame, enclosingIntRect(selectionBounds), options); + return snapshotFrameRect(frame, enclosingIntRect(frame.selection().bounds()), options); } std::unique_ptr<ImageBuffer> snapshotNode(Frame& frame, Node& node) @@ -136,7 +119,7 @@ std::unique_ptr<ImageBuffer> snapshotNode(Frame& frame, Node& node) frame.view()->setNodeToDraw(&node); LayoutRect topLevelRect; - return snapshotFrameRect(frame, snappedIntRect(node.renderer()->paintingRootRect(topLevelRect))); + return snapshotFrameRect(frame, pixelSnappedIntRect(node.renderer()->paintingRootRect(topLevelRect))); } } // namespace WebCore |
