Bug 1951780: Allow parsing anchor-size function in math function in margin properties. r=firefox-style-system-reviewers,emilio

Differential Revision: https://phabricator.services.mozilla.com/D240381
This commit is contained in:
David Shin
2025-03-06 14:09:59 +00:00
parent d8f6843ae2
commit e28efec5ed
3 changed files with 32 additions and 6 deletions

View File

@@ -1747,6 +1747,23 @@ impl LengthPercentage {
)
}
/// Parses allowing the unitless length quirk, as well as allowing
/// anchor-positioning related function, `anchor-size()`.
#[inline]
fn parse_quirky_with_anchor_size_function<'i, 't>(
context: &ParserContext,
input: &mut Parser<'i, 't>,
allow_quirks: AllowQuirks,
) -> Result<Self, ParseError<'i>> {
Self::parse_internal(
context,
input,
AllowedNumericType::All,
allow_quirks,
AllowAnchorPositioningFunctions::AllowAnchorSize,
)
}
/// Parses allowing the unitless length quirk, as well as allowing
/// anchor-positioning related functions, `anchor()` and `anchor-size()`.
#[inline]
@@ -2140,8 +2157,9 @@ impl Margin {
input: &mut Parser<'i, 't>,
allow_quirks: AllowQuirks,
) -> Result<Self, ParseError<'i>> {
if let Ok(l) = input.try_parse(|i| LengthPercentage::parse_quirky(context, i, allow_quirks))
{
if let Ok(l) = input.try_parse(|i| {
LengthPercentage::parse_quirky_with_anchor_size_function(context, i, allow_quirks)
}) {
return Ok(Self::LengthPercentage(l));
}
if input.try_parse(|i| i.expect_ident_matching("auto")).is_ok() {