From 19e946c77ee403c9ba9207181c69c3d4467e84dd Mon Sep 17 00:00:00 2001 From: EAZYBLACK Date: Thu, 24 Sep 2026 23:24:22 +0300 Subject: [PATCH] fix shit so i can cherry pick --- layout/style/nsRuleNode.cpp | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/layout/style/nsRuleNode.cpp b/layout/style/nsRuleNode.cpp index 21899afa73..4fcee57b60 100644 --- a/layout/style/nsRuleNode.cpp +++ b/layout/style/nsRuleNode.cpp @@ -13,6 +13,7 @@ #include "mozilla/ArrayUtils.h" #include "mozilla/Assertions.h" #include "mozilla/DebugOnly.h" +#include "mozilla/FloatingPoint.h" #include "mozilla/Function.h" #include "mozilla/dom/AnimationEffectReadOnlyBinding.h" // for PlaybackDirection #include "mozilla/Likely.h" @@ -2037,6 +2038,17 @@ SetValue(const nsCSSValue& aValue, FieldT& aField, #define SETFCT_UNSET_INHERIT 0x00400000 #define SETFCT_UNSET_INITIAL 0x00800000 +struct RuleNodeReduceNumberCalcOps : public css::BasicFloatCalcOps, + public css::CSSValueInputCalcOps, + public css::NumbersAlreadyNormalizedOps +{ + result_type ComputeLeafValue(const nsCSSValue& aValue) + { + MOZ_ASSERT(aValue.GetUnit() == eCSSUnit_Number, "unexpected unit"); + return aValue.GetFloatValue(); + } +}; + static void SetFactor(const nsCSSValue& aValue, float& aField, RuleNodeCacheConditions& aConditions, float aParentValue, float aInitialValue, uint32_t aFlags = 0) @@ -2047,6 +2059,9 @@ SetFactor(const nsCSSValue& aValue, float& aField, RuleNodeCacheConditions& aCon case eCSSUnit_Number: aField = aValue.GetFloatValue(); + if (mozilla::IsNaN(aField)) { + aField = 0.0f; + } if (aFlags & SETFCT_POSITIVE) { NS_ASSERTION(aField >= 0.0f, "negative value for positive-only property"); if (aField < 0.0f) { @@ -2063,25 +2078,6 @@ SetFactor(const nsCSSValue& aValue, float& aField, RuleNodeCacheConditions& aCon } return; - #include "CSSCalc.h" - - struct RuleNodeReduceNumberCalcOps - : public mozilla::css::BasicFloatCalcOps - , public mozilla::css::CSSValueInputCalcOps - { - float ComputeLeafValue(const nsCSSValue& aValue) - { - MOZ_ASSERT(aValue.GetUnit() == eCSSUnit_Number, - "Expected a number-only calc expression"); - return aValue.GetFloatValue(); - } - - float ComputeNumber(const nsCSSValue& aValue) - { - return mozilla::css::ComputeCalc(aValue, *this); - } - }; - case eCSSUnit_Calc: { RuleNodeReduceNumberCalcOps ops; aField = css::ComputeCalc(aValue, ops);