Bug 1463576 - 2. Add test-only geckoview.selection_action.show_on_focus pref; r=me draft
authorJim Chen <nchen@mozilla.com>
Fri, 01 Jun 2018 13:39:20 -0400
changeset 802939 be5910bda78f73658152274c4831ae681bf8bce5
parent 802938 9c0232d6b15b99610f8e8861eafe478b718c5237
child 802940 ef46c0d2724f9f0053c9cbc44ef578bb943adeb4
push id112001
push userbmo:nchen@mozilla.com
push dateFri, 01 Jun 2018 17:40:20 +0000
reviewersme
bugs1463576
milestone62.0a1
Bug 1463576 - 2. Add test-only geckoview.selection_action.show_on_focus pref; r=me Add the "geckoview.selection_action.show_on_focus" pref for testing only. The pref makes us show selection actions when the selection is initially collapsed in an editor, which makes it easier to test behavior for collapsed selections. MozReview-Commit-ID: 3U6UfzokHaI
mobile/android/chrome/geckoview/GeckoViewSelectionActionContent.js
--- a/mobile/android/chrome/geckoview/GeckoViewSelectionActionContent.js
+++ b/mobile/android/chrome/geckoview/GeckoViewSelectionActionContent.js
@@ -141,17 +141,19 @@ class GeckoViewSelectionActionContent ex
       // For mozcaretstatechanged, "visibilitychange" means the caret is hidden.
       reason = "visibilitychange";
     } else if (!aEvent.collapsed &&
                !aEvent.selectionVisible) {
       reason = "invisibleselection";
     } else if (aEvent.selectionEditable &&
                aEvent.collapsed &&
                reason !== "longpressonemptycontent" &&
-               reason !== "taponcaret") {
+               reason !== "taponcaret" &&
+               !Services.prefs.getBoolPref(
+                   "geckoview.selection_action.show_on_focus", false)) {
       // Don't show selection actions when merely focusing on an editor or
       // repositioning the cursor. Wait until long press or the caret is tapped
       // in order to match Android behavior.
       reason = "visibilitychange";
     }
 
     debug `handleEvent: ${reason}`;
 
@@ -200,20 +202,22 @@ class GeckoViewSelectionActionContent ex
       this._previousMessage = JSON.stringify(msg);
 
       // This event goes to GeckoViewSelectionAction.jsm, where the data is
       // further transformed and then sent to GeckoSession.
       this.eventDispatcher.sendRequest(msg, {
         onSuccess: response => {
           if (response.seqNo !== this._seqNo) {
             // Stale action.
+            warn `Stale response ${response.id}`;
             return;
           }
           let action = actions.find(action => action.id === response.id);
           if (action) {
+            debug `Performing ${response.id}`;
             action.perform.call(this, aEvent, response);
           } else {
             warn `Invalid action ${response.id}`;
           }
         },
         onError: _ => {
           // Do nothing; we can get here if the delegate was just unregistered.
         },