mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Derive ToCss for EndingShape
This commit is contained in:
parent
fe19c3810c
commit
53b465895f
1 changed files with 13 additions and 17 deletions
|
@ -69,7 +69,7 @@ pub enum GradientKind<LineDirection, Length, LengthOrPercentage, Position> {
|
|||
}
|
||||
|
||||
/// A radial gradient's ending shape.
|
||||
#[derive(Clone, Copy, Debug, HasViewportPercentage, PartialEq, ToComputedValue)]
|
||||
#[derive(Clone, Copy, Debug, HasViewportPercentage, PartialEq, ToComputedValue, ToCss)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
pub enum EndingShape<Length, LengthOrPercentage> {
|
||||
/// A circular gradient.
|
||||
|
@ -89,7 +89,7 @@ pub enum Circle<Length> {
|
|||
}
|
||||
|
||||
/// An ellipse shape.
|
||||
#[derive(Clone, Copy, Debug, HasViewportPercentage, PartialEq, ToComputedValue)]
|
||||
#[derive(Clone, Copy, Debug, HasViewportPercentage, PartialEq, ToComputedValue, ToCss)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
pub enum Ellipse<LengthOrPercentage> {
|
||||
/// An ellipse pair of radii.
|
||||
|
@ -286,30 +286,26 @@ pub trait LineDirection {
|
|||
where W: fmt::Write;
|
||||
}
|
||||
|
||||
impl<L, LoP> ToCss for EndingShape<L, LoP>
|
||||
where L: ToCss, LoP: ToCss,
|
||||
impl<L> ToCss for Circle<L>
|
||||
where
|
||||
L: ToCss,
|
||||
{
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result
|
||||
where
|
||||
W: fmt::Write,
|
||||
{
|
||||
match *self {
|
||||
EndingShape::Circle(Circle::Extent(ShapeExtent::FarthestCorner)) |
|
||||
EndingShape::Circle(Circle::Extent(ShapeExtent::Cover)) => {
|
||||
Circle::Extent(ShapeExtent::FarthestCorner) |
|
||||
Circle::Extent(ShapeExtent::Cover) => {
|
||||
dest.write_str("circle")
|
||||
},
|
||||
EndingShape::Circle(Circle::Extent(keyword)) => {
|
||||
Circle::Extent(keyword) => {
|
||||
dest.write_str("circle ")?;
|
||||
keyword.to_css(dest)
|
||||
},
|
||||
EndingShape::Circle(Circle::Radius(ref length)) => {
|
||||
Circle::Radius(ref length) => {
|
||||
length.to_css(dest)
|
||||
},
|
||||
EndingShape::Ellipse(Ellipse::Extent(keyword)) => {
|
||||
keyword.to_css(dest)
|
||||
},
|
||||
EndingShape::Ellipse(Ellipse::Radii(ref x, ref y)) => {
|
||||
x.to_css(dest)?;
|
||||
dest.write_str(" ")?;
|
||||
y.to_css(dest)
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue