Title: [271741] trunk/Source/WebCore
Revision
271741
Author
[email protected]
Date
2021-01-22 01:34:10 -0800 (Fri, 22 Jan 2021)

Log Message

Validate ItemHandles when decoding them in GPUProcess
https://bugs.webkit.org/show_bug.cgi?id=220710

Reviewed by Wenson Hsieh.

ItemHandle may contain members that need to be validated if they are encoded/decoded through memory copy instead of IPC encode/decode routines.
This is particularly true of identifiers that can be null but cannot be encoded/decoded if the identifier is null.
For these inline ItemHandles, validate them before copying them.
No observable change of behavior, coveredd by existing tests.

* platform/graphics/displaylists/DisplayList.cpp:
(WebCore::DisplayList::DisplayList::iterator::updateCurrentItem):
* platform/graphics/displaylists/DisplayListItemBuffer.cpp:
(WebCore::DisplayList::ItemHandleInspector::test):
(WebCore::DisplayList::copyInto):
(WebCore::DisplayList::ItemHandle::safeCopyInto const):
(WebCore::DisplayList::ItemHandle::copyTo const): Deleted.
* platform/graphics/displaylists/DisplayListItemBuffer.h:
* platform/graphics/displaylists/DisplayListItems.h:
(WebCore::DisplayList::ClipToImageBuffer::isValid const):
(WebCore::DisplayList::DrawImageBuffer::isValid const):
(WebCore::DisplayList::DrawNativeImage::isValid const):
(WebCore::DisplayList::DrawPattern::isValid const):
(WebCore::DisplayList::PaintFrameForMedia::isValid const):
(WebCore::DisplayList::FlushContext::FlushContext):
(WebCore::DisplayList::FlushContext::isValid const):
(WebCore::DisplayList::MetaCommandChangeItemBuffer::MetaCommandChangeItemBuffer):
(WebCore::DisplayList::MetaCommandChangeItemBuffer::isValid const):
(WebCore::DisplayList::MetaCommandChangeDestinationImageBuffer::MetaCommandChangeDestinationImageBuffer):
(WebCore::DisplayList::MetaCommandChangeDestinationImageBuffer::isValid const):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (271740 => 271741)


--- trunk/Source/WebCore/ChangeLog	2021-01-22 09:07:05 UTC (rev 271740)
+++ trunk/Source/WebCore/ChangeLog	2021-01-22 09:34:10 UTC (rev 271741)
@@ -1,3 +1,36 @@
+2021-01-22  Youenn Fablet  <[email protected]>
+
+        Validate ItemHandles when decoding them in GPUProcess
+        https://bugs.webkit.org/show_bug.cgi?id=220710
+
+        Reviewed by Wenson Hsieh.
+
+        ItemHandle may contain members that need to be validated if they are encoded/decoded through memory copy instead of IPC encode/decode routines.
+        This is particularly true of identifiers that can be null but cannot be encoded/decoded if the identifier is null.
+        For these inline ItemHandles, validate them before copying them.
+        No observable change of behavior, coveredd by existing tests.
+
+        * platform/graphics/displaylists/DisplayList.cpp:
+        (WebCore::DisplayList::DisplayList::iterator::updateCurrentItem):
+        * platform/graphics/displaylists/DisplayListItemBuffer.cpp:
+        (WebCore::DisplayList::ItemHandleInspector::test):
+        (WebCore::DisplayList::copyInto):
+        (WebCore::DisplayList::ItemHandle::safeCopyInto const):
+        (WebCore::DisplayList::ItemHandle::copyTo const): Deleted.
+        * platform/graphics/displaylists/DisplayListItemBuffer.h:
+        * platform/graphics/displaylists/DisplayListItems.h:
+        (WebCore::DisplayList::ClipToImageBuffer::isValid const):
+        (WebCore::DisplayList::DrawImageBuffer::isValid const):
+        (WebCore::DisplayList::DrawNativeImage::isValid const):
+        (WebCore::DisplayList::DrawPattern::isValid const):
+        (WebCore::DisplayList::PaintFrameForMedia::isValid const):
+        (WebCore::DisplayList::FlushContext::FlushContext):
+        (WebCore::DisplayList::FlushContext::isValid const):
+        (WebCore::DisplayList::MetaCommandChangeItemBuffer::MetaCommandChangeItemBuffer):
+        (WebCore::DisplayList::MetaCommandChangeItemBuffer::isValid const):
+        (WebCore::DisplayList::MetaCommandChangeDestinationImageBuffer::MetaCommandChangeDestinationImageBuffer):
+        (WebCore::DisplayList::MetaCommandChangeDestinationImageBuffer::isValid const):
+
 2021-01-19  Nikolas Zimmermann  <[email protected]>
 
         Continue removing glue code from RenderLayer that was recently added in r271559

Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayList.cpp (271740 => 271741)


--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayList.cpp	2021-01-22 09:07:05 UTC (rev 271740)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayList.cpp	2021-01-22 09:34:10 UTC (rev 271741)
@@ -362,7 +362,10 @@
         m_currentBufferForItem[0] = static_cast<uint8_t>(itemType);
         m_currentItemSizeInBuffer = 2 * sizeof(uint64_t) + roundUpToMultipleOf(alignof(uint64_t), dataLength);
     } else {
-        ItemHandle { m_cursor }.copyTo({ m_currentBufferForItem });
+        if (!ItemHandle { m_cursor }.safeCopy({ m_currentBufferForItem })) {
+            // FIXME: Instead of crashing, this needs to fail gracefully and inform the caller.
+            RELEASE_ASSERT_NOT_REACHED();
+        }
         m_currentItemSizeInBuffer = paddedSizeOfTypeAndItem;
     }
 }

Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItemBuffer.cpp (271740 => 271741)


--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItemBuffer.cpp	2021-01-22 09:07:05 UTC (rev 271740)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItemBuffer.cpp	2021-01-22 09:34:10 UTC (rev 271741)
@@ -539,259 +539,157 @@
     }
 }
 
-void ItemHandle::copyTo(ItemHandle destination) const
+template<typename, typename = void> inline constexpr bool HasIsValid = false;
+template<typename T> inline constexpr bool HasIsValid<T, std::void_t<decltype(std::declval<T>().isValid())>> = true;
+
+template<typename Item>
+typename std::enable_if_t<!HasIsValid<Item>, bool> copyInto(const ItemHandle& itemHandle, uint8_t* destinationWithOffset)
 {
+    new (destinationWithOffset) Item(itemHandle.get<Item>());
+    return true;
+}
+
+template<typename Item>
+typename std::enable_if_t<HasIsValid<Item>, bool> copyInto(const ItemHandle& itemHandle, uint8_t* destinationWithOffset)
+{
+    auto* newItem = new (destinationWithOffset) Item(itemHandle.get<Item>());
+    return newItem->isValid();
+}
+
+bool ItemHandle::safeCopy(ItemHandle destination) const
+{
     auto itemType = type();
     destination.data[0] = static_cast<uint8_t>(itemType);
     auto itemOffset = destination.data + sizeof(uint64_t);
     switch (itemType) {
-    case ItemType::ClipOutToPath: {
-        new (itemOffset) ClipOutToPath(get<ClipOutToPath>());
-        return;
-    }
-    case ItemType::ClipPath: {
-        new (itemOffset) ClipPath(get<ClipPath>());
-        return;
-    }
-    case ItemType::ClipToDrawingCommands: {
-        new (itemOffset) ClipToDrawingCommands(get<ClipToDrawingCommands>());
-        return;
-    }
-    case ItemType::DrawFocusRingPath: {
-        new (itemOffset) DrawFocusRingPath(get<DrawFocusRingPath>());
-        return;
-    }
-    case ItemType::DrawFocusRingRects: {
-        new (itemOffset) DrawFocusRingRects(get<DrawFocusRingRects>());
-        return;
-    }
-    case ItemType::DrawGlyphs: {
-        new (itemOffset) DrawGlyphs(get<DrawGlyphs>());
-        return;
-    }
-    case ItemType::DrawImageBuffer: {
-        new (itemOffset) DrawImageBuffer(get<DrawImageBuffer>());
-        return;
-    }
-    case ItemType::DrawLinesForText: {
-        new (itemOffset) DrawLinesForText(get<DrawLinesForText>());
-        return;
-    }
-    case ItemType::DrawNativeImage: {
-        new (itemOffset) DrawNativeImage(get<DrawNativeImage>());
-        return;
-    }
-    case ItemType::DrawPattern: {
-        new (itemOffset) DrawPattern(get<DrawPattern>());
-        return;
-    }
-    case ItemType::DrawPath: {
-        new (itemOffset) DrawPath(get<DrawPath>());
-        return;
-    }
-    case ItemType::FillCompositedRect: {
-        new (itemOffset) FillCompositedRect(get<FillCompositedRect>());
-        return;
-    }
-    case ItemType::FillPath: {
-        new (itemOffset) FillPath(get<FillPath>());
-        return;
-    }
-    case ItemType::FillRectWithColor: {
-        new (itemOffset) FillRectWithColor(get<FillRectWithColor>());
-        return;
-    }
-    case ItemType::FillRectWithGradient: {
-        new (itemOffset) FillRectWithGradient(get<FillRectWithGradient>());
-        return;
-    }
-    case ItemType::FillRectWithRoundedHole: {
-        new (itemOffset) FillRectWithRoundedHole(get<FillRectWithRoundedHole>());
-        return;
-    }
-    case ItemType::FillRoundedRect: {
-        new (itemOffset) FillRoundedRect(get<FillRoundedRect>());
-        return;
-    }
-    case ItemType::PutImageData: {
-        new (itemOffset) PutImageData(get<PutImageData>());
-        return;
-    }
-    case ItemType::SetLineDash: {
-        new (itemOffset) SetLineDash(get<SetLineDash>());
-        return;
-    }
-    case ItemType::SetState: {
-        new (itemOffset) SetState(get<SetState>());
-        return;
-    }
-    case ItemType::StrokePath: {
-        new (itemOffset) StrokePath(get<StrokePath>());
-        return;
-    }
-    case ItemType::ApplyDeviceScaleFactor: {
-        new (itemOffset) ApplyDeviceScaleFactor(get<ApplyDeviceScaleFactor>());
-        return;
-    }
+    case ItemType::ClipOutToPath:
+        return copyInto<ClipOutToPath>(*this, itemOffset);
+    case ItemType::ClipPath:
+        return copyInto<ClipPath>(*this, itemOffset);
+    case ItemType::ClipToDrawingCommands:
+        return copyInto<ClipToDrawingCommands>(*this, itemOffset);
+    case ItemType::DrawFocusRingPath:
+        return copyInto<DrawFocusRingPath>(*this, itemOffset);
+    case ItemType::DrawFocusRingRects:
+        return copyInto<DrawFocusRingRects>(*this, itemOffset);
+    case ItemType::DrawGlyphs:
+        return copyInto<DrawGlyphs>(*this, itemOffset);
+    case ItemType::DrawImageBuffer:
+        return copyInto<DrawImageBuffer>(*this, itemOffset);
+    case ItemType::DrawLinesForText:
+        return copyInto<DrawLinesForText>(*this, itemOffset);
+    case ItemType::DrawNativeImage:
+        return copyInto<DrawNativeImage>(*this, itemOffset);
+    case ItemType::DrawPattern:
+        return copyInto<DrawPattern>(*this, itemOffset);
+    case ItemType::DrawPath:
+        return copyInto<DrawPath>(*this, itemOffset);
+    case ItemType::FillCompositedRect:
+        return copyInto<FillCompositedRect>(*this, itemOffset);
+    case ItemType::FillPath:
+        return copyInto<FillPath>(*this, itemOffset);
+    case ItemType::FillRectWithColor:
+        return copyInto<FillRectWithColor>(*this, itemOffset);
+    case ItemType::FillRectWithGradient:
+        return copyInto<FillRectWithGradient>(*this, itemOffset);
+    case ItemType::FillRectWithRoundedHole:
+        return copyInto<FillRectWithRoundedHole>(*this, itemOffset);
+    case ItemType::FillRoundedRect:
+        return copyInto<FillRoundedRect>(*this, itemOffset);
+    case ItemType::PutImageData:
+        return copyInto<PutImageData>(*this, itemOffset);
+    case ItemType::SetLineDash:
+        return copyInto<SetLineDash>(*this, itemOffset);
+    case ItemType::SetState:
+        return copyInto<SetState>(*this, itemOffset);
+    case ItemType::StrokePath:
+        return copyInto<StrokePath>(*this, itemOffset);
+    case ItemType::ApplyDeviceScaleFactor:
+        return copyInto<ApplyDeviceScaleFactor>(*this, itemOffset);
 #if USE(CG)
-    case ItemType::ApplyFillPattern: {
-        new (itemOffset) ApplyFillPattern(get<ApplyFillPattern>());
-        return;
-    }
-    case ItemType::ApplyStrokePattern: {
-        new (itemOffset) ApplyStrokePattern(get<ApplyStrokePattern>());
-        return;
-    }
+    case ItemType::ApplyFillPattern:
+        return copyInto<ApplyFillPattern>(*this, itemOffset);
+    case ItemType::ApplyStrokePattern:
+        return copyInto<ApplyStrokePattern>(*this, itemOffset);
 #endif
-    case ItemType::BeginTransparencyLayer: {
-        new (itemOffset) BeginTransparencyLayer(get<BeginTransparencyLayer>());
-        return;
-    }
-    case ItemType::ClearRect: {
-        new (itemOffset) ClearRect(get<ClearRect>());
-        return;
-    }
-    case ItemType::ClearShadow: {
-        new (itemOffset) ClearShadow(get<ClearShadow>());
-        return;
-    }
-    case ItemType::Clip: {
-        new (itemOffset) Clip(get<Clip>());
-        return;
-    }
-    case ItemType::ClipOut: {
-        new (itemOffset) ClipOut(get<ClipOut>());
-        return;
-    }
-    case ItemType::ClipToImageBuffer: {
-        new (itemOffset) ClipToImageBuffer(get<ClipToImageBuffer>());
-        return;
-    }
-    case ItemType::ConcatenateCTM: {
-        new (itemOffset) ConcatenateCTM(get<ConcatenateCTM>());
-        return;
-    }
-    case ItemType::DrawDotsForDocumentMarker: {
-        new (itemOffset) DrawDotsForDocumentMarker(get<DrawDotsForDocumentMarker>());
-        return;
-    }
-    case ItemType::DrawEllipse: {
-        new (itemOffset) DrawEllipse(get<DrawEllipse>());
-        return;
-    }
-    case ItemType::DrawLine: {
-        new (itemOffset) DrawLine(get<DrawLine>());
-        return;
-    }
-    case ItemType::DrawRect: {
-        new (itemOffset) DrawRect(get<DrawRect>());
-        return;
-    }
-    case ItemType::EndTransparencyLayer: {
-        new (itemOffset) EndTransparencyLayer(get<EndTransparencyLayer>());
-        return;
-    }
-    case ItemType::FillEllipse: {
-        new (itemOffset) FillEllipse(get<FillEllipse>());
-        return;
-    }
+    case ItemType::BeginTransparencyLayer:
+        return copyInto<BeginTransparencyLayer>(*this, itemOffset);
+    case ItemType::ClearRect:
+        return copyInto<ClearRect>(*this, itemOffset);
+    case ItemType::ClearShadow:
+        return copyInto<ClearShadow>(*this, itemOffset);
+    case ItemType::Clip:
+        return copyInto<Clip>(*this, itemOffset);
+    case ItemType::ClipOut:
+        return copyInto<ClipOut>(*this, itemOffset);
+    case ItemType::ClipToImageBuffer:
+        return copyInto<ClipToImageBuffer>(*this, itemOffset);
+    case ItemType::ConcatenateCTM:
+        return copyInto<ConcatenateCTM>(*this, itemOffset);
+    case ItemType::DrawDotsForDocumentMarker:
+        return copyInto<DrawDotsForDocumentMarker>(*this, itemOffset);
+    case ItemType::DrawEllipse:
+        return copyInto<DrawEllipse>(*this, itemOffset);
+    case ItemType::DrawLine:
+        return copyInto<DrawLine>(*this, itemOffset);
+    case ItemType::DrawRect:
+        return copyInto<DrawRect>(*this, itemOffset);
+    case ItemType::EndTransparencyLayer:
+        return copyInto<EndTransparencyLayer>(*this, itemOffset);
+    case ItemType::FillEllipse:
+        return copyInto<FillEllipse>(*this, itemOffset);
 #if ENABLE(INLINE_PATH_DATA)
-    case ItemType::FillInlinePath: {
-        new (itemOffset) FillInlinePath(get<FillInlinePath>());
-        return;
-    }
+    case ItemType::FillInlinePath:
+        return copyInto<FillInlinePath>(*this, itemOffset);
 #endif
-    case ItemType::FillRect: {
-        new (itemOffset) FillRect(get<FillRect>());
-        return;
-    }
-    case ItemType::FlushContext: {
-        new (itemOffset) FlushContext(get<FlushContext>());
-        return;
-    }
-    case ItemType::MetaCommandChangeDestinationImageBuffer: {
-        new (itemOffset) MetaCommandChangeDestinationImageBuffer(get<MetaCommandChangeDestinationImageBuffer>());
-        return;
-    }
-    case ItemType::MetaCommandChangeItemBuffer: {
-        new (itemOffset) MetaCommandChangeItemBuffer(get<MetaCommandChangeItemBuffer>());
-        return;
-    }
-    case ItemType::PaintFrameForMedia: {
-        new (itemOffset) PaintFrameForMedia(get<PaintFrameForMedia>());
-        return;
-    }
-    case ItemType::Restore: {
-        new (itemOffset) Restore(get<Restore>());
-        return;
-    }
-    case ItemType::Rotate: {
-        new (itemOffset) Rotate(get<Rotate>());
-        return;
-    }
-    case ItemType::Save: {
-        new (itemOffset) Save(get<Save>());
-        return;
-    }
-    case ItemType::Scale: {
-        new (itemOffset) Scale(get<Scale>());
-        return;
-    }
-    case ItemType::SetCTM: {
-        new (itemOffset) SetCTM(get<SetCTM>());
-        return;
-    }
-    case ItemType::SetInlineFillColor: {
-        new (itemOffset) SetInlineFillColor(get<SetInlineFillColor>());
-        return;
-    }
-    case ItemType::SetInlineFillGradient: {
-        new (itemOffset) SetInlineFillGradient(get<SetInlineFillGradient>());
-        return;
-    }
-    case ItemType::SetInlineStrokeColor: {
-        new (itemOffset) SetInlineStrokeColor(get<SetInlineStrokeColor>());
-        return;
-    }
-    case ItemType::SetLineCap: {
-        new (itemOffset) SetLineCap(get<SetLineCap>());
-        return;
-    }
-    case ItemType::SetLineJoin: {
-        new (itemOffset) SetLineJoin(get<SetLineJoin>());
-        return;
-    }
-    case ItemType::SetMiterLimit: {
-        new (itemOffset) SetMiterLimit(get<SetMiterLimit>());
-        return;
-    }
-    case ItemType::SetStrokeThickness: {
-        new (itemOffset) SetStrokeThickness(get<SetStrokeThickness>());
-        return;
-    }
-    case ItemType::StrokeEllipse: {
-        new (itemOffset) StrokeEllipse(get<StrokeEllipse>());
-        return;
-    }
+    case ItemType::FillRect:
+        return copyInto<FillRect>(*this, itemOffset);
+    case ItemType::FlushContext:
+        return copyInto<FlushContext>(*this, itemOffset);
+    case ItemType::MetaCommandChangeDestinationImageBuffer:
+        return copyInto<MetaCommandChangeDestinationImageBuffer>(*this, itemOffset);
+    case ItemType::MetaCommandChangeItemBuffer:
+        return copyInto<MetaCommandChangeItemBuffer>(*this, itemOffset);
+    case ItemType::PaintFrameForMedia:
+        return copyInto<PaintFrameForMedia>(*this, itemOffset);
+    case ItemType::Restore:
+        return copyInto<Restore>(*this, itemOffset);
+    case ItemType::Rotate:
+        return copyInto<Rotate>(*this, itemOffset);
+    case ItemType::Save:
+        return copyInto<Save>(*this, itemOffset);
+    case ItemType::Scale:
+        return copyInto<Scale>(*this, itemOffset);
+    case ItemType::SetCTM:
+        return copyInto<SetCTM>(*this, itemOffset);
+    case ItemType::SetInlineFillColor:
+        return copyInto<SetInlineFillColor>(*this, itemOffset);
+    case ItemType::SetInlineFillGradient:
+        return copyInto<SetInlineFillGradient>(*this, itemOffset);
+    case ItemType::SetInlineStrokeColor:
+        return copyInto<SetInlineStrokeColor>(*this, itemOffset);
+    case ItemType::SetLineCap:
+        return copyInto<SetLineCap>(*this, itemOffset);
+    case ItemType::SetLineJoin:
+        return copyInto<SetLineJoin>(*this, itemOffset);
+    case ItemType::SetMiterLimit:
+        return copyInto<SetMiterLimit>(*this, itemOffset);
+    case ItemType::SetStrokeThickness:
+        return copyInto<SetStrokeThickness>(*this, itemOffset);
+    case ItemType::StrokeEllipse:
+        return copyInto<StrokeEllipse>(*this, itemOffset);
 #if ENABLE(INLINE_PATH_DATA)
-    case ItemType::StrokeInlinePath: {
-        new (itemOffset) StrokeInlinePath(get<StrokeInlinePath>());
-        return;
-    }
+    case ItemType::StrokeInlinePath:
+        return copyInto<StrokeInlinePath>(*this, itemOffset);
 #endif
-    case ItemType::StrokeRect: {
-        new (itemOffset) StrokeRect(get<StrokeRect>());
-        return;
+    case ItemType::StrokeRect:
+        return copyInto<StrokeRect>(*this, itemOffset);
+    case ItemType::StrokeLine:
+        return copyInto<StrokeLine>(*this, itemOffset);
+    case ItemType::Translate:
+        return copyInto<Translate>(*this, itemOffset);
     }
-    case ItemType::StrokeLine: {
-        new (itemOffset) StrokeLine(get<StrokeLine>());
-        return;
-    }
-    case ItemType::Translate: {
-        new (itemOffset) Translate(get<Translate>());
-        return;
-    }
-    }
+    return false;
 }
 
 ItemBuffer::ItemBuffer(ItemBufferHandles&& handles)

Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItemBuffer.h (271740 => 271741)


--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItemBuffer.h	2021-01-22 09:07:05 UTC (rev 271740)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItemBuffer.h	2021-01-22 09:34:10 UTC (rev 271741)
@@ -80,7 +80,7 @@
         return *reinterpret_cast<T*>(&data[sizeof(uint64_t)]);
     }
 
-    void copyTo(ItemHandle destination) const;
+    bool safeCopy(ItemHandle destination) const;
 };
 
 enum class DidChangeItemBuffer : bool { No, Yes };

Modified: trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.h (271740 => 271741)


--- trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.h	2021-01-22 09:07:05 UTC (rev 271740)
+++ trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItems.h	2021-01-22 09:34:10 UTC (rev 271741)
@@ -753,6 +753,7 @@
     
     RenderingResourceIdentifier imageBufferIdentifier() const { return m_imageBufferIdentifier; }
     FloatRect destinationRect() const { return m_destinationRect; }
+    bool isValid() const { return !!m_imageBufferIdentifier; }
 
     void apply(GraphicsContext&, WebCore::ImageBuffer&) const;
 
@@ -1033,6 +1034,8 @@
     FloatRect source() const { return m_srcRect; }
     FloatRect destinationRect() const { return m_destinationRect; }
     ImagePaintingOptions options() const { return m_options; }
+    // FIXME: We might want to validate ImagePaintingOptions.
+    bool isValid() const { return !!m_imageBufferIdentifier; }
 
     void apply(GraphicsContext&, WebCore::ImageBuffer&) const;
 
@@ -1066,6 +1069,8 @@
     RenderingResourceIdentifier imageIdentifier() const { return m_imageIdentifier; }
     const FloatRect& source() const { return m_srcRect; }
     const FloatRect& destinationRect() const { return m_destinationRect; }
+    // FIXME: We might want to validate ImagePaintingOptions.
+    bool isValid() const { return !!m_imageIdentifier; }
 
     NO_RETURN_DUE_TO_ASSERT void apply(GraphicsContext&) const;
     void apply(GraphicsContext&, NativeImage&) const;
@@ -1096,6 +1101,8 @@
     const AffineTransform& patternTransform() const { return m_patternTransform; }
     FloatPoint phase() const { return m_phase; }
     FloatSize spacing() const { return m_spacing; }
+    // FIXME: We might want to validate ImagePaintingOptions.
+    bool isValid() const { return !!m_imageIdentifier; }
 
     NO_RETURN_DUE_TO_ASSERT void apply(GraphicsContext&) const;
     void apply(GraphicsContext&, NativeImage&) const;
@@ -1999,6 +2006,8 @@
     const FloatRect& destination() const { return m_destination; }
     MediaPlayerIdentifier identifier() const { return m_identifier; }
 
+    bool isValid() const { return !!m_identifier; }
+
     NO_RETURN_DUE_TO_ASSERT void apply(GraphicsContext&) const;
 
     Optional<FloatRect> localBounds(const GraphicsContext&) const { return WTF::nullopt; }
@@ -2223,12 +2232,13 @@
     static constexpr bool isInlineItem = true;
     static constexpr bool isDrawingItem = false;
 
-    FlushContext(FlushIdentifier identifier)
+    explicit FlushContext(FlushIdentifier identifier)
         : m_identifier(identifier)
     {
     }
 
     FlushIdentifier identifier() const { return m_identifier; }
+    bool isValid() const { return !!m_identifier; }
 
     void apply(GraphicsContext&) const;
 
@@ -2244,12 +2254,13 @@
     static constexpr bool isInlineItem = true;
     static constexpr bool isDrawingItem = false;
 
-    MetaCommandChangeItemBuffer(ItemBufferIdentifier identifier)
+    explicit MetaCommandChangeItemBuffer(ItemBufferIdentifier identifier)
         : m_identifier(identifier)
     {
     }
 
     ItemBufferIdentifier identifier() const { return m_identifier; }
+    bool isValid() const { return !!m_identifier; }
 
 private:
     ItemBufferIdentifier m_identifier;
@@ -2261,12 +2272,13 @@
     static constexpr bool isInlineItem = true;
     static constexpr bool isDrawingItem = false;
 
-    MetaCommandChangeDestinationImageBuffer(RenderingResourceIdentifier identifier)
+    explicit MetaCommandChangeDestinationImageBuffer(RenderingResourceIdentifier identifier)
         : m_identifier(identifier)
     {
     }
 
     RenderingResourceIdentifier identifier() const { return m_identifier; }
+    bool isValid() const { return !!m_identifier; }
 
 private:
     RenderingResourceIdentifier m_identifier;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to