mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Auto merge of #15941 - emilio:media, r=heycam
style: Fix media query parsing when invalid queries are present. Fixes [bug 1347273](https://bugzil.la/1347273). <!-- 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/15941) <!-- Reviewable:end -->
This commit is contained in:
commit
304cafe57d
4 changed files with 34 additions and 17 deletions
|
@ -243,19 +243,13 @@ pub fn parse_media_query_list(input: &mut Parser) -> MediaList {
|
|||
}
|
||||
|
||||
let mut media_queries = vec![];
|
||||
let mut found_invalid = false;
|
||||
loop {
|
||||
match input.parse_until_before(Delimiter::Comma, MediaQuery::parse) {
|
||||
Ok(mq) => if !found_invalid {
|
||||
Ok(mq) => {
|
||||
media_queries.push(mq);
|
||||
},
|
||||
Err(..) => if !found_invalid {
|
||||
media_queries.clear();
|
||||
Err(..) => {
|
||||
media_queries.push(MediaQuery::never_matching());
|
||||
// Consume the rest of the input as if they were valid
|
||||
// expressions (they might be, they might not), but ignore the
|
||||
// result, this allows correctly parsing invalid media queries.
|
||||
found_invalid = true;
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -266,8 +260,6 @@ pub fn parse_media_query_list(input: &mut Parser) -> MediaList {
|
|||
}
|
||||
}
|
||||
|
||||
debug_assert!(!found_invalid || media_queries.len() == 1);
|
||||
|
||||
MediaList {
|
||||
media_queries: media_queries,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue