Skip to content

Commit

Permalink
BackgroundPainter::paintFillLayers should check box-shadow when fin…
Browse files Browse the repository at this point in the history
…ding an opaque layer

https://bugs.webkit.org/show_bug.cgi?id=250882
rdar://problem/104722307

Reviewed by Antti Koivisto.

This patch aligns WebKit with Gecko / Firefox and Blink / Chromium.

Merge: https://chromium.googlesource.com/chromium/blink/+/a48f4540763c24adff42b9b77d719597f51482f6

BackgroundPainter::paintFillLayers has a fast path when a layer has an opaque background image.
If a layer has an opaque background image, basically the layer's background layers will be
hidden by the background image. So we can skip rendering the background layers.
However, if box-shadow is also specified, the box-shadow will be rendered in a skipped background layer.

This causes "box-shadow disappears". We cannot use the fast path if box-shadow is specified.

* Source/WebCore/rendering/BackgroundPainter.cpp:
(BackgroundPainter::paintFillLayers):
* LayoutTests/fast/box-shadow/normal-box-shadow-with-background-image.html: Add Test Case
* LayoutTests/fast/box-shadow/normal-box-shadow-with-background-image-expected-mismatch.html: Add Test Case Expectation Mismatch

Canonical link: https://commits.webkit.org/275735@main
  • Loading branch information
Ahmad-S792 authored and Ahmad Saleem committed Mar 6, 2024
1 parent c602819 commit b6231f7
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!doctype html>
<html>
<head>
<style>
#theDiv {
height: 48px;
background-color: lightgrey;
width: 200px;
background-image: linear-gradient(red, lime), linear-gradient(blue, cyan);
}
</style>
</head>
<body>
<div id="theDiv"></div>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!doctype html>
<html>
<head>
<style>
#theDiv {
height: 48px;
background-color: lightgrey;
box-shadow: black 0px 2px 4px;
width: 200px;
background-image: linear-gradient(red, green), linear-gradient(blue, cyan);
}
</style>
</head>
<body>
<div id="theDiv"></div>
</body>
</html>
4 changes: 2 additions & 2 deletions Source/WebCore/rendering/BackgroundPainter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
* (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com)
* Copyright (C) 2005-2022 Apple Inc. All rights reserved.
* Copyright (C) 2010 Google Inc. All rights reserved.
* Copyright (C) 2010-2013 Google Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
Expand Down Expand Up @@ -131,7 +131,7 @@ void BackgroundPainter::paintFillLayers(const Color& color, const FillLayer& fil
// and pass it down.

// The clipOccludesNextLayers condition must be evaluated first to avoid short-circuiting.
if (layer->clipOccludesNextLayers(layer == &fillLayer) && layer->hasOpaqueImage(m_renderer) && layer->image()->canRender(&m_renderer, m_renderer.style().effectiveZoom()) && layer->hasRepeatXY() && layer->blendMode() == BlendMode::Normal)
if (layer->clipOccludesNextLayers(layer == &fillLayer) && layer->hasOpaqueImage(m_renderer) && layer->image()->canRender(&m_renderer, m_renderer.style().effectiveZoom()) && layer->hasRepeatXY() && layer->blendMode() == BlendMode::Normal && !boxShadowShouldBeAppliedToBackground(m_renderer, rect.location(), bleedAvoidance, { }))
break;
}

Expand Down

0 comments on commit b6231f7

Please sign in to comment.