style: Remove the last usage of lossy currentcolor.

We don't have lossy currentcolor in the style system anymore, except for a
single property -moz-font-smoothing-background-color.

I could've converted it into a proper StyleColor and thread down all the
necessary information to the font metrics code.

But it doesn't really seem worth it given it's not exposed to the web, so I just
did the simplest thing, which is making currentcolor compute to transparent to
that specific property.

This patch also removes the stores_complex_colors_lossily code and related,
since now we always can cache computed colors.

Differential Revision: https://phabricator.services.mozilla.com/D26187
This commit is contained in:
Emilio Cobos Álvarez 2019-04-06 17:47:58 +00:00
parent 681f861018
commit 5d2724994c
8 changed files with 24 additions and 78 deletions

View file

@ -11,14 +11,14 @@ use cssparser::{Color as CSSParserColor, RGBA};
use std::fmt;
use style_traits::{CssWriter, ToCss};
/// Computed value type for the specified RGBAColor.
pub type RGBAColor = RGBA;
/// The computed value of the `color` property.
pub type ColorPropertyValue = RGBA;
/// The computed value of `-moz-font-smoothing-background-color`.
pub type MozFontSmoothingBackgroundColor = RGBA;
/// A computed value for `<color>`.
pub type Color = GenericColor<RGBAColor>;
pub type Color = GenericColor<RGBA>;
impl Color {
/// Returns a complex color value representing transparent.

View file

@ -43,7 +43,7 @@ pub use self::box_::{Appearance, BreakBetween, BreakWithin, Clear, Float};
pub use self::box_::{Display, Overflow, OverflowAnchor, TransitionProperty};
pub use self::box_::{OverflowClipBox, OverscrollBehavior, Perspective, Resize};
pub use self::box_::{ScrollSnapAlign, ScrollSnapType, TouchAction, VerticalAlign, WillChange};
pub use self::color::{Color, ColorOrAuto, ColorPropertyValue, RGBAColor};
pub use self::color::{Color, ColorOrAuto, ColorPropertyValue};
pub use self::column::ColumnCount;
pub use self::counters::{Content, ContentItem, CounterIncrement, CounterSetOrReset};
pub use self::easing::TimingFunction;

View file

@ -373,15 +373,7 @@ impl ToComputedValue for Color {
type ComputedValue = ComputedColor;
fn to_computed_value(&self, context: &Context) -> ComputedColor {
let result = self.to_computed_color(Some(context)).unwrap();
if !result.is_numeric() {
if let Some(longhand) = context.for_non_inherited_property {
if longhand.stores_complex_colors_lossily() {
context.rule_cache_conditions.borrow_mut().set_uncacheable();
}
}
}
result
self.to_computed_color(Some(context)).unwrap()
}
fn from_computed_value(computed: &ComputedColor) -> Self {
@ -393,37 +385,33 @@ impl ToComputedValue for Color {
}
}
/// Specified color value, but resolved to just RGBA for computed value
/// with value from color property at the same context.
/// Specified color value for `-moz-font-smoothing-background-color`.
///
/// This property does not support `currentcolor`. We could drop it at
/// parse-time, but it's not exposed to the web so it doesn't really matter.
///
/// We resolve it to `transparent` instead.
#[derive(Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToCss, ToShmem)]
pub struct RGBAColor(pub Color);
pub struct MozFontSmoothingBackgroundColor(pub Color);
impl Parse for RGBAColor {
impl Parse for MozFontSmoothingBackgroundColor {
fn parse<'i, 't>(
context: &ParserContext,
input: &mut Parser<'i, 't>,
) -> Result<Self, ParseError<'i>> {
Color::parse(context, input).map(RGBAColor)
Color::parse(context, input).map(MozFontSmoothingBackgroundColor)
}
}
impl ToComputedValue for RGBAColor {
impl ToComputedValue for MozFontSmoothingBackgroundColor {
type ComputedValue = RGBA;
fn to_computed_value(&self, context: &Context) -> RGBA {
self.0
.to_computed_value(context)
.to_rgba(context.style().get_color().clone_color())
self.0.to_computed_value(context).to_rgba(RGBA::transparent())
}
fn from_computed_value(computed: &RGBA) -> Self {
RGBAColor(Color::rgba(*computed))
}
}
impl From<Color> for RGBAColor {
fn from(color: Color) -> RGBAColor {
RGBAColor(color)
MozFontSmoothingBackgroundColor(Color::rgba(*computed))
}
}

View file

@ -42,7 +42,7 @@ pub use self::box_::{Clear, Float, Overflow, OverflowAnchor};
pub use self::box_::{OverflowClipBox, OverscrollBehavior, Perspective, Resize};
pub use self::box_::{ScrollSnapAlign, ScrollSnapType};
pub use self::box_::{TouchAction, TransitionProperty, VerticalAlign, WillChange};
pub use self::color::{Color, ColorOrAuto, ColorPropertyValue, RGBAColor};
pub use self::color::{Color, ColorOrAuto, ColorPropertyValue};
pub use self::column::ColumnCount;
pub use self::counters::{Content, ContentItem, CounterIncrement, CounterSetOrReset};
pub use self::easing::TimingFunction;