diff options
author | Xidorn Quan <me@upsuper.org> | 2017-05-19 13:25:04 +1000 |
---|---|---|
committer | Xidorn Quan <me@upsuper.org> | 2017-05-19 13:56:54 +1000 |
commit | 0c1fd2f26e898341c2761aa386e6cefea0ec7d94 (patch) | |
tree | 25a008ff291db19a1b02ab8dbe807fd64258decb | |
parent | 1c865ddc3c7043db412e12251bf236da21802248 (diff) | |
download | servo-0c1fd2f26e898341c2761aa386e6cefea0ec7d94.tar.gz servo-0c1fd2f26e898341c2761aa386e6cefea0ec7d94.zip |
Record source location for keyframes rule.
-rw-r--r-- | components/style/stylesheets.rs | 9 | ||||
-rw-r--r-- | tests/unit/style/stylesheets.rs | 4 |
2 files changed, 10 insertions, 3 deletions
diff --git a/components/style/stylesheets.rs b/components/style/stylesheets.rs index 97907d7082b..7dd567ccfcf 100644 --- a/components/style/stylesheets.rs +++ b/components/style/stylesheets.rs @@ -565,6 +565,8 @@ pub struct KeyframesRule { pub keyframes: Vec<Arc<Locked<Keyframe>>>, /// Vendor prefix type the @keyframes has. pub vendor_prefix: Option<VendorPrefix>, + /// The line and column of the rule's source code. + pub source_location: SourceLocation, } impl ToCssWithGuard for KeyframesRule { @@ -1032,7 +1034,7 @@ enum AtRulePrelude { /// A @viewport rule prelude. Viewport, /// A @keyframes rule, with its animation name and vendor prefix if exists. - Keyframes(KeyframesName, Option<VendorPrefix>), + Keyframes(KeyframesName, Option<VendorPrefix>, SourceLocation), /// A @page rule prelude. Page(SourceLocation), /// A @document rule, with its conditional. @@ -1257,7 +1259,7 @@ impl<'a, 'b> AtRuleParser for NestedRuleParser<'a, 'b> { } let name = KeyframesName::parse(self.context, input)?; - Ok(AtRuleType::WithBlock(AtRulePrelude::Keyframes(name, prefix))) + Ok(AtRuleType::WithBlock(AtRulePrelude::Keyframes(name, prefix, location))) }, "page" => { if cfg!(feature = "gecko") { @@ -1311,12 +1313,13 @@ impl<'a, 'b> AtRuleParser for NestedRuleParser<'a, 'b> { Ok(CssRule::Viewport(Arc::new(self.shared_lock.wrap( try!(ViewportRule::parse(&context, input)))))) } - AtRulePrelude::Keyframes(name, prefix) => { + AtRulePrelude::Keyframes(name, prefix, location) => { let context = ParserContext::new_with_rule_type(self.context, Some(CssRuleType::Keyframes)); Ok(CssRule::Keyframes(Arc::new(self.shared_lock.wrap(KeyframesRule { name: name, keyframes: parse_keyframe_list(&context, input, self.shared_lock), vendor_prefix: prefix, + source_location: location, })))) } AtRulePrelude::Page(location) => { diff --git a/tests/unit/style/stylesheets.rs b/tests/unit/style/stylesheets.rs index 44c02f6c1f2..7ca36677429 100644 --- a/tests/unit/style/stylesheets.rs +++ b/tests/unit/style/stylesheets.rs @@ -246,6 +246,10 @@ fn test_parse_stylesheet() { })), ], vendor_prefix: None, + source_location: SourceLocation { + line: 16, + column: 19, + }, }))) ], &stylesheet.shared_lock), |