mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-07 21:59:54 +00:00
LibWeb/CSS: Store RadialGradientStyleValue sizes as StyleValues
No significant consequences of this, but it'll make it easier to absolutize these values.
This commit is contained in:
parent
d327f677c5
commit
fbe0567f90
Notes:
github-actions[bot]
2025-12-01 11:09:59 +00:00
Author: https://github.com/AtkinsSJ
Commit: fbe0567f90
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6894
Reviewed-by: https://github.com/Calme1709
Reviewed-by: https://github.com/gmta
3 changed files with 43 additions and 20 deletions
|
|
@ -44,10 +44,10 @@ String RadialGradientStyleValue::to_string(SerializationMode mode) const
|
|||
}());
|
||||
},
|
||||
[&](CircleSize const& circle_size) {
|
||||
builder.append(circle_size.radius.to_string());
|
||||
builder.append(circle_size.radius->to_string(mode));
|
||||
},
|
||||
[&](EllipseSize const& ellipse_size) {
|
||||
builder.appendff("{} {}", ellipse_size.radius_a.to_string(mode), ellipse_size.radius_b.to_string(mode));
|
||||
builder.appendff("{} {}", ellipse_size.radius_a->to_string(mode), ellipse_size.radius_b->to_string(mode));
|
||||
});
|
||||
|
||||
if (has_position) {
|
||||
|
|
@ -179,12 +179,36 @@ CSSPixelSize RadialGradientStyleValue::resolve_size(Layout::Node const& node, CS
|
|||
}
|
||||
},
|
||||
[&](CircleSize const& circle_size) {
|
||||
auto radius = circle_size.radius.to_px(node);
|
||||
return CSSPixelSize { radius, radius };
|
||||
if (circle_size.radius->is_length()) {
|
||||
auto radius = circle_size.radius->as_length().length().to_px(node);
|
||||
return CSSPixelSize { radius, radius };
|
||||
}
|
||||
if (circle_size.radius->is_calculated()) {
|
||||
CalculationResolutionContext context {
|
||||
.length_resolution_context = Length::ResolutionContext::for_layout_node(node),
|
||||
};
|
||||
auto radius = circle_size.radius->as_calculated().resolve_length(context)->to_px(node);
|
||||
return CSSPixelSize { radius, radius };
|
||||
}
|
||||
VERIFY_NOT_REACHED();
|
||||
},
|
||||
[&](EllipseSize const& ellipse_size) {
|
||||
auto radius_a = ellipse_size.radius_a.resolved(node, size.width()).to_px(node);
|
||||
auto radius_b = ellipse_size.radius_b.resolved(node, size.height()).to_px(node);
|
||||
auto resolve = [&](StyleValue const& radius_value, auto percentage_basis_pixels) {
|
||||
auto percentage_basis = Length::make_px(percentage_basis_pixels);
|
||||
CalculationResolutionContext context {
|
||||
.percentage_basis = percentage_basis,
|
||||
.length_resolution_context = Length::ResolutionContext::for_layout_node(node),
|
||||
};
|
||||
if (radius_value.is_length())
|
||||
return radius_value.as_length().length().to_px(node);
|
||||
if (radius_value.is_percentage())
|
||||
return percentage_basis.percentage_of(radius_value.as_percentage().percentage()).to_px(node);
|
||||
if (radius_value.is_calculated())
|
||||
return radius_value.as_calculated().resolve_length(context)->to_px(node);
|
||||
VERIFY_NOT_REACHED();
|
||||
};
|
||||
auto radius_a = resolve(*ellipse_size.radius_a, size.width());
|
||||
auto radius_b = resolve(*ellipse_size.radius_b, size.height());
|
||||
return CSSPixelSize { radius_a, radius_b };
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -31,13 +31,13 @@ public:
|
|||
};
|
||||
|
||||
struct CircleSize {
|
||||
Length radius;
|
||||
NonnullRefPtr<StyleValue const> radius;
|
||||
bool operator==(CircleSize const&) const = default;
|
||||
};
|
||||
|
||||
struct EllipseSize {
|
||||
LengthPercentage radius_a;
|
||||
LengthPercentage radius_b;
|
||||
NonnullRefPtr<StyleValue const> radius_a;
|
||||
NonnullRefPtr<StyleValue const> radius_b;
|
||||
bool operator==(EllipseSize const&) const = default;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue