summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/CSS/Supports.cpp
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2022-01-19 20:03:22 +0000
committerLinus Groh <mail@linusgroh.de>2022-01-19 21:44:45 +0000
commit7bea0d501e41ebed294b71417ee8f732a8905463 (patch)
treec7cf6272f8b47450accbc4e1c6d5efe7f0be9996 /Userland/Libraries/LibWeb/CSS/Supports.cpp
parent6d3a3f279ab8449d2d46cdc24796a57014433497 (diff)
downloadserenity-7bea0d501e41ebed294b71417ee8f732a8905463.zip
LibWeb: Remove `unknown` value in `@supports` query logic
This is in line with this recent change to Conditional-3: > Removed the “unknown” value in CSS feature queries’ boolean logic, > defining unrecognized syntaxes as “false” instead. > https://github.com/w3c/csswg-drafts/issues/6175
Diffstat (limited to 'Userland/Libraries/LibWeb/CSS/Supports.cpp')
-rw-r--r--Userland/Libraries/LibWeb/CSS/Supports.cpp34
1 files changed, 18 insertions, 16 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/Supports.cpp b/Userland/Libraries/LibWeb/CSS/Supports.cpp
index 97e4d7d073..de220a5598 100644
--- a/Userland/Libraries/LibWeb/CSS/Supports.cpp
+++ b/Userland/Libraries/LibWeb/CSS/Supports.cpp
@@ -12,27 +12,31 @@ namespace Web::CSS {
Supports::Supports(NonnullOwnPtr<Condition>&& condition)
: m_condition(move(condition))
{
- auto result = m_condition->evaluate();
- if (result == MatchResult::Unknown) {
- dbgln("!!! Evaluation of CSS Supports returned 'Unknown'!");
- }
- m_matches = result == MatchResult::True;
+ m_matches = m_condition->evaluate();
}
-MatchResult Supports::Condition::evaluate() const
+bool Supports::Condition::evaluate() const
{
switch (type) {
case Type::Not:
- return negate(children.first().evaluate());
+ return !children.first().evaluate();
case Type::And:
- return evaluate_and(children, [](auto& child) { return child.evaluate(); });
+ for (auto& child : children) {
+ if (!child.evaluate())
+ return false;
+ }
+ return true;
case Type::Or:
- return evaluate_or(children, [](auto& child) { return child.evaluate(); });
+ for (auto& child : children) {
+ if (child.evaluate())
+ return true;
+ }
+ return false;
}
VERIFY_NOT_REACHED();
}
-MatchResult Supports::InParens::evaluate() const
+bool Supports::InParens::evaluate() const
{
return value.visit(
[&](NonnullOwnPtr<Condition> const& condition) {
@@ -41,17 +45,15 @@ MatchResult Supports::InParens::evaluate() const
[&](Feature const& feature) {
return feature.evaluate();
},
- [&](GeneralEnclosed const& general_enclosed) {
- return general_enclosed.evaluate();
+ [&](GeneralEnclosed const&) {
+ return false;
});
}
-MatchResult Supports::Feature::evaluate() const
+bool Supports::Feature::evaluate() const
{
auto style_property = Parser({}, declaration).parse_as_declaration();
- if (style_property.has_value())
- return MatchResult::True;
- return MatchResult::False;
+ return style_property.has_value();
}
}