Title: [256501] trunk
Revision
256501
Author
[email protected]
Date
2020-02-12 21:53:32 -0800 (Wed, 12 Feb 2020)

Log Message

WebP image format is not supported
https://bugs.webkit.org/show_bug.cgi?id=192672

Patch by Said Abou-Hallawa <[email protected]> on 2020-02-12
Reviewed by Youenn Fablet.

Source/WebCore:

Add the mime type and the UTI of the WebP to the list of the allowed image
formats. WebP should be enabled only on macOS and iOS post Catalina.

Tests: fast/images/animated-webp-as-image.html
       fast/images/webp-as-image.html

* platform/MIMETypeRegistry.cpp:
(WebCore::MIMETypeRegistry::supportedImageMIMETypes):
* platform/graphics/cg/ImageDecoderCG.cpp:
(WebCore::animationPropertiesFromProperties):
* platform/graphics/cg/UTIRegistry.cpp:
(WebCore::defaultSupportedImageTypes):

Source/WTF:

Introduce HAVE(WEBP) for macOS and iOS.

* wtf/PlatformHave.h:

LayoutTests:

Disable the tests for all ports and enable it only for [ Catalina+ ].

* TestExpectations:
* fast/images/animated-webp-as-image-expected.html: Added.
* fast/images/animated-webp-as-image.html: Added.
* fast/images/resources/animated-red-green-blue-repeat-infinite.webp: Added.
* fast/images/resources/green-400x400.webp: Added.
* fast/images/webp-as-image-expected.html: Added.
* fast/images/webp-as-image.html: Added.
* platform/mac/TestExpectations:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (256500 => 256501)


--- trunk/LayoutTests/ChangeLog	2020-02-13 04:11:51 UTC (rev 256500)
+++ trunk/LayoutTests/ChangeLog	2020-02-13 05:53:32 UTC (rev 256501)
@@ -1,3 +1,21 @@
+2020-02-12  Said Abou-Hallawa  <[email protected]>
+
+        WebP image format is not supported
+        https://bugs.webkit.org/show_bug.cgi?id=192672
+
+        Reviewed by Youenn Fablet.
+
+        Disable the tests for all ports and enable it only for [ Catalina+ ].
+
+        * TestExpectations:
+        * fast/images/animated-webp-as-image-expected.html: Added.
+        * fast/images/animated-webp-as-image.html: Added.
+        * fast/images/resources/animated-red-green-blue-repeat-infinite.webp: Added.
+        * fast/images/resources/green-400x400.webp: Added.
+        * fast/images/webp-as-image-expected.html: Added.
+        * fast/images/webp-as-image.html: Added.
+        * platform/mac/TestExpectations:
+
 2020-02-12  Pavel Feldman  <[email protected]>
 
         Web Inspector: encode binary web socket frames using base64

Modified: trunk/LayoutTests/TestExpectations (256500 => 256501)


--- trunk/LayoutTests/TestExpectations	2020-02-13 04:11:51 UTC (rev 256500)
+++ trunk/LayoutTests/TestExpectations	2020-02-13 05:53:32 UTC (rev 256501)
@@ -1793,6 +1793,11 @@
 fast/images/animated-heics-draw.html [ Skip ]
 fast/images/animated-heics-verify.html [ Skip ]
 
+# WebP images are only supported on macOS and iOS post Catalina
+fast/images/webp-as-image.html [ Skip ]
+fast/images/animated-webp-as-image.html [ Skip ]
+fast/images/animated-webp.html [ Skip ]
+
 webkit.org/b/146182 editing/selection/leak-document-with-selection-inside.html [ Pass Failure ]
 
 # Media Sessions is not yet enabled by default: ENABLE(MEDIA_SESSION)

Added: trunk/LayoutTests/fast/images/animated-webp-as-image-expected.html (0 => 256501)


--- trunk/LayoutTests/fast/images/animated-webp-as-image-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/images/animated-webp-as-image-expected.html	2020-02-13 05:53:32 UTC (rev 256501)
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html>
+<style>
+    .box {
+        width: 100px;
+        height: 100px;
+        display: inline-block;
+    } 
+</style>    
+<body>
+    <div>
+        <p>Frames of a 3-frame animated image with infinite loopCount:</p>
+        <div class="box" style="background-color: red;"></div>
+        <div class="box" style="background-color: green;"></div>
+        <div class="box" style="background-color: blue;"></div>
+        <div class="box" style="background-color: red;"></div>
+        <div class="box" style="background-color: green;"></div>
+        <div class="box" style="background-color: blue;"></div>
+        <div class="box" style="background-color: red;"></div>
+    </div>
+</body>
+</html>

Added: trunk/LayoutTests/fast/images/animated-webp-as-image.html (0 => 256501)


--- trunk/LayoutTests/fast/images/animated-webp-as-image.html	                        (rev 0)
+++ trunk/LayoutTests/fast/images/animated-webp-as-image.html	2020-02-13 05:53:32 UTC (rev 256501)
@@ -0,0 +1,72 @@
+<!DOCTYPE html>
+<html>
+<style>
+    canvas {
+        width: 100px;
+        height: 100px;
+    }
+</style>    
+<body>
+    <div>
+        <p>Frames of a 3-frame animated image with infinite loopCount:</p>
+        <canvas id="canvas-A"></canvas>
+        <canvas id="canvas-B"></canvas>
+        <canvas id="canvas-C"></canvas>
+        <canvas id="canvas-D"></canvas>
+        <canvas id="canvas-E"></canvas>
+        <canvas id="canvas-F"></canvas>
+        <canvas id="canvas-G"></canvas>
+    </div>
+    <script>
+        function drawFrame(image, canvasId) {
+            return new Promise((resolve) => {
+                let canvas = document.getElementById("canvas-" + canvasId);
+                let context = canvas.getContext("2d");
+                context.drawImage(image, 0, 0, canvas.width, canvas.height);
+                setTimeout(() => {
+                    resolve(String.fromCharCode(canvasId.charCodeAt() + 1));
+                }, 30);
+            });
+        }
+
+        function drawImage(image, canvasId, frameCount) {
+            let promise = drawFrame(image, canvasId);
+            for (let frame = 1; frame < frameCount; ++frame) {
+                promise = promise.then((canvasId) => {
+                    return drawFrame(image, canvasId);
+                });
+            }
+            return promise;
+        }
+
+        function loadImage(src, canvasId, frameCount) {
+            return new Promise((resolve) => {
+                let image = new Image;
+                image._onload_ = (() => {
+                    drawImage(image, canvasId, frameCount).then(resolve);
+                });
+                image.src = ""
+            });
+        }
+
+        (function() {
+            if (window.internals) {
+                internals.clearMemoryCache();
+                internals.settings.setAnimatedImageDebugCanvasDrawingEnabled(true);
+            }
+
+            if (window.testRunner)
+                testRunner.waitUntilDone();
+
+            var imageSrc = "resources/animated-red-green-blue-repeat-infinite.gif";
+            var firstCanvasId = 'A';
+            var frameCount = 7;
+
+            loadImage(imageSrc, firstCanvasId, frameCount).then(() => {
+                if (window.testRunner)
+                    testRunner.notifyDone();
+            });
+        })();
+    </script>
+</body>
+</html>

Added: trunk/LayoutTests/fast/images/resources/animated-red-green-blue-repeat-infinite.webp (0 => 256501)


--- trunk/LayoutTests/fast/images/resources/animated-red-green-blue-repeat-infinite.webp	                        (rev 0)
+++ trunk/LayoutTests/fast/images/resources/animated-red-green-blue-repeat-infinite.webp	2020-02-13 05:53:32 UTC (rev 256501)
@@ -0,0 +1,2 @@
+RIFF\xB4������WEBPVP8X
+������������c����c����ANIM����������\xFF\xFF����ANMF(������������������c����c��������VP8L������/c\xC0��\xFD\x8F\xFE"\xA2\xFF��ANMF(������������������c����c����������VP8L������/c\xC0��P\xC0\x88\xFE"\xA2\xFF��ANMF(������������������c����c����������VP8L������/c\xC0��\xD1\xFF\xFE"\xA2\xFF��
\ No newline at end of file

Added: trunk/LayoutTests/fast/images/resources/green-400x400.webp (0 => 256501)


--- trunk/LayoutTests/fast/images/resources/green-400x400.webp	                        (rev 0)
+++ trunk/LayoutTests/fast/images/resources/green-400x400.webp	2020-02-13 05:53:32 UTC (rev 256501)
@@ -0,0 +1,2 @@
+RIFFh����WEBPVP8 \����P%��\x9D*\x90\x90>Q(\x92G#\xA2\xA1\xA1 ��p
+	in\xE1wa\xDC\xE0����\xD8\xBE\xD99}\xB2r\xFBd\xE4=\xF6\xC9\xC8{퓐\xF7\xDB'!\xEF\xB6NC\xDFl\x9C\x87\xBE\xD99}\xB2r\xFBd\xE4=\xF6\xC9\xC8{퓐\xF7\xDB'!\xEF\xB6NC\xDFl\x9C\x87\xBE\xD99}\xB2r\xFBd\xE4=\xF6\xC9\xC8{퓐\xF7\xDB'!\xEF\xB6NC\xDFl\x9C\x87\xBE\xD99}\xB2r\xFBd\xE4=\xF6\xC9\xC8{퓐\xF7\xDB'!\xEF\xB6NC\xDFl\x9C\x87\xBE\xD99}\xB2r\xFBd\xE4=\xF6\xC9\xC8{퓐\xF7\xDB'!\xEF\xB6NC\xDFl\x9C\x87\xBE\xD99}\xB2r\xFBd\xE4=\xF6\xC9\xC8{퓐\xF7\xDB'!\xEF\xB6NC\xDFl\x9C\x87\xBE\xD99}\xB2r\xFBd\xE4=\xF6\xC9\xC8{퓐\xF7\xDB'!\xEF\xB6NC\xDFl\x9C\x87\xBE\xD99}\xB2r\xFBd\xE4=\xF6\xC9\xC8{퓐\xF7\xDB'!\xEF\xB6NC\xDFl\x9C\x87\xBE\xD99}\xB2r\xFBd\xE4=\xF6\xC9\xC8{퓅����\xFE\xFF\xC0i\xFF\xFF\xF3\xAF\xC87j\xFF\xFD?\x86\xDE����������������������������������
\ No newline at end of file

Added: trunk/LayoutTests/fast/images/webp-as-image-expected.html (0 => 256501)


--- trunk/LayoutTests/fast/images/webp-as-image-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/images/webp-as-image-expected.html	2020-02-13 05:53:32 UTC (rev 256501)
@@ -0,0 +1,10 @@
+<style>
+	div {
+		width: 400px;
+		height: 400px;
+		background-color: green;
+	}
+</style>
+<body>
+    <div></div>
+</body>

Added: trunk/LayoutTests/fast/images/webp-as-image.html (0 => 256501)


--- trunk/LayoutTests/fast/images/webp-as-image.html	                        (rev 0)
+++ trunk/LayoutTests/fast/images/webp-as-image.html	2020-02-13 05:53:32 UTC (rev 256501)
@@ -0,0 +1,3 @@
+<body>
+    <img src=""
+</body>

Modified: trunk/LayoutTests/platform/mac/TestExpectations (256500 => 256501)


--- trunk/LayoutTests/platform/mac/TestExpectations	2020-02-13 04:11:51 UTC (rev 256500)
+++ trunk/LayoutTests/platform/mac/TestExpectations	2020-02-13 05:53:32 UTC (rev 256501)
@@ -1790,6 +1790,13 @@
 [ Catalina+ ] fast/images/animated-heics-draw.html [ Pass ]
 [ Catalina+ ] fast/images/animated-heics-verify.html [ Pass ]
 
+# <rdar://problem/8509491>
+[ Catalina+ ] fast/images/webp-as-image.html [ Pass ]
+[ Catalina+ ] fast/images/animated-webp-as-image.html [ Pass ]
+
+# <rdar://problem/59015708>
+[ Catalina+ ] fast/images/animated-webp.html [ ImageOnlyFailure ]
+
 # <rdar://problem/40172428>
 [ Catalina+ ] fast/text/font-collection.html [ ImageOnlyFailure ]
 [ Catalina+ ] fast/text/woff2.html [ ImageOnlyFailure ]

Modified: trunk/Source/WTF/ChangeLog (256500 => 256501)


--- trunk/Source/WTF/ChangeLog	2020-02-13 04:11:51 UTC (rev 256500)
+++ trunk/Source/WTF/ChangeLog	2020-02-13 05:53:32 UTC (rev 256501)
@@ -1,3 +1,14 @@
+2020-02-12  Said Abou-Hallawa  <[email protected]>
+
+        WebP image format is not supported
+        https://bugs.webkit.org/show_bug.cgi?id=192672
+
+        Reviewed by Youenn Fablet.
+
+        Introduce HAVE(WEBP) for macOS and iOS.
+
+        * wtf/PlatformHave.h:
+
 2020-02-12  Yusuke Suzuki  <[email protected]>
 
         [JSC] Compact JITCodeMap by storing BytecodeIndex and CodeLocation separately

Modified: trunk/Source/WTF/wtf/PlatformHave.h (256500 => 256501)


--- trunk/Source/WTF/wtf/PlatformHave.h	2020-02-13 04:11:51 UTC (rev 256500)
+++ trunk/Source/WTF/wtf/PlatformHave.h	2020-02-13 05:53:32 UTC (rev 256501)
@@ -588,3 +588,7 @@
 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400) || (PLATFORM(IOS_FAMILY))
 #define HAVE_GCEXTENDEDGAMEPAD_BUTTONS_THUMBSTICK 1
 #endif
+
+#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101600) || (PLATFORM(IOS_FAMILY) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 140000)
+#define HAVE_WEBP 1
+#endif

Modified: trunk/Source/WebCore/ChangeLog (256500 => 256501)


--- trunk/Source/WebCore/ChangeLog	2020-02-13 04:11:51 UTC (rev 256500)
+++ trunk/Source/WebCore/ChangeLog	2020-02-13 05:53:32 UTC (rev 256501)
@@ -1,3 +1,23 @@
+2020-02-12  Said Abou-Hallawa  <[email protected]>
+
+        WebP image format is not supported
+        https://bugs.webkit.org/show_bug.cgi?id=192672
+
+        Reviewed by Youenn Fablet.
+
+        Add the mime type and the UTI of the WebP to the list of the allowed image
+        formats. WebP should be enabled only on macOS and iOS post Catalina.
+
+        Tests: fast/images/animated-webp-as-image.html
+               fast/images/webp-as-image.html
+
+        * platform/MIMETypeRegistry.cpp:
+        (WebCore::MIMETypeRegistry::supportedImageMIMETypes):
+        * platform/graphics/cg/ImageDecoderCG.cpp:
+        (WebCore::animationPropertiesFromProperties):
+        * platform/graphics/cg/UTIRegistry.cpp:
+        (WebCore::defaultSupportedImageTypes):
+
 2020-02-12  Zalan Bujtas  <[email protected]>
 
         [LFC][IFC] Remove LineLayoutContext::m_partialTrailingTextItem

Modified: trunk/Source/WebCore/platform/MIMETypeRegistry.cpp (256500 => 256501)


--- trunk/Source/WebCore/platform/MIMETypeRegistry.cpp	2020-02-13 04:11:51 UTC (rev 256500)
+++ trunk/Source/WebCore/platform/MIMETypeRegistry.cpp	2020-02-13 05:53:32 UTC (rev 256501)
@@ -82,7 +82,9 @@
 
         "image/x-icon"_s, // Favicons don't have a MIME type in the registry either.
         "image/pjpeg"_s, //  We only get one MIME type per UTI, hence our need to add these manually
-
+#if HAVE(WEBP)
+        "image/webp"_s,
+#endif
 #if PLATFORM(IOS_FAMILY)
         // Add malformed image mimetype for compatibility with Mail and to handle malformed mimetypes from the net
         // These were removed for <rdar://problem/6564538> Re-enable UTI code in WebCore now that MobileCoreServices exists

Modified: trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp (256500 => 256501)


--- trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp	2020-02-13 04:11:51 UTC (rev 256500)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageDecoderCG.cpp	2020-02-13 05:53:32 UTC (rev 256501)
@@ -120,7 +120,10 @@
 
     if (auto animationProperties = (CFDictionaryRef)CFDictionaryGetValue(properties, kCGImagePropertyGIFDictionary))
         return animationProperties;
-
+#if HAVE(WEBP)
+    if (auto animationProperties = (CFDictionaryRef)CFDictionaryGetValue(properties, kCGImagePropertyWebPDictionary))
+        return animationProperties;
+#endif
     if (auto animationProperties = (CFDictionaryRef)CFDictionaryGetValue(properties, kCGImagePropertyPNGDictionary))
         return animationProperties;
 

Modified: trunk/Source/WebCore/platform/graphics/cg/UTIRegistry.cpp (256500 => 256501)


--- trunk/Source/WebCore/platform/graphics/cg/UTIRegistry.cpp	2020-02-13 04:11:51 UTC (rev 256500)
+++ trunk/Source/WebCore/platform/graphics/cg/UTIRegistry.cpp	2020-02-13 05:53:32 UTC (rev 256501)
@@ -35,10 +35,6 @@
 #include <wtf/NeverDestroyed.h>
 #include <ImageIO/ImageIO.h>
 
-#if ENABLE(WEB_ARCHIVE) || ENABLE(MHTML)
-#include "ArchiveFactory.h"
-#endif
-
 namespace WebCore {
 
 const HashSet<String>& defaultSupportedImageTypes()
@@ -45,17 +41,20 @@
 {
     // CG at least supports the following standard image types:
     static NeverDestroyed<HashSet<String>> defaultSupportedImageTypes = std::initializer_list<String> {
-        "com.compuserve.gif",
-        "com.microsoft.bmp",
-        "com.microsoft.cur",
-        "com.microsoft.ico",
-        "public.jpeg",
-        "public.png",
-        "public.tiff",
+        "com.compuserve.gif"_s,
+        "com.microsoft.bmp"_s,
+        "com.microsoft.cur"_s,
+        "com.microsoft.ico"_s,
+        "public.jpeg"_s,
+        "public.png"_s,
+        "public.tiff"_s,
 #if !PLATFORM(WIN)
-        "public.jpeg-2000",
-        "public.mpo-image",
+        "public.jpeg-2000"_s,
+        "public.mpo-image"_s,
 #endif
+#if HAVE(WEBP)
+        "public.webp"_s,
+#endif
     };
 
 #ifndef NDEBUG
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to