Bug 1048752. Part 33: A zero blink rate should mean the caret is always on. r=tn
authorRobert O'Callahan <robert@ocallahan.org>
Wed, 06 Aug 2014 17:19:31 +1200
changeset 199970 b2ab5b511d882e373f7d64ec73458d9e82007471
parent 199969 e1857632271dc932a5a3b8246ebc67be0c7d37b0
child 199971 6b2a05a50eec42a1b0c0aa983930a48d0f0a7c86
push id9784
push userryanvm@gmail.com
push dateSat, 16 Aug 2014 21:45:40 +0000
treeherderb2g-inbound@94ba78a42305 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstn
bugs1048752
milestone34.0a1
Bug 1048752. Part 33: A zero blink rate should mean the caret is always on. r=tn Previous changes broke this.
layout/base/nsCaret.cpp
--- a/layout/base/nsCaret.cpp
+++ b/layout/base/nsCaret.cpp
@@ -552,30 +552,31 @@ void nsCaret::ResetBlinking()
 {
   mIsBlinkOn = true;
 
   if (mReadOnly) {
     StopBlinking();
     return;
   }
 
-  if (!mBlinkTimer) {
+  if (mBlinkTimer) {
+    mBlinkTimer->Cancel();
+  } else {
     nsresult  err;
     mBlinkTimer = do_CreateInstance("@mozilla.org/timer;1", &err);
     if (NS_FAILED(err))
       return;
-  } else {
-    mBlinkTimer->Cancel();
   }
 
   uint32_t blinkRate = static_cast<uint32_t>(
     LookAndFeel::GetInt(LookAndFeel::eIntID_CaretBlinkTime, 500));
-
-  mBlinkTimer->InitWithFuncCallback(CaretBlinkCallback, this, blinkRate,
-                                    nsITimer::TYPE_REPEATING_SLACK);
+  if (blinkRate > 0) {
+    mBlinkTimer->InitWithFuncCallback(CaretBlinkCallback, this, blinkRate,
+                                      nsITimer::TYPE_REPEATING_SLACK);
+  }
 }
 
 //-----------------------------------------------------------------------------
 void nsCaret::StopBlinking()
 {
   if (mBlinkTimer)
   {
     mBlinkTimer->Cancel();