From a68766197fd9df4524ef2c31a0bdd4e005a8b168 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Wed, 15 Mar 2023 12:41:26 +0000 Subject: [PATCH] style: Add (unused for now) parsing for support conditions in @import You can use this as: input.try_parse(SupportsCondition::parse_for_import).ok() Or so. Differential Revision: https://phabricator.services.mozilla.com/D172668 --- components/style/stylesheets/supports_rule.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/components/style/stylesheets/supports_rule.rs b/components/style/stylesheets/supports_rule.rs index 763e1f891a1..653a25ccc60 100644 --- a/components/style/stylesheets/supports_rule.rs +++ b/components/style/stylesheets/supports_rule.rs @@ -186,11 +186,18 @@ impl SupportsCondition { } } + /// Parses an `@import` condition as per + /// https://drafts.csswg.org/css-cascade-5/#typedef-import-conditions + pub fn parse_for_import<'i, 't>(input: &mut Parser<'i, 't>) -> Result> { + input.expect_function_matching("supports")?; + input.parse_nested_block(parse_condition_or_declaration) + } + /// fn parse_in_parens<'i, 't>(input: &mut Parser<'i, 't>) -> Result> { - // Whitespace is normally taken care of in `Parser::next`, - // but we want to not include it in `pos` for the SupportsCondition::FutureSyntax cases. - while input.try_parse(Parser::expect_whitespace).is_ok() {} + // Whitespace is normally taken care of in `Parser::next`, but we want to not include it in + // `pos` for the SupportsCondition::FutureSyntax cases. + input.skip_whitespace(); let pos = input.position(); let location = input.current_source_location(); match *input.next()? {