mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 07:37:35 +00:00
LibWeb: Implement @supports
serialization
This commit is contained in:
parent
1cec8e473f
commit
dfba0cb2d9
3 changed files with 55 additions and 2 deletions
|
@ -73,4 +73,44 @@ bool Supports::Feature::evaluate() const
|
|||
});
|
||||
}
|
||||
|
||||
String Supports::Declaration::to_string() const
|
||||
{
|
||||
return String::formatted("({})", declaration);
|
||||
}
|
||||
|
||||
String Supports::Selector::to_string() const
|
||||
{
|
||||
return String::formatted("selector({})", selector);
|
||||
}
|
||||
|
||||
String Supports::Feature::to_string() const
|
||||
{
|
||||
return value.visit([](auto& it) { return it.to_string(); });
|
||||
}
|
||||
|
||||
String Supports::InParens::to_string() const
|
||||
{
|
||||
return value.visit(
|
||||
[](NonnullOwnPtr<Condition> const& condition) -> String { return String::formatted("({})", condition->to_string()); },
|
||||
[](auto& it) -> String { return it.to_string(); });
|
||||
}
|
||||
|
||||
String Supports::Condition::to_string() const
|
||||
{
|
||||
switch (type) {
|
||||
case Type::Not:
|
||||
return String::formatted("not {}", children.first().to_string());
|
||||
case Type::And:
|
||||
return String::join(" and ", children);
|
||||
case Type::Or:
|
||||
return String::join(" or ", children);
|
||||
}
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
String Supports::to_string() const
|
||||
{
|
||||
return m_condition->to_string();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue