Bug 1067243 - Refine the selection reason matching logic to toggle the visibility of selection carets. r=roc
authorpchang <pchang@mozilla.com>
Fri, 26 Sep 2014 15:14:35 +0800
changeset 210687 fff0b523cfc459eace313f02f3f29a388308ac9a
parent 210686 96aefa3026881ae5647664b13fc92f7f9171ad6c
child 210688 95ff64741969a7353b27b1ecc279e0970abc2c50
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersroc
bugs1067243
milestone36.0a1
Bug 1067243 - Refine the selection reason matching logic to toggle the visibility of selection carets. r=roc
layout/base/SelectionCarets.cpp
--- a/layout/base/SelectionCarets.cpp
+++ b/layout/base/SelectionCarets.cpp
@@ -851,17 +851,19 @@ SelectionCarets::NotifySelectionChanged(
                                        int16_t aReason)
 {
   bool isCollapsed;
   aSel->GetIsCollapsed(&isCollapsed);
   if (isCollapsed) {
     SetVisibility(false);
     return NS_OK;
   }
-  if (aReason & nsISelectionListener::KEYPRESS_REASON) {
+  if (!aReason || (aReason & (nsISelectionListener::DRAG_REASON |
+                               nsISelectionListener::KEYPRESS_REASON |
+                               nsISelectionListener::MOUSEDOWN_REASON))) {
     SetVisibility(false);
   } else {
     UpdateSelectionCarets();
   }
   return NS_OK;
 }
 
 static void
@@ -900,17 +902,17 @@ SelectionCarets::AsyncPanZoomStopped(con
 {
   UpdateSelectionCarets();
   DispatchScrollViewChangeEvent(mPresShell, dom::ScrollState::Stopped, aScrollPos);
 }
 
 void
 SelectionCarets::ScrollPositionChanged()
 {
-  if (!mAPZenabled) {
+  if (!mAPZenabled && mVisible) {
     SetVisibility(false);
     //TODO: handling scrolling for selection bubble when APZ is off
     LaunchScrollEndDetector();
   }
 }
 
 void
 SelectionCarets::LaunchLongTapDetector()