diff --git a/components/style/gecko/media_queries.rs b/components/style/gecko/media_queries.rs index 39b99a4fefe..ae4bad7a25a 100644 --- a/components/style/gecko/media_queries.rs +++ b/components/style/gecko/media_queries.rs @@ -280,6 +280,11 @@ impl Device { convert_nscolor_to_rgba(self.pref_sheet_prefs().mDefaultBackgroundColor) } + /// Returns the default foreground color. + pub fn default_color(&self) -> RGBA { + convert_nscolor_to_rgba(self.pref_sheet_prefs().mDefaultColor) + } + /// Returns the current effective text zoom. #[inline] fn effective_text_zoom(&self) -> f32 { diff --git a/components/style/properties/cascade.rs b/components/style/properties/cascade.rs index 234e06703bc..f9f17a57121 100644 --- a/components/style/properties/cascade.rs +++ b/components/style/properties/cascade.rs @@ -25,7 +25,7 @@ use smallvec::SmallVec; use std::borrow::Cow; use std::cell::RefCell; use crate::style_adjuster::StyleAdjuster; -use crate::values::computed; +use crate::values::{computed, specified}; /// We split the cascade in two phases: 'early' properties, and 'late' /// properties. @@ -365,24 +365,28 @@ fn should_ignore_declaration_when_ignoring_document_colors( // a background image, if we're ignoring document colors). // Here we check backplate status to decide if ignoring background-image // is the right decision. - { - let background_color = match **declaration { - PropertyDeclaration::BackgroundColor(ref color) => color, - // In the future, if/when we remove the backplate pref, we can remove this - // special case along with the 'ignored_when_colors_disabled=True' mako line - // for the "background-image" property. - #[cfg(feature = "gecko")] - PropertyDeclaration::BackgroundImage(..) => return !static_prefs::pref!("browser.display.permit_backplate"), - _ => return true, - }; + let (is_background, is_transparent) = match **declaration { + PropertyDeclaration::BackgroundColor(ref color) => (true, color.is_transparent()), + PropertyDeclaration::Color(ref color) => (false, color.0.is_transparent()), + // In the future, if/when we remove the backplate pref, we can remove this + // special case along with the 'ignored_when_colors_disabled=True' mako line + // for the "background-image" property. + #[cfg(feature = "gecko")] + PropertyDeclaration::BackgroundImage(..) => return !static_prefs::pref!("browser.display.permit_backplate"), + _ => return true, + }; - if background_color.is_transparent() { - return false; - } + if is_transparent { + return false; } - let color = device.default_background_color(); - *declaration.to_mut() = PropertyDeclaration::BackgroundColor(color.into()); + if is_background { + let color = device.default_background_color(); + *declaration.to_mut() = PropertyDeclaration::BackgroundColor(color.into()); + } else { + let color = device.default_color(); + *declaration.to_mut() = PropertyDeclaration::Color(specified::ColorPropertyValue(color.into())); + } false }