mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-25 18:58:56 +00:00
LibWeb/CSS: Use serialize_a_number() for Flex serialization
This commit is contained in:
parent
00b1b34c80
commit
1c82d74a18
Notes:
github-actions[bot]
2025-08-18 15:54:17 +00:00
Author: https://github.com/AtkinsSJ
Commit: 1c82d74a18
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5898
1 changed files with 13 additions and 3 deletions
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include <LibWeb/CSS/Flex.h>
|
#include <LibWeb/CSS/Flex.h>
|
||||||
#include <LibWeb/CSS/Percentage.h>
|
#include <LibWeb/CSS/Percentage.h>
|
||||||
|
#include <LibWeb/CSS/Serialize.h>
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
|
@ -27,9 +28,18 @@ Flex Flex::percentage_of(Percentage const& percentage) const
|
||||||
|
|
||||||
String Flex::to_string(SerializationMode serialization_mode) const
|
String Flex::to_string(SerializationMode serialization_mode) const
|
||||||
{
|
{
|
||||||
if (serialization_mode == SerializationMode::ResolvedValue)
|
// https://drafts.csswg.org/cssom/#serialize-a-css-value
|
||||||
return MUST(String::formatted("{}fr", to_fr()));
|
// AD-HOC: No spec definition, so copy the other <dimension> definitions
|
||||||
return MUST(String::formatted("{}{}", raw_value(), unit_name()));
|
if (serialization_mode == SerializationMode::ResolvedValue) {
|
||||||
|
StringBuilder builder;
|
||||||
|
serialize_a_number(builder, to_fr());
|
||||||
|
builder.append("fr"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 Flex::to_fr() const
|
double Flex::to_fr() const
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue