1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 06:58:11 +00:00

LibWeb: Parse the content property

For now, we only understand `none`, `normal`, `<image>` and `<string>`.
The various other functions and identifiers can be added later.

We can *almost* use a StyleValueList for this, except it's divided into
two parts - the content, and the optional "alt text". So, I've added a
new StyleValue for it.
This commit is contained in:
Sam Atkins 2022-02-23 19:56:25 +00:00 committed by Andreas Kling
parent a9ad72cc0f
commit adaab23149
6 changed files with 120 additions and 0 deletions

View file

@ -81,6 +81,12 @@ ColorStyleValue const& StyleValue::as_color() const
return static_cast<ColorStyleValue const&>(*this);
}
ContentStyleValue const& StyleValue::as_content() const
{
VERIFY(is_content());
return static_cast<ContentStyleValue const&>(*this);
}
FlexStyleValue const& StyleValue::as_flex() const
{
VERIFY(is_flex());
@ -1015,6 +1021,13 @@ String CombinedBorderRadiusStyleValue::to_string() const
return String::formatted("{} {} {} {} / {} {} {} {}", m_top_left->horizontal_radius().to_string(), m_top_right->horizontal_radius().to_string(), m_bottom_right->horizontal_radius().to_string(), m_bottom_left->horizontal_radius().to_string(), m_top_left->vertical_radius().to_string(), m_top_right->vertical_radius().to_string(), m_bottom_right->vertical_radius().to_string(), m_bottom_left->vertical_radius().to_string());
}
String ContentStyleValue::to_string() const
{
if (has_alt_text())
return String::formatted("{} / {}", m_content->to_string(), m_alt_text->to_string());
return m_content->to_string();
}
String FlexStyleValue::to_string() const
{
return String::formatted("{} {} {}", m_grow->to_string(), m_shrink->to_string(), m_basis->to_string());