Bug 1226118 part 13 - Move the GetAnimationCollection definitions side-by-side; r=dholbert

This is to match the order in the header file and because in the next patch I'd
like to somewhat re-implement one method in terms of the other and having them
side-by-side will make it easier to read the code.

This patch makes no code changes whatsoever besides shifting the placement of
the function definitions within the .cpp file.
This commit is contained in:
Brian Birtles 2015-12-04 08:34:17 +09:00
parent d4b16758ed
commit c4a38c62e4

View File

@ -66,6 +66,55 @@ CommonAnimationManager::RemoveAllElementCollections()
}
}
AnimationCollection*
CommonAnimationManager::GetAnimationCollection(dom::Element *aElement,
nsCSSPseudoElements::Type
aPseudoType,
bool aCreateIfNeeded)
{
if (!aCreateIfNeeded && mElementCollections.isEmpty()) {
// Early return for the most common case.
return nullptr;
}
nsIAtom *propName;
if (aPseudoType == nsCSSPseudoElements::ePseudo_NotPseudoElement) {
propName = GetAnimationsAtom();
} else if (aPseudoType == nsCSSPseudoElements::ePseudo_before) {
propName = GetAnimationsBeforeAtom();
} else if (aPseudoType == nsCSSPseudoElements::ePseudo_after) {
propName = GetAnimationsAfterAtom();
} else {
NS_ASSERTION(!aCreateIfNeeded,
"should never try to create transitions for pseudo "
"other than :before or :after");
return nullptr;
}
AnimationCollection* collection =
static_cast<AnimationCollection*>(aElement->GetProperty(propName));
if (!collection && aCreateIfNeeded) {
// FIXME: Consider arena-allocating?
collection = new AnimationCollection(aElement, propName, this);
nsresult rv =
aElement->SetProperty(propName, collection,
&AnimationCollection::PropertyDtor, false);
if (NS_FAILED(rv)) {
NS_WARNING("SetProperty failed");
// The collection must be destroyed via PropertyDtor, otherwise
// mCalledPropertyDtor assertion is triggered in destructor.
AnimationCollection::PropertyDtor(aElement, propName, collection, nullptr);
return nullptr;
}
if (aPseudoType == nsCSSPseudoElements::ePseudo_NotPseudoElement) {
aElement->SetMayHaveAnimations();
}
AddElementCollection(collection);
}
return collection;
}
AnimationCollection*
CommonAnimationManager::GetAnimationCollection(const nsIFrame* aFrame)
{
@ -235,55 +284,6 @@ CommonAnimationManager::ExtractComputedValueForTransition(
return result;
}
AnimationCollection*
CommonAnimationManager::GetAnimationCollection(dom::Element *aElement,
nsCSSPseudoElements::Type
aPseudoType,
bool aCreateIfNeeded)
{
if (!aCreateIfNeeded && mElementCollections.isEmpty()) {
// Early return for the most common case.
return nullptr;
}
nsIAtom *propName;
if (aPseudoType == nsCSSPseudoElements::ePseudo_NotPseudoElement) {
propName = GetAnimationsAtom();
} else if (aPseudoType == nsCSSPseudoElements::ePseudo_before) {
propName = GetAnimationsBeforeAtom();
} else if (aPseudoType == nsCSSPseudoElements::ePseudo_after) {
propName = GetAnimationsAfterAtom();
} else {
NS_ASSERTION(!aCreateIfNeeded,
"should never try to create transitions for pseudo "
"other than :before or :after");
return nullptr;
}
AnimationCollection* collection =
static_cast<AnimationCollection*>(aElement->GetProperty(propName));
if (!collection && aCreateIfNeeded) {
// FIXME: Consider arena-allocating?
collection = new AnimationCollection(aElement, propName, this);
nsresult rv =
aElement->SetProperty(propName, collection,
&AnimationCollection::PropertyDtor, false);
if (NS_FAILED(rv)) {
NS_WARNING("SetProperty failed");
// The collection must be destroyed via PropertyDtor, otherwise
// mCalledPropertyDtor assertion is triggered in destructor.
AnimationCollection::PropertyDtor(aElement, propName, collection, nullptr);
return nullptr;
}
if (aPseudoType == nsCSSPseudoElements::ePseudo_NotPseudoElement) {
aElement->SetMayHaveAnimations();
}
AddElementCollection(collection);
}
return collection;
}
void
CommonAnimationManager::FlushAnimations()
{