LibWeb: When growing or shrinking a border-radius, ignore it if it's 0

This function is used to calculate a matching radius that goes inside or
outside of the border. For example, if the border-radius is 10px and we
are 5px further out, the radius needs to be 15px to look right.
However, if the radius is 0 it isn't rounded, and we want to keep the
same sharp corner no matter how far we go.

This makes our outline rendering better match Chrome and Firefox.
This commit is contained in:
Sam Atkins 2023-08-24 14:31:04 +01:00 committed by Andreas Kling
commit 29b2022303
Notes: sideshowbarker 2024-07-17 09:37:30 +09:00

View file

@ -33,8 +33,10 @@ struct BorderRadiusData {
inline void shrink(CSSPixels horizontal, CSSPixels vertical) inline void shrink(CSSPixels horizontal, CSSPixels vertical)
{ {
horizontal_radius = max(CSSPixels(0), horizontal_radius - horizontal); if (horizontal_radius != 0)
vertical_radius = max(CSSPixels(0), vertical_radius - vertical); horizontal_radius = max(CSSPixels(0), horizontal_radius - horizontal);
if (vertical_radius != 0)
vertical_radius = max(CSSPixels(0), vertical_radius - vertical);
} }
}; };