Repeated background images with zero size should display the background color
authorjustin_michaud@apple.com <justin_michaud@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Dec 2018 17:33:14 +0000 (17:33 +0000)
committerjustin_michaud@apple.com <justin_michaud@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Dec 2018 17:33:14 +0000 (17:33 +0000)
https://bugs.webkit.org/show_bug.cgi?id=192962

Reviewed by Antti Koivisto.

Source/WebCore:

Test: fast/backgrounds/background-repeat-with-zero-size.html

* platform/LengthSize.h:
(WebCore::LengthSize::isEmpty const):
* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::paintFillLayerExtended):
* rendering/style/FillLayer.h:
(WebCore::FillLayer::isEmpty const):

LayoutTests:

Fix a rendering bug exposed by the CSS Variable wpt tests where repeated backgrounds with zero size
not draw the background colour underneath.

* fast/backgrounds/background-repeat-with-zero-size-expected.html: Added.
* fast/backgrounds/background-repeat-with-zero-size.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239504 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/backgrounds/background-repeat-with-zero-size-expected.html [new file with mode: 0644]
LayoutTests/fast/backgrounds/background-repeat-with-zero-size.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/LengthSize.h
Source/WebCore/rendering/RenderBoxModelObject.cpp
Source/WebCore/rendering/style/FillLayer.h

index cb4007d..c1a1a05 100644 (file)
@@ -1,3 +1,16 @@
+2018-12-21  Justin Michaud  <justin_michaud@apple.com>
+
+        Repeated background images with zero size should display the background color
+        https://bugs.webkit.org/show_bug.cgi?id=192962
+
+        Reviewed by Antti Koivisto.
+
+        Fix a rendering bug exposed by the CSS Variable wpt tests where repeated backgrounds with zero size
+        not draw the background colour underneath.
+
+        * fast/backgrounds/background-repeat-with-zero-size-expected.html: Added.
+        * fast/backgrounds/background-repeat-with-zero-size.html: Added.
+
 2018-12-20  Brent Fulgham  <bfulgham@apple.com>
 
         Show punycode if URL contains Latin small letter dotless i
diff --git a/LayoutTests/fast/backgrounds/background-repeat-with-zero-size-expected.html b/LayoutTests/fast/backgrounds/background-repeat-with-zero-size-expected.html
new file mode 100644 (file)
index 0000000..e7f5dd5
--- /dev/null
@@ -0,0 +1,17 @@
+<style>
+.el {
+  width: 150px;
+  height: 150px;
+  background-color: green;
+}
+</style>
+
+<div class="el el1">
+</div>
+
+<div class="el el2" >
+</div>
+
+<div class="el el3" style="position: relative;">
+<div style="background: red; width: 10px; height: 10px; position: absolute; top: 0; left: 0;"></div>
+</div>
diff --git a/LayoutTests/fast/backgrounds/background-repeat-with-zero-size.html b/LayoutTests/fast/backgrounds/background-repeat-with-zero-size.html
new file mode 100644 (file)
index 0000000..956fa5d
--- /dev/null
@@ -0,0 +1,31 @@
+<style>
+.el {
+  width: 150px;
+  height: 150px;
+  background-color: green;
+  background-image: linear-gradient(red,red);
+  background-size: 0 0;
+}
+
+.el1 {
+  background-repeat: repeat;
+}
+
+.el2 {
+  background-repeat: no-repeat;
+}
+
+.el3 {
+  background-repeat: no-repeat;
+  background-size: 10px 10px;
+}
+</style>
+
+<div class="el el1">
+</div>
+
+<div class="el el2">
+</div>
+
+<div class="el el3">
+</div>
index 236fedc..d799083 100644 (file)
@@ -1,3 +1,19 @@
+2018-12-21  Justin Michaud  <justin_michaud@apple.com>
+
+        Repeated background images with zero size should display the background color
+        https://bugs.webkit.org/show_bug.cgi?id=192962
+
+        Reviewed by Antti Koivisto.
+
+        Test: fast/backgrounds/background-repeat-with-zero-size.html
+
+        * platform/LengthSize.h:
+        (WebCore::LengthSize::isEmpty const):
+        * rendering/RenderBoxModelObject.cpp:
+        (WebCore::RenderBoxModelObject::paintFillLayerExtended):
+        * rendering/style/FillLayer.h:
+        (WebCore::FillLayer::isEmpty const):
+
 2018-12-21  Manuel Rego Casasnovas  <rego@igalia.com>
 
         [css-grid] Fix percentages in relative offsets for grid items
index 03b2775..22a81bf 100644 (file)
@@ -26,6 +26,8 @@ namespace WebCore {
 struct LengthSize {
     Length width;
     Length height;
+
+    bool isEmpty() const { return width.isZero() || height.isZero(); }
 };
 
 ALWAYS_INLINE bool operator==(const LengthSize& a, const LengthSize& b)
index fdc511c..2437476 100644 (file)
@@ -950,7 +950,7 @@ void RenderBoxModelObject::paintFillLayerExtended(const PaintInfo& paintInfo, co
     if (!bgLayer.next()) {
         LayoutRect backgroundRect(scrolledPaintRect);
         bool boxShadowShouldBeAppliedToBackground = this->boxShadowShouldBeAppliedToBackground(rect.location(), bleedAvoidance, box);
-        if (boxShadowShouldBeAppliedToBackground || !shouldPaintBackgroundImage || !bgLayer.hasOpaqueImage(*this) || !bgLayer.hasRepeatXY()) {
+        if (boxShadowShouldBeAppliedToBackground || !shouldPaintBackgroundImage || !bgLayer.hasOpaqueImage(*this) || !bgLayer.hasRepeatXY() || bgLayer.isEmpty()) {
             if (!boxShadowShouldBeAppliedToBackground)
                 backgroundRect.intersect(paintInfo.rect);
 
index e2be958..57ddd87 100644 (file)
@@ -101,6 +101,8 @@ public:
     bool isSizeSet() const { return static_cast<FillSizeType>(m_sizeType) != FillSizeType::None; }
     bool isMaskSourceTypeSet() const { return m_maskSourceTypeSet; }
 
+    bool isEmpty() const { return (sizeType() == FillSizeType::Size && m_sizeLength.isEmpty()) || sizeType() == FillSizeType::None; }
+
     void setImage(RefPtr<StyleImage>&& image) { m_image = WTFMove(image); m_imageSet = true; }
     void setXPosition(Length length) { m_xPosition = WTFMove(length); m_xPosSet = true; }
     void setYPosition(Length length) { m_yPosition = WTFMove(length); m_yPosSet = true; }