B2G/gecko/browser/devtools/webconsole/HUDService.jsm
/**
   * Create a panel to open the web console if it should float above
   * the content in its own window.
   * @private
   */
Create a panel to open the web console if it should float above
the content in its own window.
@private
Create a panel to open the web console if it should float above the content in its own window . @private
function WC__createOwnWindowPanel()
  {
    if (this.consolePanel) {
      return;
    }
    let width = 0;
    try {
      width = Services.prefs.getIntPref("devtools.webconsole.width");
    }
    catch (ex) {}
    if (width < 1) {
      width = this.iframe.clientWidth || this.chromeWindow.innerWidth;
    }
    let height = this.iframe.clientHeight;
    let top = 0;
    try {
      top = Services.prefs.getIntPref("devtools.webconsole.top");
    }
    catch (ex) {}
    let left = 0;
    try {
      left = Services.prefs.getIntPref("devtools.webconsole.left");
    }
    catch (ex) {}
    let panel = this.chromeDocument.createElementNS(XUL_NS, "panel");
    let config = { id: "console_window_" + this.hudId,
                   label: this.getPanelTitle(),
                   titlebar: "normal",
                   noautohide: "true",
                   norestorefocus: "true",
                   close: "true",
                   flex: "1",
                   hudId: this.hudId,
                   width: width,
                   position: "overlap",
                   top: top,
                   left: left,
                 };
    for (let attr in config) {
      panel.setAttribute(attr, config[attr]);
    }
    panel.classList.add("web-console-panel");
    let onPopupShown = (function HUD_onPopupShown() {
      panel.removeEventListener("popupshown", onPopupShown, false);
      let height = panel.clientHeight;
      this.iframe.style.height = "auto";
      this.iframe.flex = 1;
      panel.setAttribute("height", height);
    }).bind(this);
    panel.addEventListener("popupshown", onPopupShown,false);
    let onPopupHidden = (function HUD_onPopupHidden(aEvent) {
      if (aEvent.target != panel) {
        return;
      }
      panel.removeEventListener("popuphidden", onPopupHidden, false);
      let width = 0;
      try {
        width = Services.prefs.getIntPref("devtools.webconsole.width");
      }
      catch (ex) { }
      if (width > 0) {
        Services.prefs.setIntPref("devtools.webconsole.width", panel.clientWidth);
      }
      if (this.consoleWindowUnregisterOnHide) {
        HUDService.deactivateHUDForContext(this.tab, false);
      }
    }).bind(this);
    panel.addEventListener("popuphidden", onPopupHidden, false);
    let lastIndex = -1;
    if (this.outputNode && this.outputNode.getIndexOfFirstVisibleRow) {
      lastIndex = this.outputNode.getIndexOfFirstVisibleRow() +
                  this.outputNode.getNumberOfVisibleRows() - 1;
    }
    if (this.splitter.parentNode) {
      this.splitter.parentNode.removeChild(this.splitter);
    }
    this._beforePositionConsole("window", lastIndex);
    panel.appendChild(this.iframe);
    let space = this.chromeDocument.createElement("spacer");
    space.flex = 1;
    let bottomBox = this.chromeDocument.createElement("hbox");
    let resizer = this.chromeDocument.createElement("resizer");
    resizer.setAttribute("dir", "bottomend");
    resizer.setAttribute("element", config.id);
    bottomBox.appendChild(space);
    bottomBox.appendChild(resizer);
    panel.appendChild(bottomBox);
    this.mainPopupSet.appendChild(panel);
    panel.openPopup(null, "overlay", left, top, false, false);
    this.consolePanel = panel;
    this.consoleWindowUnregisterOnHide = true;
  }
function WC__createOwnWindowPanel ( ) { if ( this . consolePanel ) { return ; } let width = 0 ; try { width = Services . prefs . getIntPref ( "devtools.webconsole.width" ) ; } catch ( ex ) { } if ( width < 1 ) { width = this . iframe . clientWidth || this . chromeWindow . innerWidth ; } let height = this . iframe . clientHeight ; let top = 0 ; try { top = Services . prefs . getIntPref ( "devtools.webconsole.top" ) ; } catch ( ex ) { } let left = 0 ; try { left = Services . prefs . getIntPref ( "devtools.webconsole.left" ) ; } catch ( ex ) { } let panel = this . chromeDocument . createElementNS ( XUL_NS , "panel" ) ; let config = { id : "console_window_" + this . hudId , label : this . getPanelTitle ( ) , titlebar : "normal" , noautohide : "true" , norestorefocus : "true" , close : "true" , flex : "1" , hudId : this . hudId , width : width , position : "overlap" , top : top , left : left , } ; for ( let attr in config ) { panel . setAttribute ( attr , config [ attr ] ) ; } panel . classList . add ( "web-console-panel" ) ; let onPopupShown = ( function HUD_onPopupShown ( ) { panel . removeEventListener ( "popupshown" , onPopupShown , false ) ; let height = panel . clientHeight ; this . iframe . style . height = "auto" ; this . iframe . flex = 1 ; panel . setAttribute ( "height" , height ) ; } ) . bind ( this ) ; panel . addEventListener ( "popupshown" , onPopupShown , false ) ; let onPopupHidden = ( function HUD_onPopupHidden ( aEvent ) { if ( aEvent . target != panel ) { return ; } panel . removeEventListener ( "popuphidden" , onPopupHidden , false ) ; let width = 0 ; try { width = Services . prefs . getIntPref ( "devtools.webconsole.width" ) ; } catch ( ex ) { } if ( width > 0 ) { Services . prefs . setIntPref ( "devtools.webconsole.width" , panel . clientWidth ) ; } if ( this . consoleWindowUnregisterOnHide ) { HUDService . deactivateHUDForContext ( this . tab , false ) ; } } ) . bind ( this ) ; panel . addEventListener ( "popuphidden" , onPopupHidden , false ) ; let lastIndex = - 1 ; if ( this . outputNode && this . outputNode . getIndexOfFirstVisibleRow ) { lastIndex = this . outputNode . getIndexOfFirstVisibleRow ( ) + this . outputNode . getNumberOfVisibleRows ( ) - 1 ; } if ( this . splitter . parentNode ) { this . splitter . parentNode . removeChild ( this . splitter ) ; } this . _beforePositionConsole ( "window" , lastIndex ) ; panel . appendChild ( this . iframe ) ; let space = this . chromeDocument . createElement ( "spacer" ) ; space . flex = 1 ; let bottomBox = this . chromeDocument . createElement ( "hbox" ) ; let resizer = this . chromeDocument . createElement ( "resizer" ) ; resizer . setAttribute ( "dir" , "bottomend" ) ; resizer . setAttribute ( "element" , config . id ) ; bottomBox . appendChild ( space ) ; bottomBox . appendChild ( resizer ) ; panel . appendChild ( bottomBox ) ; this . mainPopupSet . appendChild ( panel ) ; panel . openPopup ( null , "overlay" , left , top , false , false ) ; this . consolePanel = panel ; this . consoleWindowUnregisterOnHide = true ; }
Create a panel to open the web console if it should float above
 the content in its own window.
Create a panel to open the web console if it should float above the content in its own window .
// Make sure that the HUDBox size updates when the panel is resized. // Are we destroying the HUD or repositioning it?