diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index 78af54faf978..65276586190b 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -405,6 +405,26 @@ nsLayoutUtils::HasCurrentAnimations(nsIContent* aContent, return (collection && collection->HasCurrentAnimations()); } +bool +nsLayoutUtils::HasCurrentAnimationsForProperty(nsIContent* aContent, + nsCSSProperty aProperty) +{ + if (!aContent->MayHaveAnimations()) + return false; + + static nsIAtom* const sAnimProps[] = { nsGkAtoms::transitionsProperty, + nsGkAtoms::animationsProperty, + nullptr }; + for (nsIAtom* const* animProp = sAnimProps; *animProp; animProp++) { + AnimationPlayerCollection* collection = + static_cast(aContent->GetProperty(*animProp)); + if (collection && collection->HasCurrentAnimationsForProperty(aProperty)) + return true; + } + + return false; +} + static gfxSize GetScaleForValue(const StyleAnimationValue& aValue, nsIFrame* aFrame) { diff --git a/layout/base/nsLayoutUtils.h b/layout/base/nsLayoutUtils.h index b8009575397b..835fbc5f486f 100644 --- a/layout/base/nsLayoutUtils.h +++ b/layout/base/nsLayoutUtils.h @@ -1879,13 +1879,21 @@ public: static bool HasAnimations(nsIContent* aContent, nsCSSProperty aProperty); /** - * Returns true if the content node has any current animations or transitions. + * Returns true if the content node has any current animations or transitions + * (depending on the value of |aAnimationProperty|). * A current animation is any animation that has not yet finished playing * including paused animations. */ static bool HasCurrentAnimations(nsIContent* aContent, nsIAtom* aAnimationProperty); + /** + * Returns true if the content node has any current animations or transitions + * for the specified property. + */ + static bool HasCurrentAnimationsForProperty(nsIContent* aContent, + nsCSSProperty aProperty); + /** * Checks if off-main-thread animations are enabled. */