mirror of
https://github.com/servo/servo.git
synced 2025-08-07 22:45:34 +01:00
style: Don't remain in an invalid state when encountering an at-rule in the wrong place.
Currently, attempting to parse an at-rule that is out of place, such as an @import rule after a regular style rule, will cause the parser state to be set to Invalid. This will cause any following at-rule to be rejected until we encounter a regular style rule, at which point we'll go back to the Body state. There's nothing in the CSS specs about needing to reject all following at-rules (or, as the comment above Invalid says, ignoring the entire rest of the style sheet).
This commit is contained in:
parent
6b320eaad3
commit
9c0ce7847f
3 changed files with 31 additions and 20 deletions
|
@ -255,18 +255,19 @@ impl CssRule {
|
|||
shared_lock: &shared_lock,
|
||||
loader: loader,
|
||||
state: state,
|
||||
had_hierarchy_error: false,
|
||||
namespaces: Some(&mut *guard),
|
||||
};
|
||||
|
||||
match parse_one_rule(&mut input, &mut rule_parser) {
|
||||
Ok(result) => Ok((result, rule_parser.state)),
|
||||
Err(_) => {
|
||||
Err(match rule_parser.state {
|
||||
State::Invalid => SingleRuleParseError::Hierarchy,
|
||||
_ => SingleRuleParseError::Syntax,
|
||||
})
|
||||
}
|
||||
}
|
||||
parse_one_rule(&mut input, &mut rule_parser)
|
||||
.map(|result| (result, rule_parser.state))
|
||||
.map_err(|_| {
|
||||
if rule_parser.take_had_hierarchy_error() {
|
||||
SingleRuleParseError::Hierarchy
|
||||
} else {
|
||||
SingleRuleParseError::Syntax
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue