mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Pull rule_type into ParserContext
Absorb `rule_type` into the `ParserContext` so that it's easier to pass down to deeper levels of the parser. MozReview-Commit-ID: DjBNytLxGKX
This commit is contained in:
parent
a093b0a087
commit
4574cd8ea6
35 changed files with 125 additions and 97 deletions
|
@ -612,8 +612,8 @@ pub fn parse_style_attribute(input: &str,
|
|||
url_data: &UrlExtraData,
|
||||
error_reporter: &ParseErrorReporter)
|
||||
-> PropertyDeclarationBlock {
|
||||
let context = ParserContext::new(Origin::Author, url_data, error_reporter);
|
||||
parse_property_declaration_list(&context, &mut Parser::new(input), CssRuleType::Style)
|
||||
let context = ParserContext::new(Origin::Author, url_data, error_reporter, Some(CssRuleType::Style));
|
||||
parse_property_declaration_list(&context, &mut Parser::new(input))
|
||||
}
|
||||
|
||||
/// Parse a given property declaration. Can result in multiple
|
||||
|
@ -626,9 +626,9 @@ pub fn parse_one_declaration(id: PropertyId,
|
|||
url_data: &UrlExtraData,
|
||||
error_reporter: &ParseErrorReporter)
|
||||
-> Result<ParsedDeclaration, ()> {
|
||||
let context = ParserContext::new(Origin::Author, url_data, error_reporter);
|
||||
let context = ParserContext::new(Origin::Author, url_data, error_reporter, Some(CssRuleType::Style));
|
||||
Parser::new(input).parse_entirely(|parser| {
|
||||
ParsedDeclaration::parse(id, &context, parser, false, CssRuleType::Style)
|
||||
ParsedDeclaration::parse(id, &context, parser, false)
|
||||
.map_err(|_| ())
|
||||
})
|
||||
}
|
||||
|
@ -636,7 +636,6 @@ pub fn parse_one_declaration(id: PropertyId,
|
|||
/// A struct to parse property declarations.
|
||||
struct PropertyDeclarationParser<'a, 'b: 'a> {
|
||||
context: &'a ParserContext<'b>,
|
||||
rule_type: CssRuleType,
|
||||
}
|
||||
|
||||
|
||||
|
@ -654,7 +653,7 @@ impl<'a, 'b> DeclarationParser for PropertyDeclarationParser<'a, 'b> {
|
|||
-> Result<(ParsedDeclaration, Importance), ()> {
|
||||
let id = try!(PropertyId::parse(name.into()));
|
||||
let parsed = input.parse_until_before(Delimiter::Bang, |input| {
|
||||
ParsedDeclaration::parse(id, self.context, input, false, self.rule_type)
|
||||
ParsedDeclaration::parse(id, self.context, input, false)
|
||||
.map_err(|_| ())
|
||||
})?;
|
||||
let importance = match input.try(parse_important) {
|
||||
|
@ -673,13 +672,11 @@ impl<'a, 'b> DeclarationParser for PropertyDeclarationParser<'a, 'b> {
|
|||
/// Parse a list of property declarations and return a property declaration
|
||||
/// block.
|
||||
pub fn parse_property_declaration_list(context: &ParserContext,
|
||||
input: &mut Parser,
|
||||
rule_type: CssRuleType)
|
||||
input: &mut Parser)
|
||||
-> PropertyDeclarationBlock {
|
||||
let mut block = PropertyDeclarationBlock::new();
|
||||
let parser = PropertyDeclarationParser {
|
||||
context: context,
|
||||
rule_type: rule_type,
|
||||
};
|
||||
let mut iter = DeclarationListParser::new(input, parser);
|
||||
while let Some(declaration) = iter.next() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue