зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1249219 - Part 5: Add a wrapper of AnimationAdded/Changed/Removed. r=birtles
Remove the duplicated code in nsNodeUtils. --HG-- extra : rebase_source : 8e56af9adcfefbe015d62dcf6937ca6d941bc438
This commit is contained in:
Родитель
0fab3e5678
Коммит
b32a962055
|
@ -246,7 +246,8 @@ nsNodeUtils::GetTargetForAnimation(const Animation* aAnimation)
|
|||
}
|
||||
|
||||
void
|
||||
nsNodeUtils::AnimationAdded(Animation* aAnimation)
|
||||
nsNodeUtils::AnimationMutated(Animation* aAnimation,
|
||||
AnimationMutationType aMutatedType)
|
||||
{
|
||||
Maybe<NonOwningAnimationTarget> target = GetTargetForAnimation(aAnimation);
|
||||
if (!target) {
|
||||
|
@ -255,38 +256,39 @@ nsNodeUtils::AnimationAdded(Animation* aAnimation)
|
|||
nsIDocument* doc = target->mElement->OwnerDoc();
|
||||
|
||||
if (doc->MayHaveAnimationObservers()) {
|
||||
IMPL_ANIMATION_NOTIFICATION(AnimationAdded, target->mElement, (aAnimation));
|
||||
Element* elem = target->mElement;
|
||||
switch (aMutatedType) {
|
||||
case AnimationMutationType::Added:
|
||||
IMPL_ANIMATION_NOTIFICATION(AnimationAdded, elem, (aAnimation));
|
||||
break;
|
||||
case AnimationMutationType::Changed:
|
||||
IMPL_ANIMATION_NOTIFICATION(AnimationChanged, elem, (aAnimation));
|
||||
break;
|
||||
case AnimationMutationType::Removed:
|
||||
IMPL_ANIMATION_NOTIFICATION(AnimationRemoved, elem, (aAnimation));
|
||||
break;
|
||||
default:
|
||||
MOZ_ASSERT_UNREACHABLE("unexpected mutation type");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsNodeUtils::AnimationAdded(Animation* aAnimation)
|
||||
{
|
||||
AnimationMutated(aAnimation, AnimationMutationType::Added);
|
||||
}
|
||||
|
||||
void
|
||||
nsNodeUtils::AnimationChanged(Animation* aAnimation)
|
||||
{
|
||||
Maybe<NonOwningAnimationTarget> target = GetTargetForAnimation(aAnimation);
|
||||
if (!target) {
|
||||
return;
|
||||
}
|
||||
nsIDocument* doc = target->mElement->OwnerDoc();
|
||||
|
||||
if (doc->MayHaveAnimationObservers()) {
|
||||
IMPL_ANIMATION_NOTIFICATION(AnimationChanged, target->mElement,
|
||||
(aAnimation));
|
||||
}
|
||||
AnimationMutated(aAnimation, AnimationMutationType::Changed);
|
||||
}
|
||||
|
||||
void
|
||||
nsNodeUtils::AnimationRemoved(Animation* aAnimation)
|
||||
{
|
||||
Maybe<NonOwningAnimationTarget> target = GetTargetForAnimation(aAnimation);
|
||||
if (!target) {
|
||||
return;
|
||||
}
|
||||
nsIDocument* doc = target->mElement->OwnerDoc();
|
||||
|
||||
if (doc->MayHaveAnimationObservers()) {
|
||||
IMPL_ANIMATION_NOTIFICATION(AnimationRemoved, target->mElement,
|
||||
(aAnimation));
|
||||
}
|
||||
AnimationMutated(aAnimation, AnimationMutationType::Removed);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -151,6 +151,11 @@ public:
|
|||
*/
|
||||
static mozilla::Maybe<mozilla::NonOwningAnimationTarget>
|
||||
GetTargetForAnimation(const mozilla::dom::Animation* aAnimation);
|
||||
|
||||
/**
|
||||
* Notify that an animation is added/changed/removed.
|
||||
* @param aAnimation The animation we added/changed/removed.
|
||||
*/
|
||||
static void AnimationAdded(mozilla::dom::Animation* aAnimation);
|
||||
static void AnimationChanged(mozilla::dom::Animation* aAnimation);
|
||||
static void AnimationRemoved(mozilla::dom::Animation* aAnimation);
|
||||
|
@ -306,6 +311,22 @@ private:
|
|||
JS::Handle<JSObject*> aReparentScope,
|
||||
nsCOMArray<nsINode> &aNodesWithProperties,
|
||||
nsINode *aParent, nsINode **aResult);
|
||||
|
||||
enum class AnimationMutationType
|
||||
{
|
||||
Added,
|
||||
Changed,
|
||||
Removed
|
||||
};
|
||||
/**
|
||||
* Notify the observers of the target of an animation
|
||||
* @param aAnimation The mutated animation.
|
||||
* @param aMutationType The mutation type of this animation. It could be
|
||||
* Added, Changed, or Removed.
|
||||
*/
|
||||
static void AnimationMutated(mozilla::dom::Animation* aAnimation,
|
||||
AnimationMutationType aMutatedType);
|
||||
|
||||
};
|
||||
|
||||
#endif // nsNodeUtils_h___
|
||||
|
|
Загрузка…
Ссылка в новой задаче