mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
style: Implement 'update' media feature
Differential Revision: https://phabricator.services.mozilla.com/D146338
This commit is contained in:
parent
af958c4c79
commit
08641b0ce8
1 changed files with 35 additions and 1 deletions
|
@ -284,6 +284,34 @@ fn eval_overflow_inline(context: &Context, query_value: Option<OverflowInline>)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Copy, Debug, FromPrimitive, Parse, ToCss)]
|
||||||
|
#[repr(u8)]
|
||||||
|
enum Update {
|
||||||
|
None,
|
||||||
|
Slow,
|
||||||
|
Fast,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// https://drafts.csswg.org/mediaqueries-4/#update
|
||||||
|
fn eval_update(context: &Context, query_value: Option<Update>) -> bool {
|
||||||
|
// This has similar caveats to those described in eval_overflow_block.
|
||||||
|
// For now, we report that print (incl. print media simulation,
|
||||||
|
// which can in fact update but is limited to the developer tools)
|
||||||
|
// is `update: none` and that all other contexts are `update: fast`,
|
||||||
|
// which may not be true for future platforms, like e-ink devices.
|
||||||
|
let can_update = context.device().media_type() != MediaType::print();
|
||||||
|
let query_value = match query_value {
|
||||||
|
Some(v) => v,
|
||||||
|
None => return can_update,
|
||||||
|
};
|
||||||
|
|
||||||
|
match query_value {
|
||||||
|
Update::None => !can_update,
|
||||||
|
Update::Slow => false,
|
||||||
|
Update::Fast => can_update,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn do_eval_prefers_color_scheme(
|
fn do_eval_prefers_color_scheme(
|
||||||
context: &Context,
|
context: &Context,
|
||||||
use_content: bool,
|
use_content: bool,
|
||||||
|
@ -558,7 +586,7 @@ macro_rules! bool_pref_feature {
|
||||||
/// to support new types in these entries and (2) ensuring that either
|
/// to support new types in these entries and (2) ensuring that either
|
||||||
/// nsPresContext::MediaFeatureValuesChanged is called when the value that
|
/// nsPresContext::MediaFeatureValuesChanged is called when the value that
|
||||||
/// would be returned by the evaluator function could change.
|
/// would be returned by the evaluator function could change.
|
||||||
pub static MEDIA_FEATURES: [QueryFeatureDescription; 59] = [
|
pub static MEDIA_FEATURES: [QueryFeatureDescription; 60] = [
|
||||||
feature!(
|
feature!(
|
||||||
atom!("width"),
|
atom!("width"),
|
||||||
AllowsRanges::Yes,
|
AllowsRanges::Yes,
|
||||||
|
@ -705,6 +733,12 @@ pub static MEDIA_FEATURES: [QueryFeatureDescription; 59] = [
|
||||||
keyword_evaluator!(eval_overflow_inline, OverflowInline),
|
keyword_evaluator!(eval_overflow_inline, OverflowInline),
|
||||||
ParsingRequirements::empty(),
|
ParsingRequirements::empty(),
|
||||||
),
|
),
|
||||||
|
feature!(
|
||||||
|
atom!("update"),
|
||||||
|
AllowsRanges::No,
|
||||||
|
keyword_evaluator!(eval_update, Update),
|
||||||
|
ParsingRequirements::empty(),
|
||||||
|
),
|
||||||
feature!(
|
feature!(
|
||||||
atom!("prefers-color-scheme"),
|
atom!("prefers-color-scheme"),
|
||||||
AllowsRanges::No,
|
AllowsRanges::No,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue