Bug 1464865: Some trivial cleanup. r=xidorn
authorEmilio Cobos Álvarez <emilio@crisal.io>
Tue, 29 May 2018 13:03:54 +0200
changeset 420289 4d23f192ffe345cf60527325bb56bc7d4f27c4a4
parent 420288 09d9ee3fe4bbe37634ead56e93241e761326af89
child 420290 85572fbd667360384b63a29a2d7ac0bf1285658d
push id34069
push usernerli@mozilla.com
push dateTue, 29 May 2018 21:42:06 +0000
treeherdermozilla-central@89d79c2258be [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersxidorn
bugs1464865
milestone62.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1464865: Some trivial cleanup. r=xidorn MozReview-Commit-ID: 8ClaBR9ooGb
servo/components/style/stylesheets/rule_parser.rs
--- a/servo/components/style/stylesheets/rule_parser.rs
+++ b/servo/components/style/stylesheets/rule_parser.rs
@@ -263,30 +263,30 @@ impl<'a, 'i, R: ParseErrorReporter> AtRu
                     &self.context,
                     &self.shared_lock,
                     media,
                 );
 
                 self.state = State::Imports;
                 CssRule::Import(import_rule)
             },
-            AtRuleNonBlockPrelude::Namespace(prefix, url, location) => {
-                let opt_prefix = if let Some(prefix) = prefix {
+            AtRuleNonBlockPrelude::Namespace(prefix, url, source_location) => {
+                let prefix = if let Some(prefix) = prefix {
                     self.namespaces.prefixes.insert(prefix.clone(), url.clone());
                     Some(prefix)
                 } else {
                     self.namespaces.default = Some(url.clone());
                     None
                 };
 
                 self.state = State::Namespaces;
                 CssRule::Namespace(Arc::new(self.shared_lock.wrap(NamespaceRule {
-                    prefix: opt_prefix,
-                    url: url,
-                    source_location: location,
+                    prefix,
+                    url,
+                    source_location,
                 })))
             },
         }
     }
 }
 
 pub struct QualifiedRuleParserPrelude {
     selectors: SelectorList<SelectorImpl>,
@@ -501,98 +501,97 @@ impl<'a, 'b, 'i, R: ParseErrorReporter> 
                             &context,
                             self.error_context,
                             input,
                             location,
                         )?.into(),
                     ),
                 )))
             },
-            AtRuleBlockPrelude::Media(media_queries, location) => {
+            AtRuleBlockPrelude::Media(media_queries, source_location) => {
                 Ok(CssRule::Media(Arc::new(self.shared_lock.wrap(MediaRule {
-                    media_queries: media_queries,
+                    media_queries,
                     rules: self.parse_nested_rules(input, CssRuleType::Media),
-                    source_location: location,
+                    source_location,
                 }))))
             },
-            AtRuleBlockPrelude::Supports(cond, location) => {
+            AtRuleBlockPrelude::Supports(condition, source_location) => {
                 let eval_context = ParserContext::new_with_rule_type(
                     self.context,
                     CssRuleType::Style,
                     self.namespaces,
                 );
 
-                let enabled = cond.eval(&eval_context);
+                let enabled = condition.eval(&eval_context);
                 Ok(CssRule::Supports(Arc::new(self.shared_lock.wrap(
                     SupportsRule {
-                        condition: cond,
+                        condition,
                         rules: self.parse_nested_rules(input, CssRuleType::Supports),
-                        enabled: enabled,
-                        source_location: location,
+                        enabled,
+                        source_location,
                     },
                 ))))
             },
             AtRuleBlockPrelude::Viewport => {
                 let context = ParserContext::new_with_rule_type(
                     self.context,
                     CssRuleType::Viewport,
                     self.namespaces,
                 );
 
                 Ok(CssRule::Viewport(Arc::new(self.shared_lock.wrap(
                     ViewportRule::parse(&context, self.error_context, input)?,
                 ))))
             },
-            AtRuleBlockPrelude::Keyframes(name, prefix, location) => {
+            AtRuleBlockPrelude::Keyframes(name, vendor_prefix, source_location) => {
                 let context = ParserContext::new_with_rule_type(
                     self.context,
                     CssRuleType::Keyframes,
                     self.namespaces,
                 );
 
                 Ok(CssRule::Keyframes(Arc::new(self.shared_lock.wrap(
                     KeyframesRule {
-                        name: name,
+                        name,
                         keyframes: parse_keyframe_list(
                             &context,
                             self.error_context,
                             input,
                             self.shared_lock,
                         ),
-                        vendor_prefix: prefix,
-                        source_location: location,
+                        vendor_prefix,
+                        source_location,
                     },
                 ))))
             },
-            AtRuleBlockPrelude::Page(location) => {
+            AtRuleBlockPrelude::Page(source_location) => {
                 let context = ParserContext::new_with_rule_type(
                     self.context,
                     CssRuleType::Page,
                     self.namespaces,
                 );
 
                 let declarations =
                     parse_property_declaration_list(&context, self.error_context, input);
                 Ok(CssRule::Page(Arc::new(self.shared_lock.wrap(PageRule {
                     block: Arc::new(self.shared_lock.wrap(declarations)),
-                    source_location: location,
+                    source_location,
                 }))))
             },
-            AtRuleBlockPrelude::Document(cond, location) => {
-                if cfg!(feature = "gecko") {
-                    Ok(CssRule::Document(Arc::new(self.shared_lock.wrap(
-                        DocumentRule {
-                            condition: cond,
-                            rules: self.parse_nested_rules(input, CssRuleType::Document),
-                            source_location: location,
-                        },
-                    ))))
-                } else {
+            AtRuleBlockPrelude::Document(condition, source_location) => {
+                if !cfg!(feature = "gecko") {
                     unreachable!()
                 }
+                Ok(CssRule::Document(Arc::new(self.shared_lock.wrap(
+                    DocumentRule {
+                        condition,
+                        rules: self.parse_nested_rules(input, CssRuleType::Document),
+                        source_location,
+                    },
+                ))))
             },
         }
     }
 }
 
 impl<'a, 'b, 'i, R: ParseErrorReporter> QualifiedRuleParser<'i> for NestedRuleParser<'a, 'b, R> {
     type Prelude = QualifiedRuleParserPrelude;
     type QualifiedRule = CssRule;
@@ -603,23 +602,20 @@ impl<'a, 'b, 'i, R: ParseErrorReporter> 
         input: &mut Parser<'i, 't>,
     ) -> Result<QualifiedRuleParserPrelude, ParseError<'i>> {
         let selector_parser = SelectorParser {
             stylesheet_origin: self.stylesheet_origin,
             namespaces: self.namespaces,
             url_data: Some(self.context.url_data),
         };
 
-        let location = input.current_source_location();
+        let source_location = input.current_source_location();
         let selectors = SelectorList::parse(&selector_parser, input)?;
 
-        Ok(QualifiedRuleParserPrelude {
-            selectors: selectors,
-            source_location: location,
-        })
+        Ok(QualifiedRuleParserPrelude { selectors, source_location, })
     }
 
     fn parse_block<'t>(
         &mut self,
         prelude: QualifiedRuleParserPrelude,
         input: &mut Parser<'i, 't>,
     ) -> Result<CssRule, ParseError<'i>> {
         let context =