mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 17:57:35 +00:00
LibWeb: Convert border-radii from Length to LengthPercentage :^)
The visit_lengths() code is a bit awkward but we'll clean that up later.
This commit is contained in:
parent
2a3abf09ff
commit
f75e796909
5 changed files with 46 additions and 34 deletions
|
@ -11,13 +11,16 @@
|
|||
|
||||
namespace Web::Painting {
|
||||
|
||||
BorderRadiusData normalized_border_radius_data(Layout::Node const& node, Gfx::FloatRect const& rect, CSS::Length top_left_radius, CSS::Length top_right_radius, CSS::Length bottom_right_radius, CSS::Length bottom_left_radius)
|
||||
BorderRadiusData normalized_border_radius_data(Layout::Node const& node, Gfx::FloatRect const& rect, CSS::LengthPercentage top_left_radius, CSS::LengthPercentage top_right_radius, CSS::LengthPercentage bottom_right_radius, CSS::LengthPercentage bottom_left_radius)
|
||||
{
|
||||
// FIXME: some values should be relative to the height() if specified, but which? For now, all relative values are relative to the width.
|
||||
auto bottom_left_radius_px = bottom_left_radius.resolved_or_zero(node, rect.width()).to_px(node);
|
||||
auto bottom_right_radius_px = bottom_right_radius.resolved_or_zero(node, rect.width()).to_px(node);
|
||||
auto top_left_radius_px = top_left_radius.resolved_or_zero(node, rect.width()).to_px(node);
|
||||
auto top_right_radius_px = top_right_radius.resolved_or_zero(node, rect.width()).to_px(node);
|
||||
// FIXME: Some values should be relative to the height() if specified, but which?
|
||||
// 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, rect.width()).to_px(node);
|
||||
auto bottom_right_radius_px = bottom_right_radius.resolved(width_length).resolved_or_zero(node, rect.width()).to_px(node);
|
||||
auto top_left_radius_px = top_left_radius.resolved(width_length).resolved_or_zero(node, rect.width()).to_px(node);
|
||||
auto top_right_radius_px = top_right_radius.resolved(width_length).resolved_or_zero(node, rect.width()).to_px(node);
|
||||
|
||||
// Scale overlapping curves according to https://www.w3.org/TR/css-backgrounds-3/#corner-overlap
|
||||
auto f = 1.0f;
|
||||
|
|
|
@ -17,7 +17,7 @@ struct BorderRadiusData {
|
|||
float bottom_right { 0 };
|
||||
float bottom_left { 0 };
|
||||
};
|
||||
BorderRadiusData normalized_border_radius_data(Layout::Node const&, Gfx::FloatRect const&, CSS::Length top_left_radius, CSS::Length top_right_radius, CSS::Length bottom_right_radius, CSS::Length bottom_left_radius);
|
||||
BorderRadiusData normalized_border_radius_data(Layout::Node const&, Gfx::FloatRect const&, CSS::LengthPercentage top_left_radius, CSS::LengthPercentage top_right_radius, CSS::LengthPercentage bottom_right_radius, CSS::LengthPercentage bottom_left_radius);
|
||||
|
||||
enum class BorderEdge {
|
||||
Top,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue