Title: [279793] trunk
Revision
279793
Author
mmaxfi...@apple.com
Date
2021-07-09 13:05:39 -0700 (Fri, 09 Jul 2021)

Log Message

SVGImageForContainer reports true for is<SVGImage>() but it doesn't inherit from SVGImage
https://bugs.webkit.org/show_bug.cgi?id=227807

Reviewed by Said Abou-Hallawa.

Source/WebCore:

It's too easy to write code like:
if (is<SVGImage>(image))
    downcast<SVGImage>(image).doSomething();

Test: SVGImageCasts.SVGImageForContainerIsNotSVGImage

* WebCore.xcodeproj/project.pbxproj:
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::remoteSVGRootElement const):
* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::effectiveImageDevicePixelRatio const):
* html/canvas/CanvasRenderingContext2DBase.cpp:
(WebCore::CanvasRenderingContext2DBase::drawImage):
(WebCore::CanvasRenderingContext2DBase::createPattern):
* html/canvas/WebGLRenderingContextBase.cpp:
(WebCore::WebGLRenderingContextBase::texImageSourceHelper):
* loader/cache/CachedImage.cpp:
(WebCore::CachedImage::imageForRenderer):
(WebCore::CachedImage::hasSVGImage const):
(WebCore::CachedImage::setContainerContextForClient):
(WebCore::CachedImage::imageSizeForRenderer const):
* platform/graphics/CrossfadeGeneratedImage.cpp:
(WebCore::drawCrossfadeSubimage):
* platform/graphics/Image.cpp:
(WebCore::operator<<):
* platform/graphics/Image.h:
(WebCore::Image::isSVGImageForContainer const):
(WebCore::Image::actsLikeSVGImage const):
* platform/graphics/ImageObserver.h:
* svg/graphics/SVGImage.h:
* svg/graphics/SVGImageForContainer.cpp:
(WebCore::SVGImageForContainer::SVGImageForContainer):
* svg/graphics/SVGImageForContainer.h:

Tools:

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebCore/SVGImageCasts.cpp: Added.
(TestWebKitAPI::TEST):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (279792 => 279793)


--- trunk/Source/WebCore/ChangeLog	2021-07-09 19:18:58 UTC (rev 279792)
+++ trunk/Source/WebCore/ChangeLog	2021-07-09 20:05:39 UTC (rev 279793)
@@ -1,3 +1,44 @@
+2021-07-09  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        SVGImageForContainer reports true for is<SVGImage>() but it doesn't inherit from SVGImage
+        https://bugs.webkit.org/show_bug.cgi?id=227807
+
+        Reviewed by Said Abou-Hallawa.
+
+        It's too easy to write code like:
+        if (is<SVGImage>(image))
+            downcast<SVGImage>(image).doSomething();
+
+        Test: SVGImageCasts.SVGImageForContainerIsNotSVGImage
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::remoteSVGRootElement const):
+        * html/HTMLImageElement.cpp:
+        (WebCore::HTMLImageElement::effectiveImageDevicePixelRatio const):
+        * html/canvas/CanvasRenderingContext2DBase.cpp:
+        (WebCore::CanvasRenderingContext2DBase::drawImage):
+        (WebCore::CanvasRenderingContext2DBase::createPattern):
+        * html/canvas/WebGLRenderingContextBase.cpp:
+        (WebCore::WebGLRenderingContextBase::texImageSourceHelper):
+        * loader/cache/CachedImage.cpp:
+        (WebCore::CachedImage::imageForRenderer):
+        (WebCore::CachedImage::hasSVGImage const):
+        (WebCore::CachedImage::setContainerContextForClient):
+        (WebCore::CachedImage::imageSizeForRenderer const):
+        * platform/graphics/CrossfadeGeneratedImage.cpp:
+        (WebCore::drawCrossfadeSubimage):
+        * platform/graphics/Image.cpp:
+        (WebCore::operator<<):
+        * platform/graphics/Image.h:
+        (WebCore::Image::isSVGImageForContainer const):
+        (WebCore::Image::actsLikeSVGImage const):
+        * platform/graphics/ImageObserver.h:
+        * svg/graphics/SVGImage.h:
+        * svg/graphics/SVGImageForContainer.cpp:
+        (WebCore::SVGImageForContainer::SVGImageForContainer):
+        * svg/graphics/SVGImageForContainer.h:
+
 2021-07-09  Said Abou-Hallawa  <s...@apple.com>
 
         SVGInlineTextBox::acquirePaintingResource() should return false if the resource can't be applied

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (279792 => 279793)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2021-07-09 19:18:58 UTC (rev 279792)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2021-07-09 20:05:39 UTC (rev 279793)
@@ -277,7 +277,7 @@
 		08F0BFC61255C53C00075185 /* SVGTextMetrics.h in Headers */ = {isa = PBXBuildFile; fileRef = 08F0BFC11255C53C00075185 /* SVGTextMetrics.h */; };
 		08F2F00A1213E61700DCEC48 /* RenderImageResource.h in Headers */ = {isa = PBXBuildFile; fileRef = 08F2F0081213E61700DCEC48 /* RenderImageResource.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		08F859D51463F9CD0067D933 /* SVGImageCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 08F859D31463F9CD0067D933 /* SVGImageCache.h */; settings = {ATTRIBUTES = (Private, ); }; };
-		08F859D51463F9CD0067D934 /* SVGImageForContainer.h in Headers */ = {isa = PBXBuildFile; fileRef = 08F859D31463F9CD0067D934 /* SVGImageForContainer.h */; };
+		08F859D51463F9CD0067D934 /* SVGImageForContainer.h in Headers */ = {isa = PBXBuildFile; fileRef = 08F859D31463F9CD0067D934 /* SVGImageForContainer.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		0AFDAC3D10F5448C00E1F3D2 /* PluginViewBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 0AFDAC3C10F5448C00E1F3D2 /* PluginViewBase.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		0B90561A0F2578BF0095FF6A /* DocumentThreadableLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 0B9056160F2578BE0095FF6A /* DocumentThreadableLoader.h */; settings = {ATTRIBUTES = (); }; };
 		0B90561B0F2578BF0095FF6A /* ThreadableLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 0B9056170F2578BE0095FF6A /* ThreadableLoader.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -3792,7 +3792,7 @@
 		B22362290C3AF04A0008CA9B /* JSSVGTextPathElement.h in Headers */ = {isa = PBXBuildFile; fileRef = B22362270C3AF04A0008CA9B /* JSSVGTextPathElement.h */; };
 		B23540F30D00782E002382FA /* StringTruncator.h in Headers */ = {isa = PBXBuildFile; fileRef = B23540F10D00782E002382FA /* StringTruncator.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		B25599850D00D8BA00BB825C /* SVGFEImage.h in Headers */ = {isa = PBXBuildFile; fileRef = B25598EB0D00D8B900BB825C /* SVGFEImage.h */; };
-		B25599A40D00D8BA00BB825C /* SVGImage.h in Headers */ = {isa = PBXBuildFile; fileRef = B255990C0D00D8B900BB825C /* SVGImage.h */; };
+		B25599A40D00D8BA00BB825C /* SVGImage.h in Headers */ = {isa = PBXBuildFile; fileRef = B255990C0D00D8B900BB825C /* SVGImage.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		B25599A50D00D8BA00BB825C /* EmptyClients.h in Headers */ = {isa = PBXBuildFile; fileRef = B255990D0D00D8B900BB825C /* EmptyClients.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		B27535650B053814002CE64F /* PDFDocumentImage.h in Headers */ = {isa = PBXBuildFile; fileRef = B27535370B053814002CE64F /* PDFDocumentImage.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		B27535670B053814002CE64F /* Color.h in Headers */ = {isa = PBXBuildFile; fileRef = B27535390B053814002CE64F /* Color.h */; settings = {ATTRIBUTES = (Private, ); }; };

Modified: trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp (279792 => 279793)


--- trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp	2021-07-09 19:18:58 UTC (rev 279792)
+++ trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp	2021-07-09 20:05:39 UTC (rev 279793)
@@ -3249,7 +3249,7 @@
     Image* image = cachedImage->image();
     if (!is<SVGImage>(image))
         return nullptr;
-    
+
     FrameView* frameView = downcast<SVGImage>(*image).frameView();
     if (!frameView)
         return nullptr;

Modified: trunk/Source/WebCore/html/HTMLImageElement.cpp (279792 => 279793)


--- trunk/Source/WebCore/html/HTMLImageElement.cpp	2021-07-09 19:18:58 UTC (rev 279792)
+++ trunk/Source/WebCore/html/HTMLImageElement.cpp	2021-07-09 20:05:39 UTC (rev 279793)
@@ -515,7 +515,7 @@
 
     auto* image = m_imageLoader->image()->image();
 
-    if (image && image->isSVGImage())
+    if (image && image->drawsSVGImage())
         return 1.0f;
 
     return m_imageDevicePixelRatio;

Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp (279792 => 279793)


--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp	2021-07-09 19:18:58 UTC (rev 279792)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp	2021-07-09 20:05:39 UTC (rev 279793)
@@ -1554,7 +1554,7 @@
 
     ImageObserver* observer = image->imageObserver();
 
-    if (image->isSVGImage()) {
+    if (image->drawsSVGImage()) {
         image->setImageObserver(nullptr);
         image->setContainerSize(imageRect.size());
     }
@@ -1589,7 +1589,7 @@
     else
         didDraw(normalizedDstRect);
 
-    if (image->isSVGImage())
+    if (image->drawsSVGImage())
         image->setImageObserver(observer);
 
     return { };
@@ -1977,7 +1977,7 @@
     //      the origin is clean.
     //   2) Dynamically verify the origin checks at draw time, and dirty the canvas accordingly.
     // To be on the safe side, taint the origin for all patterns containing SVG images for now.
-    if (cachedImage->image()->isSVGImage())
+    if (cachedImage->image()->drawsSVGImage())
         originClean = false;
 
     auto* image = cachedImage->imageForRenderer(imageElement.renderer());

Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp (279792 => 279793)


--- trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp	2021-07-09 19:18:58 UTC (rev 279792)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp	2021-07-09 20:05:39 UTC (rev 279793)
@@ -4837,7 +4837,7 @@
         if (!imageForRender)
             return { };
 
-        if (imageForRender->isSVGImage() || imageForRender->orientation() != ImageOrientation::None || imageForRender->hasDensityCorrectedSize())
+        if (imageForRender->drawsSVGImage() || imageForRender->orientation() != ImageOrientation::None || imageForRender->hasDensityCorrectedSize())
             imageForRender = drawImageIntoBuffer(*imageForRender, image->width(), image->height(), 1, functionName);
 
         if (!imageForRender || !validateTexFunc(functionName, functionType, SourceHTMLImageElement, target, level, internalformat, imageForRender->width(), imageForRender->height(), depth, border, format, type, xoffset, yoffset, zoffset))

Modified: trunk/Source/WebCore/loader/cache/CachedImage.cpp (279792 => 279793)


--- trunk/Source/WebCore/loader/cache/CachedImage.cpp	2021-07-09 19:18:58 UTC (rev 279792)
+++ trunk/Source/WebCore/loader/cache/CachedImage.cpp	2021-07-09 20:05:39 UTC (rev 279793)
@@ -261,7 +261,7 @@
     if (!m_image)
         return &Image::nullImage();
 
-    if (m_image->isSVGImage()) {
+    if (m_image->drawsSVGImage()) {
         Image* image = m_svgImageCache->imageForRenderer(renderer);
         if (image != &Image::nullImage())
             return image;
@@ -271,7 +271,7 @@
 
 bool CachedImage::hasSVGImage() const
 {
-    return m_image && m_image->isSVGImage();
+    return m_image && m_image->drawsSVGImage();
 }
 
 void CachedImage::setContainerContextForClient(const CachedImageClient& client, const LayoutSize& containerSize, float containerZoom, const URL& imageURL)
@@ -284,7 +284,7 @@
         return;
     }
 
-    if (!m_image->isSVGImage()) {
+    if (!m_image->drawsSVGImage()) {
         m_image->setContainerSize(containerSize);
         return;
     }
@@ -297,7 +297,7 @@
     if (!m_image)
         return { };
 
-    if (is<SVGImage>(*m_image) && sizeType == UsedSize)
+    if (m_image->drawsSVGImage() && sizeType == UsedSize)
         return m_svgImageCache->imageSizeForRenderer(renderer);
 
     return m_image->size(renderer ? renderer->imageOrientation() : ImageOrientation(ImageOrientation::FromImage));

Modified: trunk/Source/WebCore/platform/graphics/CrossfadeGeneratedImage.cpp (279792 => 279793)


--- trunk/Source/WebCore/platform/graphics/CrossfadeGeneratedImage.cpp	2021-07-09 19:18:58 UTC (rev 279792)
+++ trunk/Source/WebCore/platform/graphics/CrossfadeGeneratedImage.cpp	2021-07-09 20:05:39 UTC (rev 279793)
@@ -47,7 +47,7 @@
     FloatSize imageSize = image.size();
 
     // SVGImage resets the opacity when painting, so we have to use transparency layers to accurately paint one at a given opacity.
-    bool useTransparencyLayer = image.isSVGImage();
+    bool useTransparencyLayer = image.drawsSVGImage();
 
     GraphicsContextStateSaver stateSaver(context);
 

Modified: trunk/Source/WebCore/platform/graphics/Image.cpp (279792 => 279793)


--- trunk/Source/WebCore/platform/graphics/Image.cpp	2021-07-09 19:18:58 UTC (rev 279792)
+++ trunk/Source/WebCore/platform/graphics/Image.cpp	2021-07-09 20:05:39 UTC (rev 279793)
@@ -377,6 +377,8 @@
         ts << "gradient image";
     else if (image.isSVGImage())
         ts << "svg image";
+    else if (image.isSVGImageForContainer())
+        ts << "svg image for container";
     else if (image.isPDFDocumentImage())
         ts << "pdf image";
 

Modified: trunk/Source/WebCore/platform/graphics/Image.h (279792 => 279793)


--- trunk/Source/WebCore/platform/graphics/Image.h	2021-07-09 19:18:58 UTC (rev 279792)
+++ trunk/Source/WebCore/platform/graphics/Image.h	2021-07-09 20:05:39 UTC (rev 279793)
@@ -93,9 +93,12 @@
     virtual bool isNamedImageGeneratedImage() const { return false; }
     virtual bool isGradientImage() const { return false; }
     virtual bool isSVGImage() const { return false; }
+    virtual bool isSVGImageForContainer() const { return false; }
     virtual bool isPDFDocumentImage() const { return false; }
     virtual bool isCustomPaintImage() const { return false; }
 
+    bool drawsSVGImage() const { return isSVGImage() || isSVGImageForContainer(); }
+
     virtual bool currentFrameKnownToBeOpaque() const = 0;
     virtual bool isAnimated() const { return false; }
 
@@ -188,7 +191,7 @@
     virtual void dump(WTF::TextStream&) const;
 
 protected:
-    Image(ImageObserver* = nullptr);
+    WEBCORE_EXPORT Image(ImageObserver* = nullptr);
 
     static void fillWithSolidColor(GraphicsContext&, const FloatRect& dstRect, const Color&, CompositeOperator);
 

Modified: trunk/Source/WebCore/platform/graphics/ImageObserver.h (279792 => 279793)


--- trunk/Source/WebCore/platform/graphics/ImageObserver.h	2021-07-09 19:18:58 UTC (rev 279792)
+++ trunk/Source/WebCore/platform/graphics/ImageObserver.h	2021-07-09 20:05:39 UTC (rev 279793)
@@ -26,6 +26,7 @@
 #pragma once
 
 #include "ImageTypes.h"
+#include <wtf/URL.h>
 
 namespace WebCore {
 

Modified: trunk/Source/WebCore/svg/graphics/SVGImage.h (279792 => 279793)


--- trunk/Source/WebCore/svg/graphics/SVGImage.h	2021-07-09 19:18:58 UTC (rev 279792)
+++ trunk/Source/WebCore/svg/graphics/SVGImage.h	2021-07-09 20:05:39 UTC (rev 279793)
@@ -92,7 +92,7 @@
 
     void startAnimationTimerFired();
 
-    explicit SVGImage(ImageObserver&);
+    WEBCORE_EXPORT explicit SVGImage(ImageObserver&);
     ImageDrawResult draw(GraphicsContext&, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions& = { }) final;
     ImageDrawResult drawAsNativeImage(GraphicsContext&, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions& = { });
     ImageDrawResult drawForContainer(GraphicsContext&, const FloatSize containerSize, float containerZoom, const URL& initialFragmentURL, const FloatRect& dstRect, const FloatRect& srcRect, const ImagePaintingOptions& = { });

Modified: trunk/Source/WebCore/svg/graphics/SVGImageForContainer.cpp (279792 => 279793)


--- trunk/Source/WebCore/svg/graphics/SVGImageForContainer.cpp	2021-07-09 19:18:58 UTC (rev 279792)
+++ trunk/Source/WebCore/svg/graphics/SVGImageForContainer.cpp	2021-07-09 20:05:39 UTC (rev 279793)
@@ -27,6 +27,15 @@
 
 namespace WebCore {
 
+
+SVGImageForContainer::SVGImageForContainer(SVGImage* image, const FloatSize& containerSize, float containerZoom, const URL& initialFragmentURL)
+    : m_image(image)
+    , m_containerSize(containerSize)
+    , m_containerZoom(containerZoom)
+    , m_initialFragmentURL(initialFragmentURL)
+{
+}
+
 FloatSize SVGImageForContainer::size(ImageOrientation) const
 {
     FloatSize scaledContainerSize(m_containerSize);

Modified: trunk/Source/WebCore/svg/graphics/SVGImageForContainer.h (279792 => 279793)


--- trunk/Source/WebCore/svg/graphics/SVGImageForContainer.h	2021-07-09 19:18:58 UTC (rev 279792)
+++ trunk/Source/WebCore/svg/graphics/SVGImageForContainer.h	2021-07-09 20:05:39 UTC (rev 279793)
@@ -41,7 +41,7 @@
         return adoptRef(*new SVGImageForContainer(image, containerSize, containerZoom, initialFragmentURL));
     }
 
-    bool isSVGImage() const final { return true; }
+    bool isSVGImageForContainer() const final { return true; }
 
     FloatSize size(ImageOrientation = ImageOrientation::FromImage) const final;
 
@@ -63,13 +63,7 @@
     RefPtr<NativeImage> nativeImageForCurrentFrame(const GraphicsContext* = nullptr) final;
 
 private:
-    SVGImageForContainer(SVGImage* image, const FloatSize& containerSize, float containerZoom, const URL& initialFragmentURL)
-        : m_image(image)
-        , m_containerSize(containerSize)
-        , m_containerZoom(containerZoom)
-        , m_initialFragmentURL(initialFragmentURL)
-    {
-    }
+    WEBCORE_EXPORT SVGImageForContainer(SVGImage*, const FloatSize& containerSize, float containerZoom, const URL& initialFragmentURL);
 
     void destroyDecodedData(bool /*destroyAll*/ = true) final { }
 
@@ -80,3 +74,5 @@
 };
 
 } // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_IMAGE(SVGImageForContainer)

Modified: trunk/Tools/ChangeLog (279792 => 279793)


--- trunk/Tools/ChangeLog	2021-07-09 19:18:58 UTC (rev 279792)
+++ trunk/Tools/ChangeLog	2021-07-09 20:05:39 UTC (rev 279793)
@@ -1,3 +1,14 @@
+2021-07-09  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        SVGImageForContainer reports true for is<SVGImage>() but it doesn't inherit from SVGImage
+        https://bugs.webkit.org/show_bug.cgi?id=227807
+
+        Reviewed by Said Abou-Hallawa.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebCore/SVGImageCasts.cpp: Added.
+        (TestWebKitAPI::TEST):
+
 2021-07-09  Carlos Alberto Lopez Perez  <clo...@igalia.com>
 
         [webkitcorepy] run-webkit-tests may hang with python2 after r271683

Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (279792 => 279793)


--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2021-07-09 19:18:58 UTC (rev 279792)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2021-07-09 20:05:39 UTC (rev 279793)
@@ -119,6 +119,7 @@
 		1C81802725FB09E200608B3E /* FontRegistrySandboxCheck.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1C81802625FB09E200608B3E /* FontRegistrySandboxCheck.mm */; };
 		1C8FA53A2685A6D500B7E49E /* StringWidth.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1C8FA5392685A6D500B7E49E /* StringWidth.mm */; };
 		1C90420C2326E03C00BEF91E /* SelectionByWord.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1C90420B2326E03C00BEF91E /* SelectionByWord.mm */; };
+		1C9DD9232697655B00274DB2 /* SVGImageCasts.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C9DD9222697655B00274DB2 /* SVGImageCasts.cpp */; };
 		1C9EB8411E380DA1005C6442 /* ComplexTextController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C9EB8401E380DA1005C6442 /* ComplexTextController.cpp */; };
 		1CACADA1230620AE0007D54C /* WKWebViewOpaque.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1CACADA0230620AD0007D54C /* WKWebViewOpaque.mm */; };
 		1CB2F27C24F88379000A5BC1 /* OrthogonalFlowAvailableSize.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1CB2F27B24F88379000A5BC1 /* OrthogonalFlowAvailableSize.mm */; };
@@ -1880,6 +1881,7 @@
 		1C81802625FB09E200608B3E /* FontRegistrySandboxCheck.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = FontRegistrySandboxCheck.mm; sourceTree = "<group>"; };
 		1C8FA5392685A6D500B7E49E /* StringWidth.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = StringWidth.mm; sourceTree = "<group>"; };
 		1C90420B2326E03C00BEF91E /* SelectionByWord.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SelectionByWord.mm; sourceTree = "<group>"; };
+		1C9DD9222697655B00274DB2 /* SVGImageCasts.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SVGImageCasts.cpp; sourceTree = "<group>"; };
 		1C9EB8401E380DA1005C6442 /* ComplexTextController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ComplexTextController.cpp; sourceTree = "<group>"; };
 		1CACADA0230620AD0007D54C /* WKWebViewOpaque.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebViewOpaque.mm; sourceTree = "<group>"; };
 		1CB2F27B24F88379000A5BC1 /* OrthogonalFlowAvailableSize.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = OrthogonalFlowAvailableSize.mm; sourceTree = "<group>"; };
@@ -3765,6 +3767,7 @@
 				ECA680CD1E68CC0900731D20 /* StringUtilities.mm */,
 				CE4D5DE51F6743BA0072CFC6 /* StringWithDirection.cpp */,
 				41E67A8425D16E83007B0A4C /* STUNMessageParsingTest.cpp */,
+				1C9DD9222697655B00274DB2 /* SVGImageCasts.cpp */,
 				93A258981F92FF15003E510C /* TextCodec.cpp */,
 				CDC2C7141797089D00E627FB /* TimeRanges.cpp */,
 				7AD3FE8D1D75FB8D00B169A4 /* TransformationMatrix.cpp */,
@@ -5791,6 +5794,7 @@
 				41E67A8525D16E83007B0A4C /* STUNMessageParsingTest.cpp in Sources */,
 				7CCE7ED21A411A7E00447C4C /* SubresourceErrorCrash.mm in Sources */,
 				51EB126724CB8753000CB030 /* SunLightApplicationGenericNES.mm in Sources */,
+				1C9DD9232697655B00274DB2 /* SVGImageCasts.cpp in Sources */,
 				4433A396208044140091ED57 /* SynchronousTimeoutTests.mm in Sources */,
 				7CCE7EA81A411A1900447C4C /* SyntheticBackingScaleFactorWindow.m in Sources */,
 				E3EFB02F25506503003C2F96 /* SystemBeep.mm in Sources */,

Added: trunk/Tools/TestWebKitAPI/Tests/WebCore/SVGImageCasts.cpp (0 => 279793)


--- trunk/Tools/TestWebKitAPI/Tests/WebCore/SVGImageCasts.cpp	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/SVGImageCasts.cpp	2021-07-09 20:05:39 UTC (rev 279793)
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#include <WebCore/ImageObserver.h>
+#include <WebCore/SVGImage.h>
+#include <WebCore/SVGImageForContainer.h>
+#include <wtf/URL.h>
+
+namespace TestWebKitAPI {
+
+using namespace WebCore;
+
+class TestImageObserver : public ImageObserver {
+public:
+    URL sourceUrl() const final
+    {
+        return URL();
+    }
+
+    String mimeType() const final
+    {
+        return String();
+    }
+
+    long long expectedContentLength() const final
+    {
+        return 0;
+    }
+
+    void decodedSizeChanged(const Image&, long long) final
+    {
+    }
+
+    void didDraw(const Image&) final
+    {
+    }
+
+    bool canDestroyDecodedData(const Image&) final
+    {
+        return true;
+    }
+
+    void imageFrameAvailable(const Image&, ImageAnimatingState, const IntRect* changeRect = nullptr, DecodingStatus = DecodingStatus::Invalid) final
+    {
+    }
+
+    void changedInRect(const Image&, const IntRect* changeRect = nullptr) final
+    {
+    }
+
+    void scheduleRenderingUpdate(const Image&) final
+    {
+    }
+};
+
+TEST(SVGImageCasts, SVGImageForContainerIsNotSVGImage)
+{
+    TestImageObserver imageObserver;
+    auto svgImage = SVGImage::create(imageObserver);
+    Image& svgImageBase = svgImage.get();
+    EXPECT_TRUE(is<SVGImage>(svgImageBase));
+    EXPECT_FALSE(is<SVGImageForContainer>(svgImageBase));
+    auto svgImageForContainer = SVGImageForContainer::create(svgImage.ptr(), { }, 0, URL());
+    Image& svgImageForContainerBase = svgImageForContainer.get();
+    EXPECT_FALSE(is<SVGImage>(svgImageForContainerBase));
+    EXPECT_TRUE(is<SVGImageForContainer>(svgImageForContainerBase));
+}
+
+}
Property changes on: trunk/Tools/TestWebKitAPI/Tests/WebCore/SVGImageCasts.cpp
___________________________________________________________________

Added: svn:eol-style

+native \ No newline at end of property
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to