mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Implement ToCss serialization for CSSRules
This commit is contained in:
parent
22aebdf5d4
commit
fdbadcdce2
10 changed files with 198 additions and 28 deletions
|
@ -9,7 +9,9 @@ use parser::{ParserContext, log_css_error};
|
|||
use properties::{Importance, PropertyDeclaration, PropertyDeclarationBlock};
|
||||
use properties::PropertyDeclarationParseResult;
|
||||
use properties::animated_properties::TransitionProperty;
|
||||
use std::fmt;
|
||||
use std::sync::Arc;
|
||||
use style_traits::ToCss;
|
||||
|
||||
/// A number from 1 to 100, indicating the percentage of the animation where
|
||||
/// this keyframe should run.
|
||||
|
@ -82,6 +84,21 @@ pub struct Keyframe {
|
|||
pub block: Arc<RwLock<PropertyDeclarationBlock>>,
|
||||
}
|
||||
|
||||
impl ToCss for Keyframe {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
let mut iter = self.selector.percentages().iter();
|
||||
try!(write!(dest, "{}%", iter.next().unwrap().0));
|
||||
for percentage in iter {
|
||||
try!(write!(dest, ", "));
|
||||
try!(write!(dest, "{}%", percentage.0));
|
||||
}
|
||||
try!(dest.write_str(" { "));
|
||||
try!(self.block.read().to_css(dest));
|
||||
try!(dest.write_str(" }"));
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
/// A keyframes step value. This can be a synthetised keyframes animation, that
|
||||
/// is, one autogenerated from the current computed values, or a list of
|
||||
/// declarations to apply.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue