style: Modify background image styling to only apply URL-sourced images when backplate is enabled.

Differential Revision: https://phabricator.services.mozilla.com/D64200
This commit is contained in:
Morgan Reschenberg 2020-03-04 01:19:41 +00:00 committed by Emilio Cobos Álvarez
parent b9bf5fb868
commit 45cc310f7f

View file

@ -380,6 +380,9 @@ fn application_when_ignoring_colors(
// Here we check backplate status to decide if ignoring background-image // Here we check backplate status to decide if ignoring background-image
// is the right decision. // is the right decision.
match *declaration { match *declaration {
// If we've got multiple declarations in the same block, they'll
// get overridden at parse time. We should probably adjust this
// to turn Ignored decls into `none`. See 1619701
PropertyDeclaration::BackgroundColor(ref color) => { PropertyDeclaration::BackgroundColor(ref color) => {
if color.is_transparent() { if color.is_transparent() {
return DeclarationApplication::Apply; return DeclarationApplication::Apply;
@ -405,11 +408,19 @@ fn application_when_ignoring_colors(
// special case along with the 'ignored_when_colors_disabled=True' mako line // special case along with the 'ignored_when_colors_disabled=True' mako line
// for the "background-image" property. // for the "background-image" property.
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
PropertyDeclaration::BackgroundImage(..) => { PropertyDeclaration::BackgroundImage(ref bkg) => {
use crate::values::generics::image::Image;
// We should only allow images to be rendered in HCM if the backplate pref
// is enabled, and if all the images applied to the background are from URLs.
// If one or more background images aren't from URL's (ie. gradients)
// we should ignore all background-image styling.
if static_prefs::pref!("browser.display.permit_backplate") { if static_prefs::pref!("browser.display.permit_backplate") {
DeclarationApplication::Apply if bkg.0.iter().all(|image| matches!(*image, Image::Url(..))) {
return DeclarationApplication::Apply;
}
return DeclarationApplication::Ignore;
} else { } else {
DeclarationApplication::Ignore return DeclarationApplication::Ignore;
} }
}, },
_ => DeclarationApplication::Ignore, _ => DeclarationApplication::Ignore,