From f2e765296a73c28c3583c04c2695075078f914ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Mon, 14 Sep 2020 22:33:01 +0000 Subject: [PATCH] style: Allow :is() and :where() to have better error recovery. Adjust is-where-parsing.html to work with both the new and old behavior, and add a test for the new behavior. Depends on D90049 Differential Revision: https://phabricator.services.mozilla.com/D90050 --- components/style/gecko/selector_parser.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/components/style/gecko/selector_parser.rs b/components/style/gecko/selector_parser.rs index f5662d6871d..3c25a43fe2e 100644 --- a/components/style/gecko/selector_parser.rs +++ b/components/style/gecko/selector_parser.rs @@ -14,7 +14,7 @@ use crate::string_cache::{Atom, Namespace, WeakAtom, WeakNamespace}; use crate::values::serialize_atom_identifier; use cssparser::{BasicParseError, BasicParseErrorKind, Parser}; use cssparser::{CowRcStr, SourceLocation, ToCss, Token}; -use selectors::parser::SelectorParseErrorKind; +use selectors::parser::{SelectorParseErrorKind, ParseErrorRecovery}; use selectors::parser::{self as selector_parser, Selector}; use selectors::visitor::SelectorVisitor; use selectors::SelectorList; @@ -341,6 +341,15 @@ impl<'a, 'i> ::selectors::Parser<'i> for SelectorParser<'a> { true } + #[inline] + fn is_and_where_error_recovery(&self) -> ParseErrorRecovery { + if static_prefs::pref!("layout.css.is-and-where-better-error-recovery.enabled") { + ParseErrorRecovery::IgnoreInvalidSelector + } else { + ParseErrorRecovery::DiscardList + } + } + #[inline] fn parse_part(&self) -> bool { true