Bug 1032573 part 2 - Add a timeline member to ElementAnimations; r=dbaron

When we expose ElementAnimation objects to script they need to have a parent
object so they can be associated with a Window.

This patch adds a pointer from an ElementAnimation to its AnimationTimeline.
This commit is contained in:
Brian Birtles 2014-07-16 09:02:30 +09:00
Родитель 881f90e9a2
Коммит 9454e09015
6 изменённых файлов: 24 добавлений и 5 удалений

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

@ -12,6 +12,7 @@
#include "nsRuleData.h"
#include "nsCSSPropertySet.h"
#include "nsCSSValue.h"
#include "nsCycleCollectionParticipant.h"
#include "nsStyleContext.h"
#include "nsIFrame.h"
#include "nsLayoutUtils.h"
@ -406,6 +407,10 @@ ComputedTimingFunction::GetValue(double aPortion) const
const double ComputedTiming::kNullTimeFraction =
mozilla::PositiveInfinity<double>();
NS_IMPL_CYCLE_COLLECTION(ElementAnimation, mTimeline)
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(ElementAnimation, AddRef)
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(ElementAnimation, Release)
bool
ElementAnimation::IsRunningAt(TimeStamp aTime) const
{

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

@ -13,12 +13,14 @@
#include "nsCSSProperty.h"
#include "mozilla/MemoryReporting.h"
#include "mozilla/StyleAnimationValue.h"
#include "mozilla/dom/AnimationTimeline.h"
#include "mozilla/dom/Element.h"
#include "nsSMILKeySpline.h"
#include "nsStyleStruct.h"
#include "mozilla/Attributes.h"
#include "mozilla/FloatingPoint.h"
#include "nsCSSPseudoElements.h"
#include "nsCycleCollectionParticipant.h"
class nsIFrame;
class nsPresContext;
@ -311,13 +313,17 @@ protected:
virtual ~ElementAnimation() { }
public:
ElementAnimation()
explicit ElementAnimation(dom::AnimationTimeline* aTimeline)
: mIsRunningOnCompositor(false)
, mIsFinishedTransition(false)
, mLastNotification(LAST_NOTIFICATION_NONE)
, mTimeline(aTimeline)
{
}
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(ElementAnimation)
NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(ElementAnimation)
// FIXME: If we succeed in moving transition-specific code to a type of
// AnimationEffect (as per the Web Animations API) we should remove these
// virtual methods.
@ -397,7 +403,7 @@ public:
InfallibleTArray<AnimationProperty> mProperties;
NS_INLINE_DECL_REFCOUNTING(ElementAnimation)
nsRefPtr<dom::AnimationTimeline> mTimeline;
};
typedef InfallibleTArray<nsRefPtr<ElementAnimation> > ElementAnimationPtrArray;

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

@ -241,8 +241,9 @@ nsAnimationManager::CheckAnimationRule(nsStyleContext* aStyleContext,
}
// build the animations list
dom::AnimationTimeline* timeline = aElement->OwnerDoc()->Timeline();
ElementAnimationPtrArray newAnimations;
BuildAnimations(aStyleContext, newAnimations);
BuildAnimations(aStyleContext, timeline, newAnimations);
if (newAnimations.IsEmpty()) {
if (collection) {
@ -383,6 +384,7 @@ ResolvedStyleCache::Get(nsPresContext *aPresContext,
void
nsAnimationManager::BuildAnimations(nsStyleContext* aStyleContext,
dom::AnimationTimeline* aTimeline,
ElementAnimationPtrArray& aAnimations)
{
NS_ABORT_IF_FALSE(aAnimations.IsEmpty(), "expect empty array");
@ -410,7 +412,7 @@ nsAnimationManager::BuildAnimations(nsStyleContext* aStyleContext,
}
nsRefPtr<ElementAnimation> dest =
*aAnimations.AppendElement(new ElementAnimation());
*aAnimations.AppendElement(new ElementAnimation(aTimeline));
dest->mName = src.GetName();

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

@ -151,6 +151,7 @@ protected:
private:
void BuildAnimations(nsStyleContext* aStyleContext,
mozilla::dom::AnimationTimeline* aTimeline,
mozilla::ElementAnimationPtrArray& aAnimations);
bool BuildSegment(InfallibleTArray<mozilla::AnimationPropertySegment>&
aSegments,

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

@ -407,7 +407,9 @@ nsTransitionManager::ConsiderStartingTransition(
return;
}
nsRefPtr<ElementPropertyTransition> pt = new ElementPropertyTransition();
dom::AnimationTimeline* timeline = aElement->OwnerDoc()->Timeline();
nsRefPtr<ElementPropertyTransition> pt =
new ElementPropertyTransition(timeline);
StyleAnimationValue startValue, endValue, dummyValue;
bool haveValues =

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

@ -30,6 +30,9 @@ namespace mozilla {
struct ElementPropertyTransition : public mozilla::ElementAnimation
{
explicit ElementPropertyTransition(mozilla::dom::AnimationTimeline* aTimeline)
: mozilla::ElementAnimation(aTimeline) { }
virtual ElementPropertyTransition* AsTransition() { return this; }
virtual const ElementPropertyTransition* AsTransition() const { return this; }