B2G/gecko/browser/devtools/tilt/Tilt.jsm
/**
   * Add the browser event listeners to handle state changes.
   * Called from InspectorUI.
   */
Add the browser event listeners to handle state changes.
Add the browser event listeners to handle state changes .
function T_setup()
  {
    if (this._setupFinished) {
      return;
    }
    TiltVisualizer.Prefs.load();
    this.tiltButton.hidden = !this.enabled;
    Services.obs.addObserver(
      this._whenInitializing.bind(this), TILT_NOTIFICATIONS.INITIALIZING, false);
    Services.obs.addObserver(
      this._whenDestroyed.bind(this), TILT_NOTIFICATIONS.DESTROYED, false);
    Services.obs.addObserver(
      this._whenShown.bind(this), TILT_NOTIFICATIONS.SHOWN, false);
    Services.obs.addObserver(
      this._whenHidden.bind(this), TILT_NOTIFICATIONS.HIDDEN, false);
    Services.obs.addObserver(function(aSubject, aTopic, aWinId) {
      this.destroy(aWinId); }.bind(this),
      this.chromeWindow.InspectorUI.INSPECTOR_NOTIFICATIONS.DESTROYED, false);
    this.chromeWindow.gBrowser.tabContainer.addEventListener("TabSelect",
      this._onTabSelect.bind(this), false);
    let onOpened = function() {
      if (this.inspector && this.highlighter && this.currentInstance) {
        this.inspector.stopInspecting();
        this.inspectButton.disabled = true;
        this.highlighter.hide();
      }
    }.bind(this);
    let onClosed = function() {
      if (this.inspector && this.highlighter) {
        this.inspectButton.disabled = false;
        this.highlighter.show();
      }
    }.bind(this);
    Services.obs.addObserver(onOpened,
      this.chromeWindow.InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED, false);
    Services.obs.addObserver(onClosed,
      this.chromeWindow.InspectorUI.INSPECTOR_NOTIFICATIONS.CLOSED, false);
    Services.obs.addObserver(onOpened,
      TILT_NOTIFICATIONS.INITIALIZING, false);
    Services.obs.addObserver(onClosed,
      TILT_NOTIFICATIONS.DESTROYED, false);
    this._setupFinished = true;
  }
function T_setup ( ) { if ( this . _setupFinished ) { return ; } TiltVisualizer . Prefs . load ( ) ; this . tiltButton . hidden = ! this . enabled ; Services . obs . addObserver ( this . _whenInitializing . bind ( this ) , TILT_NOTIFICATIONS . INITIALIZING , false ) ; Services . obs . addObserver ( this . _whenDestroyed . bind ( this ) , TILT_NOTIFICATIONS . DESTROYED , false ) ; Services . obs . addObserver ( this . _whenShown . bind ( this ) , TILT_NOTIFICATIONS . SHOWN , false ) ; Services . obs . addObserver ( this . _whenHidden . bind ( this ) , TILT_NOTIFICATIONS . HIDDEN , false ) ; Services . obs . addObserver ( function ( aSubject , aTopic , aWinId ) { this . destroy ( aWinId ) ; } . bind ( this ) , this . chromeWindow . InspectorUI . INSPECTOR_NOTIFICATIONS . DESTROYED , false ) ; this . chromeWindow . gBrowser . tabContainer . addEventListener ( "TabSelect" , this . _onTabSelect . bind ( this ) , false ) ; let onOpened = function ( ) { if ( this . inspector && this . highlighter && this . currentInstance ) { this . inspector . stopInspecting ( ) ; this . inspectButton . disabled = true ; this . highlighter . hide ( ) ; } } . bind ( this ) ; let onClosed = function ( ) { if ( this . inspector && this . highlighter ) { this . inspectButton . disabled = false ; this . highlighter . show ( ) ; } } . bind ( this ) ; Services . obs . addObserver ( onOpened , this . chromeWindow . InspectorUI . INSPECTOR_NOTIFICATIONS . OPENED , false ) ; Services . obs . addObserver ( onClosed , this . chromeWindow . InspectorUI . INSPECTOR_NOTIFICATIONS . CLOSED , false ) ; Services . obs . addObserver ( onOpened , TILT_NOTIFICATIONS . INITIALIZING , false ) ; Services . obs . addObserver ( onClosed , TILT_NOTIFICATIONS . DESTROYED , false ) ; this . _setupFinished = true ; }
Add the browser event listeners to handle state changes.
Add the browser event listeners to handle state changes .
// load the preferences from the devtools.tilt branch // hide the button in the Inspector toolbar if Tilt is not enabled // add the necessary observers to handle specific notifications // FIXME: this shouldn't be done here, see bug #705131