Backed out changeset e7327bb0db03 (bug 1838740) for causing wpt failures on gradient-interpolation-method-computed.html. CLOSED TREE

This commit is contained in:
Cosmin Sabou 2023-06-23 18:46:19 +03:00
parent 7518e2e9bc
commit 887e24051d
7 changed files with 4206 additions and 156 deletions

View File

@ -8587,13 +8587,6 @@
value: @IS_NOT_RELEASE_OR_BETA@
mirror: always
# Is support for (linear|radial|conic)-gradient color interpolation methods enabled?
- name: layout.css.gradient-color-interpolation-method.enabled
type: RelaxedAtomicBool
value: false
mirror: always
rust: true
# Is support for caching an grid item's block axis measurement enabled?
- name: layout.css.grid-item-baxis-measurement.enabled
type: bool

View File

@ -6,7 +6,6 @@
//!
//! [images]: https://drafts.csswg.org/css-images/#image-values
use crate::color::{mix::ColorInterpolationMethod, ColorSpace};
use crate::custom_properties;
use crate::values::generics::position::PositionComponent;
use crate::values::generics::Optional;
@ -177,8 +176,6 @@ pub enum GenericGradient<
Linear {
/// Line direction
direction: LineDirection,
/// Method to use for color interpolation.
color_interpolation_method: ColorInterpolationMethod,
/// The color stops and interpolation hints.
items: crate::OwnedSlice<GenericGradientItem<Color, LengthPercentage>>,
/// True if this is a repeating gradient.
@ -192,8 +189,6 @@ pub enum GenericGradient<
shape: GenericEndingShape<NonNegativeLength, NonNegativeLengthPercentage>,
/// Center of gradient
position: Position,
/// Method to use for color interpolation.
color_interpolation_method: ColorInterpolationMethod,
/// The color stops and interpolation hints.
items: crate::OwnedSlice<GenericGradientItem<Color, LengthPercentage>>,
/// True if this is a repeating gradient.
@ -207,8 +202,6 @@ pub enum GenericGradient<
angle: Angle,
/// Center of gradient
position: Position,
/// Method to use for color interpolation.
color_interpolation_method: ColorInterpolationMethod,
/// The color stops and interpolation hints.
items: crate::OwnedSlice<GenericGradientItem<Color, AngleOrPercentage>>,
/// True if this is a repeating gradient.
@ -490,24 +483,17 @@ where
match *self {
Gradient::Linear {
ref direction,
ref color_interpolation_method,
ref items,
compat_mode,
..
} => {
dest.write_str("linear-gradient(")?;
let mut skip_comma = true;
if !direction.points_downwards(compat_mode) {
let mut skip_comma = if !direction.points_downwards(compat_mode) {
direction.to_css(dest, compat_mode)?;
skip_comma = false;
}
if !matches!(color_interpolation_method.space, ColorSpace::Srgb) {
if !skip_comma {
dest.write_char(' ')?;
}
color_interpolation_method.to_css(dest)?;
skip_comma = false;
}
false
} else {
true
};
for item in &**items {
if !skip_comma {
dest.write_str(", ")?;
@ -519,7 +505,6 @@ where
Gradient::Radial {
ref shape,
ref position,
ref color_interpolation_method,
ref items,
compat_mode,
..
@ -553,16 +538,7 @@ where
shape.to_css(dest)?;
}
}
let omit_color_interpolation_method =
matches!(color_interpolation_method.space, ColorSpace::Srgb);
if !omit_color_interpolation_method {
if !omit_shape || !omit_position {
dest.write_char(' ')?;
}
color_interpolation_method.to_css(dest)?;
}
let mut skip_comma = omit_shape && omit_position && omit_color_interpolation_method;
let mut skip_comma = omit_shape && omit_position;
for item in &**items {
if !skip_comma {
dest.write_str(", ")?;

View File

@ -7,7 +7,6 @@
//!
//! [image]: https://drafts.csswg.org/css-images/#image-values
use crate::color::mix::ColorInterpolationMethod;
use crate::custom_properties::SpecifiedValue;
use crate::parser::{Parse, ParserContext};
use crate::stylesheets::CorsMode;
@ -35,11 +34,6 @@ use std::fmt::{self, Write};
use style_traits::{CssType, CssWriter, KeywordsCollectFn, ParseError};
use style_traits::{SpecifiedValueInfo, StyleParseErrorKind, ToCss};
#[inline]
fn gradient_color_interpolation_method_enabled() -> bool {
static_prefs::pref!("layout.css.gradient-color-interpolation-method.enabled")
}
/// Specified values for an image according to CSS-IMAGES.
/// <https://drafts.csswg.org/css-images/#image-values>
pub type Image =
@ -669,7 +663,6 @@ impl Gradient {
generic::Gradient::Linear {
direction,
color_interpolation_method: ColorInterpolationMethod::srgb(),
items,
repeating: false,
compat_mode: GradientCompatMode::Modern,
@ -698,7 +691,6 @@ impl Gradient {
generic::Gradient::Radial {
shape,
position,
color_interpolation_method: ColorInterpolationMethod::srgb(),
items,
repeating: false,
compat_mode: GradientCompatMode::Modern,
@ -810,20 +802,6 @@ impl Gradient {
Ok(items)
}
/// Try to parse a color interpolation method.
fn try_parse_color_interpolation_method<'i, 't>(
context: &ParserContext,
input: &mut Parser<'i, 't>,
) -> Option<ColorInterpolationMethod> {
if gradient_color_interpolation_method_enabled() {
input
.try_parse(|i| ColorInterpolationMethod::parse(context, i))
.ok()
} else {
None
}
}
/// Parses a linear gradient.
/// GradientCompatMode can change during `-moz-` prefixed gradient parsing if it come across a `to` keyword.
fn parse_linear<'i, 't>(
@ -832,39 +810,23 @@ impl Gradient {
repeating: bool,
mut compat_mode: GradientCompatMode,
) -> Result<Self, ParseError<'i>> {
let mut color_interpolation_method =
Self::try_parse_color_interpolation_method(context, input);
let direction = input
.try_parse(|p| LineDirection::parse(context, p, &mut compat_mode))
.ok();
if color_interpolation_method.is_none() && direction.is_some() {
color_interpolation_method = Self::try_parse_color_interpolation_method(context, input);
}
// If either of the 2 options were specified, we require a comma.
if color_interpolation_method.is_some() || direction.is_some() {
let direction = if let Ok(d) =
input.try_parse(|i| LineDirection::parse(context, i, &mut compat_mode))
{
input.expect_comma()?;
}
d
} else {
match compat_mode {
GradientCompatMode::Modern => {
LineDirection::Vertical(VerticalPositionKeyword::Bottom)
},
_ => LineDirection::Vertical(VerticalPositionKeyword::Top),
}
};
let items = Gradient::parse_stops(context, input)?;
let color_interpolation_method = color_interpolation_method.unwrap_or_else(|| {
// TODO(tlouw): Check whether any of the stops are in a non legacy syntax, in which
// case we should default to lab() and not srgb().
// See: https://bugzilla.mozilla.org/show_bug.cgi?id=1839837
ColorInterpolationMethod::srgb()
});
let direction = direction.unwrap_or(match compat_mode {
GradientCompatMode::Modern => LineDirection::Vertical(VerticalPositionKeyword::Bottom),
_ => LineDirection::Vertical(VerticalPositionKeyword::Top),
});
Ok(Gradient::Linear {
direction,
color_interpolation_method,
items,
repeating,
compat_mode,
@ -878,9 +840,6 @@ impl Gradient {
repeating: bool,
compat_mode: GradientCompatMode,
) -> Result<Self, ParseError<'i>> {
let mut color_interpolation_method =
Self::try_parse_color_interpolation_method(context, input);
let (shape, position) = match compat_mode {
GradientCompatMode::Modern => {
let shape = input.try_parse(|i| EndingShape::parse(context, i, compat_mode));
@ -902,12 +861,7 @@ impl Gradient {
},
};
if shape.is_ok() || position.is_some() || color_interpolation_method.is_some() {
if color_interpolation_method.is_none() {
color_interpolation_method =
Self::try_parse_color_interpolation_method(context, input);
}
if shape.is_ok() || position.is_some() {
input.expect_comma()?;
}
@ -919,32 +873,19 @@ impl Gradient {
let items = Gradient::parse_stops(context, input)?;
let color_interpolation_method = color_interpolation_method.unwrap_or_else(|| {
// TODO(tlouw): Check whether any of the stops are in a non legacy syntax, in which
// case we should default to lab() and not srgb().
// See: https://bugzilla.mozilla.org/show_bug.cgi?id=1839837
ColorInterpolationMethod::srgb()
});
Ok(Gradient::Radial {
shape,
position,
color_interpolation_method,
items,
repeating,
compat_mode,
})
}
/// Parse a conic gradient.
fn parse_conic<'i, 't>(
context: &ParserContext,
input: &mut Parser<'i, 't>,
repeating: bool,
) -> Result<Self, ParseError<'i>> {
let mut color_interpolation_method =
Self::try_parse_color_interpolation_method(context, input);
let angle = input.try_parse(|i| {
i.expect_ident_matching("from")?;
// Spec allows unitless zero start angles
@ -955,20 +896,12 @@ impl Gradient {
i.expect_ident_matching("at")?;
Position::parse(context, i)
});
if angle.is_ok() || position.is_ok() {
if color_interpolation_method.is_none() {
color_interpolation_method =
Self::try_parse_color_interpolation_method(context, input);
}
input.expect_comma()?;
}
let angle = angle.unwrap_or(Angle::zero());
let position = position.unwrap_or(Position::center());
let items = generic::GradientItem::parse_comma_separated(
context,
input,
@ -979,17 +912,9 @@ impl Gradient {
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
}
let color_interpolation_method = color_interpolation_method.unwrap_or_else(|| {
// TODO(tlouw): Check whether any of the stops are in a non legacy syntax, in which
// case we should default to lab() and not srgb().
// See: https://bugzilla.mozilla.org/show_bug.cgi?id=1839837
ColorInterpolationMethod::srgb()
});
Ok(Gradient::Conic {
angle,
position,
color_interpolation_method,
items,
repeating,
})

View File

@ -1 +0,0 @@
prefs: [layout.css.gradient-color-interpolation-method.enabled:true]

View File

@ -0,0 +1,2 @@
[srgb-gradient.html]
expected: FAIL