1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 import { GeckoViewActorParent } from "resource://gre/modules/GeckoViewActorParent.sys.mjs";
7 export class SelectionActionDelegateParent extends GeckoViewActorParent {
12 return this.browsingContext.top.currentWindowGlobal.getActor(
13 "SelectionActionDelegate"
17 receiveMessage(aMessage) {
18 const { data, name } = aMessage;
20 case "ShowSelectionAction": {
21 this.rootActor.showSelectionAction(this, data);
25 case "HideSelectionAction": {
26 this.rootActor.hideSelectionAction(this, data.reason);
31 super.receiveMessage(aMessage);
36 hideSelectionAction(aRespondTo, reason) {
37 // Mark previous actions as stale. Don't do this for "invisibleselection"
38 // or "scroll" because previous actions should still be valid even after
39 // these events occur.
40 if (reason !== "invisibleselection" && reason !== "scroll") {
44 this.eventDispatcher?.sendRequest({
45 type: "GeckoView:HideSelectionAction",
50 showSelectionAction(aRespondTo, aData) {
51 this.actionId = Services.uuid.generateUUID().toString();
52 this.respondTo = aRespondTo;
54 this.eventDispatcher?.sendRequest({
55 type: "GeckoView:ShowSelectionAction",
56 actionId: this.actionId,
61 executeSelectionAction(aData) {
62 if (this.actionId === null || aData.actionId != this.actionId) {
63 warn`Stale response ${aData.id} ${aData.actionId}`;
66 this.respondTo.sendAsyncMessage("ExecuteSelectionAction", aData);
70 const { debug, warn } = SelectionActionDelegateParent.initLogging(
71 "SelectionActionDelegate"