Bug 930381 - Follow the COM rules when calling ProcessSynthMouseMoveEvent. r=mats, smaug, tnikkel, a=abillings
authorOlli Pettay <bugs@pettay.fi>
Tue, 12 Nov 2013 07:54:10 -0500
changeset 119959 11723a2e1981c437d48f1eb320dfb3bdf33ee1ec
parent 119958 31fa87bfba887094700e97222eca36fe9049dc1b
child 119960 3d28e6cbacce6b95306a2675fa57c4e06e5c9c2a
push id1095
push userryanvm@gmail.com
push dateTue, 12 Nov 2013 16:05:36 +0000
reviewersmats, smaug, tnikkel, abillings
bugs930381
milestone18.1
Bug 930381 - Follow the COM rules when calling ProcessSynthMouseMoveEvent. r=mats, smaug, tnikkel, a=abillings
layout/base/nsPresShell.cpp
layout/base/nsPresShell.h
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -3433,16 +3433,19 @@ PresShell::ScheduleViewManagerFlush()
 void
 PresShell::DispatchSynthMouseMove(nsGUIEvent *aEvent,
                                   bool aFlushOnHoverChange)
 {
   uint32_t hoverGenerationBefore = mFrameConstructor->GetHoverGeneration();
   nsEventStatus status;
   nsIView* targetView = nsIView::GetViewFor(aEvent->widget);
   targetView->GetViewManager()->DispatchEvent(aEvent, targetView, &status);
+  if (MOZ_UNLIKELY(mIsDestroying)) {
+    return;
+  }
   if (aFlushOnHoverChange &&
       hoverGenerationBefore != mFrameConstructor->GetHoverGeneration()) {
     // Flush so that the resulting reflow happens now so that our caller
     // can suppress any synthesized mouse moves caused by that reflow.
     FlushPendingNotifications(Flush_Layout);
   }
 }
 
--- a/layout/base/nsPresShell.h
+++ b/layout/base/nsPresShell.h
@@ -617,18 +617,20 @@ protected:
     void Revoke() {
       if (mPresShell) {
         mPresShell->GetPresContext()->RefreshDriver()->
           RemoveRefreshObserver(this, Flush_Display);
         mPresShell = nullptr;
       }
     }
     virtual void WillRefresh(mozilla::TimeStamp aTime) MOZ_OVERRIDE {
-      if (mPresShell)
-        mPresShell->ProcessSynthMouseMoveEvent(mFromScroll);
+      if (mPresShell) {
+        nsRefPtr<PresShell> shell = mPresShell;
+        shell->ProcessSynthMouseMoveEvent(mFromScroll);
+      }
     }
   private:
     PresShell* mPresShell;
     bool mFromScroll;
   };
   void ProcessSynthMouseMoveEvent(bool aFromScroll);
 
   void QueryIsActive();