Web Inspector: Capture Element Screenshot looks fuzzy
authorbburg@apple.com <bburg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 5 Jan 2018 00:00:25 +0000 (00:00 +0000)
committerbburg@apple.com <bburg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 5 Jan 2018 00:00:25 +0000 (00:00 +0000)
commit9b873c9c4c1981dcefbdc4327b2d32b7c5882146
tree6444022ebbf0f0fccb11cb7e8c50a9e9a57404fa
parent1a2fcc096f7d546cb14e61e10f1e8ca96ceaa551
Web Inspector: Capture Element Screenshot looks fuzzy
https://bugs.webkit.org/show_bug.cgi?id=175734
<rdar://problem/33803377>

Reviewed by Joseph Pecoraro and Simon Fraser.

Source/WebCore:

Screenshots taken by Web Inspector were being downscaled from the
internal size to the logical size, causing them to be blurry when
later upscaled to the internal size.

Replace ScaleBehavior { Scaled, Unscaled } with PreserveResolution { No, Yes }.
This is a lot less confusing to read both inside ImageBuffer and at its use sites.

Remove unused CoordinateSystem argument for ImageBuffer::toDataURL,
and replace it with PreserveResolution. Plumb PreserveResolution into toCFData
so that PreserveResolution::Yes will preserve the internal size of
the image buffer, just as it does in other methods that take PreserveResolution.

At the use site in InspectorPageAgent, always request PreserveResolution::Yes snapshots
when taking an element screenshot. For now, keep using downscaled (smaller)
snapshots when capturing canvas previews, as the previews are not full-size.

Test: inspector/page/hidpi-snapshot-size.html

* html/HTMLCanvasElement.cpp:
(WebCore::HTMLCanvasElement::makePresentationCopy):
(WebCore::HTMLCanvasElement::copiedImage const):
* html/canvas/CanvasRenderingContext2DBase.cpp:
(WebCore::CanvasRenderingContext2DBase::createPattern):
* inspector/agents/InspectorPageAgent.cpp:
(WebCore::InspectorPageAgent::snapshotNode):
(WebCore::InspectorPageAgent::snapshotRect):
* page/TextIndicator.cpp:
(WebCore::takeSnapshot):
* platform/DragImage.cpp:
(WebCore::createDragImageFromSnapshot):
* platform/graphics/BitmapImage.cpp:
(WebCore::BitmapImage::drawPattern):
* platform/graphics/ImageBuffer.h:
* platform/graphics/cairo/ImageBufferCairo.cpp:
(WebCore::ImageBuffer::sinkIntoImage):
(WebCore::ImageBuffer::copyImage const):
(WebCore::ImageBuffer::toDataURL const):
* platform/graphics/cg/ImageBufferCG.cpp:
(WebCore::createBitmapImageAfterScalingIfNeeded):
(WebCore::ImageBuffer::copyImage const):
(WebCore::ImageBuffer::sinkIntoImage):
(WebCore::ImageBuffer::toDataURL const):
(WebCore::ImageBuffer::toData const):
(WebCore::ImageBuffer::toCFData const):
* platform/graphics/gtk/ImageBufferGtk.cpp:
(WebCore::ImageBuffer::toDataURL const):
* platform/graphics/win/ImageBufferDirect2D.cpp:
(WebCore::ImageBuffer::copyImage const):
(WebCore::ImageBuffer::sinkIntoImage):
(WebCore::ImageBuffer::toDataURL const):
* svg/graphics/SVGImage.cpp:
(WebCore::SVGImage::drawPatternForContainer):

Source/WebInspectorUI:

Spruce up these functions a bit. They now optionally return a promise
if no callback is supplied. They now can take either a WI.DOMNode or a node id.

* UserInterface/Controllers/DOMTreeManager.js:
(WI.DOMTreeManager.prototype.querySelector):
(WI.DOMTreeManager.prototype.querySelectorAll):

LayoutTests:

* inspector/page/hidpi-snapshot-size-expected.txt: Added.
* inspector/page/hidpi-snapshot-size.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226425 268f45cc-cd09-0410-ab3c-d52691b4dbfc
18 files changed:
LayoutTests/ChangeLog
LayoutTests/inspector/page/hidpi-snapshot-size-expected.txt [new file with mode: 0644]
LayoutTests/inspector/page/hidpi-snapshot-size.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLCanvasElement.cpp
Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp
Source/WebCore/inspector/agents/InspectorPageAgent.cpp
Source/WebCore/page/TextIndicator.cpp
Source/WebCore/platform/DragImage.cpp
Source/WebCore/platform/graphics/BitmapImage.cpp
Source/WebCore/platform/graphics/ImageBuffer.h
Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp
Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp
Source/WebCore/platform/graphics/gtk/ImageBufferGtk.cpp
Source/WebCore/platform/graphics/win/ImageBufferDirect2D.cpp
Source/WebCore/svg/graphics/SVGImage.cpp
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Controllers/DOMTreeManager.js