Bug 1354501 - Change event target variable type to EventTarget and rename it to mTarget. r?birtles draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Tue, 03 Jul 2018 09:25:02 +0900
changeset 813415 89b29c12d507168a1ba221a5c250979f2744193e
parent 813414 3a5378897c29a7ab4bcb5b4cba94947ebd58771b
child 813416 5dad33c012f0598280a0ac63afdf7adeb6f37b22
push id114891
push userhikezoe@mozilla.com
push dateTue, 03 Jul 2018 04:49:25 +0000
reviewersbirtles
bugs1354501
milestone63.0a1
Bug 1354501 - Change event target variable type to EventTarget and rename it to mTarget. r?birtles That's because the target for web animation events (i.e. finish and cancel) is an Animation instance. MozReview-Commit-ID: 5xR325FXUo
dom/animation/AnimationEventDispatcher.cpp
dom/animation/AnimationEventDispatcher.h
--- a/dom/animation/AnimationEventDispatcher.cpp
+++ b/dom/animation/AnimationEventDispatcher.cpp
@@ -12,18 +12,18 @@
 namespace mozilla {
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(AnimationEventDispatcher)
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(AnimationEventDispatcher)
   tmp->ClearEventQueue();
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(AnimationEventDispatcher)
   for (auto& info : tmp->mPendingEvents) {
-    ImplCycleCollectionTraverse(cb, info.mElement,
-      "mozilla::AnimationEventDispatcher.mPendingEvents.mElement");
+    ImplCycleCollectionTraverse(cb, info.mTarget,
+      "mozilla::AnimationEventDispatcher.mPendingEvents.mTarget");
     ImplCycleCollectionTraverse(cb, info.mAnimation,
       "mozilla::AnimationEventDispatcher.mPendingEvents.mAnimation");
   }
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(AnimationEventDispatcher, AddRef)
 NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(AnimationEventDispatcher, Release)
 
--- a/dom/animation/AnimationEventDispatcher.h
+++ b/dom/animation/AnimationEventDispatcher.h
@@ -18,31 +18,31 @@
 
 class nsPresContext;
 class nsRefreshDriver;
 
 namespace mozilla {
 
 struct AnimationEventInfo
 {
-  RefPtr<dom::Element> mElement;
+  RefPtr<dom::EventTarget> mTarget;
   RefPtr<dom::Animation> mAnimation;
   TimeStamp mTimeStamp;
 
   typedef Variant<InternalTransitionEvent, InternalAnimationEvent> EventVariant;
   EventVariant mEvent;
 
   // For CSS animation events
   AnimationEventInfo(nsAtom* aAnimationName,
                      const NonOwningAnimationTarget& aTarget,
                      EventMessage aMessage,
                      double aElapsedTime,
                      const TimeStamp& aTimeStamp,
                      dom::Animation* aAnimation)
-    : mElement(aTarget.mElement)
+    : mTarget(aTarget.mElement)
     , mAnimation(aAnimation)
     , mTimeStamp(aTimeStamp)
     , mEvent(EventVariant(InternalAnimationEvent(true, aMessage)))
   {
     InternalAnimationEvent& event = mEvent.as<InternalAnimationEvent>();
 
     aAnimationName->ToString(event.mAnimationName);
     // XXX Looks like nobody initialize WidgetEvent::time
@@ -53,17 +53,17 @@ struct AnimationEventInfo
 
   // For CSS transition events
   AnimationEventInfo(nsCSSPropertyID aProperty,
                      const NonOwningAnimationTarget& aTarget,
                      EventMessage aMessage,
                      double aElapsedTime,
                      const TimeStamp& aTimeStamp,
                      dom::Animation* aAnimation)
-    : mElement(aTarget.mElement)
+    : mTarget(aTarget.mElement)
     , mAnimation(aAnimation)
     , mTimeStamp(aTimeStamp)
     , mEvent(EventVariant(InternalTransitionEvent(true, aMessage)))
   {
     InternalTransitionEvent& event = mEvent.as<InternalTransitionEvent>();
 
     event.mPropertyName =
       NS_ConvertUTF8toUTF16(nsCSSProps::GetStringValue(aProperty));
@@ -123,17 +123,17 @@ public:
     EventArray events;
     mPendingEvents.SwapElements(events);
     // mIsSorted will be set to true by SortEvents above, and we leave it
     // that way since mPendingEvents is now empty
     for (AnimationEventInfo& info : events) {
       MOZ_ASSERT(!info.AsWidgetEvent()->mFlags.mIsBeingDispatched &&
                  !info.AsWidgetEvent()->mFlags.mDispatchedAtLeastOnce,
                  "The WidgetEvent should be fresh");
-      EventDispatcher::Dispatch(info.mElement,
+      EventDispatcher::Dispatch(info.mTarget,
                                 mPresContext,
                                 info.AsWidgetEvent());
 
       // Bail out if our mPresContext was nullified due to destroying the pres
       // context.
       if (!mPresContext) {
         break;
       }