Bug 757278 - Handle positions are not saved.; r=rcampbell
authorVictor Porof <vporof@mozilla.com>
Thu, 31 May 2012 12:27:22 +0300
changeset 97652 fd4ff7253be8d58c627d3f54e64b79af63acdf92
parent 97651 9448caa01cf35f401cf0df93e5c8126f61021600
child 97653 96a7cf29e58881f9a53f869d8e3e3f76e4a9c081
push idunknown
push userunknown
push dateunknown
reviewersrcampbell
bugs757278
milestone15.0a1
Bug 757278 - Handle positions are not saved.; r=rcampbell
browser/app/profile/firefox.js
browser/devtools/debugger/debugger-controller.js
browser/devtools/debugger/debugger-view.js
browser/devtools/debugger/debugger.xul
browser/devtools/debugger/test/Makefile.in
browser/devtools/debugger/test/browser_dbg_panesize-inner.js
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -1043,20 +1043,22 @@ pref("devtools.layoutview.open", false);
 pref("devtools.debugger.enabled", true);
 pref("devtools.debugger.remote-enabled", false);
 pref("devtools.debugger.remote-host", "localhost");
 pref("devtools.debugger.remote-port", 6000);
 pref("devtools.debugger.remote-autoconnect", false);
 pref("devtools.debugger.remote-connection-retries", 3);
 pref("devtools.debugger.remote-timeout", 3000);
 
-// The default Debugger UI height
+// The default Debugger UI settings
 pref("devtools.debugger.ui.height", 250);
 pref("devtools.debugger.ui.remote-win.width", 900);
 pref("devtools.debugger.ui.remote-win.height", 400);
+pref("devtools.debugger.ui.stackframes-width", 200);
+pref("devtools.debugger.ui.variables-width", 300);
 
 // Enable the style inspector
 pref("devtools.styleinspector.enabled", true);
 
 // Enable the Tilt inspector
 pref("devtools.tilt.enabled", true);
 pref("devtools.tilt.intro_transition", true);
 pref("devtools.tilt.outro_transition", true);
--- a/browser/devtools/debugger/debugger-controller.js
+++ b/browser/devtools/debugger/debugger-controller.js
@@ -43,16 +43,17 @@ let DebuggerController = {
    */
   _startupDebugger: function DC__startupDebugger() {
     if (this._isInitialized) {
       return;
     }
     this._isInitialized = true;
     window.removeEventListener("DOMContentLoaded", this._startupDebugger, true);
 
+    DebuggerView.initializePanes();
     DebuggerView.initializeEditor();
     DebuggerView.StackFrames.initialize();
     DebuggerView.Properties.initialize();
     DebuggerView.Scripts.initialize();
     DebuggerView.showCloseButton(!this._isRemoteDebugger && !this._isChromeDebugger);
 
     this.dispatchEvent("Debugger:Loaded");
     this._connect();
@@ -64,16 +65,17 @@ let DebuggerController = {
    */
   _shutdownDebugger: function DC__shutdownDebugger() {
     if (this._isDestroyed) {
       return;
     }
     this._isDestroyed = true;
     window.removeEventListener("unload", this._shutdownDebugger, true);
 
+    DebuggerView.destroyPanes();
     DebuggerView.destroyEditor();
     DebuggerView.Scripts.destroy();
     DebuggerView.StackFrames.destroy();
     DebuggerView.Properties.destroy();
 
     DebuggerController.SourceScripts.disconnect();
     DebuggerController.StackFrames.disconnect();
     DebuggerController.ThreadState.disconnect();
@@ -1415,16 +1417,56 @@ XPCOMUtils.defineLazyGetter(L10N, "strin
 });
 
 /**
  * Shortcuts for accessing various debugger preferences.
  */
 let Prefs = {
 
   /**
+   * Gets the preferred stackframes pane width.
+   * @return number
+   */
+  get stackframesWidth() {
+    if (this._sfrmWidth === undefined) {
+      this._sfrmWidth = Services.prefs.getIntPref("devtools.debugger.ui.stackframes-width");
+    }
+    return this._sfrmWidth;
+  },
+
+  /**
+   * Sets the preferred stackframes pane width.
+   * @return number
+   */
+  set stackframesWidth(value) {
+    Services.prefs.setIntPref("devtools.debugger.ui.stackframes-width", value);
+    this._sfrmWidth = value;
+  },
+
+  /**
+   * Gets the preferred variables pane width.
+   * @return number
+   */
+  get variablesWidth() {
+    if (this._varsWidth === undefined) {
+      this._varsWidth = Services.prefs.getIntPref("devtools.debugger.ui.variables-width");
+    }
+    return this._varsWidth;
+  },
+
+  /**
+   * Sets the preferred variables pane width.
+   * @return number
+   */
+  set variablesWidth(value) {
+    Services.prefs.setIntPref("devtools.debugger.ui.variables-width", value);
+    this._varsWidth = value;
+  },
+
+  /**
    * Gets a flag specifying if the the debugger should automatically connect to
    * the default host and port number.
    * @return boolean
    */
   get remoteAutoConnect() {
     if (this._autoConn === undefined) {
       this._autoConn = Services.prefs.getBoolPref("devtools.debugger.remote-autoconnect");
     }
--- a/browser/devtools/debugger/debugger-view.js
+++ b/browser/devtools/debugger/debugger-view.js
@@ -14,16 +14,27 @@ const PROPERTY_VIEW_FLASH_DURATION = 400
 let DebuggerView = {
 
   /**
    * An instance of SourceEditor.
    */
   editor: null,
 
   /**
+   * Initializes UI properties for all the displayed panes.
+   */
+  initializePanes: function DV_initializePanes() {
+    let stackframes = document.getElementById("stackframes");
+    stackframes.setAttribute("width", Prefs.stackframesWidth);
+
+    let variables = document.getElementById("variables");
+    variables.setAttribute("width", Prefs.variablesWidth);
+  },
+
+  /**
    * Initializes the SourceEditor instance.
    */
   initializeEditor: function DV_initializeEditor() {
     let placeholder = document.getElementById("editor");
 
     let config = {
       mode: SourceEditor.MODES.JAVASCRIPT,
       showLineNumbers: true,
@@ -32,16 +43,27 @@ let DebuggerView = {
       showOverviewRuler: true,
     };
 
     this.editor = new SourceEditor();
     this.editor.init(placeholder, config, this._onEditorLoad.bind(this));
   },
 
   /**
+   * Removes the displayed panes and saves any necessary state.
+   */
+  destroyPanes: function DV_destroyPanes() {
+    let stackframes = document.getElementById("stackframes");
+    Prefs.stackframesWidth = stackframes.getAttribute("width");
+
+    let variables = document.getElementById("variables");
+    Prefs.variablesWidth = variables.getAttribute("width");
+  },
+
+  /**
    * Removes the SourceEditor instance and added breakpoints.
    */
   destroyEditor: function DV_destroyEditor() {
     DebuggerController.Breakpoints.destroy();
     this.editor = null;
   },
 
   /**
--- a/browser/devtools/debugger/debugger.xul
+++ b/browser/devtools/debugger/debugger.xul
@@ -40,17 +40,16 @@
 
   <vbox id="body" flex="1">
     <toolbar id="dbg-toolbar" class="devtools-toolbar">
 #ifdef XP_MACOSX
       <toolbarbutton id="close"
                      tooltiptext="&debuggerUI.closeButton.tooltip;"
                      class="devtools-closebutton"/>
 #endif
-
       <hbox id="debugger-controls">
         <toolbarbutton id="resume"
                        class="devtools-toolbarbutton"
                        type="checkbox"
                        tabindex="0"/>
         <toolbarbutton id="step-over"
                        class="devtools-toolbarbutton"
                        tooltiptext="&debuggerUI.stepOverButton.tooltip;"
@@ -72,22 +71,16 @@
       <spacer flex="1"/>
 #ifndef XP_MACOSX
       <toolbarbutton id="close"
                      tooltiptext="&debuggerUI.closeButton.tooltip;"
                      class="devtools-closebutton"/>
 #endif
     </toolbar>
     <hbox id="dbg-content" flex="1">
-      <vbox id="stack" flex="1">
-        <vbox id="stackframes" class="dbg-default" flex="1"/>
-      </vbox>
-      <splitter id="stack-script-splitter"
-                class="devtools-side-splitter"/>
-      <vbox id="editor" class="dbg-default" flex="1"/>
-      <splitter id="script-properties-splitter"
-                class="devtools-side-splitter"/>
-      <vbox id="properties" flex="1">
-        <vbox id="variables" class="dbg-default" flex="1"/>
-      </vbox>
+      <vbox id="stackframes"/>
+      <splitter id="stack-script-splitter" class="devtools-side-splitter"/>
+      <vbox id="editor" flex="1"/>
+      <splitter id="script-properties-splitter" class="devtools-side-splitter"/>
+      <vbox id="variables"/>
     </hbox>
   </vbox>
 </window>
--- a/browser/devtools/debugger/test/Makefile.in
+++ b/browser/devtools/debugger/test/Makefile.in
@@ -30,16 +30,17 @@ include $(topsrcdir)/config/rules.mk
 	browser_dbg_propertyview-05.js \
 	browser_dbg_propertyview-06.js \
 	browser_dbg_propertyview-07.js \
 	browser_dbg_propertyview-08.js \
 	browser_dbg_propertyview-09.js \
 	browser_dbg_propertyview-10.js \
 	browser_dbg_propertyview-edit.js \
 	browser_dbg_panesize.js \
+	browser_dbg_panesize-inner.js \
 	browser_dbg_stack-01.js \
 	browser_dbg_stack-02.js \
 	browser_dbg_stack-03.js \
 	browser_dbg_stack-04.js \
 	browser_dbg_stack-05.js \
 	browser_dbg_location-changes.js \
 	browser_dbg_script-switching.js \
 	browser_dbg_scripts-sorting.js \
new file mode 100644
--- /dev/null
+++ b/browser/devtools/debugger/test/browser_dbg_panesize-inner.js
@@ -0,0 +1,63 @@
+/* vim:set ts=2 sw=2 sts=2 et: */
+/*
+ * Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+function test() {
+  var tab1 = addTab(TAB1_URL, function() {
+    gBrowser.selectedTab = tab1;
+
+    ok(!DebuggerUI.getDebugger(),
+      "Shouldn't have a debugger pane for this tab yet.");
+
+    let pane = DebuggerUI.toggleDebugger();
+    let someWidth1 = parseInt(Math.random() * 200) + 100;
+    let someWidth2 = parseInt(Math.random() * 200) + 100;
+
+    ok(pane, "toggleDebugger() should return a pane.");
+
+    is(DebuggerUI.getDebugger(), pane,
+      "getDebugger() should return the same pane as toggleDebugger().");
+
+    let frame = pane._frame;
+    let content = pane.contentWindow;
+    let stackframes;
+    let variables;
+
+    frame.addEventListener("Debugger:Loaded", function dbgLoaded() {
+      frame.removeEventListener("Debugger:Loaded", dbgLoaded, true);
+
+      ok(content.Prefs.stackframesWidth,
+        "The debugger preferences should have a saved stackframesWidth value.");
+      ok(content.Prefs.variablesWidth,
+        "The debugger preferences should have a saved variablesWidth value.");
+
+      stackframes = content.document.getElementById("stackframes");
+      variables = content.document.getElementById("variables");
+
+      is(content.Prefs.stackframesWidth, stackframes.getAttribute("width"),
+        "The stackframes pane width should be the same as the preferred value.");
+      is(content.Prefs.variablesWidth, variables.getAttribute("width"),
+        "The variables pane width should be the same as the preferred value.");
+
+      stackframes.setAttribute("width", someWidth1);
+      variables.setAttribute("width", someWidth2);
+
+      removeTab(tab1);
+
+    }, true);
+
+    frame.addEventListener("Debugger:Unloaded", function dbgUnloaded() {
+      frame.removeEventListener("Debugger:Unloaded", dbgUnloaded, true);
+
+      is(content.Prefs.stackframesWidth, stackframes.getAttribute("width"),
+        "The stackframes pane width should have been saved by now.");
+      is(content.Prefs.variablesWidth, variables.getAttribute("width"),
+        "The variables pane width should have been saved by now.");
+
+      finish();
+
+    }, true);
+  });
+}