mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 19:35:51 +00:00
Bug 1734455 - Remove support for -moz-system-color() as chrome code no longer uses it (in favor of color-scheme). r=xidorn
Differential Revision: https://phabricator.services.mozilla.com/D127802
This commit is contained in:
parent
f9aea965d9
commit
445c7b4297
@ -688,21 +688,10 @@ bool Gecko_IsDocumentBody(const Element* aElement) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
nscolor Gecko_GetLookAndFeelSystemColor(int32_t aId, const Document* aDoc,
|
nscolor Gecko_GetLookAndFeelSystemColor(int32_t aId, const Document* aDoc,
|
||||||
StyleSystemColorScheme aColorScheme,
|
|
||||||
const StyleColorScheme* aStyle) {
|
const StyleColorScheme* aStyle) {
|
||||||
auto colorId = static_cast<LookAndFeel::ColorID>(aId);
|
auto colorId = static_cast<LookAndFeel::ColorID>(aId);
|
||||||
auto useStandins = LookAndFeel::ShouldUseStandins(*aDoc, colorId);
|
auto useStandins = LookAndFeel::ShouldUseStandins(*aDoc, colorId);
|
||||||
auto colorScheme = [&] {
|
auto colorScheme = LookAndFeel::ColorSchemeForStyle(*aDoc, aStyle->bits);
|
||||||
switch (aColorScheme) {
|
|
||||||
case StyleSystemColorScheme::Default:
|
|
||||||
break;
|
|
||||||
case StyleSystemColorScheme::Light:
|
|
||||||
return LookAndFeel::ColorScheme::Light;
|
|
||||||
case StyleSystemColorScheme::Dark:
|
|
||||||
return LookAndFeel::ColorScheme::Dark;
|
|
||||||
}
|
|
||||||
return LookAndFeel::ColorSchemeForStyle(*aDoc, aStyle->bits);
|
|
||||||
}();
|
|
||||||
|
|
||||||
AutoWriteLock guard(*sServoFFILock);
|
AutoWriteLock guard(*sServoFFILock);
|
||||||
return LookAndFeel::Color(colorId, colorScheme, useStandins);
|
return LookAndFeel::Color(colorId, colorScheme, useStandins);
|
||||||
|
@ -506,7 +506,6 @@ bool Gecko_IsDocumentBody(const mozilla::dom::Element* element);
|
|||||||
// because forward-declaring a nested enum/struct is impossible
|
// because forward-declaring a nested enum/struct is impossible
|
||||||
nscolor Gecko_GetLookAndFeelSystemColor(int32_t color_id,
|
nscolor Gecko_GetLookAndFeelSystemColor(int32_t color_id,
|
||||||
const mozilla::dom::Document*,
|
const mozilla::dom::Document*,
|
||||||
mozilla::StyleSystemColorScheme,
|
|
||||||
const mozilla::StyleColorScheme*);
|
const mozilla::StyleColorScheme*);
|
||||||
|
|
||||||
int32_t Gecko_GetLookAndFeelInt(int32_t int_id);
|
int32_t Gecko_GetLookAndFeelInt(int32_t int_id);
|
||||||
|
@ -508,7 +508,6 @@ cbindgen-types = [
|
|||||||
{ gecko = "StyleFontFamilyNameSyntax", servo = "crate::values::computed::font::FontFamilyNameSyntax" },
|
{ gecko = "StyleFontFamilyNameSyntax", servo = "crate::values::computed::font::FontFamilyNameSyntax" },
|
||||||
{ gecko = "StyleGenericColor", servo = "crate::values::generics::color::Color" },
|
{ gecko = "StyleGenericColor", servo = "crate::values::generics::color::Color" },
|
||||||
{ gecko = "StyleSystemColor", servo = "crate::values::specified::color::SystemColor" },
|
{ gecko = "StyleSystemColor", servo = "crate::values::specified::color::SystemColor" },
|
||||||
{ gecko = "StyleSystemColorScheme", servo = "crate::values::specified::color::SystemColorScheme" },
|
|
||||||
{ gecko = "StyleSystemFont", servo = "crate::values::specified::font::SystemFont" },
|
{ gecko = "StyleSystemFont", servo = "crate::values::specified::font::SystemFont" },
|
||||||
{ gecko = "StyleGenericColorOrAuto", servo = "crate::values::generics::color::ColorOrAuto" },
|
{ gecko = "StyleGenericColorOrAuto", servo = "crate::values::generics::color::ColorOrAuto" },
|
||||||
{ gecko = "StyleGenericScrollbarColor", servo = "crate::values::generics::ui::ScrollbarColor" },
|
{ gecko = "StyleGenericScrollbarColor", servo = "crate::values::generics::ui::ScrollbarColor" },
|
||||||
|
@ -12,8 +12,6 @@ const NON_CONTENT_ACCESSIBLE_VALUES = {
|
|||||||
"-moz-disabledfield",
|
"-moz-disabledfield",
|
||||||
"-moz-colheaderhovertext",
|
"-moz-colheaderhovertext",
|
||||||
"-moz-colheadertext",
|
"-moz-colheadertext",
|
||||||
"-moz-system-color(highlight, light)",
|
|
||||||
"-moz-system-color(highlight, dark)",
|
|
||||||
"-moz-nativevisitedhyperlinktext",
|
"-moz-nativevisitedhyperlinktext",
|
||||||
"text-select-foreground",
|
"text-select-foreground",
|
||||||
"text-select-background",
|
"text-select-background",
|
||||||
|
@ -178,20 +178,6 @@ impl ToCss for ColorMix {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The color scheme for a specific system color.
|
|
||||||
#[cfg(feature = "gecko")]
|
|
||||||
#[derive(Clone, Copy, Debug, MallocSizeOf, Parse, PartialEq, ToCss, ToShmem)]
|
|
||||||
#[repr(u8)]
|
|
||||||
pub enum SystemColorScheme {
|
|
||||||
/// The default color-scheme for the document.
|
|
||||||
#[css(skip)]
|
|
||||||
Default,
|
|
||||||
/// A light color scheme.
|
|
||||||
Light,
|
|
||||||
/// A dark color scheme.
|
|
||||||
Dark,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Specified color value
|
/// Specified color value
|
||||||
#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToShmem)]
|
#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToShmem)]
|
||||||
pub enum Color {
|
pub enum Color {
|
||||||
@ -206,10 +192,9 @@ pub enum Color {
|
|||||||
},
|
},
|
||||||
/// A complex color value from computed value
|
/// A complex color value from computed value
|
||||||
Complex(ComputedColor),
|
Complex(ComputedColor),
|
||||||
/// Either a system color, or a `-moz-system-color(<system-color>, light|dark)`
|
/// A system color.
|
||||||
/// function which allows chrome code to choose between color schemes.
|
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
System(SystemColor, SystemColorScheme),
|
System(SystemColor),
|
||||||
/// A color mix.
|
/// A color mix.
|
||||||
ColorMix(Box<ColorMix>),
|
ColorMix(Box<ColorMix>),
|
||||||
/// Quirksmode-only rule for inheriting color from the body
|
/// Quirksmode-only rule for inheriting color from the body
|
||||||
@ -464,7 +449,7 @@ pub enum SystemColor {
|
|||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
impl SystemColor {
|
impl SystemColor {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn compute(&self, cx: &Context, scheme: SystemColorScheme) -> ComputedColor {
|
fn compute(&self, cx: &Context) -> ComputedColor {
|
||||||
use crate::gecko_bindings::bindings;
|
use crate::gecko_bindings::bindings;
|
||||||
|
|
||||||
let colors = &cx.device().pref_sheet_prefs().mColors;
|
let colors = &cx.device().pref_sheet_prefs().mColors;
|
||||||
@ -481,7 +466,7 @@ impl SystemColor {
|
|||||||
|
|
||||||
_ => {
|
_ => {
|
||||||
let color = unsafe {
|
let color = unsafe {
|
||||||
bindings::Gecko_GetLookAndFeelSystemColor(*self as i32, cx.device().document(), scheme, &style_color_scheme)
|
bindings::Gecko_GetLookAndFeelSystemColor(*self as i32, cx.device().document(), &style_color_scheme)
|
||||||
};
|
};
|
||||||
if color == bindings::NS_SAME_AS_FOREGROUND_COLOR {
|
if color == bindings::NS_SAME_AS_FOREGROUND_COLOR {
|
||||||
return ComputedColor::currentcolor();
|
return ComputedColor::currentcolor();
|
||||||
@ -562,20 +547,6 @@ impl<'a, 'b: 'a, 'i: 'a> ::cssparser::ColorComponentParser<'i> for ColorComponen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_moz_system_color<'i, 't>(
|
|
||||||
context: &ParserContext,
|
|
||||||
input: &mut Parser<'i, 't>,
|
|
||||||
) -> Result<(SystemColor, SystemColorScheme), ParseError<'i>> {
|
|
||||||
debug_assert!(context.chrome_rules_enabled());
|
|
||||||
input.expect_function_matching("-moz-system-color")?;
|
|
||||||
input.parse_nested_block(|input| {
|
|
||||||
let color = SystemColor::parse(context, input)?;
|
|
||||||
input.expect_comma()?;
|
|
||||||
let scheme = SystemColorScheme::parse(input)?;
|
|
||||||
Ok((color, scheme))
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Parse for Color {
|
impl Parse for Color {
|
||||||
fn parse<'i, 't>(
|
fn parse<'i, 't>(
|
||||||
context: &ParserContext,
|
context: &ParserContext,
|
||||||
@ -601,15 +572,7 @@ impl Parse for Color {
|
|||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
{
|
{
|
||||||
if let Ok(system) = input.try_parse(|i| SystemColor::parse(context, i)) {
|
if let Ok(system) = input.try_parse(|i| SystemColor::parse(context, i)) {
|
||||||
return Ok(Color::System(system, SystemColorScheme::Default));
|
return Ok(Color::System(system));
|
||||||
}
|
|
||||||
|
|
||||||
if context.chrome_rules_enabled() {
|
|
||||||
if let Ok((color, scheme)) =
|
|
||||||
input.try_parse(|i| parse_moz_system_color(context, i))
|
|
||||||
{
|
|
||||||
return Ok(Color::System(color, scheme));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -648,17 +611,7 @@ impl ToCss for Color {
|
|||||||
Color::Complex(_) => Ok(()),
|
Color::Complex(_) => Ok(()),
|
||||||
Color::ColorMix(ref mix) => mix.to_css(dest),
|
Color::ColorMix(ref mix) => mix.to_css(dest),
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
Color::System(system, scheme) => {
|
Color::System(system) => system.to_css(dest),
|
||||||
if scheme == SystemColorScheme::Default {
|
|
||||||
system.to_css(dest)
|
|
||||||
} else {
|
|
||||||
dest.write_str("-moz-system-color(")?;
|
|
||||||
system.to_css(dest)?;
|
|
||||||
dest.write_str(", ")?;
|
|
||||||
scheme.to_css(dest)?;
|
|
||||||
dest.write_char(')')
|
|
||||||
}
|
|
||||||
},
|
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
Color::InheritFromBodyQuirk => Ok(()),
|
Color::InheritFromBodyQuirk => Ok(()),
|
||||||
}
|
}
|
||||||
@ -819,7 +772,7 @@ impl Color {
|
|||||||
))
|
))
|
||||||
},
|
},
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
Color::System(system, scheme) => system.compute(context?, scheme),
|
Color::System(system) => system.compute(context?),
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
Color::InheritFromBodyQuirk => ComputedColor::rgba(context?.device().body_text_color()),
|
Color::InheritFromBodyQuirk => ComputedColor::rgba(context?.device().body_text_color()),
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user