Title: [261548] trunk
Revision
261548
Author
[email protected]
Date
2020-05-12 00:20:57 -0700 (Tue, 12 May 2020)

Log Message

Need to advertise support for WebP in the Accept header
https://bugs.webkit.org/show_bug.cgi?id=211735

Patch by Said Abou-Hallawa <[email protected]> on 2020-05-12
Reviewed by Darin Adler.

Source/WebCore:

On Mac and iOS, the system has to support WebP: HAVE(WEBP).
On other platforms, WebKit has to be able to decode WebP images: USE(WEBP).

* css/CSSCalculationValue.cpp:
(WebCore::createCSS):
Fix unrealted coding style issue.

* loader/cache/CachedResourceRequest.cpp:
(WebCore::acceptHeaderValueForImageResource):
(WebCore::acceptHeaderValueFromType):

LayoutTests:

* http/tests/misc/resources/image-checks-for-accept.php:
Make sure the Accept header accepts all images mime types.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (261547 => 261548)


--- trunk/LayoutTests/ChangeLog	2020-05-12 05:52:55 UTC (rev 261547)
+++ trunk/LayoutTests/ChangeLog	2020-05-12 07:20:57 UTC (rev 261548)
@@ -1,3 +1,13 @@
+2020-05-12  Said Abou-Hallawa  <[email protected]>
+
+        Need to advertise support for WebP in the Accept header
+        https://bugs.webkit.org/show_bug.cgi?id=211735
+
+        Reviewed by Darin Adler.
+
+        * http/tests/misc/resources/image-checks-for-accept.php:
+        Make sure the Accept header accepts all images mime types.
+
 2020-05-11  Diego Pino Garcia  <[email protected]>
 
         [GTK] Gardening, update test expectations

Modified: trunk/LayoutTests/http/tests/misc/resources/image-checks-for-accept.php (261547 => 261548)


--- trunk/LayoutTests/http/tests/misc/resources/image-checks-for-accept.php	2020-05-12 05:52:55 UTC (rev 261547)
+++ trunk/LayoutTests/http/tests/misc/resources/image-checks-for-accept.php	2020-05-12 07:20:57 UTC (rev 261548)
@@ -1,6 +1,7 @@
 <?php
-    if($_SERVER["HTTP_ACCEPT"] == "image/png,image/svg+xml,image/*;q=0.8,*/*;q=0.5"
-        || $_SERVER["HTTP_ACCEPT"] == "image/png,image/svg+xml,image/*;q=0.8,video/*;q=0.8,*/*;q=0.5")
+    $allimages = 'image/*';
+    $pos = strpos($_SERVER["HTTP_ACCEPT"], $allimages);
+    if ($pos !== false)
     {
         header("Content-Type: image/jpg");
         header("Cache-Control: no-store");

Modified: trunk/Source/WebCore/ChangeLog (261547 => 261548)


--- trunk/Source/WebCore/ChangeLog	2020-05-12 05:52:55 UTC (rev 261547)
+++ trunk/Source/WebCore/ChangeLog	2020-05-12 07:20:57 UTC (rev 261548)
@@ -1,3 +1,21 @@
+2020-05-12  Said Abou-Hallawa  <[email protected]>
+
+        Need to advertise support for WebP in the Accept header
+        https://bugs.webkit.org/show_bug.cgi?id=211735
+
+        Reviewed by Darin Adler.
+
+        On Mac and iOS, the system has to support WebP: HAVE(WEBP).
+        On other platforms, WebKit has to be able to decode WebP images: USE(WEBP).
+
+        * css/CSSCalculationValue.cpp:
+        (WebCore::createCSS):
+        Fix unrealted coding style issue.
+
+        * loader/cache/CachedResourceRequest.cpp:
+        (WebCore::acceptHeaderValueForImageResource):
+        (WebCore::acceptHeaderValueFromType):
+
 2020-05-11  Darin Adler  <[email protected]>
 
         Fix problems caught by replacing WTF::Optional with std::optional

Modified: trunk/Source/WebCore/css/CSSCalculationValue.cpp (261547 => 261548)


--- trunk/Source/WebCore/css/CSSCalculationValue.cpp	2020-05-12 05:52:55 UTC (rev 261547)
+++ trunk/Source/WebCore/css/CSSCalculationValue.cpp	2020-05-12 07:20:57 UTC (rev 261548)
@@ -1954,7 +1954,8 @@
             if (children.isEmpty())
                 return nullptr;
             return CSSCalcOperationNode::createSum(WTFMove(children));
-        } case CalcOperator::Subtract: {
+        }
+        case CalcOperator::Subtract: {
             ASSERT(operationChildren.size() == 2);
 
             Vector<Ref<CSSCalcExpressionNode>> values;

Modified: trunk/Source/WebCore/loader/cache/CachedResourceRequest.cpp (261547 => 261548)


--- trunk/Source/WebCore/loader/cache/CachedResourceRequest.cpp	2020-05-12 05:52:55 UTC (rev 261547)
+++ trunk/Source/WebCore/loader/cache/CachedResourceRequest.cpp	2020-05-12 07:20:57 UTC (rev 261548)
@@ -122,6 +122,19 @@
     m_resourceRequest.setDomainForCachePartition(domain);
 }
 
+static inline constexpr ASCIILiteral acceptHeaderValueForImageResource(bool supportsVideoImage)
+{
+#if HAVE(WEBP) || USE(WEBP)
+    #define WEBP_HEADER_PART "image/webp,"
+#else
+    #define WEBP_HEADER_PART ""
+#endif
+    if (supportsVideoImage)
+        return WEBP_HEADER_PART "image/png,image/svg+xml,image/*;q=0.8,video/*;q=0.8,*/*;q=0.5"_s;
+    return WEBP_HEADER_PART "image/png,image/svg+xml,image/*;q=0.8,*/*;q=0.5"_s;
+    #undef WEBP_HEADER_PART
+}
+
 static inline String acceptHeaderValueFromType(CachedResource::Type type)
 {
     switch (type) {
@@ -128,9 +141,7 @@
     case CachedResource::Type::MainResource:
         return "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"_s;
     case CachedResource::Type::ImageResource:
-        if (ImageDecoder::supportsMediaType(ImageDecoder::MediaType::Video))
-            return "image/png,image/svg+xml,image/*;q=0.8,video/*;q=0.8,*/*;q=0.5"_s;
-        return "image/png,image/svg+xml,image/*;q=0.8,*/*;q=0.5"_s;
+        return acceptHeaderValueForImageResource(ImageDecoder::supportsMediaType(ImageDecoder::MediaType::Video));
     case CachedResource::Type::CSSStyleSheet:
         return "text/css,*/*;q=0.1"_s;
     case CachedResource::Type::SVGDocumentResource:
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to