Bug 1204872 - Add documentation and rename mCaretMode. r=roc
authorTing-Yu Lin <tlin@mozilla.com>
Sat, 19 Sep 2015 01:05:18 +0800
changeset 295898 2a71fef0196b092254cb846f840e1cac87d7190e
parent 295897 309b4d1ab81c67783d7db0968bcff7c88108ba4f
child 295899 65087042a08e82eb55e6869b7836dc3a0e254015
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs1204872
milestone43.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1204872 - Add documentation and rename mCaretMode. r=roc Rename mCaretMode to mLastUpdateCaretsMode to make it clear that this variable track the caret mode since last update. This also avoid the confusion that GetCaretMode() returns mCaretMode.
layout/base/AccessibleCaretManager.cpp
layout/base/AccessibleCaretManager.h
--- a/layout/base/AccessibleCaretManager.cpp
+++ b/layout/base/AccessibleCaretManager.cpp
@@ -94,19 +94,19 @@ AccessibleCaretManager::HideCarets()
     DispatchCaretStateChangedEvent(CaretChangedReason::Visibilitychange);
     CancelCaretTimeoutTimer();
   }
 }
 
 void
 AccessibleCaretManager::UpdateCarets(UpdateCaretsHint aHint)
 {
-  mCaretMode = GetCaretMode();
+  mLastUpdateCaretMode = GetCaretMode();
 
-  switch (mCaretMode) {
+  switch (mLastUpdateCaretMode) {
   case CaretMode::None:
     HideCarets();
     break;
   case CaretMode::Cursor:
     UpdateCaretsForCursorMode(aHint);
     break;
   case CaretMode::Selection:
     UpdateCaretsForSelectionMode(aHint);
@@ -397,44 +397,44 @@ AccessibleCaretManager::OnScrollStart()
   AC_LOG("%s", __FUNCTION__);
 
   HideCarets();
 }
 
 void
 AccessibleCaretManager::OnScrollEnd()
 {
-  if (mCaretMode != GetCaretMode()) {
+  if (mLastUpdateCaretMode != GetCaretMode()) {
     return;
   }
 
   if (GetCaretMode() == CaretMode::Cursor) {
     AC_LOG("%s: HideCarets()", __FUNCTION__);
     HideCarets();
   } else {
     AC_LOG("%s: UpdateCarets()", __FUNCTION__);
     UpdateCarets();
   }
 }
 
 void
 AccessibleCaretManager::OnScrollPositionChanged()
 {
-  if (mCaretMode != GetCaretMode()) {
+  if (mLastUpdateCaretMode != GetCaretMode()) {
     return;
   }
 
   AC_LOG("%s: UpdateCarets(RespectOldAppearance)", __FUNCTION__);
   UpdateCarets(UpdateCaretsHint::RespectOldAppearance);
 }
 
 void
 AccessibleCaretManager::OnReflow()
 {
-  if (mCaretMode != GetCaretMode()) {
+  if (mLastUpdateCaretMode != GetCaretMode()) {
     return;
   }
 
   if (mFirstCaret->IsVisuallyVisible() || mSecondCaret->IsVisuallyVisible()) {
     AC_LOG("%s: UpdateCarets()", __FUNCTION__);
     UpdateCarets();
   }
 }
--- a/layout/base/AccessibleCaretManager.h
+++ b/layout/base/AccessibleCaretManager.h
@@ -110,17 +110,20 @@ protected:
     // Update everything including appearance and position.
     Default,
 
     // Update everything while respecting the old appearance. For example, if
     // the caret in cursor mode is hidden due to timeout, do not change its
     // appearance to Normal.
     RespectOldAppearance
   };
+  // Update carets based on current selection status.
   void UpdateCarets(UpdateCaretsHint aHint = UpdateCaretsHint::Default);
+
+  // Force hiding all carets regardless of the current selection status.
   void HideCarets();
 
   void UpdateCaretsForCursorMode(UpdateCaretsHint aHint);
   void UpdateCaretsForSelectionMode(UpdateCaretsHint aHint);
   void UpdateCaretsForTilt();
 
   // Get the nearest enclosing focusable frame of aFrame.
   // @return focusable frame if there is any; nullptr otherwise.
@@ -177,17 +180,21 @@ protected:
 
   // Second caret is used solely in selection mode, and is attached to selection
   // highlight as the right caret.
   UniquePtr<AccessibleCaret> mSecondCaret;
 
   // The caret being pressed or dragged.
   AccessibleCaret* mActiveCaret = nullptr;
 
+  // The timer for hiding the caret in cursor mode after timeout behind the
+  // preference "layout.accessiblecaret.timeout_ms".
   nsCOMPtr<nsITimer> mCaretTimeoutTimer;
-  CaretMode mCaretMode = CaretMode::None;
+
+  // The caret mode since last update carets.
+  CaretMode mLastUpdateCaretMode = CaretMode::None;
 
   static const int32_t kAutoScrollTimerDelay = 30;
 };
 
 } // namespace mozilla
 
 #endif // AccessibleCaretManager_h