Use render box background over border draw strategy in cases with background-image
authorjunov@google.com <junov@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Dec 2012 17:11:37 +0000 (17:11 +0000)
committerjunov@google.com <junov@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Dec 2012 17:11:37 +0000 (17:11 +0000)
https://bugs.webkit.org/show_bug.cgi?id=103409

Reviewed by Simon Fraser.

Source/WebCore:

The BackgroundOverBorderBleedAvoidance mode was not being used in
cases where the background is an opaque image. It was also not
being used in cases with multiple layers. The multiple layer
case is now safe with respect to color bleeding if the top layer
is opaque, thank to the recent addition of layer occlusion culling
in r135629.

No new tests. Testing already covered by the following tests:
fast/backgrounds/background-opaque-images-over-color.html
fast/backgrounds/gradient-background-leakage-2.html

* rendering/RenderBox.cpp:
(WebCore::RenderBox::determineBackgroundBleedAvoidance):
(WebCore::RenderBox::backgroundHasOpaqueTopLayer):
* rendering/RenderBox.h:
(RenderBox):

LayoutTests:

Added image failure expectation for
fast/backgrounds/gradient-background-leakage-2.html which needs
new baselines.

* platform/chromium/TestExpectations:

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

LayoutTests/ChangeLog
LayoutTests/platform/chromium/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderBox.cpp
Source/WebCore/rendering/RenderBox.h

index e67834c..bcf59ff 100644 (file)
@@ -1,3 +1,16 @@
+2012-12-12  Justin Novosad  <junov@google.com>
+
+        Use render box background over border draw strategy in cases with background-image
+        https://bugs.webkit.org/show_bug.cgi?id=103409
+
+        Reviewed by Simon Fraser.
+
+        Added image failure expectation for 
+        fast/backgrounds/gradient-background-leakage-2.html which needs
+        new baselines.
+
+        * platform/chromium/TestExpectations:
+
 2012-12-12  Philippe Normand  <pnormand@igalia.com>
 
         Unreviewed, GTK gardening. Flag some flaky media tests after r137271.
index 106278c..269b185 100644 (file)
@@ -2142,6 +2142,9 @@ crbug.com/77494 [ Android ] fast/repaint/transform-replaced-shadows.html [ Failu
 
 crbug.com/43890 [ Win ] http/tests/loading/basic.html [ Failure Pass ]
 
+# Test need new image baselines with fix for webkit.org/b/103409
+webkit.org/b/103409 fast/backgrounds/gradient-background-leakage-2.html [ ImageOnlyFailure Pass ]
+
 # The following tests fail on all platforms and need further investigation.
 # Many of these are skipped on the Mac platform
 webkit.org/b/45991 canvas/philip/tests/2d.drawImage.broken.html [ Failure ]
index 1d098d7..d29149e 100644 (file)
@@ -1,3 +1,27 @@
+2012-12-12  Justin Novosad  <junov@google.com>
+
+        Use render box background over border draw strategy in cases with background-image
+        https://bugs.webkit.org/show_bug.cgi?id=103409
+
+        Reviewed by Simon Fraser.
+
+        The BackgroundOverBorderBleedAvoidance mode was not being used in
+        cases where the background is an opaque image. It was also not
+        being used in cases with multiple layers. The multiple layer
+        case is now safe with respect to color bleeding if the top layer
+        is opaque, thank to the recent addition of layer occlusion culling
+        in r135629.
+
+        No new tests. Testing already covered by the following tests:
+        fast/backgrounds/background-opaque-images-over-color.html
+        fast/backgrounds/gradient-background-leakage-2.html
+
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::determineBackgroundBleedAvoidance):
+        (WebCore::RenderBox::backgroundHasOpaqueTopLayer):
+        * rendering/RenderBox.h:
+        (RenderBox):
+
 2012-12-12  Ilya Tikhonovsky  <loislo@chromium.org>
 
         Web Inspector: instrument static parts of RenderBlock and RenderBox
index d8ff2a5..252d309 100644 (file)
@@ -888,7 +888,7 @@ BackgroundBleedAvoidance RenderBox::determineBackgroundBleedAvoidance(GraphicsCo
     FloatSize contextScaling(static_cast<float>(ctm.xScale()), static_cast<float>(ctm.yScale()));
     if (borderObscuresBackgroundEdge(contextScaling))
         return BackgroundBleedShrinkBackground;
-    if (!style->hasAppearance() && borderObscuresBackground() && backgroundIsSingleOpaqueLayer())
+    if (!style->hasAppearance() && borderObscuresBackground() && backgroundHasOpaqueTopLayer())
         return BackgroundBleedBackgroundOverBorder;
 
     return BackgroundBleedUseTransparencyLayer;
@@ -961,21 +961,25 @@ void RenderBox::paintBackground(const PaintInfo& paintInfo, const LayoutRect& pa
     }
 }
 
-bool RenderBox::backgroundIsSingleOpaqueLayer() const
+bool RenderBox::backgroundHasOpaqueTopLayer() const
 {
     const FillLayer* fillLayer = style()->backgroundLayers();
-    if (!fillLayer || fillLayer->next() || fillLayer->clip() != BorderFillBox || fillLayer->composite() != CompositeSourceOver)
+    if (!fillLayer || fillLayer->clip() != BorderFillBox)
         return false;
 
     // Clipped with local scrolling
     if (hasOverflowClip() && fillLayer->attachment() == LocalBackgroundAttachment)
         return false;
 
-    Color bgColor = style()->visitedDependentColor(CSSPropertyBackgroundColor);
-    if (bgColor.isValid() && bgColor.alpha() == 255)
+    if (fillLayer->hasOpaqueImage(this) && fillLayer->hasRepeatXY() && fillLayer->image()->canRender(this, style()->effectiveZoom()))
         return true;
-    
-    // FIXME: return true if a background image is present and is opaque
+
+    // If there is only one layer and no image, check whether the background color is opaque
+    if (!fillLayer->next() && !fillLayer->hasImage()) {
+        Color bgColor = style()->visitedDependentColor(CSSPropertyBackgroundColor);
+        if (bgColor.isValid() && bgColor.alpha() == 255)
+            return true;
+    }
 
     return false;
 }
index 8447b3d..5b8a6e4 100644 (file)
@@ -585,7 +585,7 @@ protected:
     void paintMaskImages(const PaintInfo&, const LayoutRect&);
 
     BackgroundBleedAvoidance determineBackgroundBleedAvoidance(GraphicsContext*) const;
-    bool backgroundIsSingleOpaqueLayer() const;
+    bool backgroundHasOpaqueTopLayer() const;
 
 #if PLATFORM(MAC)
     void paintCustomHighlight(const LayoutPoint&, const AtomicString& type, bool behindText);