Bug 1037145 - Remove esc as a keybinding to close responsive mode. r=paul

This commit is contained in:
Brian Grinstead 2014-07-24 07:59:00 +02:00
Родитель 655939c918
Коммит 16a7c0b529
4 изменённых файлов: 10 добавлений и 37 удалений

Просмотреть файл

@ -302,20 +302,8 @@ Toolbox.prototype = {
}, true);
},
_isResponsiveModeActive: function() {
let responsiveModeActive = false;
if (this.target.isLocalTab) {
let tab = this.target.tab;
let browserWindow = tab.ownerDocument.defaultView;
let responsiveUIManager = browserWindow.ResponsiveUI.ResponsiveUIManager;
responsiveModeActive = responsiveUIManager.isActiveForTab(tab);
}
return responsiveModeActive;
},
_splitConsoleOnKeypress: function(e) {
let responsiveModeActive = this._isResponsiveModeActive();
if (e.keyCode === e.DOM_VK_ESCAPE && !responsiveModeActive) {
if (e.keyCode === e.DOM_VK_ESCAPE) {
this.toggleSplitConsole();
// If the debugger is paused, don't let the ESC key stop any pending
// navigation.

Просмотреть файл

@ -173,12 +173,10 @@ function ResponsiveUI(aWindow, aTab)
this.bound_startResizing = this.startResizing.bind(this);
this.bound_stopResizing = this.stopResizing.bind(this);
this.bound_onDrag = this.onDrag.bind(this);
this.bound_onKeypress = this.onKeypress.bind(this);
// Events
this.tab.addEventListener("TabClose", this);
this.tabContainer.addEventListener("TabSelect", this);
this.mainWindow.document.addEventListener("keypress", this.bound_onKeypress, false);
this.buildUI();
this.checkMenus();
@ -282,7 +280,6 @@ ResponsiveUI.prototype = {
this.stopResizing();
// Remove listeners.
this.mainWindow.document.removeEventListener("keypress", this.bound_onKeypress, false);
this.menulist.removeEventListener("select", this.bound_presetSelected, true);
this.menulist.removeEventListener("change", this.bound_handleManualInput, true);
this.tab.removeEventListener("TabClose", this);
@ -313,21 +310,6 @@ ResponsiveUI.prototype = {
ResponsiveUIManager.emit("off", { tab: this.tab });
},
/**
* Handle keypressed.
*
* @param aEvent
*/
onKeypress: function RUI_onKeypress(aEvent) {
if (aEvent.keyCode == this.mainWindow.KeyEvent.DOM_VK_ESCAPE &&
this.mainWindow.gBrowser.selectedBrowser == this.browser) {
aEvent.preventDefault();
aEvent.stopPropagation();
this.close();
}
},
/**
* Handle events
*/

Просмотреть файл

@ -79,22 +79,25 @@ function test() {
ruleView.element.addEventListener("CssRuleViewRefreshed", function refresh() {
ruleView.element.removeEventListener("CssRuleViewRefreshed", refresh, false);
is(numberOfRules(), 2, "Should have two rules after growing.");
testEscapeCloses();
testEscapeOpensSplitConsole();
}, false);
instance.setSize(500, 500);
}
function testEscapeCloses() {
function testEscapeOpensSplitConsole() {
is(document.getElementById("Tools:ResponsiveUI").getAttribute("checked"), "true", "menu checked");
ok(!inspector._toolbox._splitConsole, "Console is not split.");
inspector._toolbox.once("split-console", function() {
mgr.once("off", function() {executeSoon(finishUp)});
mgr.toggle(window, gBrowser.selectedTab);
});
EventUtils.synthesizeKey("VK_ESCAPE", {});
}
function finishUp() {
ok(!inspector._toolbox._splitConsole, "Console is still not split after pressing escape.");
ok(inspector._toolbox._splitConsole, "Console is split after pressing escape.");
// Menus are correctly updated?
is(document.getElementById("Tools:ResponsiveUI").getAttribute("checked"), "false", "menu unchecked");

Просмотреть файл

@ -249,7 +249,7 @@ function test() {
info("XXX BUG 851296: 'off' received.");
executeSoon(restart);
});
EventUtils.synthesizeKey("VK_ESCAPE", {});
mgr.toggle(window, gBrowser.selectedTab);
}
function restart() {
@ -276,7 +276,7 @@ function test() {
is(content.innerHeight, heightBeforeClose, "height restored.");
mgr.once("off", function() {executeSoon(testScreenshot)});
EventUtils.synthesizeKey("VK_ESCAPE", {});
mgr.toggle(window, gBrowser.selectedTab);
}
function testScreenshot() {