mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-08 06:09:58 +00:00
LibWeb/CSS: Store linear-gradient() angle as a StyleValue
This means we now support calc() there too.
This commit is contained in:
parent
73fbaaba77
commit
d327f677c5
Notes:
github-actions[bot]
2025-12-01 11:10:08 +00:00
Author: https://github.com/AtkinsSJ
Commit: d327f677c5
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6894
Reviewed-by: https://github.com/Calme1709
Reviewed-by: https://github.com/gmta
5 changed files with 24 additions and 22 deletions
|
|
@ -8,6 +8,8 @@
|
|||
*/
|
||||
|
||||
#include "LinearGradientStyleValue.h"
|
||||
#include <LibWeb/CSS/StyleValues/AngleStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h>
|
||||
#include <LibWeb/Layout/Node.h>
|
||||
#include <LibWeb/Painting/DisplayListRecorder.h>
|
||||
|
||||
|
|
@ -53,8 +55,8 @@ String LinearGradientStyleValue::to_string(SerializationMode mode) const
|
|||
[&](SideOrCorner side_or_corner) {
|
||||
builder.appendff("{}{}", m_properties.gradient_type == GradientType::Standard ? "to "sv : ""sv, side_or_corner_to_string(side_or_corner));
|
||||
},
|
||||
[&](Angle const& angle) {
|
||||
builder.append(angle.to_string());
|
||||
[&](NonnullRefPtr<StyleValue const> const& angle) {
|
||||
builder.append(angle->to_string(mode));
|
||||
});
|
||||
|
||||
if (has_color_space)
|
||||
|
|
@ -114,8 +116,14 @@ float LinearGradientStyleValue::angle_degrees(CSSPixelSize gradient_size) const
|
|||
return angle + 180.0;
|
||||
return angle;
|
||||
},
|
||||
[&](Angle const& angle) {
|
||||
return angle.to_degrees();
|
||||
[&](NonnullRefPtr<StyleValue const> const& style_value) {
|
||||
if (style_value->is_angle())
|
||||
return style_value->as_angle().angle().to_degrees();
|
||||
if (style_value->is_calculated()) {
|
||||
if (auto maybe_angle = style_value->as_calculated().resolve_angle({}); maybe_angle.has_value())
|
||||
return maybe_angle->to_degrees();
|
||||
}
|
||||
return 0.0;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue