Bug 1046055 part 4 - Add HasCurrentAnimationsForProperty to nsLayoutUtils; r=dbaron

This patch adds a method to nsLayoutUtils, alongside the existing
HasCurrentAnimations, that returns true if there exists an unfinished animation
on the element for the specified property.
This commit is contained in:
Brian Birtles 2014-10-02 15:14:14 +09:00
Родитель 139a4e3a73
Коммит d77b5db74f
2 изменённых файлов: 29 добавлений и 1 удалений

Просмотреть файл

@ -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<AnimationPlayerCollection*>(aContent->GetProperty(*animProp));
if (collection && collection->HasCurrentAnimationsForProperty(aProperty))
return true;
}
return false;
}
static gfxSize
GetScaleForValue(const StyleAnimationValue& aValue, nsIFrame* aFrame)
{

Просмотреть файл

@ -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.
*/