browser/devtools/canvasdebugger/panel.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* -*- Mode: javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* vim: set ft=javascript ts=2 et sw=2 tw=80: */
     3 /* This Source Code Form is subject to the terms of the Mozilla Public
     4  * License, v. 2.0. If a copy of the MPL was not distributed with this
     5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 "use strict";
     8 const { Cc, Ci, Cu, Cr } = require("chrome");
     9 const promise = Cu.import("resource://gre/modules/Promise.jsm", {}).Promise;
    10 const EventEmitter = require("devtools/toolkit/event-emitter");
    11 const { CanvasFront } = require("devtools/server/actors/canvas");
    12 const { DevToolsUtils } = Cu.import("resource://gre/modules/devtools/DevToolsUtils.jsm", {});
    14 function CanvasDebuggerPanel(iframeWindow, toolbox) {
    15   this.panelWin = iframeWindow;
    16   this._toolbox = toolbox;
    17   this._destroyer = null;
    19   EventEmitter.decorate(this);
    20 };
    22 exports.CanvasDebuggerPanel = CanvasDebuggerPanel;
    24 CanvasDebuggerPanel.prototype = {
    25   /**
    26    * Open is effectively an asynchronous constructor.
    27    *
    28    * @return object
    29    *         A promise that is resolved when the Canvas Debugger completes opening.
    30    */
    31   open: function() {
    32     let targetPromise;
    34     // Local debugging needs to make the target remote.
    35     if (!this.target.isRemote) {
    36       targetPromise = this.target.makeRemote();
    37     } else {
    38       targetPromise = promise.resolve(this.target);
    39     }
    41     return targetPromise
    42       .then(() => {
    43         this.panelWin.gToolbox = this._toolbox;
    44         this.panelWin.gTarget = this.target;
    45         this.panelWin.gFront = new CanvasFront(this.target.client, this.target.form);
    46         return this.panelWin.startupCanvasDebugger();
    47       })
    48       .then(() => {
    49         this.isReady = true;
    50         this.emit("ready");
    51         return this;
    52       })
    53       .then(null, function onError(aReason) {
    54         DevToolsUtils.reportException("CanvasDebuggerPanel.prototype.open", aReason);
    55       });
    56   },
    58   // DevToolPanel API
    60   get target() this._toolbox.target,
    62   destroy: function() {
    63     // Make sure this panel is not already destroyed.
    64     if (this._destroyer) {
    65       return this._destroyer;
    66     }
    68     return this._destroyer = this.panelWin.shutdownCanvasDebugger().then(() => {
    69       this.emit("destroyed");
    70     });
    71   }
    72 };

mercurial