From 81a07b4351fad96843824e6ef86d5b4d27d25190 Mon Sep 17 00:00:00 2001 From: quasicomputational Date: Thu, 27 Dec 2018 14:43:34 +0000 Subject: [PATCH] style: Implement the 'overflow-block' media query. Bug: 1422235 Reviewed-by: emilio --- components/style/gecko/media_features.rs | 42 ++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/components/style/gecko/media_features.rs b/components/style/gecko/media_features.rs index 25355c45d70..ede01f3b1b9 100644 --- a/components/style/gecko/media_features.rs +++ b/components/style/gecko/media_features.rs @@ -9,7 +9,7 @@ use crate::gecko_bindings::structs; use crate::media_queries::media_feature::{AllowsRanges, ParsingRequirements}; use crate::media_queries::media_feature::{Evaluator, MediaFeatureDescription}; use crate::media_queries::media_feature_expression::{AspectRatio, RangeOrOperator}; -use crate::media_queries::Device; +use crate::media_queries::{Device, MediaType}; use crate::values::computed::CSSPixelLength; use crate::values::computed::Resolution; use crate::Atom; @@ -295,6 +295,38 @@ fn eval_prefers_reduced_motion(device: &Device, query_value: Option) -> bool { + // For the time being, assume that printing (including previews) + // is the only time when we paginate, and we are otherwise always + // scrolling. This is true at the moment in Firefox, but may need + // updating in the future (e.g., ebook readers built with Stylo, a + // billboard mode that doesn't support overflow at all). + // + // If this ever changes, don't forget to change eval_overflow_inline too. + let scrolling = device.media_type() != MediaType::print(); + let query_value = match query_value { + Some(v) => v, + None => return true, + }; + + match query_value { + OverflowBlock::None | + OverflowBlock::OptionalPaged => false, + OverflowBlock::Scroll => scrolling, + OverflowBlock::Paged => !scrolling, + } +} + /// https://drafts.csswg.org/mediaqueries-4/#mf-interaction bitflags! { struct PointerCapabilities: u8 { @@ -473,7 +505,7 @@ lazy_static! { /// to support new types in these entries and (2) ensuring that either /// nsPresContext::MediaFeatureValuesChanged is called when the value that /// would be returned by the evaluator function could change. - pub static ref MEDIA_FEATURES: [MediaFeatureDescription; 48] = [ + pub static ref MEDIA_FEATURES: [MediaFeatureDescription; 49] = [ feature!( atom!("width"), AllowsRanges::Yes, @@ -592,6 +624,12 @@ lazy_static! { keyword_evaluator!(eval_prefers_reduced_motion, PrefersReducedMotion), ParsingRequirements::empty(), ), + feature!( + atom!("overflow-block"), + AllowsRanges::No, + keyword_evaluator!(eval_overflow_block, OverflowBlock), + ParsingRequirements::empty(), + ), feature!( atom!("pointer"), AllowsRanges::No,