style: Add @keyframe rule parsing.

This commit is contained in:
Emilio Cobos Álvarez 2016-06-16 16:14:09 +02:00
parent 7b2080c5b7
commit c1fd7432e9
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
5 changed files with 197 additions and 15 deletions

View file

@ -9,11 +9,13 @@ use std::borrow::ToOwned;
use std::sync::Arc;
use std::sync::Mutex;
use string_cache::{Atom, Namespace};
use style::error_reporting::ParseErrorReporter;
use style::keyframes::{Keyframe, KeyframeSelector, KeyframePercentage};
use style::parser::ParserContextExtraData;
use style::properties::{PropertyDeclaration, PropertyDeclarationBlock, DeclaredValue, longhands};
use style::stylesheets::{CSSRule, StyleRule, Origin};
use style::error_reporting::ParseErrorReporter;
use style::servo::Stylesheet;
use style::stylesheets::{CSSRule, StyleRule, KeyframesRule, Origin};
use style::values::specified::{LengthOrPercentageOrAuto, Percentage};
use url::Url;
#[test]
@ -24,7 +26,10 @@ fn test_parse_stylesheet() {
input[type=hidden i] { display: none !important; }
html , body /**/ { display: block; }
#d1 > .ok { background: blue; }
";
@keyframes foo {
from { width: 0% }
to { width: 100%}
}";
let url = Url::parse("about::test").unwrap();
let stylesheet = Stylesheet::from_str(css, url, Origin::UserAgent,
Box::new(CSSErrorReporterTest),
@ -145,6 +150,34 @@ fn test_parse_stylesheet() {
important: Arc::new(vec![]),
},
}),
CSSRule::Keyframes(KeyframesRule {
name: "foo".into(),
keyframes: vec![
Keyframe {
selector: KeyframeSelector::new_for_unit_testing(
vec![KeyframePercentage::new(0.)]),
declarations: PropertyDeclarationBlock {
normal: Arc::new(vec![
PropertyDeclaration::Width(DeclaredValue::Value(
LengthOrPercentageOrAuto::Percentage(Percentage(0.)))),
]),
important: Arc::new(vec![]),
}
},
Keyframe {
selector: KeyframeSelector::new_for_unit_testing(
vec![KeyframePercentage::new(1.)]),
declarations: PropertyDeclarationBlock {
normal: Arc::new(vec![
PropertyDeclaration::Width(DeclaredValue::Value(
LengthOrPercentageOrAuto::Percentage(Percentage(1.)))),
]),
important: Arc::new(vec![]),
}
},
]
})
],
});
}