Bug 1025709 part 9 - Move heavy lifting of GetAnimationsForCompositor from ElementAnimations/ElementTransitions to base class; r=heycam

This patch still leaves ElementAnimations|
ElementTransitions::GetAnimationsForCompositor as shortcuts
for the method now defined on CommonElementAnimationData.
This commit is contained in:
Brian Birtles 2014-06-20 12:39:25 +09:00
parent 5aba002a6b
commit 4af742b557
5 changed files with 35 additions and 32 deletions

View File

@ -415,10 +415,9 @@ nsDisplayListBuilder::AddAnimationsAndTransitionsToLayer(Layer* aLayer,
if (!content) {
return;
}
ElementTransitions* et =
nsTransitionManager::GetTransitionsForCompositor(content, aProperty);
ElementAnimations* ea =
CommonElementAnimationData* et =
nsTransitionManager::GetAnimationsForCompositor(content, aProperty);
CommonElementAnimationData* ea =
nsAnimationManager::GetAnimationsForCompositor(content, aProperty);
if (!ea && !et) {

View File

@ -76,6 +76,25 @@ CommonAnimationManager::RemoveAllElementData()
}
}
CommonElementAnimationData*
CommonAnimationManager::GetAnimationsForCompositor(nsIContent* aContent,
nsIAtom* aElementProperty,
nsCSSProperty aProperty)
{
if (!aContent->MayHaveAnimations())
return nullptr;
CommonElementAnimationData* animations =
static_cast<CommonElementAnimationData*>(
aContent->GetProperty(aElementProperty));
if (!animations ||
!animations->HasAnimationOfProperty(aProperty) ||
!animations->CanPerformOnCompositorThread(
CommonElementAnimationData::CanAnimate_AllowPartial)) {
return nullptr;
}
return animations;
}
/*
* nsISupports implementation
*/

View File

@ -75,6 +75,11 @@ protected:
virtual void ElementDataRemoved() = 0;
void RemoveAllElementData();
static CommonElementAnimationData*
GetAnimationsForCompositor(nsIContent* aContent,
nsIAtom* aElementProperty,
nsCSSProperty aProperty);
// Update the style on aElement from the transition stored in this manager and
// the new parent style - aParentStyle. aElement must be transitioning or
// animated. Returns the updated style.

View File

@ -91,21 +91,11 @@ public:
{
}
static ElementAnimations* GetAnimationsForCompositor(nsIContent* aContent,
nsCSSProperty aProperty)
static mozilla::css::CommonElementAnimationData*
GetAnimationsForCompositor(nsIContent* aContent, nsCSSProperty aProperty)
{
if (!aContent->MayHaveAnimations())
return nullptr;
ElementAnimations* animations = static_cast<ElementAnimations*>(
aContent->GetProperty(nsGkAtoms::animationsProperty));
if (!animations)
return nullptr;
bool propertyMatches = animations->HasAnimationOfProperty(aProperty);
return (propertyMatches &&
animations->CanPerformOnCompositorThread(
mozilla::css::CommonElementAnimationData::CanAnimate_AllowPartial))
? animations
: nullptr;
return mozilla::css::CommonAnimationManager::GetAnimationsForCompositor(
aContent, nsGkAtoms::animationsProperty, aProperty);
}
// Returns true if aContent or any of its ancestors has an animation.

View File

@ -86,21 +86,11 @@ public:
typedef mozilla::css::CommonElementAnimationData CommonElementAnimationData;
static ElementTransitions*
GetTransitionsForCompositor(nsIContent* aContent,
nsCSSProperty aProperty)
static CommonElementAnimationData*
GetAnimationsForCompositor(nsIContent* aContent, nsCSSProperty aProperty)
{
if (!aContent->MayHaveAnimations()) {
return nullptr;
}
ElementTransitions* transitions = GetTransitions(aContent);
if (!transitions ||
!transitions->HasAnimationOfProperty(aProperty) ||
!transitions->CanPerformOnCompositorThread(
CommonElementAnimationData::CanAnimate_AllowPartial)) {
return nullptr;
}
return transitions;
return mozilla::css::CommonAnimationManager::GetAnimationsForCompositor(
aContent, nsGkAtoms::transitionsProperty, aProperty);
}
/**