style: Do not ignore color: transparent in high contrast mode.

PDFJS uses it, for example to allow text selection. It's not great if it shows
on top of the actual PDF :-)

Differential Revision: https://phabricator.services.mozilla.com/D58703
This commit is contained in:
Emilio Cobos Álvarez 2020-01-14 20:25:03 +00:00
parent e9c14bb9fc
commit c569d314a5
No known key found for this signature in database
GPG key ID: E1152D0994E4BF8A
2 changed files with 25 additions and 16 deletions

View file

@ -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 {

View file

@ -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
}