summaryrefslogtreecommitdiffstats
path: root/mobile/android/actors/GeckoViewPrintDelegateParent.sys.mjs
blob: db2edf652b3290b92a0d60e63653c11bc80a62a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

import { GeckoViewActorParent } from "resource://gre/modules/GeckoViewActorParent.sys.mjs";

export class GeckoViewPrintDelegateParent extends GeckoViewActorParent {
  constructor() {
    super();
    this._browserStaticClone = null;
  }

  set browserStaticClone(staticClone) {
    this._browserStaticClone = staticClone;
  }

  get browserStaticClone() {
    return this._browserStaticClone;
  }

  clearStaticClone() {
    // Removes static browser element from DOM that was made for window.print
    this.browserStaticClone?.remove();
    this.browserStaticClone = null;
  }

  printRequest() {
    if (this.browserStaticClone != null) {
      this.eventDispatcher.sendRequest({
        type: "GeckoView:DotPrintRequest",
        canonicalBrowsingContextId: this.browserStaticClone.browsingContext.id,
      });
    }
  }
}