mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-15 12:23:15 +00:00
LibWeb: Evaluate no-preference
media-features as false
As noted, this is not 100% to the spec, but effectively the same - `no-preference` is only allowed to appear in features that evaluate it as false in a boolean context. This is also the only identifier besides `none` that evaluates to false. If other identifiers gain this property in the future, we can make it more robust then.
This commit is contained in:
parent
aa48dda3a4
commit
7c4402ba92
|
@ -95,8 +95,14 @@ bool MediaFeature::evaluate(HTML::Window const& window) const
|
|||
return !queried_value.ratio().is_degenerate();
|
||||
if (queried_value.is_resolution())
|
||||
return queried_value.resolution().to_dots_per_pixel() != 0;
|
||||
if (queried_value.is_ident())
|
||||
return queried_value.ident() != ValueID::None;
|
||||
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 identifiers in the future, we can
|
||||
// add more robust handling for them then.
|
||||
return queried_value.ident() != ValueID::None
|
||||
&& queried_value.ident() != ValueID::NoPreference;
|
||||
}
|
||||
return false;
|
||||
|
||||
case Type::ExactValue:
|
||||
|
|
Loading…
Reference in a new issue