pub(crate) struct PropertyDeclarationParser<'a, I: 'a + HasImportance>
{
pub(crate) context: &'a ParserContext,
pub(crate) marker: PhantomData<&'a I>,
}
impl<'a, 'i, I: HasImportance> AtRuleParser<'i> for PropertyDeclarationParser<'a, I>
{
type PreludeNoBlock = ();
type PreludeBlock = ();
type AtRule = PropertyDeclaration<I>;
type Error = CustomParseError<'i>;
}
impl<'a, 'i, I: HasImportance> DeclarationParser<'i> for PropertyDeclarationParser<'a, I>
{
type Declaration = PropertyDeclaration<I>;
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 (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 = I::validateParsedImportance(Importance::parse(input))?;
input.expect_exhausted()?;
Ok
(
PropertyDeclaration
{
vendor_prefix,
name,
value,
importance,
}
)
}
}