mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Impl to_css for KeyframeSelector.
This commit is contained in:
parent
0ad0641872
commit
1c865ddc3c
1 changed files with 14 additions and 7 deletions
|
@ -73,6 +73,19 @@ impl KeyframePercentage {
|
||||||
/// converted at parse time to percentages.
|
/// converted at parse time to percentages.
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
pub struct KeyframeSelector(Vec<KeyframePercentage>);
|
pub struct KeyframeSelector(Vec<KeyframePercentage>);
|
||||||
|
|
||||||
|
impl ToCss for KeyframeSelector {
|
||||||
|
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||||
|
let mut iter = self.0.iter();
|
||||||
|
iter.next().unwrap().to_css(dest)?;
|
||||||
|
for percentage in iter {
|
||||||
|
write!(dest, ", ")?;
|
||||||
|
percentage.to_css(dest)?;
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl KeyframeSelector {
|
impl KeyframeSelector {
|
||||||
/// Return the list of percentages this selector contains.
|
/// Return the list of percentages this selector contains.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -108,12 +121,7 @@ pub struct Keyframe {
|
||||||
impl ToCssWithGuard for Keyframe {
|
impl ToCssWithGuard for Keyframe {
|
||||||
fn to_css<W>(&self, guard: &SharedRwLockReadGuard, dest: &mut W) -> fmt::Result
|
fn to_css<W>(&self, guard: &SharedRwLockReadGuard, dest: &mut W) -> fmt::Result
|
||||||
where W: fmt::Write {
|
where W: fmt::Write {
|
||||||
let mut iter = self.selector.percentages().iter();
|
self.selector.to_css(dest)?;
|
||||||
try!(iter.next().unwrap().to_css(dest));
|
|
||||||
for percentage in iter {
|
|
||||||
try!(write!(dest, ", "));
|
|
||||||
try!(percentage.to_css(dest));
|
|
||||||
}
|
|
||||||
try!(dest.write_str(" { "));
|
try!(dest.write_str(" { "));
|
||||||
try!(self.block.read_with(guard).to_css(dest));
|
try!(self.block.read_with(guard).to_css(dest));
|
||||||
try!(dest.write_str(" }"));
|
try!(dest.write_str(" }"));
|
||||||
|
@ -121,7 +129,6 @@ impl ToCssWithGuard for Keyframe {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl Keyframe {
|
impl Keyframe {
|
||||||
/// Parse a CSS keyframe.
|
/// Parse a CSS keyframe.
|
||||||
pub fn parse(css: &str, parent_stylesheet: &Stylesheet)
|
pub fn parse(css: &str, parent_stylesheet: &Stylesheet)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue