Bug 1430924 - AnimationEventInfo and TransitionEventInfo take NonOwningAnimationTarget instead of Element and CSSPseudoElementType pair. r?boris
MozReview-Commit-ID: HYN9AWuyjem
--- a/layout/style/AnimationCommon.h
+++ b/layout/style/AnimationCommon.h
@@ -163,16 +163,23 @@ public:
void GetElement(dom::Element*& aElement,
CSSPseudoElementType& aPseudoType) const
{
aElement = mTarget.mElement;
aPseudoType = mTarget.mPseudoType;
}
+ const NonOwningAnimationTarget& Target() const { return mTarget; }
+
+ nsPresContext* GetPresContext() const
+ {
+ return nsContentUtils::GetContextForContent(mTarget.mElement);
+ }
+
private:
NonOwningAnimationTarget mTarget;
};
template <class EventInfo>
class DelayedEventDispatcher
{
public:
--- a/layout/style/nsAnimationManager.cpp
+++ b/layout/style/nsAnimationManager.cpp
@@ -193,27 +193,21 @@ CSSAnimation::QueueEvents(StickyTimeDura
// disassociated from CSS) no events are fired. If it becomes desirable
// for these animations to still fire events we should spec the concept
// of the "original owning element" or "event target" and allow script
// to set it when creating a CSSAnimation object.
if (!mOwningElement.IsSet()) {
return;
}
- dom::Element* owningElement;
- CSSPseudoElementType owningPseudoType;
- mOwningElement.GetElement(owningElement, owningPseudoType);
- MOZ_ASSERT(owningElement, "Owning element should be set");
-
- // Get the nsAnimationManager so we can queue events on it
- nsPresContext* presContext =
- nsContentUtils::GetContextForContent(owningElement);
+ nsPresContext* presContext = mOwningElement.GetPresContext();
if (!presContext) {
return;
}
+ // Get the nsAnimationManager so we can queue events on it
nsAnimationManager* manager = presContext->AnimationManager();
const StickyTimeDuration zeroDuration;
uint64_t currentIteration = 0;
ComputedTiming::AnimationPhase currentPhase;
StickyTimeDuration intervalStartTime;
StickyTimeDuration intervalEndTime;
StickyTimeDuration iterationStartTime;
@@ -311,17 +305,17 @@ CSSAnimation::QueueEvents(StickyTimeDura
}
break;
}
mPreviousPhase = currentPhase;
mPreviousIteration = currentIteration;
for (const AnimationEventParams& event : events){
manager->QueueEvent(
- AnimationEventInfo(owningElement, owningPseudoType,
+ AnimationEventInfo(mOwningElement.Target(),
event.mMessage, mAnimationName,
event.mElapsedTime, event.mTimeStamp,
this));
}
}
void
CSSAnimation::UpdateTiming(SeekFlag aSeekFlag, SyncNotifyFlag aSyncNotifyFlag)
--- a/layout/style/nsAnimationManager.h
+++ b/layout/style/nsAnimationManager.h
@@ -36,34 +36,34 @@ enum class CSSPseudoElementType : uint8_
struct NonOwningAnimationTarget;
struct AnimationEventInfo {
RefPtr<dom::Element> mElement;
RefPtr<dom::Animation> mAnimation;
InternalAnimationEvent mEvent;
TimeStamp mTimeStamp;
- AnimationEventInfo(dom::Element* aElement,
- CSSPseudoElementType aPseudoType,
+ AnimationEventInfo(const NonOwningAnimationTarget& aTarget,
EventMessage aMessage,
nsAtom* aAnimationName,
const StickyTimeDuration& aElapsedTime,
const TimeStamp& aTimeStamp,
dom::Animation* aAnimation)
- : mElement(aElement)
+ : mElement(aTarget.mElement)
, mAnimation(aAnimation)
, mEvent(true, aMessage)
, mTimeStamp(aTimeStamp)
{
// XXX Looks like nobody initialize WidgetEvent::time
aAnimationName->ToString(mEvent.mAnimationName);
mEvent.mElapsedTime =
nsRFPService::ReduceTimePrecisionAsSecs(aElapsedTime.ToSeconds());
mEvent.mPseudoElement =
- AnimationCollection<dom::CSSAnimation>::PseudoTypeAsString(aPseudoType);
+ AnimationCollection<dom::CSSAnimation>::PseudoTypeAsString(
+ aTarget.mPseudoType);
}
// InternalAnimationEvent doesn't support copy-construction, so we need
// to ourselves in order to work with nsTArray
AnimationEventInfo(const AnimationEventInfo& aOther)
: mElement(aOther.mElement)
, mAnimation(aOther.mAnimation)
, mEvent(true, aOther.mEvent.mMessage)
--- a/layout/style/nsTransitionManager.cpp
+++ b/layout/style/nsTransitionManager.cpp
@@ -210,23 +210,17 @@ CSSTransition::UpdateTiming(SeekFlag aSe
void
CSSTransition::QueueEvents(StickyTimeDuration aActiveTime)
{
if (!mOwningElement.IsSet()) {
return;
}
- dom::Element* owningElement;
- CSSPseudoElementType owningPseudoType;
- mOwningElement.GetElement(owningElement, owningPseudoType);
- MOZ_ASSERT(owningElement, "Owning element should be set");
-
- nsPresContext* presContext =
- nsContentUtils::GetContextForContent(owningElement);
+ nsPresContext* presContext = mOwningElement.GetPresContext();
if (!presContext) {
return;
}
const StickyTimeDuration zeroDuration = StickyTimeDuration();
TransitionPhase currentPhase;
StickyTimeDuration intervalStartTime;
@@ -344,17 +338,17 @@ CSSTransition::QueueEvents(StickyTimeDur
endTimeStamp });
}
break;
}
mPreviousTransitionPhase = currentPhase;
nsTransitionManager* manager = presContext->TransitionManager();
for (const TransitionEventParams& evt : events) {
- manager->QueueEvent(TransitionEventInfo(owningElement, owningPseudoType,
+ manager->QueueEvent(TransitionEventInfo(mOwningElement.Target(),
evt.mMessage,
TransitionProperty(),
evt.mElapsedTime,
evt.mTimeStamp,
this));
}
}
--- a/layout/style/nsTransitionManager.h
+++ b/layout/style/nsTransitionManager.h
@@ -302,34 +302,34 @@ struct AnimationTypeTraits<dom::CSSTrans
};
struct TransitionEventInfo {
RefPtr<dom::Element> mElement;
RefPtr<dom::Animation> mAnimation;
InternalTransitionEvent mEvent;
TimeStamp mTimeStamp;
- TransitionEventInfo(dom::Element* aElement,
- CSSPseudoElementType aPseudoType,
+ TransitionEventInfo(const NonOwningAnimationTarget& aTarget,
EventMessage aMessage,
nsCSSPropertyID aProperty,
StickyTimeDuration aDuration,
const TimeStamp& aTimeStamp,
dom::Animation* aAnimation)
- : mElement(aElement)
+ : mElement(aTarget.mElement)
, mAnimation(aAnimation)
, mEvent(true, aMessage)
, mTimeStamp(aTimeStamp)
{
// XXX Looks like nobody initialize WidgetEvent::time
mEvent.mPropertyName =
NS_ConvertUTF8toUTF16(nsCSSProps::GetStringValue(aProperty));
mEvent.mElapsedTime = aDuration.ToSeconds();
mEvent.mPseudoElement =
- AnimationCollection<dom::CSSTransition>::PseudoTypeAsString(aPseudoType);
+ AnimationCollection<dom::CSSTransition>::PseudoTypeAsString(
+ aTarget.mPseudoType);
}
// InternalTransitionEvent doesn't support copy-construction, so we need
// to ourselves in order to work with nsTArray
TransitionEventInfo(const TransitionEventInfo& aOther)
: mElement(aOther.mElement)
, mAnimation(aOther.mAnimation)
, mEvent(aOther.mEvent)