summaryrefslogtreecommitdiff
path: root/layout
diff options
context:
space:
mode:
authorFranklinDM <mrmineshafter17@gmail.com>2023-05-13 14:50:12 +0800
committerFranklinDM <mrmineshafter17@gmail.com>2023-05-13 19:22:42 +0800
commit19650c6f8a55e1cfed6acd9bcf415409569f0945 (patch)
tree6bedf6319b09ae6603717cc523a7a5ed5a74a051 /layout
parentaed983c97b6a5f8faf40576d742ab14729df099d (diff)
downloaduxp-19650c6f8a55e1cfed6acd9bcf415409569f0945.tar.gz
Issue #1765 - Part 1: Move ReduceNumberCalcOps struct up higher, rename IsCSSTokenCalcFunction to CSSParserImpl::IsCalcFunctionToken
Diffstat (limited to 'layout')
-rw-r--r--layout/style/nsCSSParser.cpp52
1 files changed, 27 insertions, 25 deletions
diff --git a/layout/style/nsCSSParser.cpp b/layout/style/nsCSSParser.cpp
index 1483eb0a11..244abf36ae 100644
--- a/layout/style/nsCSSParser.cpp
+++ b/layout/style/nsCSSParser.cpp
@@ -137,6 +137,22 @@ struct CSSParserInputState {
bool mHavePushBack;
};
+struct ReduceNumberCalcOps : public mozilla::css::BasicFloatCalcOps,
+ public mozilla::css::CSSValueInputCalcOps
+{
+ 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");
+ return aValue.GetFloatValue();
+ }
+
+ float ComputeNumber(const nsCSSValue& aValue)
+ {
+ return mozilla::css::ComputeCalc(aValue, *this);
+ }
+};
+
static_assert(css::eAuthorSheetFeatures == 0 &&
css::eUserSheetFeatures == 1 &&
css::eAgentSheetFeatures == 2,
@@ -895,6 +911,7 @@ protected:
};
bool IsFunctionTokenValidForImageLayerImage(const nsCSSToken& aToken) const;
+ bool IsCalcFunctionToken(const nsCSSToken& aToken) const;
bool ParseImageLayersItem(ImageLayersShorthandParseState& aState,
const nsCSSPropertyID aTable[]);
@@ -7867,14 +7884,6 @@ CSSParserImpl::ParseOneOrLargerVariant(nsCSSValue& aValue,
return result;
}
-static bool
-IsCSSTokenCalcFunction(const nsCSSToken& aToken)
-{
- return aToken.mType == eCSSToken_Function &&
- (aToken.mIdent.LowerCaseEqualsLiteral("calc") ||
- aToken.mIdent.LowerCaseEqualsLiteral("-moz-calc"));
-}
-
// Assigns to aValue iff it returns CSSParseResult::Ok.
CSSParseResult
CSSParserImpl::ParseVariant(nsCSSValue& aValue,
@@ -8174,7 +8183,7 @@ CSSParserImpl::ParseVariant(nsCSSValue& aValue,
}
}
if ((aVariantMask & VARIANT_CALC) &&
- IsCSSTokenCalcFunction(*tk)) {
+ IsCalcFunctionToken(*tk)) {
// calc() currently allows only lengths and percents and number inside it.
// And note that in current implementation, number cannot be mixed with
// length and percent.
@@ -12438,6 +12447,14 @@ CSSParserImpl::IsFunctionTokenValidForImageLayerImage(
funcName.LowerCaseEqualsLiteral("-webkit-repeating-radial-gradient")));
}
+bool
+CSSParserImpl::IsCalcFunctionToken(const nsCSSToken& aToken) const
+{
+ return aToken.mType == eCSSToken_Function &&
+ (aToken.mIdent.LowerCaseEqualsLiteral("calc") ||
+ aToken.mIdent.LowerCaseEqualsLiteral("-moz-calc"));
+}
+
// Parse one item of the background shorthand property.
bool
CSSParserImpl::ParseImageLayersItem(
@@ -13830,21 +13847,6 @@ CSSParserImpl::ParseCalcAdditiveExpression(nsCSSValue& aValue,
}
}
-struct ReduceNumberCalcOps : public mozilla::css::BasicFloatCalcOps,
- public mozilla::css::CSSValueInputCalcOps
-{
- result_type ComputeLeafValue(const nsCSSValue& aValue)
- {
- MOZ_ASSERT(aValue.GetUnit() == eCSSUnit_Number, "unexpected unit");
- return aValue.GetFloatValue();
- }
-
- float ComputeNumber(const nsCSSValue& aValue)
- {
- return mozilla::css::ComputeCalc(aValue, *this);
- }
-};
-
// * If aVariantMask is VARIANT_NUMBER, this function parses the
// <number-multiplicative-expression> production.
// * If aVariantMask does not contain VARIANT_NUMBER, this function
@@ -13965,7 +13967,7 @@ CSSParserImpl::ParseCalcTerm(nsCSSValue& aValue, uint32_t& aVariantMask)
// Either an additive expression in parentheses...
if (mToken.IsSymbol('(') ||
// Treat nested calc() as plain parenthesis.
- IsCSSTokenCalcFunction(mToken)) {
+ IsCalcFunctionToken(mToken)) {
if (!ParseCalcAdditiveExpression(aValue, aVariantMask) ||
!ExpectSymbol(')', true)) {
SkipUntil(')');