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
--- 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) {