Bug 1143139 - Cancel all timer when SelectionCarets are terminated. r=roc, a=sledru
authorMorris Tseng <mtseng@mozilla.com>
Tue, 17 Mar 2015 21:31:00 +0100
changeset 257950 c5ee2892aedd992b60680542de0461532aa43662
parent 257949 dd8d81c94d4dd3f367d9c3891da3575d17f487a0
child 257951 3fcf7cee3050870e8f4d16b652f83529cf82078b
push id4610
push userjlund@mozilla.com
push dateMon, 30 Mar 2015 18:32:55 +0000
treeherdermozilla-beta@4df54044d9ef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc, sledru
bugs1143139
milestone38.0a2
Bug 1143139 - Cancel all timer when SelectionCarets are terminated. r=roc, a=sledru
layout/base/SelectionCarets.cpp
--- a/layout/base/SelectionCarets.cpp
+++ b/layout/base/SelectionCarets.cpp
@@ -122,38 +122,38 @@ SelectionCarets::Init()
   mDocShell = static_cast<nsDocShell*>(docShell);
 }
 
 SelectionCarets::~SelectionCarets()
 {
   SELECTIONCARETS_LOG("Destructor");
   MOZ_ASSERT(NS_IsMainThread());
 
-  if (mLongTapDetectorTimer) {
-    mLongTapDetectorTimer->Cancel();
-    mLongTapDetectorTimer = nullptr;
-  }
-
-  if (mScrollEndDetectorTimer) {
-    mScrollEndDetectorTimer->Cancel();
-    mScrollEndDetectorTimer = nullptr;
-  }
-
   mPresShell = nullptr;
 }
 
 void
 SelectionCarets::Terminate()
 {
   nsRefPtr<nsDocShell> docShell(mDocShell.get());
   if (docShell) {
     docShell->RemoveWeakReflowObserver(this);
     docShell->RemoveWeakScrollObserver(this);
   }
 
+  if (mLongTapDetectorTimer) {
+    mLongTapDetectorTimer->Cancel();
+    mLongTapDetectorTimer = nullptr;
+  }
+
+  if (mScrollEndDetectorTimer) {
+    mScrollEndDetectorTimer->Cancel();
+    mScrollEndDetectorTimer = nullptr;
+  }
+
   mPresShell = nullptr;
 }
 
 nsEventStatus
 SelectionCarets::HandleEvent(WidgetEvent* aEvent)
 {
   WidgetMouseEvent *mouseEvent = aEvent->AsMouseEvent();
   if (mouseEvent && mouseEvent->reason == WidgetMouseEvent::eSynthesized) {