mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:37:34 +00:00
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
This commit is contained in:
parent
6d3a3f279a
commit
7bea0d501e
2 changed files with 22 additions and 19 deletions
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue