From 0c1fd2f26e898341c2761aa386e6cefea0ec7d94 Mon Sep 17 00:00:00 2001 From: Xidorn Quan Date: Fri, 19 May 2017 13:25:04 +1000 Subject: [PATCH] Record source location for keyframes rule. --- components/style/stylesheets.rs | 9 ++++++--- 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>>, /// Vendor prefix type the @keyframes has. pub vendor_prefix: Option, + /// 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), + Keyframes(KeyframesName, Option, 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),