servo: Merge #17173 - Stop parsing @supports rules before Delimiter::Bang (from Manishearth:supports-fixes); r=upsuper
authorManish Goregaokar <manishsmail@gmail.com>
Mon, 05 Jun 2017 23:19:31 -0700
changeset 410599 4eec513103917702b10147724052bb7046e49045
parent 410598 ec1ca0d0f8ec1a25f5d167ad8a6ec24311bb1e12
child 410600 c8ad7f9c7cf8aeb383a875ba8a53bfb608325cd0
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersupsuper
bugs17173, 15482
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
servo/components/style/stylesheets/supports_rule.rs
servo/ports/geckolib/glue.rs
--- a/servo/components/style/stylesheets/supports_rule.rs
+++ b/servo/components/style/stylesheets/supports_rule.rs
@@ -1,15 +1,15 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 //! [@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};
 use std::fmt;
 use style_traits::ToCss;
 use stylearc::Arc;
 use stylesheets::{CssRuleType, CssRules};
 
@@ -258,13 +258,16 @@ impl Declaration {
         let id = if let Ok(id) = PropertyId::parse((&*self.prop).into()) {
             id
         } else {
             return false
         };
         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()
     }
 }
--- a/servo/ports/geckolib/glue.rs
+++ b/servo/ports/geckolib/glue.rs
@@ -2293,17 +2293,17 @@ pub extern "C" fn Servo_CSSSupports2(pro
         QuirksMode::NoQuirks
     ).is_ok()
 }
 
 #[no_mangle]
 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;
         let context = ParserContext::new_for_cssom(url_data, &reporter, Some(CssRuleType::Style),
                                                    PARSING_MODE_DEFAULT,
                                                    QuirksMode::NoQuirks);
         cond.eval(&context)
     } else {