1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 17:57:35 +00:00

LibWeb: Allow LengthPercentage to hold a calculated value

Most of the time, we cannot resolve a `calc()` expression until we go to
use it. Since any `<length-percentage>` can legally be a `calc
()`, let's store it in `LengthPercentage` rather than make every single
user care about this distinction.
This commit is contained in:
Sam Atkins 2022-01-27 14:38:59 +00:00 committed by Andreas Kling
parent f0fb84dfcb
commit ce0de4b2b4
11 changed files with 145 additions and 107 deletions

View file

@ -17,10 +17,10 @@ BorderRadiusData normalized_border_radius_data(Layout::Node const& node, Gfx::Fl
// Spec just says "Refer to corresponding dimension of the border box."
// For now, all relative values are relative to the width.
auto width_length = CSS::Length::make_px(rect.width());
auto bottom_left_radius_px = bottom_left_radius.resolved(width_length).resolved_or_zero(node).to_px(node);
auto bottom_right_radius_px = bottom_right_radius.resolved(width_length).resolved_or_zero(node).to_px(node);
auto top_left_radius_px = top_left_radius.resolved(width_length).resolved_or_zero(node).to_px(node);
auto top_right_radius_px = top_right_radius.resolved(width_length).resolved_or_zero(node).to_px(node);
auto bottom_left_radius_px = bottom_left_radius.resolved(node, width_length).resolved_or_zero(node).to_px(node);
auto bottom_right_radius_px = bottom_right_radius.resolved(node, width_length).resolved_or_zero(node).to_px(node);
auto top_left_radius_px = top_left_radius.resolved(node, width_length).resolved_or_zero(node).to_px(node);
auto top_right_radius_px = top_right_radius.resolved(node, width_length).resolved_or_zero(node).to_px(node);
// Scale overlapping curves according to https://www.w3.org/TR/css-backgrounds-3/#corner-overlap
auto f = 1.0f;