1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 07:07:45 +00:00

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
parent d1aea87889
commit 29b2022303

View file

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