Bug 808691 - The remote and chrome debugger windows should remember their size across sessions, r=past

This commit is contained in:
Victor Porof 2012-11-10 13:14:40 +02:00
parent a82078b744
commit 26d567403e
5 changed files with 125 additions and 223 deletions

View File

@ -1047,8 +1047,10 @@ pref("devtools.debugger.remote-timeout", 20000);
// 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.win-x", 0);
pref("devtools.debugger.ui.win-y", 0);
pref("devtools.debugger.ui.win-width", 900);
pref("devtools.debugger.ui.win-height", 400);
pref("devtools.debugger.ui.stackframes-width", 200);
pref("devtools.debugger.ui.variables-width", 300);
pref("devtools.debugger.ui.panes-visible-on-startup", false);

View File

@ -328,7 +328,6 @@ DebuggerPane.prototype = {
Prefs.height = this._frame.height;
this._frame.removeEventListener("Debugger:Unloaded", this.close, true);
this._nbox.removeChild(this._splitter);
this._nbox.removeChild(this._frame);
@ -395,10 +394,7 @@ RemoteDebuggerWindow.prototype = {
this.globalUI._remoteDebugger = this;
this._dbgwin = this.globalUI.chromeWindow.open(DBG_XUL,
L10N.getStr("remoteDebuggerWindowTitle"),
"width=" + Prefs.remoteWinWidth + "," +
"height=" + Prefs.remoteWinHeight + "," +
"chrome,dependent,resizable,centerscreen");
L10N.getStr("remoteDebuggerWindowTitle"), "chrome,dependent,resizable");
let self = this;
@ -426,6 +422,7 @@ RemoteDebuggerWindow.prototype = {
}
delete this.globalUI._remoteDebugger;
this._dbgwin.removeEventListener("Debugger:Unloaded", this.close, true);
this._dbgwin.close();
this._dbgwin = null;
this._win = null;
@ -496,15 +493,40 @@ ChromeDebuggerProcess.prototype = {
let profileService = Cc["@mozilla.org/toolkit/profile-service;1"]
.createInstance(Ci.nsIToolkitProfileService);
let dbgProfileName;
let profileName;
try {
dbgProfileName = profileService.selectedProfile.name + CHROME_DEBUGGER_PROFILE_NAME;
} catch(e) {
dbgProfileName = CHROME_DEBUGGER_PROFILE_NAME;
// Attempt to get the required chrome debugging profile name string.
profileName = profileService.selectedProfile.name + CHROME_DEBUGGER_PROFILE_NAME;
} catch (e) {
// Requested profile string could not be retrieved.
profileName = CHROME_DEBUGGER_PROFILE_NAME;
Cu.reportError(e);
}
this._dbgProfile = profileService.createProfile(null, null, dbgProfileName);
let profileObject;
try {
// Attempt to get the required chrome debugging profile toolkit object.
profileObject = profileService.getProfileByName(profileName);
// The profile exists but the corresponding folder may have been deleted.
var enumerator = Services.dirsvc.get("ProfD", Ci.nsIFile).parent.directoryEntries;
while (enumerator.hasMoreElements()) {
let profileDir = enumerator.getNext().QueryInterface(Ci.nsIFile);
if (profileDir.leafName.contains(profileName)) {
// Requested profile was found and the folder exists.
this._dbgProfile = profileObject;
return;
}
}
// Requested profile was found but the folder was deleted. Cleanup needed.
profileObject.remove(true);
} catch (e) {
// Requested profile object was not found.
Cu.reportError(e);
}
// Create a new chrome debugging profile.
this._dbgProfile = profileService.createProfile(null, null, profileName);
profileService.flush();
},
@ -523,9 +545,7 @@ ChromeDebuggerProcess.prototype = {
let args = [
"-no-remote", "-P", this._dbgProfile.name,
"-chrome", DBG_XUL,
"-width", Prefs.remoteWinWidth,
"-height", Prefs.remoteWinHeight];
"-chrome", DBG_XUL];
process.runwAsync(args, args.length, { observe: this.close.bind(this) });
this._dbgProcess = process;
@ -547,9 +567,6 @@ ChromeDebuggerProcess.prototype = {
if (this._dbgProcess.isRunning) {
this._dbgProcess.kill();
}
if (this._dbgProfile) {
this._dbgProfile.remove(false);
}
if (typeof this._closeCallback == "function") {
this._closeCallback.call({}, this);
}
@ -589,39 +606,17 @@ let Prefs = {
* Gets the preferred height of the debugger pane.
* @return number
*/
get height() {
if (this._height === undefined) {
this._height = Services.prefs.getIntPref("devtools.debugger.ui.height");
}
return this._height;
},
get height()
Services.prefs.getIntPref("devtools.debugger.ui.height"),
/**
* Sets the preferred height of the debugger pane.
* @param number value
* @param number aValue
*/
set height(value) {
Services.prefs.setIntPref("devtools.debugger.ui.height", value);
this._height = value;
}
set height(aValue)
Services.prefs.setIntPref("devtools.debugger.ui.height", aValue)
};
/**
* Gets the preferred width of the remote debugger window.
* @return number
*/
XPCOMUtils.defineLazyGetter(Prefs, "remoteWinWidth", function() {
return Services.prefs.getIntPref("devtools.debugger.ui.remote-win.width");
});
/**
* Gets the preferred height of the remote debugger window.
* @return number
*/
XPCOMUtils.defineLazyGetter(Prefs, "remoteWinHeight", function() {
return Services.prefs.getIntPref("devtools.debugger.ui.remote-win.height");
});
/**
* Gets the preferred default remote debugging host.
* @return string

View File

@ -1247,201 +1247,66 @@ XPCOMUtils.defineLazyGetter(L10N, "ellipsis", function() {
return Services.prefs.getComplexValue("intl.ellipsis", Ci.nsIPrefLocalizedString).data;
});
const STACKFRAMES_WIDTH = "devtools.debugger.ui.stackframes-width";
const VARIABLES_WIDTH = "devtools.debugger.ui.variables-width";
const PANES_VISIBLE_ON_STARTUP = "devtools.debugger.ui.panes-visible-on-startup";
const VARIABLES_NON_ENUM_VISIBLE = "devtools.debugger.ui.variables-non-enum-visible";
const VARIABLES_SEARCHBOX_VISIBLE = "devtools.debugger.ui.variables-searchbox-visible";
const REMOTE_HOST = "devtools.debugger.remote-host";
const REMOTE_PORT = "devtools.debugger.remote-port";
const REMOTE_AUTO_CONNECT = "devtools.debugger.remote-autoconnect";
const REMOTE_CONNECTION_RETRIES = "devtools.debugger.remote-connection-retries";
const REMOTE_TIMEOUT = "devtools.debugger.remote-timeout";
/**
* Shortcuts for accessing various debugger preferences.
*/
let Prefs = {
/**
* Gets the preferred stackframes pane width.
* @return number
* Helper method for getting a pref value.
*
* @param string aType
* @param string aPrefName
* @return any
*/
get stackframesWidth() {
if (this._stackframesWidth === undefined) {
this._stackframesWidth = Services.prefs.getIntPref(STACKFRAMES_WIDTH);
_get: function P__get(aType, aPrefName) {
if (this[aPrefName] === undefined) {
this[aPrefName] = Services.prefs["get" + aType + "Pref"](aPrefName);
}
return this._stackframesWidth;
return this[aPrefName];
},
/**
* Sets the preferred stackframes pane width.
* @param number value
* Helper method for setting a pref value.
*
* @param string aType
* @param string aPrefName
* @param any aValue
*/
set stackframesWidth(value) {
Services.prefs.setIntPref(STACKFRAMES_WIDTH, value);
this._stackframesWidth = value;
_set: function P__set(aType, aPrefName, aValue) {
Services.prefs["set" + aType + "Pref"](aPrefName, aValue);
this[aPrefName] = aValue;
},
/**
* Gets the preferred variables pane width.
* @return number
* Maps a property name to a pref, defining lazy getters and setters.
*
* @param string aType
* @param string aPropertyName
* @param string aPrefName
*/
get variablesWidth() {
if (this._variablesWidth === undefined) {
this._variablesWidth = Services.prefs.getIntPref(VARIABLES_WIDTH);
}
return this._variablesWidth;
},
/**
* Sets the preferred variables pane width.
* @param number value
*/
set variablesWidth(value) {
Services.prefs.setIntPref(VARIABLES_WIDTH, value);
this._variablesWidth = value;
},
/**
* Gets the preferred panes visibility state on startup.
* @return boolean
*/
get panesVisibleOnStartup() {
if (this._panesVisible === undefined) {
this._panesVisible = Services.prefs.getBoolPref(PANES_VISIBLE_ON_STARTUP);
}
return this._panesVisible;
},
/**
* Sets the preferred panes visibility state on startup.
* @param boolean value
*/
set panesVisibleOnStartup(value) {
Services.prefs.setBoolPref(PANES_VISIBLE_ON_STARTUP, value);
this._panesVisible = value;
},
/**
* Gets a flag specifying if the debugger should show non-enumerable
* properties and variables in the scope view.
* @return boolean
*/
get variablesNonEnumVisible() {
if (this._varNonEnum === undefined) {
this._varNonEnum = Services.prefs.getBoolPref(VARIABLES_NON_ENUM_VISIBLE);
}
return this._varNonEnum;
},
/**
* Sets a flag specifying if the debugger should show non-enumerable
* properties and variables in the scope view.
* @param boolean value
*/
set variablesNonEnumVisible(value) {
Services.prefs.setBoolPref(VARIABLES_NON_ENUM_VISIBLE, value);
this._varNonEnum = value;
},
/**
* Gets a flag specifying if the a variables searchbox should be shown.
* @return boolean
*/
get variablesSearchboxVisible() {
if (this._varSearchbox === undefined) {
this._varSearchbox = Services.prefs.getBoolPref(VARIABLES_SEARCHBOX_VISIBLE);
}
return this._varSearchbox;
},
/**
* Sets a flag specifying if the a variables searchbox should be shown.
* @param boolean value
*/
set variablesSearchboxVisible(value) {
Services.prefs.setBoolPref(VARIABLES_SEARCHBOX_VISIBLE, value);
this._varSearchbox = value;
},
/**
* Gets the preferred default remote debugging host.
* @return string
*/
get remoteHost() {
if (this._remoteHost === undefined) {
this._remoteHost = Services.prefs.getCharPref(REMOTE_HOST);
}
return this._remoteHost;
},
/**
* Sets the preferred default remote debugging host.
* @param string value
*/
set remoteHost(value) {
Services.prefs.setCharPref(REMOTE_HOST, value);
this._remoteHost = value;
},
/**
* Gets the preferred default remote debugging port.
* @return number
*/
get remotePort() {
if (this._remotePort === undefined) {
this._remotePort = Services.prefs.getIntPref(REMOTE_PORT);
}
return this._remotePort;
},
/**
* Sets the preferred default remote debugging port.
* @param number value
*/
set remotePort(value) {
Services.prefs.setIntPref(REMOTE_PORT, value);
this._remotePort = value;
},
/**
* Gets a flag specifying if the debugger should automatically connect to
* the default host and port number.
* @return boolean
*/
get remoteAutoConnect() {
if (this._autoConnect === undefined) {
this._autoConnect = Services.prefs.getBoolPref(REMOTE_AUTO_CONNECT);
}
return this._autoConnect;
},
/**
* Sets a flag specifying if the debugger should automatically connect to
* the default host and port number.
* @param boolean value
*/
set remoteAutoConnect(value) {
Services.prefs.setBoolPref(REMOTE_AUTO_CONNECT, value);
this._autoConnect = value;
map: function P_map(aType, aPropertyName, aPrefName) {
Object.defineProperty(this, aPropertyName, {
get: function() this._get(aType, aPrefName),
set: function(aValue) this._set(aType, aPrefName, aValue)
});
}
};
/**
* Gets the max number of attempts to reconnect to a remote server.
* @return number
*/
XPCOMUtils.defineLazyGetter(Prefs, "remoteConnectionRetries", function() {
return Services.prefs.getIntPref(REMOTE_CONNECTION_RETRIES);
});
/**
* Gets the remote debugging connection timeout (in milliseconds).
* @return number
*/
XPCOMUtils.defineLazyGetter(Prefs, "remoteTimeout", function() {
return Services.prefs.getIntPref(REMOTE_TIMEOUT);
});
Prefs.map("Int", "height", "devtools.debugger.ui.height");
Prefs.map("Int", "windowX", "devtools.debugger.ui.win-x");
Prefs.map("Int", "windowY", "devtools.debugger.ui.win-y");
Prefs.map("Int", "windowWidth", "devtools.debugger.ui.win-width");
Prefs.map("Int", "windowHeight", "devtools.debugger.ui.win-height");
Prefs.map("Int", "stackframesWidth", "devtools.debugger.ui.stackframes-width");
Prefs.map("Int", "variablesWidth", "devtools.debugger.ui.variables-width");
Prefs.map("Bool", "panesVisibleOnStartup", "devtools.debugger.ui.panes-visible-on-startup");
Prefs.map("Bool", "variablesNonEnumVisible", "devtools.debugger.ui.variables-non-enum-visible");
Prefs.map("Bool", "variablesSearchboxVisible", "devtools.debugger.ui.variables-searchbox-visible");
Prefs.map("Char", "remoteHost", "devtools.debugger.remote-host");
Prefs.map("Int", "remotePort", "devtools.debugger.remote-port");
Prefs.map("Bool", "remoteAutoConnect", "devtools.debugger.remote-autoconnect");
Prefs.map("Int", "remoteConnectionRetries", "devtools.debugger.remote-connection-retries");
Prefs.map("Int", "remoteTimeout", "devtools.debugger.remote-timeout");
/**
* Returns true if this is a remote debugger instance.

View File

@ -29,6 +29,12 @@ let DebuggerView = {
*/
initialize: function DV_initialize(aCallback) {
dumpn("Initializing the DebuggerView");
if (window._isRemoteDebugger || window._isChromeDebugger) {
window.moveTo(Prefs.windowX, Prefs.windowY);
window.resizeTo(Prefs.windowWidth, Prefs.windowHeight);
}
this.Toolbar.initialize();
this.Options.initialize();
this.ChromeGlobals.initialize();
@ -47,7 +53,7 @@ let DebuggerView = {
this.Variables.lazyEmpty = true;
this._initializePanes();
this._initializeEditor(aCallback)
this._initializeEditor(aCallback);
},
/**
@ -58,6 +64,14 @@ let DebuggerView = {
*/
destroy: function DV_destroy(aCallback) {
dumpn("Destroying the DebuggerView");
if (window._isRemoteDebugger || window._isChromeDebugger) {
Prefs.windowX = window.screenX;
Prefs.windowY = window.screenY;
Prefs.windowWidth = window.outerWidth;
Prefs.windowHeight = window.outerHeight;
}
this.Toolbar.destroy();
this.Options.destroy();
this.ChromeGlobals.destroy();

View File

@ -20,6 +20,32 @@ function test() {
gWindow = aWindow;
let gDebugger = gWindow.contentWindow;
info("Current remote window x: " +
Services.prefs.getIntPref("devtools.debugger.ui.win-x"));
info("Current remote window y: " +
Services.prefs.getIntPref("devtools.debugger.ui.win-y"));
info("Current remote window width: " +
Services.prefs.getIntPref("devtools.debugger.ui.win-width"));
info("Current remote window height: " +
Services.prefs.getIntPref("devtools.debugger.ui.win-height"));
is(gDebugger.Prefs.windowX,
Services.prefs.getIntPref("devtools.debugger.ui.win-x"),
"Current window x pref corresponds to the debugger pref.");
is(gDebugger.Prefs.windowY,
Services.prefs.getIntPref("devtools.debugger.ui.win-y"),
"Current window y pref corresponds to the debugger pref.");
is(gDebugger.Prefs.windowWidth,
Services.prefs.getIntPref("devtools.debugger.ui.win-width"),
"Current window width pref corresponds to the debugger pref.");
is(gDebugger.Prefs.windowHeight,
Services.prefs.getIntPref("devtools.debugger.ui.win-height"),
"Current window height pref corresponds to the debugger pref.");
info("Current remote host: " +
Services.prefs.getCharPref("devtools.debugger.remote-host"));
info("Current remote port: " +