LibWeb: Properly serialize position/edge style values

This commit is contained in:
Gingeh 2024-11-29 22:44:14 +11:00 committed by Sam Atkins
commit 84150f972f
Notes: github-actions[bot] 2024-12-13 11:36:34 +00:00
21 changed files with 461 additions and 288 deletions

View file

@ -34,7 +34,7 @@ Gfx::Path Inset::to_path(CSSPixelRect reference_box, Layout::Node const& node) c
return path_from_resolved_rect(top, right, bottom, left);
}
String Inset::to_string() const
String Inset::to_string(CSSStyleValue::SerializationMode) const
{
return MUST(String::formatted("inset({} {} {} {})", inset_box.top(), inset_box.right(), inset_box.bottom(), inset_box.left()));
}
@ -49,7 +49,7 @@ Gfx::Path Xywh::to_path(CSSPixelRect reference_box, Layout::Node const& node) co
return path_from_resolved_rect(top, right, bottom, left);
}
String Xywh::to_string() const
String Xywh::to_string(CSSStyleValue::SerializationMode) const
{
return MUST(String::formatted("xywh({} {} {} {})", x, y, width, height));
}
@ -68,7 +68,7 @@ Gfx::Path Rect::to_path(CSSPixelRect reference_box, Layout::Node const& node) co
return path_from_resolved_rect(top, max(right, left), max(bottom, top), left);
}
String Rect::to_string() const
String Rect::to_string(CSSStyleValue::SerializationMode) const
{
return MUST(String::formatted("rect({} {} {} {})", box.top(), box.right(), box.bottom(), box.left()));
}
@ -123,9 +123,9 @@ Gfx::Path Circle::to_path(CSSPixelRect reference_box, Layout::Node const& node)
return path;
}
String Circle::to_string() const
String Circle::to_string(CSSStyleValue::SerializationMode mode) const
{
return MUST(String::formatted("circle({} at {})", radius_to_string(radius), position->to_string(CSSStyleValue::SerializationMode::Normal)));
return MUST(String::formatted("circle({} at {})", radius_to_string(radius), position->to_string(mode)));
}
Gfx::Path Ellipse::to_path(CSSPixelRect reference_box, Layout::Node const& node) const
@ -168,9 +168,9 @@ Gfx::Path Ellipse::to_path(CSSPixelRect reference_box, Layout::Node const& node)
return path;
}
String Ellipse::to_string() const
String Ellipse::to_string(CSSStyleValue::SerializationMode mode) const
{
return MUST(String::formatted("ellipse({} {} at {})", radius_to_string(radius_x), radius_to_string(radius_y), position->to_string(CSSStyleValue::SerializationMode::Normal)));
return MUST(String::formatted("ellipse({} {} at {})", radius_to_string(radius_x), radius_to_string(radius_y), position->to_string(mode)));
}
Gfx::Path Polygon::to_path(CSSPixelRect reference_box, Layout::Node const& node) const
@ -193,7 +193,7 @@ Gfx::Path Polygon::to_path(CSSPixelRect reference_box, Layout::Node const& node)
return path;
}
String Polygon::to_string() const
String Polygon::to_string(CSSStyleValue::SerializationMode) const
{
StringBuilder builder;
builder.append("polygon("sv);
@ -220,10 +220,10 @@ Gfx::Path BasicShapeStyleValue::to_path(CSSPixelRect reference_box, Layout::Node
});
}
String BasicShapeStyleValue::to_string(SerializationMode) const
String BasicShapeStyleValue::to_string(SerializationMode mode) const
{
return m_basic_shape.visit([](auto const& shape) {
return shape.to_string();
return m_basic_shape.visit([mode](auto const& shape) {
return shape.to_string(mode);
});
}