diff --git a/dom/animation/AnimValuesStyleRule.cpp b/dom/animation/AnimValuesStyleRule.cpp index 4070950c5470..08b91453a4bb 100644 --- a/dom/animation/AnimValuesStyleRule.cpp +++ b/dom/animation/AnimValuesStyleRule.cpp @@ -56,6 +56,14 @@ AnimValuesStyleRule::MightMapInheritedStyleData() return mStyleBits & NS_STYLE_INHERITED_STRUCT_MASK; } +bool +AnimValuesStyleRule::GetDiscretelyAnimatedCSSValue(nsCSSProperty aProperty, + nsCSSValue* aValue) +{ + MOZ_ASSERT(false, "GetDiscretelyAnimatedCSSValue is not implemented yet"); + return false; +} + #ifdef DEBUG void AnimValuesStyleRule::List(FILE* out, int32_t aIndent) const diff --git a/dom/animation/AnimValuesStyleRule.h b/dom/animation/AnimValuesStyleRule.h index 97f7d4f5309a..8a4ee1f6dcdc 100644 --- a/dom/animation/AnimValuesStyleRule.h +++ b/dom/animation/AnimValuesStyleRule.h @@ -32,6 +32,8 @@ public: // nsIStyleRule implementation void MapRuleInfoInto(nsRuleData* aRuleData) override; bool MightMapInheritedStyleData() override; + bool GetDiscretelyAnimatedCSSValue(nsCSSProperty aProperty, + nsCSSValue* aValue) override; #ifdef DEBUG void List(FILE* out = stdout, int32_t aIndent = 0) const override; #endif diff --git a/dom/base/nsMappedAttributes.cpp b/dom/base/nsMappedAttributes.cpp index fb1943b248e3..52e8f4e91721 100644 --- a/dom/base/nsMappedAttributes.cpp +++ b/dom/base/nsMappedAttributes.cpp @@ -192,6 +192,14 @@ nsMappedAttributes::MightMapInheritedStyleData() return true; } +/* virtual */ bool +nsMappedAttributes::GetDiscretelyAnimatedCSSValue(nsCSSProperty aProperty, + nsCSSValue* aValue) +{ + MOZ_ASSERT(false, "GetDiscretelyAnimatedCSSValue is not implemented yet"); + return false; +} + #ifdef DEBUG /* virtual */ void nsMappedAttributes::List(FILE* out, int32_t aIndent) const diff --git a/dom/base/nsMappedAttributes.h b/dom/base/nsMappedAttributes.h index 45808281754e..30105c4d5ed0 100644 --- a/dom/base/nsMappedAttributes.h +++ b/dom/base/nsMappedAttributes.h @@ -75,6 +75,8 @@ public: // nsIStyleRule virtual void MapRuleInfoInto(nsRuleData* aRuleData) override; virtual bool MightMapInheritedStyleData() override; + virtual bool GetDiscretelyAnimatedCSSValue(nsCSSProperty aProperty, + nsCSSValue* aValue) override; #ifdef DEBUG virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override; #endif diff --git a/dom/html/HTMLBodyElement.cpp b/dom/html/HTMLBodyElement.cpp index 0a924074d24e..0c115f47b6be 100644 --- a/dom/html/HTMLBodyElement.cpp +++ b/dom/html/HTMLBodyElement.cpp @@ -174,6 +174,14 @@ BodyRule::MightMapInheritedStyleData() return false; } +/* virtual */ bool +BodyRule::GetDiscretelyAnimatedCSSValue(nsCSSProperty aProperty, + nsCSSValue* aValue) +{ + MOZ_ASSERT(false, "GetDiscretelyAnimatedCSSValue is not implemented yet"); + return false; +} + #ifdef DEBUG /* virtual */ void BodyRule::List(FILE* out, int32_t aIndent) const diff --git a/dom/html/HTMLBodyElement.h b/dom/html/HTMLBodyElement.h index 5696ecfd142f..20e2acba7bae 100644 --- a/dom/html/HTMLBodyElement.h +++ b/dom/html/HTMLBodyElement.h @@ -29,6 +29,8 @@ public: // nsIStyleRule interface virtual void MapRuleInfoInto(nsRuleData* aRuleData) override; virtual bool MightMapInheritedStyleData() override; + virtual bool GetDiscretelyAnimatedCSSValue(nsCSSProperty aProperty, + nsCSSValue* aValue) override; #ifdef DEBUG virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override; #endif diff --git a/layout/style/Declaration.cpp b/layout/style/Declaration.cpp index c6eea9d2ae15..f77921c14329 100644 --- a/layout/style/Declaration.cpp +++ b/layout/style/Declaration.cpp @@ -35,6 +35,14 @@ ImportantStyleData::MightMapInheritedStyleData() return Declaration()->MapsImportantInheritedStyleData(); } +/* virtual */ bool +ImportantStyleData::GetDiscretelyAnimatedCSSValue(nsCSSProperty aProperty, + nsCSSValue* aValue) +{ + return Declaration()->GetDiscretelyAnimatedCSSValue(aProperty, aValue); +} + + #ifdef DEBUG /* virtual */ void ImportantStyleData::List(FILE* out, int32_t aIndent) const @@ -111,6 +119,21 @@ Declaration::MightMapInheritedStyleData() return mData->HasInheritedStyleData(); } +/* virtual */ bool +Declaration::GetDiscretelyAnimatedCSSValue(nsCSSProperty aProperty, + nsCSSValue* aValue) +{ + nsCSSCompressedDataBlock* data = GetValueIsImportant(aProperty) + ? mImportantData : mData; + const nsCSSValue* value = data->ValueFor(aProperty); + if (!value) { + return false; + } + *aValue = *value; + return true; +} + + bool Declaration::MapsImportantInheritedStyleData() const { diff --git a/layout/style/Declaration.h b/layout/style/Declaration.h index 46561e406619..f1d444c45a81 100644 --- a/layout/style/Declaration.h +++ b/layout/style/Declaration.h @@ -60,6 +60,8 @@ public: // nsIStyleRule interface virtual void MapRuleInfoInto(nsRuleData* aRuleData) override; virtual bool MightMapInheritedStyleData() override; + virtual bool GetDiscretelyAnimatedCSSValue(nsCSSProperty aProperty, + nsCSSValue* aValue) override; #ifdef DEBUG virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override; #endif @@ -103,6 +105,8 @@ public: // nsIStyleRule implementation virtual void MapRuleInfoInto(nsRuleData *aRuleData) override; virtual bool MightMapInheritedStyleData() override; + virtual bool GetDiscretelyAnimatedCSSValue(nsCSSProperty aProperty, + nsCSSValue* aValue) override; #ifdef DEBUG virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override; #endif diff --git a/layout/style/StyleAnimationValue.cpp b/layout/style/StyleAnimationValue.cpp index 430549cd0648..be062cc49a5d 100644 --- a/layout/style/StyleAnimationValue.cpp +++ b/layout/style/StyleAnimationValue.cpp @@ -499,6 +499,7 @@ StyleAnimationValue::ComputeDistance(nsCSSProperty aProperty, case eUnit_UnparsedString: case eUnit_URL: case eUnit_CurrentColor: + case eUnit_DiscreteCSSValue: return false; case eUnit_Enumerated: @@ -2269,6 +2270,7 @@ StyleAnimationValue::AddWeighted(nsCSSProperty aProperty, case eUnit_UnparsedString: case eUnit_URL: case eUnit_CurrentColor: + case eUnit_DiscreteCSSValue: return false; case eUnit_Enumerated: @@ -3061,14 +3063,16 @@ StyleAnimationValue::UncomputeValue(nsCSSProperty aProperty, break; case eUnit_Calc: case eUnit_ObjectPosition: - case eUnit_URL: { + case eUnit_URL: + case eUnit_DiscreteCSSValue: { nsCSSValue* val = aComputedValue.GetCSSValueValue(); // Sanity-check that the underlying unit in the nsCSSValue is what we // expect for our StyleAnimationValue::Unit: MOZ_ASSERT((unit == eUnit_Calc && val->GetUnit() == eCSSUnit_Calc) || (unit == eUnit_ObjectPosition && val->GetUnit() == eCSSUnit_Array) || - (unit == eUnit_URL && val->GetUnit() == eCSSUnit_URL), + (unit == eUnit_URL && val->GetUnit() == eCSSUnit_URL) || + unit == eUnit_DiscreteCSSValue, "unexpected unit"); aSpecifiedValue = *val; break; @@ -3597,8 +3601,11 @@ StyleAnimationValue::ExtractComputedValue(nsCSSProperty aProperty, aStyleContext->StyleData(nsCSSProps::kSIDTable[aProperty]); ptrdiff_t ssOffset = nsCSSProps::kStyleStructOffsetTable[aProperty]; nsStyleAnimType animType = nsCSSProps::kAnimTypeTable[aProperty]; - MOZ_ASSERT(0 <= ssOffset || animType == eStyleAnimType_Custom, - "must be dealing with animatable property"); + MOZ_ASSERT(0 <= ssOffset || + animType == eStyleAnimType_Custom || + animType == eStyleAnimType_Discrete, + "all animation types other than Custom and Discrete must " \ + "specify a style struct offset to extract values from"); switch (animType) { case eStyleAnimType_Custom: switch (aProperty) { @@ -4213,6 +4220,14 @@ StyleAnimationValue::ExtractComputedValue(nsCSSProperty aProperty, eUnit_Shadow); return true; } + case eStyleAnimType_Discrete: { + auto cssValue = MakeUnique(eCSSUnit_Unset); + aStyleContext->RuleNode()->GetDiscretelyAnimatedCSSValue(aProperty, + cssValue.get()); + aComputedValue.SetAndAdoptCSSValueValue(cssValue.release(), + eUnit_DiscreteCSSValue); + return true; + } case eStyleAnimType_None: NS_NOTREACHED("shouldn't use on non-animatable properties"); } @@ -4318,6 +4333,7 @@ StyleAnimationValue::operator=(const StyleAnimationValue& aOther) case eUnit_Calc: case eUnit_ObjectPosition: case eUnit_URL: + case eUnit_DiscreteCSSValue: MOZ_ASSERT(IsCSSValueUnit(mUnit), "This clause is for handling nsCSSValue-backed units"); MOZ_ASSERT(aOther.mValue.mCSSValue, "values may not be null"); @@ -4595,6 +4611,7 @@ StyleAnimationValue::operator==(const StyleAnimationValue& aOther) const case eUnit_Calc: case eUnit_ObjectPosition: case eUnit_URL: + case eUnit_DiscreteCSSValue: MOZ_ASSERT(IsCSSValueUnit(mUnit), "This clause is for handling nsCSSValue-backed units"); return *mValue.mCSSValue == *aOther.mValue.mCSSValue; diff --git a/layout/style/StyleAnimationValue.h b/layout/style/StyleAnimationValue.h index 14509db454b4..bc29cb5db7cb 100644 --- a/layout/style/StyleAnimationValue.h +++ b/layout/style/StyleAnimationValue.h @@ -277,6 +277,7 @@ public: eUnit_ObjectPosition, // nsCSSValue* (never null), always with a // 4-entry nsCSSValue::Array eUnit_URL, // nsCSSValue* (never null), always with a css::URLValue + eUnit_DiscreteCSSValue, // nsCSSValue* (never null) eUnit_CSSValuePair, // nsCSSValuePair* (never null) eUnit_CSSValueTriplet, // nsCSSValueTriplet* (never null) eUnit_CSSRect, // nsCSSRect* (never null) @@ -477,7 +478,8 @@ private: static bool IsCSSValueUnit(Unit aUnit) { return aUnit == eUnit_Calc || aUnit == eUnit_ObjectPosition || - aUnit == eUnit_URL; + aUnit == eUnit_URL || + aUnit == eUnit_DiscreteCSSValue; } static bool IsCSSValuePairUnit(Unit aUnit) { return aUnit == eUnit_CSSValuePair; diff --git a/layout/style/nsCSSPropList.h b/layout/style/nsCSSPropList.h index 5f80a6123c0b..26edead97568 100644 --- a/layout/style/nsCSSPropList.h +++ b/layout/style/nsCSSPropList.h @@ -334,7 +334,7 @@ CSS_PROP_POSITION( VARIANT_HK, kAutoCompletionAlignJustifyContent, CSS_PROP_NO_OFFSET, - eStyleAnimType_None) + eStyleAnimType_Discrete) CSS_PROP_POSITION( align-items, align_items, @@ -344,7 +344,7 @@ CSS_PROP_POSITION( VARIANT_HK, kAutoCompletionAlignItems, CSS_PROP_NO_OFFSET, - eStyleAnimType_None) + eStyleAnimType_Discrete) CSS_PROP_POSITION( align-self, align_self, @@ -354,7 +354,7 @@ CSS_PROP_POSITION( VARIANT_HK, kAutoCompletionAlignJustifySelf, CSS_PROP_NO_OFFSET, - eStyleAnimType_None) + eStyleAnimType_Discrete) CSS_PROP_SHORTHAND( all, all, @@ -2358,7 +2358,7 @@ CSS_PROP_POSITION( VARIANT_HK, kAutoCompletionAlignJustifyContent, CSS_PROP_NO_OFFSET, - eStyleAnimType_None) + eStyleAnimType_Discrete) CSS_PROP_POSITION( justify-items, justify_items, @@ -2369,7 +2369,7 @@ CSS_PROP_POSITION( // for auto-completion we use same values as justify-self: kAutoCompletionAlignJustifySelf, CSS_PROP_NO_OFFSET, - eStyleAnimType_None) + eStyleAnimType_Discrete) CSS_PROP_POSITION( justify-self, justify_self, @@ -2379,7 +2379,7 @@ CSS_PROP_POSITION( VARIANT_HK, kAutoCompletionAlignJustifySelf, CSS_PROP_NO_OFFSET, - eStyleAnimType_None) + eStyleAnimType_Discrete) #ifndef CSS_PROP_LIST_ONLY_COMPONENTS_OF_ALL_SHORTHAND #ifndef CSS_PROP_LIST_EXCLUDE_INTERNAL CSS_PROP_FONT( diff --git a/layout/style/nsCSSProps.h b/layout/style/nsCSSProps.h index e5050f97af75..d8201d356746 100644 --- a/layout/style/nsCSSProps.h +++ b/layout/style/nsCSSProps.h @@ -326,6 +326,9 @@ enum nsStyleAnimType { // RefPtr values eStyleAnimType_Shadow, + // discrete values + eStyleAnimType_Discrete, + // property not animatable eStyleAnimType_None }; diff --git a/layout/style/nsHTMLStyleSheet.cpp b/layout/style/nsHTMLStyleSheet.cpp index 25f7d3224673..288d93384490 100644 --- a/layout/style/nsHTMLStyleSheet.cpp +++ b/layout/style/nsHTMLStyleSheet.cpp @@ -58,6 +58,14 @@ nsHTMLStyleSheet::HTMLColorRule::MightMapInheritedStyleData() return true; } +/* virtual */ bool +nsHTMLStyleSheet::HTMLColorRule:: +GetDiscretelyAnimatedCSSValue(nsCSSProperty aProperty, nsCSSValue* aValue) +{ + MOZ_ASSERT(false, "GetDiscretelyAnimatedCSSValue is not implemented yet"); + return false; +} + #ifdef DEBUG /* virtual */ void nsHTMLStyleSheet::HTMLColorRule::List(FILE* out, int32_t aIndent) const @@ -103,6 +111,14 @@ nsHTMLStyleSheet::TableTHRule::MightMapInheritedStyleData() return true; } +/* virtual */ bool +nsHTMLStyleSheet::TableTHRule:: +GetDiscretelyAnimatedCSSValue(nsCSSProperty aProperty, nsCSSValue* aValue) +{ + MOZ_ASSERT(false, "GetDiscretelyAnimatedCSSValue is not implemented yet"); + return false; +} + /* virtual */ void nsHTMLStyleSheet::TableQuirkColorRule::MapRuleInfoInto(nsRuleData* aRuleData) { @@ -122,6 +138,13 @@ nsHTMLStyleSheet::TableQuirkColorRule::MightMapInheritedStyleData() return true; } +/* virtual */ bool +nsHTMLStyleSheet::TableQuirkColorRule:: +GetDiscretelyAnimatedCSSValue(nsCSSProperty aProperty, nsCSSValue* aValue) +{ + MOZ_ASSERT(false, "GetDiscretelyAnimatedCSSValue is not implemented yet"); + return false; +} NS_IMPL_ISUPPORTS(nsHTMLStyleSheet::LangRule, nsIStyleRule) @@ -142,6 +165,14 @@ nsHTMLStyleSheet::LangRule::MightMapInheritedStyleData() return true; } +/* virtual */ bool +nsHTMLStyleSheet::LangRule:: +GetDiscretelyAnimatedCSSValue(nsCSSProperty aProperty, nsCSSValue* aValue) +{ + MOZ_ASSERT(false, "GetDiscretelyAnimatedCSSValue is not implemented yet"); + return false; +} + #ifdef DEBUG /* virtual */ void nsHTMLStyleSheet::LangRule::List(FILE* out, int32_t aIndent) const diff --git a/layout/style/nsHTMLStyleSheet.h b/layout/style/nsHTMLStyleSheet.h index 62fddf160f4e..ed53483fe725 100644 --- a/layout/style/nsHTMLStyleSheet.h +++ b/layout/style/nsHTMLStyleSheet.h @@ -84,6 +84,8 @@ private: // nsIStyleRule interface virtual void MapRuleInfoInto(nsRuleData* aRuleData) override; virtual bool MightMapInheritedStyleData() override; + virtual bool GetDiscretelyAnimatedCSSValue(nsCSSProperty aProperty, + nsCSSValue* aValue) override; #ifdef DEBUG virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override; #endif @@ -107,6 +109,8 @@ private: // nsIStyleRule interface virtual void MapRuleInfoInto(nsRuleData* aRuleData) override = 0; virtual bool MightMapInheritedStyleData() override = 0; + virtual bool GetDiscretelyAnimatedCSSValue(nsCSSProperty aProperty, + nsCSSValue* aValue) override = 0; #ifdef DEBUG virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override; #endif @@ -121,6 +125,8 @@ private: virtual void MapRuleInfoInto(nsRuleData* aRuleData) override; virtual bool MightMapInheritedStyleData() override; + virtual bool GetDiscretelyAnimatedCSSValue(nsCSSProperty aProperty, + nsCSSValue* aValue) override; }; // Rule to handle quirk table colors @@ -130,6 +136,8 @@ private: virtual void MapRuleInfoInto(nsRuleData* aRuleData) override; virtual bool MightMapInheritedStyleData() override; + virtual bool GetDiscretelyAnimatedCSSValue(nsCSSProperty aProperty, + nsCSSValue* aValue) override; }; public: // for mLangRuleTable structures only @@ -149,6 +157,8 @@ public: // for mLangRuleTable structures only // nsIStyleRule interface virtual void MapRuleInfoInto(nsRuleData* aRuleData) override; virtual bool MightMapInheritedStyleData() override; + virtual bool GetDiscretelyAnimatedCSSValue(nsCSSProperty aProperty, + nsCSSValue* aValue) override; #ifdef DEBUG virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override; #endif diff --git a/layout/style/nsIStyleRule.h b/layout/style/nsIStyleRule.h index 9301728b4135..36c3d3ee19e1 100644 --- a/layout/style/nsIStyleRule.h +++ b/layout/style/nsIStyleRule.h @@ -13,8 +13,10 @@ #include +#include "nsCSSProperty.h" #include "nsISupports.h" +class nsCSSValue; struct nsRuleData; // IID for the nsIStyleRule interface {f75f3f70-435d-43a6-a01b-65970489ca26} @@ -77,6 +79,13 @@ public: */ virtual bool MightMapInheritedStyleData() = 0; + /** + * Gets and sets given aProperty's value to aValue. + * Returns true, if aValue is filled in this rule. + */ + virtual bool GetDiscretelyAnimatedCSSValue(nsCSSProperty aProperty, + nsCSSValue* aValue) = 0; + #ifdef DEBUG virtual void List(FILE* out = stdout, int32_t aIndent = 0) const = 0; #endif diff --git a/layout/style/nsRuleNode.cpp b/layout/style/nsRuleNode.cpp index 5f1ed453c9f8..b3be9dcd8187 100644 --- a/layout/style/nsRuleNode.cpp +++ b/layout/style/nsRuleNode.cpp @@ -10364,6 +10364,21 @@ nsRuleNode::GetStyleData(nsStyleStructID aSID, return data; } +void +nsRuleNode::GetDiscretelyAnimatedCSSValue(nsCSSProperty aProperty, + nsCSSValue* aValue) +{ + for (nsRuleNode* node = this; node; node = node->GetParent()) { + nsIStyleRule* rule = node->GetRule(); + if (!rule) { + continue; + } + if (rule->GetDiscretelyAnimatedCSSValue(aProperty, aValue)) { + return; + } + } +} + /* static */ bool nsRuleNode::HasAuthorSpecifiedRules(nsStyleContext* aStyleContext, uint32_t ruleTypeMask, diff --git a/layout/style/nsRuleNode.h b/layout/style/nsRuleNode.h index 8c14cb08d3b9..6aea143af28b 100644 --- a/layout/style/nsRuleNode.h +++ b/layout/style/nsRuleNode.h @@ -861,6 +861,8 @@ public: nsStyleContext* aContext, bool aComputeData); + void GetDiscretelyAnimatedCSSValue(nsCSSProperty aProperty, + nsCSSValue* aValue); // See comments in GetStyleData for an explanation of what the // code below does. diff --git a/layout/style/nsStyleSet.cpp b/layout/style/nsStyleSet.cpp index 3faa23ff898a..1d72d657e2c1 100644 --- a/layout/style/nsStyleSet.cpp +++ b/layout/style/nsStyleSet.cpp @@ -62,6 +62,14 @@ nsEmptyStyleRule::MightMapInheritedStyleData() return false; } +/* virtual */ bool +nsEmptyStyleRule::GetDiscretelyAnimatedCSSValue(nsCSSProperty aProperty, + nsCSSValue* aValue) +{ + MOZ_ASSERT(false, "GetDiscretelyAnimatedCSSValue is not implemented yet"); + return false; +} + #ifdef DEBUG /* virtual */ void nsEmptyStyleRule::List(FILE* out, int32_t aIndent) const @@ -121,6 +129,14 @@ nsInitialStyleRule::MightMapInheritedStyleData() return true; } +/* virtual */ bool +nsInitialStyleRule::GetDiscretelyAnimatedCSSValue(nsCSSProperty aProperty, + nsCSSValue* aValue) +{ + MOZ_ASSERT(false, "GetDiscretelyAnimatedCSSValue is not implemented yet"); + return false; +} + #ifdef DEBUG /* virtual */ void nsInitialStyleRule::List(FILE* out, int32_t aIndent) const @@ -152,6 +168,14 @@ nsDisableTextZoomStyleRule::MightMapInheritedStyleData() return true; } +/* virtual */ bool +nsDisableTextZoomStyleRule:: +GetDiscretelyAnimatedCSSValue(nsCSSProperty aProperty, nsCSSValue* aValue) +{ + MOZ_ASSERT(false, "GetDiscretelyAnimatedCSSValue is not implemented yet"); + return false; +} + #ifdef DEBUG /* virtual */ void nsDisableTextZoomStyleRule::List(FILE* out, int32_t aIndent) const diff --git a/layout/style/nsStyleSet.h b/layout/style/nsStyleSet.h index 8aed8c85ba59..a50d0e263880 100644 --- a/layout/style/nsStyleSet.h +++ b/layout/style/nsStyleSet.h @@ -52,6 +52,8 @@ public: NS_DECL_ISUPPORTS virtual void MapRuleInfoInto(nsRuleData* aRuleData) override; virtual bool MightMapInheritedStyleData() override; + virtual bool GetDiscretelyAnimatedCSSValue(nsCSSProperty aProperty, + nsCSSValue* aValue) override; #ifdef DEBUG virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override; #endif @@ -66,6 +68,8 @@ public: NS_DECL_ISUPPORTS virtual void MapRuleInfoInto(nsRuleData* aRuleData) override; virtual bool MightMapInheritedStyleData() override; + virtual bool GetDiscretelyAnimatedCSSValue(nsCSSProperty aProperty, + nsCSSValue* aValue) override; #ifdef DEBUG virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override; #endif @@ -80,6 +84,8 @@ public: NS_DECL_ISUPPORTS virtual void MapRuleInfoInto(nsRuleData* aRuleData) override; virtual bool MightMapInheritedStyleData() override; + virtual bool GetDiscretelyAnimatedCSSValue(nsCSSProperty aProperty, + nsCSSValue* aValue) override; #ifdef DEBUG virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override; #endif diff --git a/layout/style/nsTransitionManager.cpp b/layout/style/nsTransitionManager.cpp index f1f30e8cde1b..69aaeeda55db 100644 --- a/layout/style/nsTransitionManager.cpp +++ b/layout/style/nsTransitionManager.cpp @@ -283,6 +283,17 @@ NS_IMPL_CYCLE_COLLECTION(nsTransitionManager, mEventDispatcher) NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(nsTransitionManager, AddRef) NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(nsTransitionManager, Release) +static inline bool +ExtractNonDiscreteComputedValue(nsCSSProperty aProperty, + nsStyleContext* aStyleContext, + StyleAnimationValue& aComputedValue) +{ + return (nsCSSProps::kAnimTypeTable[aProperty] != eStyleAnimType_Discrete || + aProperty == eCSSProperty_visibility) && + StyleAnimationValue::ExtractComputedValue(aProperty, aStyleContext, + aComputedValue); +} + void nsTransitionManager::StyleContextChanged(dom::Element *aElement, nsStyleContext *aOldStyleContext, @@ -552,9 +563,8 @@ nsTransitionManager::UpdateTransitions( // duration are both zero, or because the new value is not // interpolable); a new transition would have anim->ToValue() // matching currentValue - !StyleAnimationValue::ExtractComputedValue(anim->TransitionProperty(), - aNewStyleContext, - currentValue) || + !ExtractNonDiscreteComputedValue(anim->TransitionProperty(), + aNewStyleContext, currentValue) || currentValue != anim->ToValue()) { // stop the transition if (anim->HasCurrentEffect()) { @@ -619,12 +629,8 @@ nsTransitionManager::ConsiderStartingTransition( StyleAnimationValue startValue, endValue, dummyValue; bool haveValues = - StyleAnimationValue::ExtractComputedValue(aProperty, - aOldStyleContext, - startValue) && - StyleAnimationValue::ExtractComputedValue(aProperty, - aNewStyleContext, - endValue); + ExtractNonDiscreteComputedValue(aProperty, aOldStyleContext, startValue) && + ExtractNonDiscreteComputedValue(aProperty, aNewStyleContext, endValue); bool haveChange = startValue != endValue; @@ -929,9 +935,8 @@ nsTransitionManager::PruneCompletedTransitions(mozilla::dom::Element* aElement, // Since effect is a finished transition, we know it didn't // influence style. StyleAnimationValue currentValue; - if (!StyleAnimationValue::ExtractComputedValue(anim->TransitionProperty(), - aNewStyleContext, - currentValue) || + if (!ExtractNonDiscreteComputedValue(anim->TransitionProperty(), + aNewStyleContext, currentValue) || currentValue != anim->ToValue()) { anim->CancelFromStyle(); animations.RemoveElementAt(i);