1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 01:17:35 +00:00

LibWeb: Implement @supports selector(.foo)

This is defined in
https://www.w3.org/TR/css-conditional-4/#at-supports-ext which just
became a CR. :^)
This commit is contained in:
Sam Atkins 2022-02-19 17:22:05 +00:00 committed by Andreas Kling
parent c50ea8c1dd
commit 7880718fa8
4 changed files with 93 additions and 9 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Sam Atkins <atkinssj@serenityos.org>
* Copyright (c) 2021-2022, Sam Atkins <atkinssj@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -50,10 +50,27 @@ bool Supports::InParens::evaluate() const
});
}
bool Supports::Feature::evaluate() const
bool Supports::Declaration::evaluate() const
{
auto style_property = Parser({}, declaration).parse_as_declaration();
return style_property.has_value();
}
bool Supports::Selector::evaluate() const
{
auto style_property = Parser({}, selector).parse_as_selector();
return style_property.has_value();
}
bool Supports::Feature::evaluate() const
{
return value.visit(
[&](Declaration const& declaration) {
return declaration.evaluate();
},
[&](Selector const& selector) {
return selector.evaluate();
});
}
}