mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
style: Only apply grayscale filter for printing on print preview.
Differential Revision: https://phabricator.services.mozilla.com/D88065
This commit is contained in:
parent
16e0fd3e1f
commit
35716fd514
2 changed files with 28 additions and 1 deletions
|
@ -521,6 +521,18 @@ fn eval_moz_is_glyph(
|
||||||
query_value.map_or(is_glyph, |v| v == is_glyph)
|
query_value.map_or(is_glyph, |v| v == is_glyph)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn eval_moz_print_preview(
|
||||||
|
device: &Device,
|
||||||
|
query_value: Option<bool>,
|
||||||
|
_: Option<RangeOrOperator>,
|
||||||
|
) -> 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(
|
fn eval_moz_is_resource_document(
|
||||||
device: &Device,
|
device: &Device,
|
||||||
query_value: Option<bool>,
|
query_value: Option<bool>,
|
||||||
|
@ -601,7 +613,7 @@ macro_rules! system_metric_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: [MediaFeatureDescription; 55] = [
|
pub static MEDIA_FEATURES: [MediaFeatureDescription; 56] = [
|
||||||
feature!(
|
feature!(
|
||||||
atom!("width"),
|
atom!("width"),
|
||||||
AllowsRanges::Yes,
|
AllowsRanges::Yes,
|
||||||
|
@ -799,6 +811,12 @@ pub static MEDIA_FEATURES: [MediaFeatureDescription; 55] = [
|
||||||
Evaluator::Ident(eval_moz_os_version),
|
Evaluator::Ident(eval_moz_os_version),
|
||||||
ParsingRequirements::CHROME_AND_UA_ONLY,
|
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-backward")),
|
||||||
system_metric_feature!(atom!("-moz-scrollbar-start-forward")),
|
system_metric_feature!(atom!("-moz-scrollbar-start-forward")),
|
||||||
system_metric_feature!(atom!("-moz-scrollbar-end-backward")),
|
system_metric_feature!(atom!("-moz-scrollbar-end-backward")),
|
||||||
|
|
|
@ -206,6 +206,15 @@ impl Device {
|
||||||
self.reset_computed_values();
|
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.
|
/// Returns the current media type of the device.
|
||||||
pub fn media_type(&self) -> MediaType {
|
pub fn media_type(&self) -> MediaType {
|
||||||
let pc = match self.pres_context() {
|
let pc = match self.pres_context() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue