зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1660857 - Only apply grayscale filter for printing on print preview. r=jwatt,dholbert
Depends on D88064 Differential Revision: https://phabricator.services.mozilla.com/D88065
This commit is contained in:
Родитель
39209de5eb
Коммит
0686e31ea8
|
@ -312,7 +312,7 @@
|
|||
margin: 0.125in 0.25in;
|
||||
}
|
||||
|
||||
@media (monochrome) {
|
||||
@media (monochrome) and (-moz-print-preview) {
|
||||
*|*::-moz-page {
|
||||
filter: grayscale(1);
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ function testToggle(toggle) {
|
|||
|
||||
const TOGGLES = [
|
||||
"-moz-is-glyph",
|
||||
"-moz-print-preview",
|
||||
"-moz-scrollbar-start-backward",
|
||||
"-moz-scrollbar-start-forward",
|
||||
"-moz-scrollbar-end-backward",
|
||||
|
|
|
@ -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<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(
|
||||
device: &Device,
|
||||
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
|
||||
/// 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")),
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -50,6 +50,7 @@ STATIC_ATOMS = [
|
|||
Atom("mozsignature", "moz-signature"), # Used by MailNews.
|
||||
Atom("_moz_is_glyph", "-moz-is-glyph"),
|
||||
Atom("_moz_original_size", "_moz_original_size"),
|
||||
Atom("_moz_print_preview", "-moz-print-preview"),
|
||||
Atom("menuactive", "_moz-menuactive"),
|
||||
Atom("_poundDefault", "#default"),
|
||||
Atom("_asterisk", "*"),
|
||||
|
|
Загрузка…
Ссылка в новой задаче