mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Add Ellipse to basic_shape.rs
This commit is contained in:
parent
77f345476f
commit
78ce65d5a8
2 changed files with 92 additions and 2 deletions
|
@ -18,7 +18,7 @@ use cssparser::{self, Parser, ToCss, Token};
|
|||
pub enum BasicShape {
|
||||
Inset(InsetRect),
|
||||
Circle(Circle),
|
||||
// Ellipse(Ellipse),
|
||||
Ellipse(Ellipse),
|
||||
// Polygon(Polygon),
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,7 @@ impl ToCss for BasicShape {
|
|||
match *self {
|
||||
BasicShape::Inset(rect) => rect.to_css(dest),
|
||||
BasicShape::Circle(circle) => circle.to_css(dest),
|
||||
BasicShape::Ellipse(e) => e.to_css(dest),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -75,6 +76,28 @@ impl ToCss for Circle {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Copy, Debug)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
pub struct Ellipse {
|
||||
pub semiaxis_a: ShapeRadius,
|
||||
pub semiaxis_b: ShapeRadius,
|
||||
pub position: Position,
|
||||
}
|
||||
|
||||
impl ToCss for Ellipse {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
if ShapeRadius::ClosestSide != self.semiaxis_a
|
||||
&& ShapeRadius::ClosestSide != self.semiaxis_b {
|
||||
try!(self.semiaxis_a.to_css(dest));
|
||||
try!(dest.write_str(" "));
|
||||
try!(self.semiaxis_b.to_css(dest));
|
||||
try!(dest.write_str(" "));
|
||||
}
|
||||
try!(dest.write_str("at "));
|
||||
self.position.to_css(dest)
|
||||
}
|
||||
}
|
||||
|
||||
/// https://drafts.csswg.org/css-shapes/#typedef-shape-radius
|
||||
#[derive(Clone, PartialEq, Copy, Debug)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue