зеркало из https://github.com/mozilla/gecko-dev.git
servo: Merge #17173 - Stop parsing @supports rules before Delimiter::Bang (from Manishearth:supports-fixes); r=upsuper
Fixes #15482 Shorthand parsing uses `parse_entirely`, so we have to ask it to stop before the `!important`. An alternate fix is to not use `parse_entirely` there and ensuring that all callers of `PropertyDeclaration::parse_into()` check that the input is exhausted. Two of the three callers do that anyway because they check for `!important`. We also weren't checking for the end of the parser for `CSS.supports()`. Source-Repo: https://github.com/servo/servo Source-Revision: eaa01223a7add99ce4cc241b686100856b7594d6 --HG-- extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear extra : subtree_revision : 271b84c5cb44b18f04d1c887ae98ec5154ab8817
This commit is contained in:
Родитель
3b2de9fd64
Коммит
2c28080629
|
@ -4,7 +4,7 @@
|
|||
|
||||
//! [@supports rules](https://drafts.csswg.org/css-conditional-3/#at-supports)
|
||||
|
||||
use cssparser::{parse_important, Parser, SourceLocation, Token};
|
||||
use cssparser::{Delimiter, parse_important, Parser, SourceLocation, Token};
|
||||
use parser::ParserContext;
|
||||
use properties::{PropertyId, PropertyDeclaration, SourcePropertyDeclaration};
|
||||
use shared_lock::{DeepCloneWithLock, Locked, SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard};
|
||||
|
@ -263,7 +263,10 @@ impl Declaration {
|
|||
let mut input = Parser::new(&self.val);
|
||||
let context = ParserContext::new_with_rule_type(cx, Some(CssRuleType::Style));
|
||||
let mut declarations = SourcePropertyDeclaration::new();
|
||||
let res = PropertyDeclaration::parse_into(&mut declarations, id, &context, &mut input);
|
||||
let res = input.parse_until_before(Delimiter::Bang, |input| {
|
||||
PropertyDeclaration::parse_into(&mut declarations, id, &context, input)
|
||||
.map_err(|_| ())
|
||||
});
|
||||
let _ = input.try(parse_important);
|
||||
res.is_ok() && input.is_exhausted()
|
||||
}
|
||||
|
|
|
@ -2298,7 +2298,7 @@ pub extern "C" fn Servo_CSSSupports2(property: *const nsACString,
|
|||
pub extern "C" fn Servo_CSSSupports(cond: *const nsACString) -> bool {
|
||||
let condition = unsafe { cond.as_ref().unwrap().as_str_unchecked() };
|
||||
let mut input = Parser::new(&condition);
|
||||
let cond = parse_condition_or_declaration(&mut input);
|
||||
let cond = input.parse_entirely(|i| parse_condition_or_declaration(i));
|
||||
if let Ok(cond) = cond {
|
||||
let url_data = unsafe { dummy_url_data() };
|
||||
let reporter = RustLogReporter;
|
||||
|
|
Загрузка…
Ссылка в новой задаче