Bug 1317030 - Removing/reattaching an element from the DOM triggers spurious mouseenter events, r=masayuki
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Mon, 14 Nov 2016 13:19:11 +0200
changeset 438633 9cb1f00af10bc3f614a0411c7b6b874946540b97
parent 438632 aef4a0fdca31ba6d36908c169121a0fb9fe90dc7
child 438634 8c4b29e6e5bd48410d01477d2bc5cd477a70950c
push id35794
push usersledru@mozilla.com
push dateMon, 14 Nov 2016 22:18:09 +0000
reviewersmasayuki
bugs1317030
milestone52.0a1
Bug 1317030 - Removing/reattaching an element from the DOM triggers spurious mouseenter events, r=masayuki
dom/events/EventStateManager.cpp
--- a/dom/events/EventStateManager.cpp
+++ b/dom/events/EventStateManager.cpp
@@ -3999,17 +3999,17 @@ public:
           mTargets.AppendObject(current);
         }
         // mouseenter/leave is fired only on elements.
         current = current->GetParent();
       }
     }
   }
 
-  ~EnterLeaveDispatcher()
+  void Dispatch()
   {
     if (mEventMessage == eMouseEnter || mEventMessage == ePointerEnter) {
       for (int32_t i = mTargets.Count() - 1; i >= 0; --i) {
         mESM->DispatchMouseOrPointerEvent(mMouseEvent, mEventMessage,
                                           mTargets[i], mRelatedTarget);
       }
     } else {
       for (int32_t i = 0; i < mTargets.Count(); ++i) {
@@ -4084,16 +4084,17 @@ EventStateManager::NotifyMouseOut(Widget
 
   EnterLeaveDispatcher leaveDispatcher(this, wrapper->mLastOverElement,
                                        movingInto, aMouseEvent,
                                        isPointer ? ePointerLeave : eMouseLeave);
 
   // Fire mouseout
   DispatchMouseOrPointerEvent(aMouseEvent, isPointer ? ePointerOut : eMouseOut,
                               wrapper->mLastOverElement, aMovingInto);
+  leaveDispatcher.Dispatch();
 
   wrapper->mLastOverFrame = nullptr;
   wrapper->mLastOverElement = nullptr;
 
   // Turn recursion protection back off
   wrapper->mFirstOutEventElement = nullptr;
 }
 
@@ -4157,16 +4158,17 @@ EventStateManager::NotifyMouseOver(Widge
   }
 
   if (dispatch) {
     // Fire mouseover
     wrapper->mLastOverFrame = 
       DispatchMouseOrPointerEvent(aMouseEvent,
                                   isPointer ? ePointerOver : eMouseOver,
                                   aContent, lastOverElement);
+    enterDispatcher->Dispatch();
     wrapper->mLastOverElement = aContent;
   } else {
     wrapper->mLastOverFrame = nullptr;
     wrapper->mLastOverElement = nullptr;
   }
 
   // Turn recursion protection back off
   wrapper->mFirstOverEventElement = nullptr;