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
}
/// 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.
fn is_is_alias(&self, _name: &str) -> bool {
false
@ -334,17 +329,6 @@ pub struct SelectorList<Impl: SelectorImpl>(
#[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> {
/// Parse a comma-separated list of Selectors.
/// <https://drafts.csswg.org/selectors/#grouping>
@ -357,42 +341,26 @@ impl<Impl: SelectorImpl> SelectorList<Impl> {
where
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>(
parser: &P,
input: &mut CssParser<'i, 't>,
state: SelectorParsingState,
recovery: ParseErrorRecovery,
) -> Result<Self, ParseError<'i, P::Error>>
where
P: Parser<'i, Impl = Impl>,
{
let mut values = SmallVec::new();
loop {
let selector = input.parse_until_before(Delimiter::Comma, |input| {
values.push(input.parse_until_before(Delimiter::Comma, |input| {
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() {
Err(_) => return Ok(SelectorList(values)),
Ok(&Token::Comma) => break,
Ok(_) => {
debug_assert!(!was_ok, "Shouldn't have got a selector if getting here");
}
}
})?);
match input.next() {
Err(_) => return Ok(SelectorList(values)),
Ok(&Token::Comma) => continue,
Ok(_) => unreachable!(),
}
}
}
@ -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
Impl: SelectorImpl,
I: Iterator<Item = &'a Selector<Impl>>,
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 {
if !first {
dest.write_str(", ")?;
}
first = false;
dest.write_str(", ")?;
selector.to_css(dest)?;
}
Ok(())
@ -2298,7 +2266,6 @@ where
parser,
input,
state | SelectorParsingState::DISALLOW_PSEUDOS,
parser.is_and_where_error_recovery(),
)?;
Ok(component(inner.0.into_vec().into_boxed_slice()))
}
@ -2691,10 +2658,6 @@ pub mod tests {
true
}
fn is_and_where_error_recovery(&self) -> ParseErrorRecovery {
ParseErrorRecovery::DiscardList
}
fn parse_part(&self) -> bool {
true
}