Bug 1451627 - Don't use SelectionActionDelegate in Fennec; r?esawin draft
authorJim Chen <nchen@mozilla.com>
Mon, 09 Apr 2018 10:13:02 -0400
changeset 779227 e440644b368cf6b24f220c35d4f132280d55f8aa
parent 779226 c5fe0822a55a53ed45ac771042262c0489748f9c
child 779231 4c8e7d0091a54b3785f9c1572fbd38c689aa8fe1
push id105706
push userbmo:nchen@mozilla.com
push dateMon, 09 Apr 2018 14:15:23 +0000
reviewersesawin
bugs1451627
milestone61.0a1
Bug 1451627 - Don't use SelectionActionDelegate in Fennec; r?esawin Prevent the mozcaretstatechanged event from reaching GeckoViewSelectionActionContent.js in Fennec, because ActionBarHandler.jsm already handles the event for Fennec. MozReview-Commit-ID: GoLhfz4qrtM
mobile/android/chrome/geckoview/GeckoViewSelectionActionContent.js
mobile/android/geckoview/src/main/java/org/mozilla/geckoview/BasicSelectionActionDelegate.java
mobile/android/modules/ActionBarHandler.jsm
--- a/mobile/android/chrome/geckoview/GeckoViewSelectionActionContent.js
+++ b/mobile/android/chrome/geckoview/GeckoViewSelectionActionContent.js
@@ -125,22 +125,22 @@ class GeckoViewSelectionActionContent ex
       }
     }
 
     return offset;
   }
 
   register() {
     debug("register");
-    addEventListener("mozcaretstatechanged", this);
+    addEventListener("mozcaretstatechanged", this, { mozSystemGroup: true });
   }
 
   unregister() {
     debug("unregister");
-    removeEventListener("mozcaretstatechanged", this);
+    removeEventListener("mozcaretstatechanged", this, { mozSystemGroup: true });
   }
 
   /**
    * Receive and act on AccessibleCarets caret state-change
    * (mozcaretstatechanged) events.
    */
   handleEvent(aEvent) {
     let reason = aEvent.reason;
--- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/BasicSelectionActionDelegate.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/BasicSelectionActionDelegate.java
@@ -128,16 +128,19 @@ public class BasicSelectionActionDelegat
 
     /**
      * Perform the specified action. Override to perform custom actions.
      *
      * @param id Action ID.
      * @return True if the action was performed.
      */
     protected boolean performAction(final String id) {
+        if (mResponse == null) {
+            return false;
+        }
         mResponse.respond(id);
 
         // Android behavior is to clear selection on copy.
         if (ACTION_COPY.equals(id)) {
             if (mUseFloatingToolbar) {
                 clearSelection();
             } else {
                 mActionMode.finish();
--- a/mobile/android/modules/ActionBarHandler.jsm
+++ b/mobile/android/modules/ActionBarHandler.jsm
@@ -45,16 +45,18 @@ var ActionBarHandler = {
   _boundingClientRect: null, // Current selections boundingClientRect.
   _actionBarActions: null, // Most-recent set of actions sent to ActionBar.
 
   /**
    * Receive and act on AccessibleCarets caret state-change
    * (mozcaretstatechanged) events.
    */
   handleEvent: function(e) {
+    e.stopImmediatePropagation();
+
     // Close an open ActionBar, if carets no longer logically visible.
     if (this._selectionID && !e.caretVisible) {
       this._uninit(false);
       return;
     }
 
     if (!this._selectionID && e.collapsed) {
       switch (e.reason) {