Bug 1339797 - Fix select-all events fired by touch incorrectly hide the carets. r?mtseng draft
authorTing-Yu Lin <tlin@mozilla.com>
Fri, 17 Feb 2017 14:08:48 +0800
changeset 485793 ac3c65dd04a110805312d0e5ca612e76bcdee3fa
parent 485692 6cefe01ca7744d6ac3960c69eac833e2e65f7f8f
child 546122 59bad34d028571753922a83b763b6f1ca6edb08a
push id45849
push userbmo:tlin@mozilla.com
push dateFri, 17 Feb 2017 07:05:00 +0000
reviewersmtseng
bugs1339797
milestone54.0a1
Bug 1339797 - Fix select-all events fired by touch incorrectly hide the carets. r?mtseng sHideCaretsForMouseInput is default to true on all platforms. When clicking "SELECT ALL" on Fennec toolbar in <input>, AccessibleCaretManager will receive SELECTALL_REASON with MOZ_SOURCE_TOUCH. We should hide the carets only if the select-all reason is fired by keyboard, not by touch. MozReview-Commit-ID: D7FYIH5ZGS0
layout/base/AccessibleCaretManager.cpp
--- a/layout/base/AccessibleCaretManager.cpp
+++ b/layout/base/AccessibleCaretManager.cpp
@@ -191,19 +191,20 @@ AccessibleCaretManager::OnSelectionChang
 
   // For mouse input we don't want to show the carets.
   if (sHideCaretsForMouseInput &&
       mLastInputSource == nsIDOMMouseEvent::MOZ_SOURCE_MOUSE) {
     HideCarets();
     return NS_OK;
   }
 
-  // No need to show the carets for select all action when we want to hide
-  // the carets for mouse input.
+  // When we want to hide the carets for mouse input, hide them for select
+  // all action fired by keyboard as well.
   if (sHideCaretsForMouseInput &&
+      mLastInputSource == nsIDOMMouseEvent::MOZ_SOURCE_KEYBOARD &&
       (aReason & nsISelectionListener::SELECTALL_REASON)) {
     HideCarets();
     return NS_OK;
   }
 
   UpdateCarets();
   return NS_OK;
 }