From 9d3876bda08e0b7e115b13260f06aecac1fe0d28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Wed, 15 Jul 2020 03:45:33 +0000 Subject: [PATCH] style: Apply a grayscale filter to pages when monochrome. This hooks the "monochrome" media query and co to the nsIPrintSettings.printInColor setting. This print setting we're using is not exposed in the print preview UI, but you can test it setting the print.print_in_color preference to "false", and then print preview will correctly show up greyscale'd. Once this lands, the UI folks just have to use it as they see fit :) I would've liked to add a proper rendering test, but the print reftests check only whether the PDF text matches. I could add a test to printpreview_helper.xhtml, but I'm refactoring that file in bug 1648064 so I'd rather wait a bit and add it in a separate bug. The test for the media feature should make sure that we test that code path at least. Differential Revision: https://phabricator.services.mozilla.com/D83552 --- components/style/gecko/media_features.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/components/style/gecko/media_features.rs b/components/style/gecko/media_features.rs index f3b8297439f..0a86980167c 100644 --- a/components/style/gecko/media_features.rs +++ b/components/style/gecko/media_features.rs @@ -247,13 +247,12 @@ fn eval_color_index( /// https://drafts.csswg.org/mediaqueries-4/#monochrome fn eval_monochrome( - _: &Device, + device: &Device, query_value: Option, range_or_operator: Option, ) -> bool { // For color devices we should return 0. - // FIXME: On a monochrome device, return the actual color depth, not 0! - let depth = 0; + let depth = unsafe { bindings::Gecko_MediaFeatures_GetMonochromeBitsPerPixel(device.document()) }; RangeOrOperator::evaluate(range_or_operator, query_value, depth) }