--- a/mobile/android/chrome/geckoview/GeckoViewSelectionActionContent.js
+++ b/mobile/android/chrome/geckoview/GeckoViewSelectionActionContent.js
@@ -18,88 +18,62 @@ class GeckoViewSelectionActionContent ex
this._seqNo = 0;
this._isActive = false;
this._previousMessage = {};
this._actions = [{
id: "org.mozilla.geckoview.CUT",
predicate: e => !e.collapsed && e.selectionEditable && !this._isPasswordField(e),
- perform: _ => this._domWindowUtils.sendContentCommandEvent("cut"),
+ perform: _ => docShell.doCommand("cmd_cut"),
}, {
id: "org.mozilla.geckoview.COPY",
predicate: e => !e.collapsed && !this._isPasswordField(e),
- perform: _ => this._domWindowUtils.sendContentCommandEvent("copy"),
+ perform: _ => docShell.doCommand("cmd_copy"),
}, {
id: "org.mozilla.geckoview.PASTE",
predicate: e => e.selectionEditable &&
Services.clipboard.hasDataMatchingFlavors(
["text/unicode"], 1, Ci.nsIClipboard.kGlobalClipboard),
- perform: _ => this._domWindowUtils.sendContentCommandEvent("paste"),
+ perform: _ => docShell.doCommand("cmd_paste"),
}, {
id: "org.mozilla.geckoview.DELETE",
predicate: e => !e.collapsed && e.selectionEditable,
- perform: _ => this._domWindowUtils.sendContentCommandEvent("delete"),
+ perform: _ => docShell.doCommand("cmd_delete"),
}, {
id: "org.mozilla.geckoview.COLLAPSE_TO_START",
predicate: e => !e.collapsed && e.selectionEditable,
- perform: e => this._getSelection(e).collapseToStart(),
+ perform: e => docShell.doCommand("cmd_moveLeft"),
}, {
id: "org.mozilla.geckoview.COLLAPSE_TO_END",
predicate: e => !e.collapsed && e.selectionEditable,
- perform: e => this._getSelection(e).collapseToEnd(),
+ perform: e => docShell.doCommand("cmd_moveRight"),
}, {
id: "org.mozilla.geckoview.UNSELECT",
predicate: e => !e.collapsed && !e.selectionEditable,
- perform: e => this._getSelection(e).removeAllRanges(),
+ perform: e => docShell.doCommand("cmd_selectNone"),
}, {
id: "org.mozilla.geckoview.SELECT_ALL",
predicate: e => e.reason !== "longpressonemptycontent",
- perform: e => this._getSelectionController(e).selectAll(),
+ perform: e => docShell.doCommand("cmd_selectAll"),
}];
}
- get _domWindowUtils() {
- return content.QueryInterface(Ci.nsIInterfaceRequestor)
- .getInterface(Ci.nsIDOMWindowUtils);
- }
-
_isPasswordField(aEvent) {
if (!aEvent.selectionEditable) {
return false;
}
const win = aEvent.target.defaultView;
const focus = aEvent.target.activeElement;
return win && win.HTMLInputElement &&
focus instanceof win.HTMLInputElement &&
!focus.mozIsTextField(/* excludePassword */ true);
}
- _getSelectionController(aEvent) {
- if (aEvent.selectionEditable) {
- const focus = aEvent.target.activeElement;
- if (focus instanceof Ci.nsIDOMNSEditableElement && focus.editor) {
- return focus.editor.selectionController;
- }
- }
-
- return aEvent.target.defaultView
- .QueryInterface(Ci.nsIInterfaceRequestor)
- .getInterface(Ci.nsIDocShell)
- .QueryInterface(Ci.nsIInterfaceRequestor)
- .getInterface(Ci.nsISelectionDisplay)
- .QueryInterface(Ci.nsISelectionController);
- }
-
- _getSelection(aEvent) {
- return this._getSelectionController(aEvent)
- .getSelection(Ci.nsISelectionController.SELECTION_NORMAL);
- }
-
_getFrameOffset(aEvent) {
// Get correct offset in case of nested iframe.
const offset = {
left: 0,
top: 0,
};
let currentWindow = aEvent.target.defaultView;