mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-05 23:38:38 +09:00
Issue #1765 - Follow-Up: For parsing calc() in non-hue component of hsl/a(), explicitly expect <percentage> values
This commit is contained in:
parent
41eb02d1e1
commit
2e3953399a
1 changed files with 13 additions and 3 deletions
|
|
@ -143,8 +143,7 @@ struct ReduceNumberCalcOps : public mozilla::css::BasicFloatCalcOps,
|
|||
{
|
||||
result_type ComputeLeafValue(const nsCSSValue& aValue)
|
||||
{
|
||||
// FIXME: Restore this assertion once ParseColor no longer uses this class.
|
||||
//MOZ_ASSERT(aValue.GetUnit() == eCSSUnit_Number, "unexpected unit");
|
||||
MOZ_ASSERT(aValue.GetUnit() == eCSSUnit_Number, "unexpected unit");
|
||||
return aValue.GetFloatValue();
|
||||
}
|
||||
|
||||
|
|
@ -154,6 +153,17 @@ struct ReduceNumberCalcOps : public mozilla::css::BasicFloatCalcOps,
|
|||
}
|
||||
};
|
||||
|
||||
// Same as above, but reduces leaves as <percentage>. You normally don't want to use this.
|
||||
// Only useful in parsing percentage saturation and lightness values by ParseColorComponent.
|
||||
struct ReducePercentageCalcOps : ReduceNumberCalcOps
|
||||
{
|
||||
result_type ComputeLeafValue(const nsCSSValue& aValue)
|
||||
{
|
||||
MOZ_ASSERT(aValue.GetUnit() == eCSSUnit_Percent, "unexpected unit");
|
||||
return aValue.GetPercentValue();
|
||||
}
|
||||
};
|
||||
|
||||
static_assert(css::eAuthorSheetFeatures == 0 &&
|
||||
css::eUserSheetFeatures == 1 &&
|
||||
css::eAgentSheetFeatures == 2,
|
||||
|
|
@ -7324,7 +7334,7 @@ CSSParserImpl::ParseColorComponent(float& aComponent, Maybe<char> aSeparator)
|
|||
if (!ParseCalc(aValue, VARIANT_LPN | VARIANT_CALC)) {
|
||||
return false;
|
||||
}
|
||||
ReduceNumberCalcOps ops;
|
||||
ReducePercentageCalcOps ops;
|
||||
value = mozilla::css::ComputeCalc(aValue, ops);
|
||||
} else {
|
||||
REPORT_UNEXPECTED_TOKEN(PEExpectedPercent);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue