mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-04 23:29:52 +00:00
LibWeb/CSS: Use serialize_a_number() for Angle serialization
Gets us 12 known passes!
This commit is contained in:
parent
dffebee901
commit
00b1b34c80
Notes:
github-actions[bot]
2025-08-18 15:54:23 +00:00
Author: https://github.com/AtkinsSJ
Commit: 00b1b34c80
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5898
2 changed files with 28 additions and 17 deletions
|
@ -7,6 +7,7 @@
|
|||
#include <AK/Math.h>
|
||||
#include <LibWeb/CSS/Angle.h>
|
||||
#include <LibWeb/CSS/Percentage.h>
|
||||
#include <LibWeb/CSS/Serialize.h>
|
||||
#include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
@ -29,9 +30,20 @@ Angle Angle::percentage_of(Percentage const& percentage) const
|
|||
|
||||
String Angle::to_string(SerializationMode serialization_mode) const
|
||||
{
|
||||
if (serialization_mode == SerializationMode::ResolvedValue)
|
||||
return MUST(String::formatted("{}deg", to_degrees()));
|
||||
return MUST(String::formatted("{}{}", raw_value(), unit_name()));
|
||||
// https://drafts.csswg.org/cssom/#serialize-a-css-value
|
||||
// -> <angle>
|
||||
// The <number> component serialized as per <number> followed by the unit in canonical form as defined in its
|
||||
// respective specification.
|
||||
if (serialization_mode == SerializationMode::ResolvedValue) {
|
||||
StringBuilder builder;
|
||||
serialize_a_number(builder, to_degrees());
|
||||
builder.append("deg"sv);
|
||||
return builder.to_string_without_validation();
|
||||
}
|
||||
StringBuilder builder;
|
||||
serialize_a_number(builder, raw_value());
|
||||
builder.append(unit_name());
|
||||
return builder.to_string_without_validation();
|
||||
}
|
||||
|
||||
double Angle::to_degrees() const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue