From a149af11997a31d68491f1942147a7a2fb50db45 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Sat, 12 Jun 2021 11:36:16 +0000 Subject: [PATCH] Issue #1781 - Part 2: Fix animation interpolation for stroke-dashoffset. Since we have calc() and floats working now, this is a trivial fix. --- layout/style/StyleAnimationValue.cpp | 14 ++++++++++++-- layout/style/nsCSSPropList.h | 3 ++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/layout/style/StyleAnimationValue.cpp b/layout/style/StyleAnimationValue.cpp index ff67835536..2332de6a6a 100644 --- a/layout/style/StyleAnimationValue.cpp +++ b/layout/style/StyleAnimationValue.cpp @@ -63,11 +63,15 @@ GetCommonUnit(nsCSSPropertyID aProperty, StyleAnimationValue::Unit aSecondUnit) { if (aFirstUnit != aSecondUnit) { + bool numberAsPixel = + nsCSSProps::PropHasFlags(aProperty, CSS_PROPERTY_NUMBERS_ARE_PIXELS); if (nsCSSProps::PropHasFlags(aProperty, CSS_PROPERTY_STORES_CALC) && - (aFirstUnit == StyleAnimationValue::eUnit_Coord || + ((aFirstUnit == StyleAnimationValue::eUnit_Float && numberAsPixel) || + aFirstUnit == StyleAnimationValue::eUnit_Coord || aFirstUnit == StyleAnimationValue::eUnit_Percent || aFirstUnit == StyleAnimationValue::eUnit_Calc) && - (aSecondUnit == StyleAnimationValue::eUnit_Coord || + ((aSecondUnit == StyleAnimationValue::eUnit_Float && numberAsPixel) || + aSecondUnit == StyleAnimationValue::eUnit_Coord || aSecondUnit == StyleAnimationValue::eUnit_Percent || aSecondUnit == StyleAnimationValue::eUnit_Calc)) { // We can use calc() as the common unit. @@ -354,6 +358,12 @@ ExtractCalcValue(const StyleAnimationValue& aValue) result.mHasPercent = true; return result; } + if (aValue.GetUnit() == StyleAnimationValue::eUnit_Float) { + result.mLength = aValue.GetFloatValue(); + result.mPercent = 0.0f; + result.mHasPercent = false; + return result; + } MOZ_ASSERT(aValue.GetUnit() == StyleAnimationValue::eUnit_Calc, "unexpected unit"); nsCSSValue *val = aValue.GetCSSValueValue(); diff --git a/layout/style/nsCSSPropList.h b/layout/style/nsCSSPropList.h index f0cab6b131..45e919d4f8 100644 --- a/layout/style/nsCSSPropList.h +++ b/layout/style/nsCSSPropList.h @@ -3814,7 +3814,8 @@ CSS_PROP_SVG( stroke_dashoffset, StrokeDashoffset, CSS_PROPERTY_PARSE_VALUE | - CSS_PROPERTY_NUMBERS_ARE_PIXELS, + CSS_PROPERTY_NUMBERS_ARE_PIXELS | + CSS_PROPERTY_STORES_CALC, "", VARIANT_HLPN | VARIANT_OPENTYPE_SVG_KEYWORD | VARIANT_CALC, kStrokeContextValueKTable,