mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 19:17:44 +00:00
LibWeb: Implement @supports
serialization
This commit is contained in:
parent
1cec8e473f
commit
dfba0cb2d9
3 changed files with 55 additions and 2 deletions
|
@ -24,16 +24,19 @@ public:
|
|||
struct Declaration {
|
||||
String declaration;
|
||||
bool evaluate() const;
|
||||
String to_string() const;
|
||||
};
|
||||
|
||||
struct Selector {
|
||||
String selector;
|
||||
bool evaluate() const;
|
||||
String to_string() const;
|
||||
};
|
||||
|
||||
struct Feature {
|
||||
Variant<Declaration, Selector> value;
|
||||
bool evaluate() const;
|
||||
String to_string() const;
|
||||
};
|
||||
|
||||
struct Condition;
|
||||
|
@ -41,6 +44,7 @@ public:
|
|||
Variant<NonnullOwnPtr<Condition>, Feature, GeneralEnclosed> value;
|
||||
|
||||
bool evaluate() const;
|
||||
String to_string() const;
|
||||
};
|
||||
|
||||
struct Condition {
|
||||
|
@ -53,6 +57,7 @@ public:
|
|||
Vector<InParens> children;
|
||||
|
||||
bool evaluate() const;
|
||||
String to_string() const;
|
||||
};
|
||||
|
||||
static NonnullRefPtr<Supports> create(NonnullOwnPtr<Condition>&& condition)
|
||||
|
@ -61,6 +66,7 @@ public:
|
|||
}
|
||||
|
||||
bool matches() const { return m_matches; }
|
||||
String to_string() const;
|
||||
|
||||
private:
|
||||
Supports(NonnullOwnPtr<Condition>&&);
|
||||
|
@ -70,3 +76,11 @@ private:
|
|||
};
|
||||
|
||||
}
|
||||
|
||||
template<>
|
||||
struct AK::Formatter<Web::CSS::Supports::InParens> : AK::Formatter<StringView> {
|
||||
ErrorOr<void> format(FormatBuilder& builder, Web::CSS::Supports::InParens const& in_parens)
|
||||
{
|
||||
return Formatter<StringView>::format(builder, in_parens.to_string());
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue