Commit ccd62ad9 authored by Fredrik Söderqvist's avatar Fredrik Söderqvist Committed by Chromium LUCI CQ

Use the same spread application for both inner and outer box shadows

Move the logic from PaintNormalBoxShadow() into a helper function
(ApplySpreadToShadowShape) and call that from PaintInsetBoxShadow() as
well (with the specified spread negated).

Bug: 1159514
Change-Id: I9cf91deaa998c5d1db23f0cad569697214fb493d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2624209Reviewed-by: default avatarStephen Chenney <schenney@chromium.org>
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#842539}
parent 0d47c073
...@@ -59,6 +59,24 @@ void BoxPainterBase::PaintFillLayers(const PaintInfo& paint_info, ...@@ -59,6 +59,24 @@ void BoxPainterBase::PaintFillLayers(const PaintInfo& paint_info,
context.EndLayer(); context.EndLayer();
} }
namespace {
void ApplySpreadToShadowShape(FloatRoundedRect& shadow_shape, float spread) {
if (spread == 0)
return;
if (spread >= 0)
shadow_shape.ExpandRadii(spread);
else
shadow_shape.ShrinkRadii(-spread);
if (!shadow_shape.IsRenderable())
shadow_shape.AdjustRadii();
shadow_shape.ConstrainRadii();
}
} // namespace
void BoxPainterBase::PaintNormalBoxShadow(const PaintInfo& info, void BoxPainterBase::PaintNormalBoxShadow(const PaintInfo& info,
const PhysicalRect& paint_rect, const PhysicalRect& paint_rect,
const ComputedStyle& style, const ComputedStyle& style,
...@@ -147,14 +165,7 @@ void BoxPainterBase::PaintNormalBoxShadow(const PaintInfo& info, ...@@ -147,14 +165,7 @@ void BoxPainterBase::PaintNormalBoxShadow(const PaintInfo& info,
if (has_border_radius) { if (has_border_radius) {
FloatRoundedRect rounded_fill_rect = border; FloatRoundedRect rounded_fill_rect = border;
rounded_fill_rect.Inflate(shadow_spread); rounded_fill_rect.Inflate(shadow_spread);
ApplySpreadToShadowShape(rounded_fill_rect, shadow_spread);
if (shadow_spread >= 0)
rounded_fill_rect.ExpandRadii(shadow_spread);
else
rounded_fill_rect.ShrinkRadii(-shadow_spread);
if (!rounded_fill_rect.IsRenderable())
rounded_fill_rect.AdjustRadii();
rounded_fill_rect.ConstrainRadii();
context.FillRoundedRect(rounded_fill_rect, Color::kBlack); context.FillRoundedRect(rounded_fill_rect, Color::kBlack);
} else { } else {
context.FillRect(fill_rect, Color::kBlack); context.FillRect(fill_rect, Color::kBlack);
...@@ -255,10 +266,7 @@ void BoxPainterBase::PaintInsetBoxShadow(const PaintInfo& info, ...@@ -255,10 +266,7 @@ void BoxPainterBase::PaintInsetBoxShadow(const PaintInfo& info,
GraphicsContextStateSaver state_saver(context); GraphicsContextStateSaver state_saver(context);
if (bounds.IsRounded()) { if (bounds.IsRounded()) {
context.ClipRoundedRect(bounds); context.ClipRoundedRect(bounds);
if (shadow.Spread() < 0) ApplySpreadToShadowShape(inner_rounded_rect, -shadow.Spread());
inner_rounded_rect.ExpandRadii(-shadow.Spread());
else
inner_rounded_rect.ShrinkRadii(shadow.Spread());
} else { } else {
context.Clip(bounds.Rect()); context.Clip(bounds.Rect());
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment