1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 14:28:12 +00:00

LibWeb: Add CSS::Size::to_string() and an AK::Formatter for it

This commit is contained in:
Andreas Kling 2022-09-26 11:14:42 +02:00
parent fdc9dc5729
commit fce1c673c7
2 changed files with 30 additions and 0 deletions

View file

@ -74,4 +74,24 @@ bool Size::contains_percentage() const
}
}
String Size::to_string() const
{
switch (m_type) {
case Type::Auto:
return "auto";
case Type::Length:
case Type::Percentage:
return m_length_percentage.to_string();
case Type::MinContent:
return "min-content";
case Type::MaxContent:
return "max-content";
case Type::FitContent:
return String::formatted("fit-content({})", m_length_percentage.to_string());
case Type::None:
return "none";
}
VERIFY_NOT_REACHED();
}
}