diff --git a/components/style/gecko/media_features.rs b/components/style/gecko/media_features.rs index ed0dac47795..c96996a18ea 100644 --- a/components/style/gecko/media_features.rs +++ b/components/style/gecko/media_features.rs @@ -521,6 +521,18 @@ fn eval_moz_is_glyph( query_value.map_or(is_glyph, |v| v == is_glyph) } +fn eval_moz_print_preview( + device: &Device, + query_value: Option, + _: Option, +) -> bool { + let is_print_preview = device.is_print_preview(); + if is_print_preview { + debug_assert_eq!(device.media_type(), MediaType::print()); + } + query_value.map_or(is_print_preview, |v| v == is_print_preview) +} + fn eval_moz_is_resource_document( device: &Device, query_value: Option, @@ -601,7 +613,7 @@ macro_rules! system_metric_feature { /// 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 MEDIA_FEATURES: [MediaFeatureDescription; 55] = [ +pub static MEDIA_FEATURES: [MediaFeatureDescription; 56] = [ feature!( atom!("width"), AllowsRanges::Yes, @@ -799,6 +811,12 @@ pub static MEDIA_FEATURES: [MediaFeatureDescription; 55] = [ Evaluator::Ident(eval_moz_os_version), ParsingRequirements::CHROME_AND_UA_ONLY, ), + feature!( + atom!("-moz-print-preview"), + AllowsRanges::No, + Evaluator::BoolInteger(eval_moz_print_preview), + ParsingRequirements::CHROME_AND_UA_ONLY, + ), system_metric_feature!(atom!("-moz-scrollbar-start-backward")), system_metric_feature!(atom!("-moz-scrollbar-start-forward")), system_metric_feature!(atom!("-moz-scrollbar-end-backward")), diff --git a/components/style/gecko/media_queries.rs b/components/style/gecko/media_queries.rs index cf28002e621..e5ffccf11c1 100644 --- a/components/style/gecko/media_queries.rs +++ b/components/style/gecko/media_queries.rs @@ -206,6 +206,15 @@ impl Device { self.reset_computed_values(); } + /// Returns whether this document is in print preview. + pub fn is_print_preview(&self) -> bool { + let pc = match self.pres_context() { + Some(pc) => pc, + None => return false, + }; + pc.mType == structs::nsPresContext_nsPresContextType_eContext_PrintPreview + } + /// Returns the current media type of the device. pub fn media_type(&self) -> MediaType { let pc = match self.pres_context() {