mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 12:19:54 +00:00
LibWeb/CSS: Correct how we evaluate boolean media-features
The spec has a general rule for this, which is roughly that "If it's not a falsey value, it's true". However, a couple of media-features are always false, apparently breaking this rule. To handle that, we have an array of false keywords in the JSON, instead of a single keyword. For those always-false media-features, we can enter all their values into this array. Gets us 2 more WPT subtest passes.
This commit is contained in:
parent
00617884a6
commit
fb975cc156
Notes:
github-actions[bot]
2025-05-23 09:18:59 +00:00
Author: https://github.com/AtkinsSJ
Commit: fb975cc156
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4817
5 changed files with 107 additions and 14 deletions
|
@ -121,12 +121,9 @@ MatchResult MediaFeature::evaluate(HTML::Window const* window) const
|
|||
if (queried_value.is_resolution())
|
||||
return as_match_result(queried_value.resolution().resolved(calculation_context).map([](auto& it) { return it.to_dots_per_pixel(); }).value_or(0) != 0);
|
||||
if (queried_value.is_ident()) {
|
||||
// NOTE: It is not technically correct to always treat `no-preference` as false, but every
|
||||
// media-feature that accepts it as a value treats it as false, so good enough. :^)
|
||||
// If other features gain this property for other keywords in the future, we can
|
||||
// add more robust handling for them then.
|
||||
return as_match_result(queried_value.ident() != Keyword::None
|
||||
&& queried_value.ident() != Keyword::NoPreference);
|
||||
if (media_feature_keyword_is_falsey(m_id, queried_value.ident()))
|
||||
return MatchResult::False;
|
||||
return MatchResult::True;
|
||||
}
|
||||
return MatchResult::False;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue