Bug 697762 - Land the debugger in m-c (Part 1); r=msucan
authorPanos Astithas <past@mozilla.com>
Wed, 04 Jan 2012 21:12:31 +0200
changeset 80213 8a01a89f3eaa6c377213bf96f1570b4aa84c1e40
parent 80212 90200db603e608b44ffc88b20ef9ed7708a26b07
child 80214 2975bd4a74bc7932407e9a773b7e7d9489b5e9e0
push id86
push userpastithas@mozilla.com
push dateWed, 04 Jan 2012 19:15:37 +0000
reviewersmsucan
bugs697762
milestone11.0a1
Bug 697762 - Land the debugger in m-c (Part 1); r=msucan
browser/devtools/debugger/debugger-view.js
browser/devtools/debugger/debugger.js
browser/makefiles.sh
toolkit/devtools/debugger/server/dbg-server.js
toolkit/toolkit-makefiles.sh
--- a/browser/devtools/debugger/debugger-view.js
+++ b/browser/devtools/debugger/debugger-view.js
@@ -241,17 +241,16 @@ DebuggerView.Stackframes = {
   _onFramesClick: null,
 
   /**
    * Listener handling the stackframes container scroll event.
    */
   _onFramesScroll: function DVF__onFramesScroll(e) {
     // update the stackframes container only if we have to
     if (this._dirty) {
-
       let clientHeight = this._frames.clientHeight;
       let scrollTop = this._frames.scrollTop;
       let scrollHeight = this._frames.scrollHeight;
 
       // if the stackframes container was scrolled past 95% of the height,
       // load more content
       if (scrollTop >= (scrollHeight - clientHeight) * 0.95) {
         this._dirty = false;
@@ -330,20 +329,21 @@ DebuggerView.Properties = {
 
   /**
    * Adds a scope to contain any inspected variables.
    * If the optional id is not specified, the scope html node will have a
    * default id set as aName-scope.
    *
    * @param string aName
    *        The scope name (e.g. "Local", "Global" or "With block").
-   * @paarm string aId
+   * @param string aId
    *        Optional, an id for the scope html node.
    * @return object
-   *         The newly created html node representing the added scope.
+   *         The newly created html node representing the added scope or null
+   *         if a node was not created.
    */
   _addScope: function DVP__addScope(aName, aId) {
     // make sure the parent container exists
     if (!this._vars) {
       return null;
     }
 
     // compute the id of the element if not specified
@@ -371,17 +371,17 @@ DebuggerView.Properties = {
    * Adds a variable to a specified scope.
    * If the optional id is not specified, the variable html node will have a
    * default id set as aScope.id->aName-variable.
    *
    * @param object aScope
    *        The parent scope element.
    * @param string aName
    *        The variable name.
-   * @paarm string aId
+   * @param string aId
    *        Optional, an id for the variable html node.
    * @return object
    *         The newly created html node representing the added var.
    */
   _addVar: function DVP__addVar(aScope, aName, aId) {
     // make sure the scope container exists
     if (!aScope) {
       return null;
@@ -692,17 +692,17 @@ DebuggerView.Properties = {
 
   /**
    * Creates an element which contains generic nodes and functionality used by
    * any scope, variable or property added to the tree.
    *
    * @param string aName
    *        A generic name used in a title strip.
    * @param string aId
-   *        Obligatory id used by the created element node.
+   *        id used by the created element node.
    * @param string aClass
    *        Recommended style class used by the created element node.
    * @param object aParent
    *        The parent node which will contain the element.
    * @return object
    *         The newly created html node representing the generic elem.
    */
   _createPropertyElement: function DVP__createPropertyElement(aName, aId, aClass, aParent) {
--- a/browser/devtools/debugger/debugger.js
+++ b/browser/devtools/debugger/debugger.js
@@ -84,16 +84,20 @@ function startDebuggingTab(aClient, aTab
       });
     }
   });
 }
 
 function shutdownDebugger()
 {
   window.removeEventListener("unload", shutdownDebugger, false);
+
+  SourceScripts.disconnect();
+  StackFrames.disconnect();
+  ThreadState.disconnect();
   ThreadState.activeThread = false;
 
   DebuggerView.Stackframes.destroy();
   DebuggerView.Properties.destroy();
   DebuggerView.Scripts.destroy();
 }
 
 
@@ -124,16 +128,25 @@ var ThreadState = {
    * Update the UI after a thread state change.
    */
   update: function TS_update(aEvent) {
     DebuggerView.Stackframes.updateState(this.activeThread.state);
     if (aEvent == "detached") {
       ThreadState.activeThread = false;
     }
   },
+
+  /**
+   * Disconnect from the client.
+   */
+  disconnect: function TS_disconnect() {
+    this.activeThread.removeListener("paused", ThreadState.update);
+    this.activeThread.removeListener("resumed", ThreadState.update);
+    this.activeThread.removeListener("detached", ThreadState.update);
+  }
 };
 
 ThreadState.update = ThreadState.update.bind(ThreadState);
 
 /**
  * Keeps the stack frame list up-to-date, using the thread client's
  * stack frame cache.
  */
@@ -155,16 +168,25 @@ var StackFrames = {
     this.activeThread = aThreadClient;
     aThreadClient.addListener("paused", this.onPaused);
     aThreadClient.addListener("framesadded", this.onFrames);
     aThreadClient.addListener("framescleared", this.onFramesCleared);
     this.onFramesCleared();
     aCallback && aCallback();
   },
 
+  /**
+   * Disconnect from the client.
+   */
+  disconnect: function TS_disconnect() {
+    this.activeThread.removeListener("paused", this.onPaused);
+    this.activeThread.removeListener("framesadded", this.onFrames);
+    this.activeThread.removeListener("framescleared", this.onFramesCleared);
+  },
+
   onPaused: function SF_onPaused() {
     this.activeThread.fillFrames(this.pageSize);
   },
 
   /**
    * Handler for the thread client's framesadded notification.
    */
   onFrames: function SF_onFrames() {
@@ -365,16 +387,25 @@ var SourceScripts = {
     this.activeThread = aThreadClient;
     aThreadClient.addListener("paused", this.onPaused);
     aThreadClient.addListener("scriptsadded", this.onScripts);
     aThreadClient.addListener("scriptscleared", this.onScriptsCleared);
     this.onScriptsCleared();
     aCallback && aCallback();
   },
 
+  /**
+   * Disconnect from the client.
+   */
+  disconnect: function TS_disconnect() {
+    this.activeThread.removeListener("paused", this.onPaused);
+    this.activeThread.removeListener("scriptsadded", this.onScripts);
+    this.activeThread.removeListener("scriptscleared", this.onScriptsCleared);
+  },
+
   onPaused: function SS_onPaused() {
     this.activeThread.fillScripts();
   },
 
   /**
    * Handler for the debugger client's unsolicited newScript notification.
    */
   onNewScript: function SS_onNewScript(aNotification, aPacket) {
--- a/browser/makefiles.sh
+++ b/browser/makefiles.sh
@@ -59,16 +59,17 @@ browser/components/safebrowsing/Makefile
 browser/components/search/Makefile
 browser/components/sessionstore/Makefile
 browser/components/sessionstore/src/Makefile
 browser/components/sidebar/src/Makefile
 browser/components/shell/Makefile
 browser/components/shell/public/Makefile
 browser/components/shell/src/Makefile
 browser/components/wintaskbar/Makefile
+browser/devtools/debugger/Makefile
 browser/fuel/Makefile
 browser/fuel/public/Makefile
 browser/fuel/src/Makefile
 browser/installer/Makefile
 browser/installer/windows/Makefile
 browser/locales/Makefile
 browser/themes/Makefile
 browser/themes/pinstripe/browser/Makefile
@@ -94,11 +95,12 @@ if [ "$ENABLE_TESTS" ]; then
     browser/components/feeds/test/chrome/Makefile
     browser/components/places/tests/Makefile
     browser/components/places/tests/chrome/Makefile
     browser/components/places/tests/browser/Makefile
     browser/components/privatebrowsing/test/Makefile
     browser/components/privatebrowsing/test/browser/Makefile
     browser/components/safebrowsing/content/test/Makefile
     browser/components/wintaskbar/test/Makefile
+    browser/devtools/debugger/test/Makefile
     browser/fuel/test/Makefile
   "
 fi
--- a/toolkit/devtools/debugger/server/dbg-server.js
+++ b/toolkit/devtools/debugger/server/dbg-server.js
@@ -336,56 +336,56 @@ function DebuggerServerConnection(aPrefi
 
 DebuggerServerConnection.prototype = {
   _prefix: null,
   get prefix() { return this._prefix },
 
   _transport: null,
   get transport() { return this._transport },
 
-  send: function(aPacket) {
+  send: function DSC_send(aPacket) {
     this.transport.send(aPacket);
   },
 
-  allocID: function(aPrefix) {
-    return this.prefix + (aPrefix ? aPrefix : '') + this._nextID++;
+  allocID: function DSC_allocID(aPrefix) {
+    return this.prefix + (aPrefix || '') + this._nextID++;
   },
 
   /**
    * Add a map of actor IDs to the connection.
    */
-  addActorPool: function(aActorPool) {
+  addActorPool: function DSC_addActorPool(aActorPool) {
     this._extraPools.push(aActorPool);
   },
 
   /**
    * Remove a previously-added pool of actors to the connection.
    */
-  removeActorPool: function(aActorPool) {
+  removeActorPool: function DSC_removeActorPool(aActorPool) {
     let index = this._extraPools.splice(this._extraPools.lastIndexOf(aActorPool), 1);
   },
 
   /**
    * Add an actor to the default actor pool for this connection.
    */
-  addActor: function(aActor) {
+  addActor: function DSC_addActor(aActor) {
     this._actorPool.addActor(aActor);
   },
 
   /**
    * Remove an actor to the default actor pool for this connection.
    */
-  removeActor: function(aActor) {
+  removeActor: function DSC_removeActor(aActor) {
     this._actorPool.removeActor(aActor);
   },
 
   /**
    * Add a cleanup to the default actor pool for this connection.
    */
-  addCleanup: function(aCleanup) {
+  addCleanup: function DSC_addCleanup(aCleanup) {
     this._actorPool.addCleanup(aCleanup);
   },
 
   /**
    * Look up an actor implementation for an actorID.  Will search
    * all the actor pools registered with the connection.
    *
    * @param aActorID string
@@ -406,17 +406,17 @@ DebuggerServerConnection.prototype = {
       return this.rootActor;
     }
 
     return null;
   },
 
   // Transport hooks.
 
-  onPacket: function(aPacket) {
+  onPacket: function DSC_onPacket(aPacket) {
     let actor = this.getActor(aPacket.to);
     if (!actor) {
       this.transport.send({ from: aPacket.to ? aPacket.to : "root",
                             error: "noSuchActor" });
       return;
     }
 
     var ret = null;
@@ -443,17 +443,17 @@ DebuggerServerConnection.prototype = {
 
     if (!ret.from) {
       ret.from = aPacket.to;
     }
 
     this.transport.send(ret);
   },
 
-  onClosed: function() {
+  onClosed: function DSC_onClosed() {
     dumpn("Cleaning up connection.");
 
     this._actorPool.cleanup();
     this._actorPool = null;
     this._extraPools.map(function(p) { p.cleanup(); });
     this._extraPools = null;
 
     DebuggerServer._connectionClosed(this);
--- a/toolkit/toolkit-makefiles.sh
+++ b/toolkit/toolkit-makefiles.sh
@@ -628,16 +628,17 @@ MAKEFILES_xulapp="
   toolkit/components/startup/Makefile
   toolkit/components/startup/public/Makefile
   toolkit/components/statusfilter/Makefile
   toolkit/components/typeaheadfind/Makefile
   toolkit/components/url-classifier/Makefile
   toolkit/components/urlformatter/Makefile
   toolkit/components/viewconfig/Makefile
   toolkit/components/viewsource/Makefile
+  toolkit/devtools/Makefile
   toolkit/locales/Makefile
   toolkit/mozapps/downloads/Makefile
   toolkit/mozapps/extensions/Makefile
   toolkit/mozapps/handling/Makefile
   toolkit/mozapps/plugins/Makefile
   toolkit/mozapps/readstrings/Makefile
   toolkit/mozapps/update/Makefile
   toolkit/mozapps/update/updater/Makefile