Title: [259701] trunk
Revision
259701
Author
za...@apple.com
Date
2020-04-07 20:36:05 -0700 (Tue, 07 Apr 2020)

Log Message

fastclick.com: A Gradient banner is missing
https://bugs.webkit.org/show_bug.cgi?id=210169
<rdar://problem/60680979>

Reviewed by Simon Fraser.

Source/WebCore:

This patch ensures that if the non-fixed specified size for the background content computes to be a close-to-zero value, we produce at least one device pixel size content.
(and this is similar to what we do for FillSizeType::Contain/Cover.)

Test: fast/backgrounds/generated-bck-image-with-small-relative-size.html

* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::calculateFillTileSize const):

LayoutTests:

* fast/backgrounds/generated-bck-image-with-small-relative-size-expected.html: Added.
* fast/backgrounds/generated-bck-image-with-small-relative-size.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (259700 => 259701)


--- trunk/LayoutTests/ChangeLog	2020-04-08 02:38:42 UTC (rev 259700)
+++ trunk/LayoutTests/ChangeLog	2020-04-08 03:36:05 UTC (rev 259701)
@@ -1,3 +1,14 @@
+2020-04-07  Zalan Bujtas  <za...@apple.com>
+
+        fastclick.com: A Gradient banner is missing
+        https://bugs.webkit.org/show_bug.cgi?id=210169
+        <rdar://problem/60680979>
+
+        Reviewed by Simon Fraser.
+
+        * fast/backgrounds/generated-bck-image-with-small-relative-size-expected.html: Added.
+        * fast/backgrounds/generated-bck-image-with-small-relative-size.html: Added.
+
 2020-04-07  Per Arne Vollan  <pvol...@apple.com>
 
         [iOS] Deny mach lookup access to the runningboard service in the WebContent process

Added: trunk/LayoutTests/fast/backgrounds/generated-bck-image-with-small-relative-size-expected.html (0 => 259701)


--- trunk/LayoutTests/fast/backgrounds/generated-bck-image-with-small-relative-size-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/backgrounds/generated-bck-image-with-small-relative-size-expected.html	2020-04-08 03:36:05 UTC (rev 259701)
@@ -0,0 +1,8 @@
+<style>
+div {
+    background-color: green;
+}
+</style>
+This tests that generated background images with relatively small size show up.
+<div style="height: 10px; width: 100px;"></div>
+<div style="height: 100px; width: 10px;"></div>

Added: trunk/LayoutTests/fast/backgrounds/generated-bck-image-with-small-relative-size.html (0 => 259701)


--- trunk/LayoutTests/fast/backgrounds/generated-bck-image-with-small-relative-size.html	                        (rev 0)
+++ trunk/LayoutTests/fast/backgrounds/generated-bck-image-with-small-relative-size.html	2020-04-08 03:36:05 UTC (rev 259701)
@@ -0,0 +1,8 @@
+<style>
+div {
+    background: linear-gradient(green, green);
+}
+</style>
+This tests that generated background images with relatively small size show up.
+<div style="height: 10px; width: 100px; background-size: 100% 1%;"></div>
+<div style="height: 100px; width: 10px; background-size: 1% 100%;"></div>

Modified: trunk/Source/WebCore/ChangeLog (259700 => 259701)


--- trunk/Source/WebCore/ChangeLog	2020-04-08 02:38:42 UTC (rev 259700)
+++ trunk/Source/WebCore/ChangeLog	2020-04-08 03:36:05 UTC (rev 259701)
@@ -1,3 +1,19 @@
+2020-04-07  Zalan Bujtas  <za...@apple.com>
+
+        fastclick.com: A Gradient banner is missing
+        https://bugs.webkit.org/show_bug.cgi?id=210169
+        <rdar://problem/60680979>
+
+        Reviewed by Simon Fraser.
+
+        This patch ensures that if the non-fixed specified size for the background content computes to be a close-to-zero value, we produce at least one device pixel size content.
+        (and this is similar to what we do for FillSizeType::Contain/Cover.)
+
+        Test: fast/backgrounds/generated-bck-image-with-small-relative-size.html
+
+        * rendering/RenderBoxModelObject.cpp:
+        (WebCore::RenderBoxModelObject::calculateFillTileSize const):
+
 2020-04-07  Joonghun Park  <jh718.p...@samsung.com>
 
         Unreviewed. remove the build warning below since r243033.

Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp (259700 => 259701)


--- trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp	2020-04-08 02:38:42 UTC (rev 259700)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp	2020-04-08 03:36:05 UTC (rev 259701)
@@ -1069,6 +1069,7 @@
 {
     StyleImage* image = fillLayer.image();
     FillSizeType type = fillLayer.size().type;
+    auto devicePixelSize = LayoutUnit { 1.0 / document().deviceScaleFactor() };
 
     LayoutSize imageIntrinsicSize;
     if (image) {
@@ -1086,13 +1087,19 @@
 
         if (layerWidth.isFixed())
             tileSize.setWidth(layerWidth.value());
-        else if (layerWidth.isPercentOrCalculated())
-            tileSize.setWidth(valueForLength(layerWidth, positioningAreaSize.width()));
+        else if (layerWidth.isPercentOrCalculated()) {
+            auto resolvedWidth = valueForLength(layerWidth, positioningAreaSize.width());
+            // Non-zero resolved value should always produce some content.
+            tileSize.setWidth(!resolvedWidth ? resolvedWidth : std::max(devicePixelSize, resolvedWidth));
+        }
         
         if (layerHeight.isFixed())
             tileSize.setHeight(layerHeight.value());
-        else if (layerHeight.isPercentOrCalculated())
-            tileSize.setHeight(valueForLength(layerHeight, positioningAreaSize.height()));
+        else if (layerHeight.isPercentOrCalculated()) {
+            auto resolvedHeight = valueForLength(layerHeight, positioningAreaSize.height());
+            // Non-zero resolved value should always produce some content.
+            tileSize.setHeight(!resolvedHeight ? resolvedHeight : std::max(devicePixelSize, resolvedHeight));
+        }
 
         // If one of the values is auto we have to use the appropriate
         // scale to maintain our aspect ratio.
@@ -1128,12 +1135,11 @@
         float horizontalScaleFactor = localImageIntrinsicSize.width() ? (localPositioningAreaSize.width() / localImageIntrinsicSize.width()) : 1;
         float verticalScaleFactor = localImageIntrinsicSize.height() ? (localPositioningAreaSize.height() / localImageIntrinsicSize.height()) : 1;
         float scaleFactor = type == FillSizeType::Contain ? std::min(horizontalScaleFactor, verticalScaleFactor) : std::max(horizontalScaleFactor, verticalScaleFactor);
-        float singleScaledPixel = 1.0 / document().deviceScaleFactor();
         
         if (localImageIntrinsicSize.isEmpty())
             return { };
         
-        return LayoutSize(localImageIntrinsicSize.scaled(scaleFactor).expandedTo({ singleScaledPixel, singleScaledPixel }));
+        return LayoutSize(localImageIntrinsicSize.scaled(scaleFactor).expandedTo({ devicePixelSize, devicePixelSize }));
     }
     }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to