mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
style: Cleanup gradient parsing by removing the simple-moz-gradient parsing pref.
It looks like bug 1547939 will stick, given how fast the other regressions came in for bug 1337655. We haven't seen any regression from this, and it seems unlikely that we'd want this code back. This blocks further improvements to the style system. Simplifying this code allows me to remove all the conversion code for gradients. Let me know if you think it's premature and I'm happy to wait, but I really want to see this code gone :) Differential Revision: https://phabricator.services.mozilla.com/D33820
This commit is contained in:
parent
e9b0d54a95
commit
3980dc31cd
5 changed files with 50 additions and 443 deletions
|
@ -39,9 +39,9 @@ pub enum Image<Gradient, MozImageRect, ImageUrl> {
|
|||
/// A CSS gradient.
|
||||
/// <https://drafts.csswg.org/css-images/#gradients>
|
||||
#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToResolvedValue, ToShmem)]
|
||||
pub struct Gradient<LineDirection, Length, LengthPercentage, Position, Color, Angle> {
|
||||
pub struct Gradient<LineDirection, Length, LengthPercentage, Position, Color> {
|
||||
/// Gradients can be linear or radial.
|
||||
pub kind: GradientKind<LineDirection, Length, LengthPercentage, Position, Angle>,
|
||||
pub kind: GradientKind<LineDirection, Length, LengthPercentage, Position>,
|
||||
/// The color stops and interpolation hints.
|
||||
pub items: Vec<GradientItem<Color, LengthPercentage>>,
|
||||
/// True if this is a repeating gradient.
|
||||
|
@ -63,15 +63,11 @@ pub enum CompatMode {
|
|||
|
||||
/// A gradient kind.
|
||||
#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToResolvedValue, ToShmem)]
|
||||
pub enum GradientKind<LineDirection, Length, LengthPercentage, Position, Angle> {
|
||||
pub enum GradientKind<LineDirection, Length, LengthPercentage, Position> {
|
||||
/// A linear gradient.
|
||||
Linear(LineDirection),
|
||||
/// A radial gradient.
|
||||
Radial(
|
||||
EndingShape<Length, LengthPercentage>,
|
||||
Position,
|
||||
Option<Angle>,
|
||||
),
|
||||
Radial(EndingShape<Length, LengthPercentage>, Position),
|
||||
}
|
||||
|
||||
/// A radial gradient's ending shape.
|
||||
|
@ -268,14 +264,13 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
impl<D, L, LoP, P, C, A> ToCss for Gradient<D, L, LoP, P, C, A>
|
||||
impl<D, L, LoP, P, C> ToCss for Gradient<D, L, LoP, P, C>
|
||||
where
|
||||
D: LineDirection,
|
||||
L: ToCss,
|
||||
LoP: ToCss,
|
||||
P: ToCss,
|
||||
C: ToCss,
|
||||
A: ToCss,
|
||||
{
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
|
@ -300,7 +295,7 @@ where
|
|||
direction.to_css(dest, self.compat_mode)?;
|
||||
false
|
||||
},
|
||||
GradientKind::Radial(ref shape, ref position, ref angle) => {
|
||||
GradientKind::Radial(ref shape, ref position) => {
|
||||
let omit_shape = match *shape {
|
||||
EndingShape::Ellipse(Ellipse::Extent(ShapeExtent::Cover)) |
|
||||
EndingShape::Ellipse(Ellipse::Extent(ShapeExtent::FarthestCorner)) => true,
|
||||
|
@ -315,10 +310,6 @@ where
|
|||
position.to_css(dest)?;
|
||||
} else {
|
||||
position.to_css(dest)?;
|
||||
if let Some(ref a) = *angle {
|
||||
dest.write_str(" ")?;
|
||||
a.to_css(dest)?;
|
||||
}
|
||||
if !omit_shape {
|
||||
dest.write_str(", ")?;
|
||||
shape.to_css(dest)?;
|
||||
|
@ -338,7 +329,7 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
impl<D, L, LoP, P, A> GradientKind<D, L, LoP, P, A> {
|
||||
impl<D, L, LoP, P> GradientKind<D, L, LoP, P> {
|
||||
fn label(&self) -> &str {
|
||||
match *self {
|
||||
GradientKind::Linear(..) => "linear",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue