Backed out 2 changesets (bug 1664718) for causing wpt and bc failures.

CLOSED TREE

Backed out changeset 62e71d3b6b32 (bug 1664718)
Backed out changeset c8a8791a26ed (bug 1664718)
This commit is contained in:
Mihai Alexandru Michis 2020-09-14 20:32:50 +03:00 committed by Emilio Cobos Álvarez
parent 6728aad0c6
commit b1dbbb2969

View file

@ -251,11 +251,6 @@ pub trait Parser<'i> {
false false
} }
/// The error recovery that selector lists inside :is() and :where() have.
fn is_and_where_error_recovery(&self) -> ParseErrorRecovery {
ParseErrorRecovery::IgnoreInvalidSelector
}
/// Whether the given function name is an alias for the `:is()` function. /// Whether the given function name is an alias for the `:is()` function.
fn is_is_alias(&self, _name: &str) -> bool { fn is_is_alias(&self, _name: &str) -> bool {
false false
@ -334,17 +329,6 @@ pub struct SelectorList<Impl: SelectorImpl>(
#[shmem(field_bound)] pub SmallVec<[Selector<Impl>; 1]>, #[shmem(field_bound)] pub SmallVec<[Selector<Impl>; 1]>,
); );
/// How to treat invalid selectors in a selector list.
pub enum ParseErrorRecovery {
/// Discard the entire selector list, this is the default behavior for
/// almost all of CSS.
DiscardList,
/// Ignore invalid selectors, potentially creating an empty selector list.
///
/// This is the error recovery mode of :is() and :where()
IgnoreInvalidSelector,
}
impl<Impl: SelectorImpl> SelectorList<Impl> { impl<Impl: SelectorImpl> SelectorList<Impl> {
/// Parse a comma-separated list of Selectors. /// Parse a comma-separated list of Selectors.
/// <https://drafts.csswg.org/selectors/#grouping> /// <https://drafts.csswg.org/selectors/#grouping>
@ -357,42 +341,26 @@ impl<Impl: SelectorImpl> SelectorList<Impl> {
where where
P: Parser<'i, Impl = Impl>, P: Parser<'i, Impl = Impl>,
{ {
Self::parse_with_state(parser, input, SelectorParsingState::empty(), ParseErrorRecovery::DiscardList) Self::parse_with_state(parser, input, SelectorParsingState::empty())
} }
#[inline]
fn parse_with_state<'i, 't, P>( fn parse_with_state<'i, 't, P>(
parser: &P, parser: &P,
input: &mut CssParser<'i, 't>, input: &mut CssParser<'i, 't>,
state: SelectorParsingState, state: SelectorParsingState,
recovery: ParseErrorRecovery,
) -> Result<Self, ParseError<'i, P::Error>> ) -> Result<Self, ParseError<'i, P::Error>>
where where
P: Parser<'i, Impl = Impl>, P: Parser<'i, Impl = Impl>,
{ {
let mut values = SmallVec::new(); let mut values = SmallVec::new();
loop { loop {
let selector = input.parse_until_before(Delimiter::Comma, |input| { values.push(input.parse_until_before(Delimiter::Comma, |input| {
parse_selector(parser, input, state) parse_selector(parser, input, state)
}); })?);
let was_ok = selector.is_ok();
match selector {
Ok(selector) => values.push(selector),
Err(err) => match recovery {
ParseErrorRecovery::DiscardList => return Err(err),
ParseErrorRecovery::IgnoreInvalidSelector => {},
},
}
loop {
match input.next() { match input.next() {
Err(_) => return Ok(SelectorList(values)), Err(_) => return Ok(SelectorList(values)),
Ok(&Token::Comma) => break, Ok(&Token::Comma) => continue,
Ok(_) => { Ok(_) => unreachable!(),
debug_assert!(!was_ok, "Shouldn't have got a selector if getting here");
}
}
} }
} }
} }
@ -1283,18 +1251,18 @@ impl<Impl: SelectorImpl> Debug for LocalName<Impl> {
} }
} }
fn serialize_selector_list<'a, Impl, I, W>(iter: I, dest: &mut W) -> fmt::Result fn serialize_selector_list<'a, Impl, I, W>(mut iter: I, dest: &mut W) -> fmt::Result
where where
Impl: SelectorImpl, Impl: SelectorImpl,
I: Iterator<Item = &'a Selector<Impl>>, I: Iterator<Item = &'a Selector<Impl>>,
W: fmt::Write, W: fmt::Write,
{ {
let mut first = true; let first = iter
.next()
.expect("Empty SelectorList, should contain at least one selector");
first.to_css(dest)?;
for selector in iter { for selector in iter {
if !first {
dest.write_str(", ")?; dest.write_str(", ")?;
}
first = false;
selector.to_css(dest)?; selector.to_css(dest)?;
} }
Ok(()) Ok(())
@ -2298,7 +2266,6 @@ where
parser, parser,
input, input,
state | SelectorParsingState::DISALLOW_PSEUDOS, state | SelectorParsingState::DISALLOW_PSEUDOS,
parser.is_and_where_error_recovery(),
)?; )?;
Ok(component(inner.0.into_vec().into_boxed_slice())) Ok(component(inner.0.into_vec().into_boxed_slice()))
} }
@ -2691,10 +2658,6 @@ pub mod tests {
true true
} }
fn is_and_where_error_recovery(&self) -> ParseErrorRecovery {
ParseErrorRecovery::DiscardList
}
fn parse_part(&self) -> bool { fn parse_part(&self) -> bool {
true true
} }