Diff
Modified: trunk/Source/WebCore/ChangeLog (278613 => 278614)
--- trunk/Source/WebCore/ChangeLog 2021-06-08 16:51:42 UTC (rev 278613)
+++ trunk/Source/WebCore/ChangeLog 2021-06-08 16:53:06 UTC (rev 278614)
@@ -1,3 +1,37 @@
+2021-06-08 Devin Rousso <[email protected]>
+
+ Require that callsites of `SnapshotOptions` specify a `PixelFormat` and `DestinationColorSpace`
+ https://bugs.webkit.org/show_bug.cgi?id=226756
+
+ Reviewed by Sam Weinig.
+
+ Don't wrap `PixelFormat` or `DestinationColorSpace` with `std::optional` as we want each
+ callsite to explicity configure them. This makes it easier to find where values for each
+ are used as there's no implicit behavior.
+
+ No behavior change. Followup after r278565.
+
+ * page/FrameSnapshotting.h:
+ * page/FrameSnapshotting.cpp:
+ (WebCore::snapshotFrameRect):
+ (WebCore::snapshotFrameRectWithClip):
+ (WebCore::snapshotNode):
+ (WebCore::snapshotSelection):
+
+ * inspector/agents/InspectorPageAgent.cpp:
+ (WebCore::InspectorPageAgent::snapshotNode):
+ (WebCore::InspectorPageAgent::snapshotRect):
+ * page/PageConsoleClient.cpp:
+ (WebCore::PageConsoleClient::screenshot):
+ * page/TextIndicator.cpp:
+ (WebCore::snapshotOptionsForTextIndicatorOptions):
+ (WebCore::takeSnapshots):
+ * platform/DragImage.cpp:
+ (WebCore::createDragImageForNode):
+ (WebCore::createDragImageForSelection):
+ (WebCore::createDragImageForRange):
+ (WebCore::createDragImageForImage):
+
2021-06-08 Sam Weinig <[email protected]>
Move some hand rolled CSSProperty predicates to be generated based on new CSSProperties.json properties
Modified: trunk/Source/WebCore/inspector/agents/InspectorPageAgent.cpp (278613 => 278614)
--- trunk/Source/WebCore/inspector/agents/InspectorPageAgent.cpp 2021-06-08 16:51:42 UTC (rev 278613)
+++ trunk/Source/WebCore/inspector/agents/InspectorPageAgent.cpp 2021-06-08 16:53:06 UTC (rev 278614)
@@ -1072,7 +1072,7 @@
if (!node)
return makeUnexpected(errorString);
- auto snapshot = WebCore::snapshotNode(m_inspectedPage.mainFrame(), *node);
+ auto snapshot = WebCore::snapshotNode(m_inspectedPage.mainFrame(), *node, { { }, PixelFormat::BGRA8, DestinationColorSpace::SRGB() });
if (!snapshot)
return makeUnexpected("Could not capture snapshot"_s);
@@ -1081,7 +1081,7 @@
Protocol::ErrorStringOr<String> InspectorPageAgent::snapshotRect(int x, int y, int width, int height, Protocol::Page::CoordinateSystem coordinateSystem)
{
- SnapshotOptions options;
+ SnapshotOptions options { { }, PixelFormat::BGRA8, DestinationColorSpace::SRGB() };
if (coordinateSystem == Protocol::Page::CoordinateSystem::Viewport)
options.flags.add(SnapshotFlags::InViewCoordinates);
Modified: trunk/Source/WebCore/page/FrameSnapshotting.cpp (278613 => 278614)
--- trunk/Source/WebCore/page/FrameSnapshotting.cpp 2021-06-08 16:51:42 UTC (rev 278613)
+++ trunk/Source/WebCore/page/FrameSnapshotting.cpp 2021-06-08 16:53:06 UTC (rev 278614)
@@ -31,7 +31,6 @@
#include "config.h"
#include "FrameSnapshotting.h"
-#include "DestinationColorSpace.h"
#include "Document.h"
#include "FloatRect.h"
#include "Frame.h"
@@ -40,7 +39,6 @@
#include "GraphicsContext.h"
#include "ImageBuffer.h"
#include "Page.h"
-#include "PixelFormat.h"
#include "RenderObject.h"
#include "Settings.h"
#include <wtf/OptionSet.h>
@@ -114,7 +112,7 @@
if (options.flags.contains(SnapshotFlags::PaintWithIntegralScaleFactor))
scaleFactor = ceilf(scaleFactor);
- auto buffer = ImageBuffer::create(imageRect.size(), RenderingMode::Unaccelerated, scaleFactor, options.colorSpace.value_or(DestinationColorSpace::SRGB()), options.pixelFormat.value_or(PixelFormat::BGRA8));
+ auto buffer = ImageBuffer::create(imageRect.size(), RenderingMode::Unaccelerated, scaleFactor, options.colorSpace, options.pixelFormat);
if (!buffer)
return nullptr;
buffer->context().translate(-imageRect.x(), -imageRect.y());
Modified: trunk/Source/WebCore/page/FrameSnapshotting.h (278613 => 278614)
--- trunk/Source/WebCore/page/FrameSnapshotting.h 2021-06-08 16:51:42 UTC (rev 278613)
+++ trunk/Source/WebCore/page/FrameSnapshotting.h 2021-06-08 16:53:06 UTC (rev 278614)
@@ -29,19 +29,18 @@
#pragma once
+#include "DestinationColorSpace.h"
+#include "PixelFormat.h"
#include <memory>
-#include <optional>
#include <wtf/Forward.h>
namespace WebCore {
-class DestinationColorSpace;
class FloatRect;
class Frame;
class IntRect;
class ImageBuffer;
class Node;
-enum class PixelFormat : uint8_t;
enum class SnapshotFlags : uint8_t {
ExcludeSelectionHighlighting = 1 << 0,
@@ -54,14 +53,14 @@
};
struct SnapshotOptions {
- OptionSet<SnapshotFlags> flags { };
- std::optional<PixelFormat> pixelFormat { };
- std::optional<DestinationColorSpace> colorSpace { };
+ OptionSet<SnapshotFlags> flags;
+ PixelFormat pixelFormat;
+ DestinationColorSpace colorSpace;
};
-WEBCORE_EXPORT RefPtr<ImageBuffer> snapshotFrameRect(Frame&, const IntRect&, SnapshotOptions&& = { });
-RefPtr<ImageBuffer> snapshotFrameRectWithClip(Frame&, const IntRect&, const Vector<FloatRect>& clipRects, SnapshotOptions&& = { });
-RefPtr<ImageBuffer> snapshotNode(Frame&, Node&, SnapshotOptions&& = { });
-WEBCORE_EXPORT RefPtr<ImageBuffer> snapshotSelection(Frame&, SnapshotOptions&& = { });
+WEBCORE_EXPORT RefPtr<ImageBuffer> snapshotFrameRect(Frame&, const IntRect&, SnapshotOptions&&);
+RefPtr<ImageBuffer> snapshotFrameRectWithClip(Frame&, const IntRect&, const Vector<FloatRect>& clipRects, SnapshotOptions&&);
+RefPtr<ImageBuffer> snapshotNode(Frame&, Node&, SnapshotOptions&&);
+WEBCORE_EXPORT RefPtr<ImageBuffer> snapshotSelection(Frame&, SnapshotOptions&&);
} // namespace WebCore
Modified: trunk/Source/WebCore/page/PageConsoleClient.cpp (278613 => 278614)
--- trunk/Source/WebCore/page/PageConsoleClient.cpp 2021-06-08 16:51:42 UTC (rev 278613)
+++ trunk/Source/WebCore/page/PageConsoleClient.cpp 2021-06-08 16:53:06 UTC (rev 278614)
@@ -358,7 +358,7 @@
if (dataURL.isEmpty()) {
if (!snapshot)
- snapshot = WebCore::snapshotNode(m_page.mainFrame(), *node);
+ snapshot = WebCore::snapshotNode(m_page.mainFrame(), *node, { { }, PixelFormat::BGRA8, DestinationColorSpace::SRGB() });
if (snapshot)
dataURL = snapshot->toDataURL("image/png"_s, std::nullopt, PreserveResolution::Yes);
@@ -404,7 +404,7 @@
if (!target) {
// If no target is provided, capture an image of the viewport.
IntRect imageRect(IntPoint::zero(), m_page.mainFrame().view()->sizeForVisibleContent());
- if (auto snapshot = WebCore::snapshotFrameRect(m_page.mainFrame(), imageRect, { { SnapshotFlags::InViewCoordinates } }))
+ if (auto snapshot = WebCore::snapshotFrameRect(m_page.mainFrame(), imageRect, { { SnapshotFlags::InViewCoordinates }, PixelFormat::BGRA8, DestinationColorSpace::SRGB() }))
dataURL = snapshot->toDataURL("image/png"_s, std::nullopt, PreserveResolution::Yes);
}
Modified: trunk/Source/WebCore/page/TextIndicator.cpp (278613 => 278614)
--- trunk/Source/WebCore/page/TextIndicator.cpp 2021-06-08 16:51:42 UTC (rev 278613)
+++ trunk/Source/WebCore/page/TextIndicator.cpp 2021-06-08 16:53:06 UTC (rev 278614)
@@ -127,8 +127,7 @@
static SnapshotOptions snapshotOptionsForTextIndicatorOptions(OptionSet<TextIndicatorOption> options)
{
- SnapshotOptions snapshotOptions;
- snapshotOptions.flags.add(SnapshotFlags::PaintWithIntegralScaleFactor);
+ SnapshotOptions snapshotOptions { { SnapshotFlags::PaintWithIntegralScaleFactor }, PixelFormat::BGRA8, DestinationColorSpace::SRGB() };
if (!options.contains(TextIndicatorOption::PaintAllContent)) {
if (options.contains(TextIndicatorOption::PaintBackgrounds))
@@ -162,7 +161,7 @@
if (data.options.contains(TextIndicatorOption::IncludeSnapshotWithSelectionHighlight)) {
float snapshotScaleFactor;
- data.contentImageWithHighlight = takeSnapshot(frame, snapshotRect, { }, snapshotScaleFactor, clipRectsInDocumentCoordinates);
+ data.contentImageWithHighlight = takeSnapshot(frame, snapshotRect, { { }, PixelFormat::BGRA8, DestinationColorSpace::SRGB() }, snapshotScaleFactor, clipRectsInDocumentCoordinates);
ASSERT(!data.contentImageWithHighlight || data.contentImageScaleFactor >= snapshotScaleFactor);
}
@@ -169,7 +168,7 @@
if (data.options.contains(TextIndicatorOption::IncludeSnapshotOfAllVisibleContentWithoutSelection)) {
float snapshotScaleFactor;
auto snapshotRect = frame.view()->visibleContentRect();
- data.contentImageWithoutSelection = takeSnapshot(frame, snapshotRect, { { SnapshotFlags::PaintEverythingExcludingSelection } }, snapshotScaleFactor, { });
+ data.contentImageWithoutSelection = takeSnapshot(frame, snapshotRect, { { SnapshotFlags::PaintEverythingExcludingSelection }, PixelFormat::BGRA8, DestinationColorSpace::SRGB() }, snapshotScaleFactor, { });
data.contentImageWithoutSelectionRectInRootViewCoordinates = frame.view()->contentsToRootView(snapshotRect);
}
Modified: trunk/Source/WebCore/platform/DragImage.cpp (278613 => 278614)
--- trunk/Source/WebCore/platform/DragImage.cpp 2021-06-08 16:51:42 UTC (rev 278613)
+++ trunk/Source/WebCore/platform/DragImage.cpp 2021-06-08 16:53:06 UTC (rev 278614)
@@ -119,7 +119,7 @@
DragImageRef createDragImageForNode(Frame& frame, Node& node)
{
ScopedNodeDragEnabler enableDrag(frame, node);
- return createDragImageFromSnapshot(snapshotNode(frame, node), &node);
+ return createDragImageFromSnapshot(snapshotNode(frame, node, { { }, PixelFormat::BGRA8, DestinationColorSpace::SRGB() }), &node);
}
#if !PLATFORM(IOS_FAMILY) || !ENABLE(DRAG_SUPPORT)
@@ -126,7 +126,7 @@
DragImageRef createDragImageForSelection(Frame& frame, TextIndicatorData&, bool forceBlackText)
{
- SnapshotOptions options;
+ SnapshotOptions options { { }, PixelFormat::BGRA8, DestinationColorSpace::SRGB() };
if (forceBlackText)
options.flags.add(SnapshotFlags::ForceBlackText);
return createDragImageFromSnapshot(snapshotSelection(frame, WTFMove(options)), nullptr);
@@ -184,8 +184,7 @@
if (!startRenderer || !endRenderer)
return nullptr;
- SnapshotOptions options;
- options.flags.add(SnapshotFlags::PaintSelectionOnly);
+ SnapshotOptions options { { SnapshotFlags::PaintSelectionOnly }, PixelFormat::BGRA8, DestinationColorSpace::SRGB() };
if (forceBlackText)
options.flags.add(SnapshotFlags::ForceBlackText);
@@ -218,7 +217,7 @@
elementRect = snappedIntRect(topLevelRect);
imageRect = paintingRect;
- return createDragImageFromSnapshot(snapshotNode(frame, node), &node);
+ return createDragImageFromSnapshot(snapshotNode(frame, node, { { }, PixelFormat::BGRA8, DestinationColorSpace::SRGB() }), &node);
}
#if !PLATFORM(IOS_FAMILY) || !ENABLE(DRAG_SUPPORT)
Modified: trunk/Source/WebKit/ChangeLog (278613 => 278614)
--- trunk/Source/WebKit/ChangeLog 2021-06-08 16:51:42 UTC (rev 278613)
+++ trunk/Source/WebKit/ChangeLog 2021-06-08 16:53:06 UTC (rev 278614)
@@ -1,3 +1,19 @@
+2021-06-08 Devin Rousso <[email protected]>
+
+ Require that callsites of `SnapshotOptions` specify a `PixelFormat` and `DestinationColorSpace`
+ https://bugs.webkit.org/show_bug.cgi?id=226756
+
+ Reviewed by Sam Weinig.
+
+ Don't wrap `PixelFormat` or `DestinationColorSpace` with `std::optional` as we want each
+ callsite to explicity configure them. This makes it easier to find where values for each
+ are used as there's no implicit behavior.
+
+ No behavior change. Followup after r278565.
+
+ * WebProcess/WebPage/WebFrame.cpp:
+ (WebKit::WebFrame::createSelectionSnapshot const):
+
2021-06-08 Jean-Yves Avenard <[email protected]>
[MSE] Rework handling of SourceBuffer's buffer full.
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebFrame.cpp (278613 => 278614)
--- trunk/Source/WebKit/WebProcess/WebPage/WebFrame.cpp 2021-06-08 16:51:42 UTC (rev 278613)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebFrame.cpp 2021-06-08 16:53:06 UTC (rev 278614)
@@ -842,7 +842,7 @@
RefPtr<ShareableBitmap> WebFrame::createSelectionSnapshot() const
{
- auto snapshot = snapshotSelection(*coreFrame(), { { WebCore::SnapshotFlags::ForceBlackText } });
+ auto snapshot = snapshotSelection(*coreFrame(), { { WebCore::SnapshotFlags::ForceBlackText }, PixelFormat::BGRA8, DestinationColorSpace::SRGB() });
if (!snapshot)
return nullptr;