Title: [141267] branches/chromium/1364
- Revision
- 141267
- Author
- ju...@google.com
- Date
- 2013-01-30 07:06:43 -0800 (Wed, 30 Jan 2013)
Log Message
Merge 141160
> REGRESSION (r135628-135632): Double box shadow failure to render
> https://bugs.webkit.org/show_bug.cgi?id=107833
>
> Reviewed by Simon Fraser.
>
> Source/WebCore:
>
> Regression caused by http://trac.webkit.org/changeset/135629
> The regression was due to faulty occlusion logic that was assuming
> that drawing the background color of a render box background layer
> could be skipped when the same layer also has an opaque image attached.
> In the case where the background color is drawn for the purpose of
> rendering a box shadow, the shadow is typically not
> completely occluded by the background image because of the shadow
> blur and/or offset. This patch fixes the problem by not culling a
> background draw if it is used to draw a box shadow.
>
> Test: fast/backgrounds/gradient-background-shadow.html
>
> * rendering/RenderBoxModelObject.cpp:
> (WebCore::RenderBoxModelObject::paintFillLayerExtended):
> Changing occlusion culling test to never cull background color
> draw if it is used to draw a box shadow. This is because box shadows
> can draw outside the border fill region.
>
> LayoutTests:
>
> New ref test verifies that box shadow is drawn when
> background is an opaque image. Test uses an blue gradient
> as background image. Reference uses blue background color.
>
> * fast/backgrounds/gradient-background-shadow-expected.html: Added.
> * fast/backgrounds/gradient-background-shadow.html: Added.
>
TBR=ju...@google.com
Review URL: https://codereview.chromium.org/12089070
Modified Paths
Added Paths
Diff
Copied: branches/chromium/1364/LayoutTests/fast/backgrounds/gradient-background-shadow-expected.html (from rev 141160, trunk/LayoutTests/fast/backgrounds/gradient-background-shadow-expected.html) (0 => 141267)
--- branches/chromium/1364/LayoutTests/fast/backgrounds/gradient-background-shadow-expected.html (rev 0)
+++ branches/chromium/1364/LayoutTests/fast/backgrounds/gradient-background-shadow-expected.html 2013-01-30 15:06:43 UTC (rev 141267)
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <style type="text/css">
+ .box {
+ height: 50px;
+ width: 50px;
+ background-color: blue;
+ -webkit-box-shadow: 20px 20px 5px green;
+ }
+ </style>
+</head>
+<body>
+ Test passes when a blue box is drawn with a green shadow.
+ <div class="box"></div>
+</body>
+</html>
Copied: branches/chromium/1364/LayoutTests/fast/backgrounds/gradient-background-shadow.html (from rev 141160, trunk/LayoutTests/fast/backgrounds/gradient-background-shadow.html) (0 => 141267)
--- branches/chromium/1364/LayoutTests/fast/backgrounds/gradient-background-shadow.html (rev 0)
+++ branches/chromium/1364/LayoutTests/fast/backgrounds/gradient-background-shadow.html 2013-01-30 15:06:43 UTC (rev 141267)
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <style type="text/css">
+ .box {
+ height: 50px;
+ width: 50px;
+ background-image: -webkit-linear-gradient(blue, blue);
+ background-color: red;
+ -webkit-box-shadow: 20px 20px 5px green;
+ }
+ </style>
+</head>
+<body>
+ Test passes when a blue box is drawn with a green shadow.
+ <div class="box"></div>
+</body>
+</html>
Modified: branches/chromium/1364/Source/WebCore/rendering/RenderBoxModelObject.cpp (141266 => 141267)
--- branches/chromium/1364/Source/WebCore/rendering/RenderBoxModelObject.cpp 2013-01-30 15:00:04 UTC (rev 141266)
+++ branches/chromium/1364/Source/WebCore/rendering/RenderBoxModelObject.cpp 2013-01-30 15:06:43 UTC (rev 141267)
@@ -912,35 +912,37 @@
// Paint the color first underneath all images, culled if background image occludes it.
// FIXME: In the bgLayer->hasFiniteBounds() case, we could improve the culling test
// by verifying whether the background image covers the entire layout rect.
- if (!bgLayer->next() && !(shouldPaintBackgroundImage && bgLayer->hasOpaqueImage(this) && bgLayer->hasRepeatXY())) {
+ if (!bgLayer->next()) {
IntRect backgroundRect(pixelSnappedIntRect(scrolledPaintRect));
bool boxShadowShouldBeAppliedToBackground = this->boxShadowShouldBeAppliedToBackground(bleedAvoidance, box);
- if (!boxShadowShouldBeAppliedToBackground)
- backgroundRect.intersect(paintInfo.rect);
+ if (boxShadowShouldBeAppliedToBackground || !shouldPaintBackgroundImage || !bgLayer->hasOpaqueImage(this) || !bgLayer->hasRepeatXY()) {
+ if (!boxShadowShouldBeAppliedToBackground)
+ backgroundRect.intersect(paintInfo.rect);
- // If we have an alpha and we are painting the root element, go ahead and blend with the base background color.
- Color baseColor;
- bool shouldClearBackground = false;
- if (isOpaqueRoot) {
- baseColor = view()->frameView()->baseBackgroundColor();
- if (!baseColor.alpha())
- shouldClearBackground = true;
- }
+ // If we have an alpha and we are painting the root element, go ahead and blend with the base background color.
+ Color baseColor;
+ bool shouldClearBackground = false;
+ if (isOpaqueRoot) {
+ baseColor = view()->frameView()->baseBackgroundColor();
+ if (!baseColor.alpha())
+ shouldClearBackground = true;
+ }
- GraphicsContextStateSaver shadowStateSaver(*context, boxShadowShouldBeAppliedToBackground);
- if (boxShadowShouldBeAppliedToBackground)
- applyBoxShadowForBackground(context, style());
+ GraphicsContextStateSaver shadowStateSaver(*context, boxShadowShouldBeAppliedToBackground);
+ if (boxShadowShouldBeAppliedToBackground)
+ applyBoxShadowForBackground(context, style());
- if (baseColor.alpha()) {
- if (bgColor.alpha())
- baseColor = baseColor.blend(bgColor);
+ if (baseColor.alpha()) {
+ if (bgColor.alpha())
+ baseColor = baseColor.blend(bgColor);
- context->fillRect(backgroundRect, baseColor, style()->colorSpace(), CompositeCopy);
- } else if (bgColor.alpha()) {
- CompositeOperator operation = shouldClearBackground ? CompositeCopy : context->compositeOperation();
- context->fillRect(backgroundRect, bgColor, style()->colorSpace(), operation);
- } else if (shouldClearBackground)
- context->clearRect(backgroundRect);
+ context->fillRect(backgroundRect, baseColor, style()->colorSpace(), CompositeCopy);
+ } else if (bgColor.alpha()) {
+ CompositeOperator operation = shouldClearBackground ? CompositeCopy : context->compositeOperation();
+ context->fillRect(backgroundRect, bgColor, style()->colorSpace(), operation);
+ } else if (shouldClearBackground)
+ context->clearRect(backgroundRect);
+ }
}
// no progressive loading of the background image
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes