--- 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 =