mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Add Circle to basic_shape.rs
This commit is contained in:
parent
44e33bcdc5
commit
77f345476f
3 changed files with 88 additions and 4 deletions
|
@ -9,6 +9,7 @@
|
|||
|
||||
use values::computed::{Length, LengthOrPercentage};
|
||||
use values::computed::BorderRadiusSize;
|
||||
use values::computed::position::Position;
|
||||
use std::fmt;
|
||||
use cssparser::{self, Parser, ToCss, Token};
|
||||
|
||||
|
@ -16,11 +17,20 @@ use cssparser::{self, Parser, ToCss, Token};
|
|||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
pub enum BasicShape {
|
||||
Inset(InsetRect),
|
||||
// Circle(Circle),
|
||||
Circle(Circle),
|
||||
// Ellipse(Ellipse),
|
||||
// Polygon(Polygon),
|
||||
}
|
||||
|
||||
impl ToCss for BasicShape {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
match *self {
|
||||
BasicShape::Inset(rect) => rect.to_css(dest),
|
||||
BasicShape::Circle(circle) => circle.to_css(dest),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Copy, Debug)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
pub struct InsetRect {
|
||||
|
@ -50,6 +60,21 @@ impl ToCss for InsetRect {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Copy, Debug)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
pub struct Circle {
|
||||
pub radius: ShapeRadius,
|
||||
pub position: Position,
|
||||
}
|
||||
|
||||
impl ToCss for Circle {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
try!(self.radius.to_css(dest));
|
||||
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