mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
style: Only a single name allowed in @container rule
Differential Revision: https://phabricator.services.mozilla.com/D158775
This commit is contained in:
parent
2c1799a8df
commit
aba0a4bce0
2 changed files with 31 additions and 16 deletions
|
@ -157,12 +157,8 @@ impl ContainerCondition {
|
||||||
context: &ParserContext,
|
context: &ParserContext,
|
||||||
input: &mut Parser<'a, '_>,
|
input: &mut Parser<'a, '_>,
|
||||||
) -> Result<Self, ParseError<'a>> {
|
) -> Result<Self, ParseError<'a>> {
|
||||||
use crate::parser::Parse;
|
|
||||||
|
|
||||||
// FIXME: This is a bit ambiguous:
|
|
||||||
// https://github.com/w3c/csswg-drafts/issues/7203
|
|
||||||
let name = input
|
let name = input
|
||||||
.try_parse(|input| ContainerName::parse(context, input))
|
.try_parse(|input| ContainerName::parse_for_query(context, input))
|
||||||
.ok()
|
.ok()
|
||||||
.unwrap_or_else(ContainerName::none);
|
.unwrap_or_else(ContainerName::none);
|
||||||
let condition = QueryCondition::parse(context, input, FeatureType::Container)?;
|
let condition = QueryCondition::parse(context, input, FeatureType::Container)?;
|
||||||
|
|
|
@ -1539,17 +1539,15 @@ impl ContainerName {
|
||||||
pub fn is_none(&self) -> bool {
|
pub fn is_none(&self) -> bool {
|
||||||
self.0.is_empty()
|
self.0.is_empty()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
impl Parse for ContainerName {
|
fn parse_internal<'i>(
|
||||||
fn parse<'i, 't>(
|
input: &mut Parser<'i, '_>,
|
||||||
_: &ParserContext,
|
for_query: bool,
|
||||||
input: &mut Parser<'i, 't>,
|
|
||||||
) -> Result<Self, ParseError<'i>> {
|
) -> Result<Self, ParseError<'i>> {
|
||||||
let mut idents = vec![];
|
let mut idents = vec![];
|
||||||
let location = input.current_source_location();
|
let location = input.current_source_location();
|
||||||
let first = input.expect_ident()?;
|
let first = input.expect_ident()?;
|
||||||
if first.eq_ignore_ascii_case("none") {
|
if !for_query && first.eq_ignore_ascii_case("none") {
|
||||||
return Ok(Self::none());
|
return Ok(Self::none());
|
||||||
}
|
}
|
||||||
const DISALLOWED_CONTAINER_NAMES: &'static [&'static str] =
|
const DISALLOWED_CONTAINER_NAMES: &'static [&'static str] =
|
||||||
|
@ -1559,14 +1557,35 @@ impl Parse for ContainerName {
|
||||||
first,
|
first,
|
||||||
DISALLOWED_CONTAINER_NAMES,
|
DISALLOWED_CONTAINER_NAMES,
|
||||||
)?);
|
)?);
|
||||||
while let Ok(name) = input.try_parse(|input| {
|
if !for_query {
|
||||||
let ident = input.expect_ident()?;
|
while let Ok(name) = input.try_parse(|input| {
|
||||||
CustomIdent::from_ident(location, &ident, DISALLOWED_CONTAINER_NAMES)
|
let ident = input.expect_ident()?;
|
||||||
}) {
|
CustomIdent::from_ident(location, &ident, DISALLOWED_CONTAINER_NAMES)
|
||||||
idents.push(name);
|
}) {
|
||||||
|
idents.push(name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Ok(ContainerName(idents.into()))
|
Ok(ContainerName(idents.into()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// https://github.com/w3c/csswg-drafts/issues/7203
|
||||||
|
/// Only a single name allowed in @container rule.
|
||||||
|
/// Disallow none for container-name in @container rule.
|
||||||
|
pub fn parse_for_query<'i, 't>(
|
||||||
|
_: &ParserContext,
|
||||||
|
input: &mut Parser<'i, 't>,
|
||||||
|
) -> Result<Self, ParseError<'i>> {
|
||||||
|
Self::parse_internal(input, /* for_query = */ true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Parse for ContainerName {
|
||||||
|
fn parse<'i, 't>(
|
||||||
|
_: &ParserContext,
|
||||||
|
input: &mut Parser<'i, 't>,
|
||||||
|
) -> Result<Self, ParseError<'i>> {
|
||||||
|
Self::parse_internal(input, /* for_query = */ false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A specified value for the `perspective` property.
|
/// A specified value for the `perspective` property.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue