Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(230)

Unified Diff: third_party/WebKit/Source/core/paint/BoxDecorationData.cpp

Issue 1675823002: Force bleed avoidance for some background image rendering (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Image over image test Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/paint/BoxDecorationData.cpp
diff --git a/third_party/WebKit/Source/core/paint/BoxDecorationData.cpp b/third_party/WebKit/Source/core/paint/BoxDecorationData.cpp
index ef35fb1fffab783a39ddaa21d7c09b690541270b..dafa5088679eacd4808ba2454147c3c514503b6d 100644
--- a/third_party/WebKit/Source/core/paint/BoxDecorationData.cpp
+++ b/third_party/WebKit/Source/core/paint/BoxDecorationData.cpp
@@ -5,6 +5,7 @@
#include "core/paint/BoxDecorationData.h"
#include "core/layout/LayoutBox.h"
+#include "core/paint/BoxPainter.h"
#include "core/style/BorderEdge.h"
#include "core/style/ComputedStyle.h"
#include "platform/RuntimeEnabledFeatures.h"
@@ -47,13 +48,25 @@ BackgroundBleedAvoidance BoxDecorationData::determineBackgroundBleedAvoidance(co
if (!hasBackground)
return BackgroundBleedNone;
- if (!hasBorderDecoration || !layoutBox.style()->hasBorderRadius() || layoutBox.canRenderBorderImage()) {
+ const ComputedStyle& boxStyle = layoutBox.styleRef();
+ const bool hasBorderRadius = boxStyle.hasBorderRadius();
+ if (!hasBorderDecoration || !hasBorderRadius || layoutBox.canRenderBorderImage()) {
if (layoutBox.backgroundShouldAlwaysBeClipped())
return BackgroundBleedClipOnly;
+ // Border radius clipping may require layer bleed avoidance if we are going to draw
+ // an image over something else, because we do not want the antialiasing to lead to bleeding
+ if (boxStyle.hasBackgroundImage() && hasBorderRadius) {
+ // But if the top layer is opaque for the purposes of background painting, we do not
+ // need the bleed avoidance because we will not paint anything behind the top layer.
+ // But only if we need to draw something underneath.
+ const FillLayer& fillLayer = layoutBox.style()->backgroundLayers();
+ if ((backgroundColor.alpha() || fillLayer.next()) && !BoxPainter::isFillLayerOpaque(fillLayer, layoutBox))
+ return BackgroundBleedClipLayer;
+ }
return BackgroundBleedNone;
}
- if (borderObscuresBackgroundEdge(*layoutBox.style()))
+ if (borderObscuresBackgroundEdge(boxStyle))
return BackgroundBleedShrinkBackground;
return BackgroundBleedClipLayer;

Powered by Google App Engine
This is Rietveld 408576698