mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Move ToCss impl for Shadow types to values mod.
This commit is contained in:
parent
f388c0ab1e
commit
2bd1ff0450
3 changed files with 39 additions and 42 deletions
|
@ -19,56 +19,14 @@ ${helpers.predefined_type("opacity",
|
|||
extra_prefixes="webkit"
|
||||
ignored_when_colors_disabled="True"
|
||||
spec="https://drafts.csswg.org/css-backgrounds/#box-shadow">
|
||||
use std::fmt;
|
||||
use style_traits::ToCss;
|
||||
|
||||
pub type SpecifiedValue = specified::Shadow;
|
||||
|
||||
impl ToCss for SpecifiedValue {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
if self.inset {
|
||||
try!(dest.write_str("inset "));
|
||||
}
|
||||
try!(self.offset_x.to_css(dest));
|
||||
try!(dest.write_str(" "));
|
||||
try!(self.offset_y.to_css(dest));
|
||||
try!(dest.write_str(" "));
|
||||
try!(self.blur_radius.to_css(dest));
|
||||
try!(dest.write_str(" "));
|
||||
try!(self.spread_radius.to_css(dest));
|
||||
|
||||
if let Some(ref color) = self.color {
|
||||
try!(dest.write_str(" "));
|
||||
try!(color.to_css(dest));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
pub mod computed_value {
|
||||
use values::computed::Shadow;
|
||||
|
||||
pub type T = Shadow;
|
||||
}
|
||||
|
||||
impl ToCss for computed_value::T {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
if self.inset {
|
||||
try!(dest.write_str("inset "));
|
||||
}
|
||||
try!(self.blur_radius.to_css(dest));
|
||||
try!(dest.write_str(" "));
|
||||
try!(self.spread_radius.to_css(dest));
|
||||
try!(dest.write_str(" "));
|
||||
try!(self.offset_x.to_css(dest));
|
||||
try!(dest.write_str(" "));
|
||||
try!(self.offset_y.to_css(dest));
|
||||
try!(dest.write_str(" "));
|
||||
try!(self.color.to_css(dest));
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parse(context: &ParserContext, input: &mut Parser) -> Result<specified::Shadow, ()> {
|
||||
specified::Shadow::parse(context, input, false)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue