pub(crate) struct PropertyDeclarationParser<'a>
{
pub(crate) context: &'a ParserContext,
pub(crate) parsingAKeyFramePropertyDeclarationListSoImportantIsDisallowed: bool,
}
impl<'a, 'i> AtRuleParser<'i> for PropertyDeclarationParser<'a>
{
type PreludeNoBlock = ();
type PreludeBlock = ();
type AtRule = PropertyDeclaration;
type Error = CustomParseError<'i>;
}
impl<'a, 'i> DeclarationParser<'i> for PropertyDeclarationParser<'a>
{
type Declaration = PropertyDeclaration;
type Error = CustomParseError<'i>;
fn parse_value<'t>(&mut self, name: CowRcStr<'i>, input: &mut Parser<'i, 't>) -> Result<Self::Declaration, ParseError<'i, Self::Error>>
{
let sourceLocation = input.current_source_location();
let (vendor_prefix, unprefixedPropertyName) = VendorPrefix::findPrefixIfAnyForAsciiLowerCaseName(name.to_ascii_lowercase());
let name = Atom::from(unprefixedPropertyName);
let value = input.parse_until_before(Delimiter::Bang, |input|
{
if let Ok(cssWideKeyword) = input.try(|input| CssWideKeyword::parse(input))
{
Ok(UnparsedPropertyValue::CssWideKeyword(cssWideKeyword))
}
else
{
Ok(UnparsedPropertyValue::SpecifiedValue(SpecifiedValue::parse(self.context, input)?))
}
})?;
let importance = Importance::parse(input);
if self.parsingAKeyFramePropertyDeclarationListSoImportantIsDisallowed && importance.isImportant()
{
return Err(ParseError::Custom(CustomParseError::ImportantIsNotAllowedInKeyframePropertyDeclarationValues(sourceLocation)));
}
input.expect_exhausted()?;
Ok
(
PropertyDeclaration
{
vendor_prefix,
name,
value,
importance,
}
)
}
}