зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1891700 - Accept color-mix() in font palette override colors, provided the components used are absolute colors. r=tlouw
Differential Revision: https://phabricator.services.mozilla.com/D208115
This commit is contained in:
Родитель
5b3c7e1864
Коммит
2851ee606a
|
@ -44,12 +44,17 @@ impl Parse for FontPaletteOverrideColor {
|
|||
let index = NonNegativeInteger::parse(context, input)?;
|
||||
let location = input.current_source_location();
|
||||
let color = SpecifiedColor::parse(context, input)?;
|
||||
// Only absolute colors are accepted here.
|
||||
if let SpecifiedColor::Absolute { .. } = color {
|
||||
Ok(FontPaletteOverrideColor { index, color })
|
||||
} else {
|
||||
Err(location.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
// Only absolute colors are accepted here:
|
||||
// https://drafts.csswg.org/css-fonts/#override-color
|
||||
// https://drafts.csswg.org/css-color-5/#absolute-color
|
||||
// so check that the specified color can be resolved without a context
|
||||
// or currentColor value.
|
||||
if color.resolve_to_absolute().is_some() {
|
||||
// We store the specified color (not the resolved absolute color)
|
||||
// because that is what the rule exposes to authors.
|
||||
return Ok(FontPaletteOverrideColor { index, color });
|
||||
}
|
||||
Err(location.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -178,14 +183,15 @@ impl FontPaletteValuesRule {
|
|||
}
|
||||
}
|
||||
for c in &self.override_colors {
|
||||
if let SpecifiedColor::Absolute(ref absolute) = c.color {
|
||||
unsafe {
|
||||
Gecko_SetFontPaletteOverride(
|
||||
palette_values,
|
||||
c.index.0.value(),
|
||||
(&absolute.color) as *const _ as *mut _,
|
||||
);
|
||||
}
|
||||
// We checked at parse time that the specified color can be resolved
|
||||
// in this way, so the unwrap() here will succeed.
|
||||
let absolute = c.color.resolve_to_absolute().unwrap();
|
||||
unsafe {
|
||||
Gecko_SetFontPaletteOverride(
|
||||
palette_values,
|
||||
c.index.0.value(),
|
||||
(&absolute) as *const _ as *mut _,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -607,6 +607,35 @@ impl Color {
|
|||
}))
|
||||
}
|
||||
|
||||
/// Resolve this Color into an AbsoluteColor if it does not use any of the
|
||||
/// forms that are invalid in an absolute color.
|
||||
/// https://drafts.csswg.org/css-color-5/#absolute-color
|
||||
/// Returns None if the specified color is not valid as an absolute color.
|
||||
pub fn resolve_to_absolute(&self) -> Option<AbsoluteColor> {
|
||||
use crate::values::specified::percentage::ToPercentage;
|
||||
|
||||
match self {
|
||||
Self::Absolute(c) => return Some(c.color),
|
||||
Self::ColorMix(ref mix) => {
|
||||
if let Some(left) = mix.left.resolve_to_absolute() {
|
||||
if let Some(right) = mix.right.resolve_to_absolute() {
|
||||
return Some(crate::color::mix::mix(
|
||||
mix.interpolation,
|
||||
&left,
|
||||
mix.left_percentage.to_percentage(),
|
||||
&right,
|
||||
mix.right_percentage.to_percentage(),
|
||||
mix.flags,
|
||||
))
|
||||
}
|
||||
}
|
||||
},
|
||||
_ => (),
|
||||
};
|
||||
|
||||
None
|
||||
}
|
||||
|
||||
/// Parse a color, with quirks.
|
||||
///
|
||||
/// <https://quirks.spec.whatwg.org/#the-hashless-hex-color-quirk>
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
[font-palette-values-invalid.html]
|
||||
expected:
|
||||
if (os == "android") and fission: [OK, TIMEOUT]
|
|
@ -1,5 +0,0 @@
|
|||
[font-palette-values-valid.html]
|
||||
expected:
|
||||
if (os == "android") and fission: [OK, TIMEOUT]
|
||||
[CSS Fonts Module Level 4: parsing @font-palette-values 33]
|
||||
expected: FAIL
|
Загрузка…
Ссылка в новой задаче