B2G/gecko/browser/devtools/shared/DeveloperToolbar.jsm
/**
 * Panel to handle tooltips.
 *
 * There is a tooltip bug on Windows and OSX that prevents tooltips from being
 * positioned properly (bug 786975). There is a Gnome panel bug on Linux that
 * causes ugly focus issues (https://bugzilla.gnome.org/show_bug.cgi?id=621848).
 * We now use a tooltip on Linux and a panel on OSX & Windows.
 *
 * If a panel has no content and no height it is not shown when openPopup is
 * called on Windows and OSX (bug 692348) ... this prevents the panel from
 * appearing the first time it is shown. Setting the panel's height to 1px
 * before calling openPopup works around this issue as we resize it ourselves
 * anyway.
 *
 * @param aChromeDoc document from which we can pull the parts we need.
 * @param aInput the input element that should get focus.
 * @param aLoadCallback called when the panel is loaded properly.
 */
Panel to handle tooltips.
There is a tooltip bug on Windows and OSX that prevents tooltips from being
positioned properly (bug 786975). There is a Gnome panel bug on Linux that
causes ugly focus issues .
We now use a tooltip on Linux and a panel on OSX & Windows.

If a panel has no content and no height it is not shown when openPopup is
called on Windows and OSX (bug 692348) ... this prevents the panel from
appearing the first time it is shown. Setting the panel's height to 1px
before calling openPopup works around this issue as we resize it ourselves
anyway.

@param aChromeDoc document from which we can pull the parts we need.
@param aInput the input element that should get focus.
@param aLoadCallback called when the panel is loaded properly.
Panel to handle tooltips . There is a tooltip bug on Windows and OSX that prevents tooltips from being positioned properly ( bug 786975 ) . There is a Gnome panel bug on Linux that causes ugly focus issues . We now use a tooltip on Linux and a panel on OSX & Windows . If a panel has no content and no height it is not shown when openPopup is called on Windows and OSX ( bug 692348 ) ... this prevents the panel from appearing the first time it is shown . Setting the panel ' s height to 1px before calling openPopup works around this issue as we resize it ourselves anyway . @param aChromeDoc document from which we can pull the parts we need . @param aInput the input element that should get focus . @param aLoadCallback called when the panel is loaded properly .
function TooltipPanel(aChromeDoc, aInput, aLoadCallback)
{
  this._input = aInput;
  this._toolbar = aChromeDoc.getElementById("developer-toolbar");
  this._dimensions = { start: 0, end: 0 };
  this._onload = this._onload.bind(this);
  this._loadCallback = aLoadCallback;
  this._panel = aChromeDoc.createElement(isLinux ? "tooltip" : "panel");
  this._panel.id = "gcli-tooltip";
  this._panel.classList.add("gcli-panel");
  if (isLinux) {
    this.canHide = false;
    this._onpopuphiding = this._onpopuphiding.bind(this);
    this._panel.addEventListener("popuphiding", this._onpopuphiding, true);
  } else {
    this._panel.setAttribute("noautofocus", "true");
    this._panel.setAttribute("noautohide", "true");
    this._panel.setAttribute("height", "1px");
  }
  this._toolbar.parentElement.insertBefore(this._panel, this._toolbar);
  this._frame = aChromeDoc.createElementNS(NS_XHTML, "iframe");
  this._frame.id = "gcli-tooltip-frame";
  this._frame.setAttribute("src", "chrome://browser/content/devtools/commandlinetooltip.xhtml");
  this._frame.setAttribute("flex", "1");
  this._frame.setAttribute("sandbox", "allow-same-origin");
  this._panel.appendChild(this._frame);
  this._frame.addEventListener("load", this._onload, true);
  this.loaded = false;
}
function TooltipPanel ( aChromeDoc , aInput , aLoadCallback ) { this . _input = aInput ; this . _toolbar = aChromeDoc . getElementById ( "developer-toolbar" ) ; this . _dimensions = { start : 0 , end : 0 } ; this . _onload = this . _onload . bind ( this ) ; this . _loadCallback = aLoadCallback ; this . _panel = aChromeDoc . createElement ( isLinux ? "tooltip" : "panel" ) ; this . _panel . id = "gcli-tooltip" ; this . _panel . classList . add ( "gcli-panel" ) ; if ( isLinux ) { this . canHide = false ; this . _onpopuphiding = this . _onpopuphiding . bind ( this ) ; this . _panel . addEventListener ( "popuphiding" , this . _onpopuphiding , true ) ; } else { this . _panel . setAttribute ( "noautofocus" , "true" ) ; this . _panel . setAttribute ( "noautohide" , "true" ) ; this . _panel . setAttribute ( "height" , "1px" ) ; } this . _toolbar . parentElement . insertBefore ( this . _panel , this . _toolbar ) ; this . _frame = aChromeDoc . createElementNS ( NS_XHTML , "iframe" ) ; this . _frame . id = "gcli-tooltip-frame" ; this . _frame . setAttribute ( "src" , "chrome://browser/content/devtools/commandlinetooltip.xhtml" ) ; this . _frame . setAttribute ( "flex" , "1" ) ; this . _frame . setAttribute ( "sandbox" , "allow-same-origin" ) ; this . _panel . appendChild ( this . _frame ) ; this . _frame . addEventListener ( "load" , this . _onload , true ) ; this . loaded = false ; }
Panel to handle tooltips.
Panel to handle tooltips .
/*
  <tooltip|panel id="gcli-tooltip"
         type="arrow"
         noautofocus="true"
         noautohide="true"
         class="gcli-panel">
    <html:iframe xmlns:html="http://www.w3.org/1999/xhtml"
                 id="gcli-tooltip-frame"
                 src="chrome://browser/content/devtools/commandlinetooltip.xhtml"
                 flex="1"
                 sandbox="allow-same-origin"/>
  </tooltip|panel>
  */ // TODO: Switch back from tooltip to panel when metacity focus issue is fixed: // https://bugzilla.mozilla.org/show_bug.cgi?id=780102 // Bug 692348: On Windows and OSX if a panel has no content and no height // openPopup fails to display it. Setting the height to 1px alows the panel // to be displayed before has content or a real height i.e. the first time // it is displayed.