From b2dea4577a114f938a0d8a3361a55777cf809d0a Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Wed, 2 Jul 2025 12:34:42 +0100 Subject: [PATCH] LibWeb/Painting: Only calculate light/dark border color that's used We previously calculated both before deciding which one we wanted. --- Libraries/LibWeb/Painting/BorderPainting.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Libraries/LibWeb/Painting/BorderPainting.cpp b/Libraries/LibWeb/Painting/BorderPainting.cpp index 157ab75fc6f..4787b5c17ff 100644 --- a/Libraries/LibWeb/Painting/BorderPainting.cpp +++ b/Libraries/LibWeb/Painting/BorderPainting.cpp @@ -54,13 +54,14 @@ Gfx::Color border_color(BorderEdge edge, BordersDataDevicePixels const& borders_ }(); if (border_data.line_style == CSS::LineStyle::Inset) { - auto top_left_color = dark_color_for_inset_and_outset(border_data.color); - auto bottom_right_color = light_color_for_inset_and_outset(border_data.color); - return (edge == BorderEdge::Left || edge == BorderEdge::Top) ? top_left_color : bottom_right_color; - } else if (border_data.line_style == CSS::LineStyle::Outset) { - auto top_left_color = light_color_for_inset_and_outset(border_data.color); - auto bottom_right_color = dark_color_for_inset_and_outset(border_data.color); - return (edge == BorderEdge::Left || edge == BorderEdge::Top) ? top_left_color : bottom_right_color; + if (edge == BorderEdge::Left || edge == BorderEdge::Top) + return dark_color_for_inset_and_outset(border_data.color); + return light_color_for_inset_and_outset(border_data.color); + } + if (border_data.line_style == CSS::LineStyle::Outset) { + if (edge == BorderEdge::Left || edge == BorderEdge::Top) + return light_color_for_inset_and_outset(border_data.color); + return dark_color_for_inset_and_outset(border_data.color); } return border_data.color;