Backed out changeset b71c8c052463 (bug 1943846) for causing mass failures. CLOSED...
[gecko.git] / devtools / client / fronts / highlighters.js
blobb1e159e5fc02e09b75654e92200dd898acc220aa
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 "use strict";
7 const {
8 FrontClassWithSpec,
9 registerFront,
10 } = require("resource://devtools/shared/protocol.js");
11 const {
12 customHighlighterSpec,
13 } = require("resource://devtools/shared/specs/highlighters.js");
14 const {
15 safeAsyncMethod,
16 } = require("resource://devtools/shared/async-utils.js");
18 class CustomHighlighterFront extends FrontClassWithSpec(customHighlighterSpec) {
19 constructor(client, targetFront, parentFront) {
20 super(client, targetFront, parentFront);
22 // show/hide requests can be triggered while DevTools are closing.
23 this.show = safeAsyncMethod(this.show.bind(this), () => this.isDestroyed());
24 this.hide = safeAsyncMethod(this.hide.bind(this), () => this.isDestroyed());
26 this._isShown = false;
29 show(...args) {
30 this._isShown = true;
31 return super.show(...args);
34 hide() {
35 this._isShown = false;
36 return super.hide();
39 isShown() {
40 return this._isShown;
43 destroy() {
44 if (this.isDestroyed()) {
45 return;
47 super.finalize(); // oneway call, doesn't expect a response.
48 super.destroy();
52 exports.CustomHighlighterFront = CustomHighlighterFront;
53 registerFront(CustomHighlighterFront);