mirror of
https://github.com/servo/servo.git
synced 2025-06-21 15:49:04 +01:00
Auto merge of #17324 - ferjm:bug1371393.column, r=SimonSapin
stylo: set location for NestedRuleParser during prelude parsing From https://bugzilla.mozilla.org/show_bug.cgi?id=1371393 <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/17324) <!-- Reviewable:end -->
This commit is contained in:
commit
b0392dbf39
2 changed files with 23 additions and 14 deletions
|
@ -257,15 +257,19 @@ impl<'a, 'i> AtRuleParser<'i> for TopLevelRuleParser<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub struct QualifiedRuleParserPrelude {
|
||||||
|
selectors: SelectorList<SelectorImpl>,
|
||||||
|
source_location: SourceLocation,
|
||||||
|
}
|
||||||
|
|
||||||
impl<'a, 'i> QualifiedRuleParser<'i> for TopLevelRuleParser<'a> {
|
impl<'a, 'i> QualifiedRuleParser<'i> for TopLevelRuleParser<'a> {
|
||||||
type Prelude = SelectorList<SelectorImpl>;
|
type Prelude = QualifiedRuleParserPrelude;
|
||||||
type QualifiedRule = CssRule;
|
type QualifiedRule = CssRule;
|
||||||
type Error = SelectorParseError<'i, StyleParseError<'i>>;
|
type Error = SelectorParseError<'i, StyleParseError<'i>>;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn parse_prelude<'t>(&mut self, input: &mut Parser<'i, 't>)
|
fn parse_prelude<'t>(&mut self, input: &mut Parser<'i, 't>)
|
||||||
-> Result<SelectorList<SelectorImpl>, ParseError<'i>> {
|
-> Result<QualifiedRuleParserPrelude, ParseError<'i>> {
|
||||||
self.state = State::Body;
|
self.state = State::Body;
|
||||||
|
|
||||||
// "Freeze" the namespace map (no more namespace rules can be parsed
|
// "Freeze" the namespace map (no more namespace rules can be parsed
|
||||||
|
@ -281,7 +285,7 @@ impl<'a, 'i> QualifiedRuleParser<'i> for TopLevelRuleParser<'a> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn parse_block<'t>(
|
fn parse_block<'t>(
|
||||||
&mut self,
|
&mut self,
|
||||||
prelude: SelectorList<SelectorImpl>,
|
prelude: QualifiedRuleParserPrelude,
|
||||||
input: &mut Parser<'i, 't>
|
input: &mut Parser<'i, 't>
|
||||||
) -> Result<CssRule, ParseError<'i>> {
|
) -> Result<CssRule, ParseError<'i>> {
|
||||||
QualifiedRuleParser::parse_block(&mut self.nested(), prelude, input)
|
QualifiedRuleParser::parse_block(&mut self.nested(), prelude, input)
|
||||||
|
@ -482,33 +486,38 @@ impl<'a, 'b, 'i> AtRuleParser<'i> for NestedRuleParser<'a, 'b> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'b, 'i> QualifiedRuleParser<'i> for NestedRuleParser<'a, 'b> {
|
impl<'a, 'b, 'i> QualifiedRuleParser<'i> for NestedRuleParser<'a, 'b> {
|
||||||
type Prelude = SelectorList<SelectorImpl>;
|
type Prelude = QualifiedRuleParserPrelude;
|
||||||
type QualifiedRule = CssRule;
|
type QualifiedRule = CssRule;
|
||||||
type Error = SelectorParseError<'i, StyleParseError<'i>>;
|
type Error = SelectorParseError<'i, StyleParseError<'i>>;
|
||||||
|
|
||||||
fn parse_prelude<'t>(&mut self, input: &mut Parser<'i, 't>)
|
fn parse_prelude<'t>(&mut self, input: &mut Parser<'i, 't>)
|
||||||
-> Result<SelectorList<SelectorImpl>, ParseError<'i>> {
|
-> Result<QualifiedRuleParserPrelude, ParseError<'i>> {
|
||||||
let selector_parser = SelectorParser {
|
let selector_parser = SelectorParser {
|
||||||
stylesheet_origin: self.stylesheet_origin,
|
stylesheet_origin: self.stylesheet_origin,
|
||||||
namespaces: self.context.namespaces.unwrap(),
|
namespaces: self.context.namespaces.unwrap(),
|
||||||
};
|
};
|
||||||
|
|
||||||
SelectorList::parse(&selector_parser, input)
|
let location = get_location_with_offset(input.current_source_location(),
|
||||||
|
self.context.line_number_offset);
|
||||||
|
let selectors = SelectorList::parse(&selector_parser, input)?;
|
||||||
|
|
||||||
|
Ok(QualifiedRuleParserPrelude {
|
||||||
|
selectors: selectors,
|
||||||
|
source_location: location,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_block<'t>(
|
fn parse_block<'t>(
|
||||||
&mut self,
|
&mut self,
|
||||||
prelude: SelectorList<SelectorImpl>,
|
prelude: QualifiedRuleParserPrelude,
|
||||||
input: &mut Parser<'i, 't>
|
input: &mut Parser<'i, 't>
|
||||||
) -> Result<CssRule, ParseError<'i>> {
|
) -> Result<CssRule, ParseError<'i>> {
|
||||||
let location = get_location_with_offset(input.current_source_location(),
|
|
||||||
self.context.line_number_offset);
|
|
||||||
let context = ParserContext::new_with_rule_type(self.context, Some(CssRuleType::Style));
|
let context = ParserContext::new_with_rule_type(self.context, Some(CssRuleType::Style));
|
||||||
let declarations = parse_property_declaration_list(&context, input);
|
let declarations = parse_property_declaration_list(&context, input);
|
||||||
Ok(CssRule::Style(Arc::new(self.shared_lock.wrap(StyleRule {
|
Ok(CssRule::Style(Arc::new(self.shared_lock.wrap(StyleRule {
|
||||||
selectors: prelude,
|
selectors: prelude.selectors,
|
||||||
block: Arc::new(self.shared_lock.wrap(declarations)),
|
block: Arc::new(self.shared_lock.wrap(declarations)),
|
||||||
source_location: location,
|
source_location: prelude.source_location,
|
||||||
}))))
|
}))))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,7 +116,7 @@ fn test_parse_stylesheet() {
|
||||||
]))),
|
]))),
|
||||||
source_location: SourceLocation {
|
source_location: SourceLocation {
|
||||||
line: 3,
|
line: 3,
|
||||||
column: 31,
|
column: 9,
|
||||||
},
|
},
|
||||||
}))),
|
}))),
|
||||||
CssRule::Style(Arc::new(stylesheet.shared_lock.wrap(StyleRule {
|
CssRule::Style(Arc::new(stylesheet.shared_lock.wrap(StyleRule {
|
||||||
|
@ -143,7 +143,7 @@ fn test_parse_stylesheet() {
|
||||||
]))),
|
]))),
|
||||||
source_location: SourceLocation {
|
source_location: SourceLocation {
|
||||||
line: 11,
|
line: 11,
|
||||||
column: 27,
|
column: 9,
|
||||||
},
|
},
|
||||||
}))),
|
}))),
|
||||||
CssRule::Style(Arc::new(stylesheet.shared_lock.wrap(StyleRule {
|
CssRule::Style(Arc::new(stylesheet.shared_lock.wrap(StyleRule {
|
||||||
|
@ -205,7 +205,7 @@ fn test_parse_stylesheet() {
|
||||||
]))),
|
]))),
|
||||||
source_location: SourceLocation {
|
source_location: SourceLocation {
|
||||||
line: 15,
|
line: 15,
|
||||||
column: 20,
|
column: 9,
|
||||||
},
|
},
|
||||||
}))),
|
}))),
|
||||||
CssRule::Keyframes(Arc::new(stylesheet.shared_lock.wrap(KeyframesRule {
|
CssRule::Keyframes(Arc::new(stylesheet.shared_lock.wrap(KeyframesRule {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue