Changeset 278614 in webkit
- Timestamp:
- Jun 8, 2021, 9:53:06 AM (5 years ago)
- Location:
- trunk/Source
- Files:
-
- 9 edited
-
WebCore/ChangeLog (modified) (1 diff)
-
WebCore/inspector/agents/InspectorPageAgent.cpp (modified) (2 diffs)
-
WebCore/page/FrameSnapshotting.cpp (modified) (3 diffs)
-
WebCore/page/FrameSnapshotting.h (modified) (3 diffs)
-
WebCore/page/PageConsoleClient.cpp (modified) (2 diffs)
-
WebCore/page/TextIndicator.cpp (modified) (3 diffs)
-
WebCore/platform/DragImage.cpp (modified) (4 diffs)
-
WebKit/ChangeLog (modified) (1 diff)
-
WebKit/WebProcess/WebPage/WebFrame.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r278611 r278614 1 2021-06-08 Devin Rousso <drousso@apple.com> 2 3 Require that callsites of `SnapshotOptions` specify a `PixelFormat` and `DestinationColorSpace` 4 https://bugs.webkit.org/show_bug.cgi?id=226756 5 6 Reviewed by Sam Weinig. 7 8 Don't wrap `PixelFormat` or `DestinationColorSpace` with `std::optional` as we want each 9 callsite to explicity configure them. This makes it easier to find where values for each 10 are used as there's no implicit behavior. 11 12 No behavior change. Followup after r278565. 13 14 * page/FrameSnapshotting.h: 15 * page/FrameSnapshotting.cpp: 16 (WebCore::snapshotFrameRect): 17 (WebCore::snapshotFrameRectWithClip): 18 (WebCore::snapshotNode): 19 (WebCore::snapshotSelection): 20 21 * inspector/agents/InspectorPageAgent.cpp: 22 (WebCore::InspectorPageAgent::snapshotNode): 23 (WebCore::InspectorPageAgent::snapshotRect): 24 * page/PageConsoleClient.cpp: 25 (WebCore::PageConsoleClient::screenshot): 26 * page/TextIndicator.cpp: 27 (WebCore::snapshotOptionsForTextIndicatorOptions): 28 (WebCore::takeSnapshots): 29 * platform/DragImage.cpp: 30 (WebCore::createDragImageForNode): 31 (WebCore::createDragImageForSelection): 32 (WebCore::createDragImageForRange): 33 (WebCore::createDragImageForImage): 34 1 35 2021-06-08 Sam Weinig <weinig@apple.com> 2 36 -
trunk/Source/WebCore/inspector/agents/InspectorPageAgent.cpp
r278565 r278614 1073 1073 return makeUnexpected(errorString); 1074 1074 1075 auto snapshot = WebCore::snapshotNode(m_inspectedPage.mainFrame(), *node );1075 auto snapshot = WebCore::snapshotNode(m_inspectedPage.mainFrame(), *node, { { }, PixelFormat::BGRA8, DestinationColorSpace::SRGB() }); 1076 1076 if (!snapshot) 1077 1077 return makeUnexpected("Could not capture snapshot"_s); … … 1082 1082 Protocol::ErrorStringOr<String> InspectorPageAgent::snapshotRect(int x, int y, int width, int height, Protocol::Page::CoordinateSystem coordinateSystem) 1083 1083 { 1084 SnapshotOptions options ;1084 SnapshotOptions options { { }, PixelFormat::BGRA8, DestinationColorSpace::SRGB() }; 1085 1085 if (coordinateSystem == Protocol::Page::CoordinateSystem::Viewport) 1086 1086 options.flags.add(SnapshotFlags::InViewCoordinates); -
trunk/Source/WebCore/page/FrameSnapshotting.cpp
r278565 r278614 32 32 #include "FrameSnapshotting.h" 33 33 34 #include "DestinationColorSpace.h"35 34 #include "Document.h" 36 35 #include "FloatRect.h" … … 41 40 #include "ImageBuffer.h" 42 41 #include "Page.h" 43 #include "PixelFormat.h"44 42 #include "RenderObject.h" 45 43 #include "Settings.h" … … 115 113 scaleFactor = ceilf(scaleFactor); 116 114 117 auto buffer = ImageBuffer::create(imageRect.size(), RenderingMode::Unaccelerated, scaleFactor, options.colorSpace .value_or(DestinationColorSpace::SRGB()), options.pixelFormat.value_or(PixelFormat::BGRA8));115 auto buffer = ImageBuffer::create(imageRect.size(), RenderingMode::Unaccelerated, scaleFactor, options.colorSpace, options.pixelFormat); 118 116 if (!buffer) 119 117 return nullptr; -
trunk/Source/WebCore/page/FrameSnapshotting.h
r278565 r278614 30 30 #pragma once 31 31 32 #include "DestinationColorSpace.h" 33 #include "PixelFormat.h" 32 34 #include <memory> 33 #include <optional>34 35 #include <wtf/Forward.h> 35 36 36 37 namespace WebCore { 37 38 38 class DestinationColorSpace;39 39 class FloatRect; 40 40 class Frame; … … 42 42 class ImageBuffer; 43 43 class Node; 44 enum class PixelFormat : uint8_t;45 44 46 45 enum class SnapshotFlags : uint8_t { … … 55 54 56 55 struct SnapshotOptions { 57 OptionSet<SnapshotFlags> flags { };58 std::optional<PixelFormat> pixelFormat { };59 std::optional<DestinationColorSpace> colorSpace { };56 OptionSet<SnapshotFlags> flags; 57 PixelFormat pixelFormat; 58 DestinationColorSpace colorSpace; 60 59 }; 61 60 62 WEBCORE_EXPORT RefPtr<ImageBuffer> snapshotFrameRect(Frame&, const IntRect&, SnapshotOptions&& = { });63 RefPtr<ImageBuffer> snapshotFrameRectWithClip(Frame&, const IntRect&, const Vector<FloatRect>& clipRects, SnapshotOptions&& = { });64 RefPtr<ImageBuffer> snapshotNode(Frame&, Node&, SnapshotOptions&& = { });65 WEBCORE_EXPORT RefPtr<ImageBuffer> snapshotSelection(Frame&, SnapshotOptions&& = { });61 WEBCORE_EXPORT RefPtr<ImageBuffer> snapshotFrameRect(Frame&, const IntRect&, SnapshotOptions&&); 62 RefPtr<ImageBuffer> snapshotFrameRectWithClip(Frame&, const IntRect&, const Vector<FloatRect>& clipRects, SnapshotOptions&&); 63 RefPtr<ImageBuffer> snapshotNode(Frame&, Node&, SnapshotOptions&&); 64 WEBCORE_EXPORT RefPtr<ImageBuffer> snapshotSelection(Frame&, SnapshotOptions&&); 66 65 67 66 } // namespace WebCore -
trunk/Source/WebCore/page/PageConsoleClient.cpp
r278565 r278614 359 359 if (dataURL.isEmpty()) { 360 360 if (!snapshot) 361 snapshot = WebCore::snapshotNode(m_page.mainFrame(), *node );361 snapshot = WebCore::snapshotNode(m_page.mainFrame(), *node, { { }, PixelFormat::BGRA8, DestinationColorSpace::SRGB() }); 362 362 363 363 if (snapshot) … … 405 405 // If no target is provided, capture an image of the viewport. 406 406 IntRect imageRect(IntPoint::zero(), m_page.mainFrame().view()->sizeForVisibleContent()); 407 if (auto snapshot = WebCore::snapshotFrameRect(m_page.mainFrame(), imageRect, { { SnapshotFlags::InViewCoordinates } }))407 if (auto snapshot = WebCore::snapshotFrameRect(m_page.mainFrame(), imageRect, { { SnapshotFlags::InViewCoordinates }, PixelFormat::BGRA8, DestinationColorSpace::SRGB() })) 408 408 dataURL = snapshot->toDataURL("image/png"_s, std::nullopt, PreserveResolution::Yes); 409 409 } -
trunk/Source/WebCore/page/TextIndicator.cpp
r278565 r278614 128 128 static SnapshotOptions snapshotOptionsForTextIndicatorOptions(OptionSet<TextIndicatorOption> options) 129 129 { 130 SnapshotOptions snapshotOptions; 131 snapshotOptions.flags.add(SnapshotFlags::PaintWithIntegralScaleFactor); 130 SnapshotOptions snapshotOptions { { SnapshotFlags::PaintWithIntegralScaleFactor }, PixelFormat::BGRA8, DestinationColorSpace::SRGB() }; 132 131 133 132 if (!options.contains(TextIndicatorOption::PaintAllContent)) { … … 163 162 if (data.options.contains(TextIndicatorOption::IncludeSnapshotWithSelectionHighlight)) { 164 163 float snapshotScaleFactor; 165 data.contentImageWithHighlight = takeSnapshot(frame, snapshotRect, { }, snapshotScaleFactor, clipRectsInDocumentCoordinates);164 data.contentImageWithHighlight = takeSnapshot(frame, snapshotRect, { { }, PixelFormat::BGRA8, DestinationColorSpace::SRGB() }, snapshotScaleFactor, clipRectsInDocumentCoordinates); 166 165 ASSERT(!data.contentImageWithHighlight || data.contentImageScaleFactor >= snapshotScaleFactor); 167 166 } … … 170 169 float snapshotScaleFactor; 171 170 auto snapshotRect = frame.view()->visibleContentRect(); 172 data.contentImageWithoutSelection = takeSnapshot(frame, snapshotRect, { { SnapshotFlags::PaintEverythingExcludingSelection } }, snapshotScaleFactor, { });171 data.contentImageWithoutSelection = takeSnapshot(frame, snapshotRect, { { SnapshotFlags::PaintEverythingExcludingSelection }, PixelFormat::BGRA8, DestinationColorSpace::SRGB() }, snapshotScaleFactor, { }); 173 172 data.contentImageWithoutSelectionRectInRootViewCoordinates = frame.view()->contentsToRootView(snapshotRect); 174 173 } -
trunk/Source/WebCore/platform/DragImage.cpp
r278565 r278614 120 120 { 121 121 ScopedNodeDragEnabler enableDrag(frame, node); 122 return createDragImageFromSnapshot(snapshotNode(frame, node ), &node);122 return createDragImageFromSnapshot(snapshotNode(frame, node, { { }, PixelFormat::BGRA8, DestinationColorSpace::SRGB() }), &node); 123 123 } 124 124 … … 127 127 DragImageRef createDragImageForSelection(Frame& frame, TextIndicatorData&, bool forceBlackText) 128 128 { 129 SnapshotOptions options ;129 SnapshotOptions options { { }, PixelFormat::BGRA8, DestinationColorSpace::SRGB() }; 130 130 if (forceBlackText) 131 131 options.flags.add(SnapshotFlags::ForceBlackText); … … 185 185 return nullptr; 186 186 187 SnapshotOptions options; 188 options.flags.add(SnapshotFlags::PaintSelectionOnly); 187 SnapshotOptions options { { SnapshotFlags::PaintSelectionOnly }, PixelFormat::BGRA8, DestinationColorSpace::SRGB() }; 189 188 if (forceBlackText) 190 189 options.flags.add(SnapshotFlags::ForceBlackText); … … 219 218 imageRect = paintingRect; 220 219 221 return createDragImageFromSnapshot(snapshotNode(frame, node ), &node);220 return createDragImageFromSnapshot(snapshotNode(frame, node, { { }, PixelFormat::BGRA8, DestinationColorSpace::SRGB() }), &node); 222 221 } 223 222 -
trunk/Source/WebKit/ChangeLog
r278603 r278614 1 2021-06-08 Devin Rousso <drousso@apple.com> 2 3 Require that callsites of `SnapshotOptions` specify a `PixelFormat` and `DestinationColorSpace` 4 https://bugs.webkit.org/show_bug.cgi?id=226756 5 6 Reviewed by Sam Weinig. 7 8 Don't wrap `PixelFormat` or `DestinationColorSpace` with `std::optional` as we want each 9 callsite to explicity configure them. This makes it easier to find where values for each 10 are used as there's no implicit behavior. 11 12 No behavior change. Followup after r278565. 13 14 * WebProcess/WebPage/WebFrame.cpp: 15 (WebKit::WebFrame::createSelectionSnapshot const): 16 1 17 2021-06-08 Jean-Yves Avenard <jya@apple.com> 2 18 -
trunk/Source/WebKit/WebProcess/WebPage/WebFrame.cpp
r278565 r278614 843 843 RefPtr<ShareableBitmap> WebFrame::createSelectionSnapshot() const 844 844 { 845 auto snapshot = snapshotSelection(*coreFrame(), { { WebCore::SnapshotFlags::ForceBlackText } });845 auto snapshot = snapshotSelection(*coreFrame(), { { WebCore::SnapshotFlags::ForceBlackText }, PixelFormat::BGRA8, DestinationColorSpace::SRGB() }); 846 846 if (!snapshot) 847 847 return nullptr;
Note:
See TracChangeset
for help on using the changeset viewer.