Backed out changeset ee81f5bac27a (bug 888571)

This commit is contained in:
Jared Wein 2013-06-30 08:36:00 -04:00
parent e295c5e8fc
commit c4c38afa54
3 changed files with 50 additions and 22 deletions

View File

@ -20,11 +20,6 @@ let CustomizationHandler = {
}
},
isCustomizing: function() {
return document.documentElement.hasAttribute("customizing") ||
document.documentElement.hasAttribute("customize-exiting");
},
_customizationStarting: function() {
// Disable the toolbar context menu items
let menubar = document.getElementById("main-menubar");

View File

@ -1241,6 +1241,8 @@ var gBrowserInit = {
gNavToolbox.addEventListener("customizationstarting", CustomizationHandler);
gNavToolbox.addEventListener("customizationending", CustomizationHandler);
gCustomizeMode.init();
// End startup crash tracking after a delay to catch crashes while restoring
// tabs and to postpone saving the pref to disk.
try {
@ -1351,6 +1353,7 @@ var gBrowserInit = {
IndexedDBPromptHelper.uninit();
SocialUI.uninit();
LightweightThemeListener.uninit();
gCustomizeMode.uninit();
PanelUI.uninit();
}
@ -3750,17 +3753,6 @@ var XULBrowserWindow = {
// fix bug 253793 - turn off highlight when page changes
gFindBar.getElement("highlight").checked = false;
}
// Try not to instantiate gCustomizeMode as much as possible,
// so don't use CustomizeMode.jsm to check for URI or customizing.
let customizingURI = "about:customizing";
if (location == customizingURI &&
!CustomizationHandler.isCustomizing()) {
gCustomizeMode.enter();
} else if (location != customizingURI &&
CustomizationHandler.isCustomizing()) {
gCustomizeMode.exit();
}
}
UpdateBackForwardCommands(gBrowser.webNavigation);

View File

@ -31,12 +31,6 @@ function CustomizeMode(aWindow) {
this.window = aWindow;
this.document = aWindow.document;
this.browser = aWindow.gBrowser;
// There are two palettes - there's the palette that can be overlayed with
// toolbar items in browser.xul. This is invisible, and never seen by the
// user. Then there's the visible palette, which gets populated and displayed
// to the user when in customizing mode.
this.visiblePalette = this.document.getElementById(kPaletteId);
};
CustomizeMode.prototype = {
@ -61,6 +55,22 @@ CustomizeMode.prototype = {
return this.document.getElementById("PanelUI-contents");
},
init: function() {
// There are two palettes - there's the palette that can be overlayed with
// toolbar items in browser.xul. This is invisible, and never seen by the
// user. Then there's the visible palette, which gets populated and displayed
// to the user when in customizing mode.
this.visiblePalette = this.document.getElementById(kPaletteId);
this.browser.tabContainer.addEventListener("TabSelect", this, false);
this.browser.addTabsProgressListener(this);
},
uninit: function() {
this.browser.tabContainer.removeEventListener("TabSelect", this, false);
this.browser.removeTabsProgressListener(this);
},
enter: function() {
if (this._customizing || this._transitioning) {
return;
@ -639,6 +649,9 @@ CustomizeMode.prototype = {
aEvent.preventDefault();
}
break;
case "TabSelect":
this._onTabSelect(aEvent);
break;
}
},
@ -972,6 +985,34 @@ CustomizeMode.prototype = {
return aElement;
},
_onTabSelect: function(aEvent) {
this._toggleCustomizationModeIfNecessary();
},
onLocationChange: function(aBrowser, aProgress, aRequest, aLocation, aFlags) {
if (this.browser.selectedBrowser != aBrowser) {
return;
}
this._toggleCustomizationModeIfNecessary();
},
/**
* Looks at the currently selected browser tab, and if the location
* is set to kAboutURI and we're not customizing, enters customize mode.
* If we're not at kAboutURI and we are customizing, exits customize mode.
*/
_toggleCustomizationModeIfNecessary: function() {
let browser = this.browser.selectedBrowser;
if (browser.currentURI.spec == kAboutURI &&
!this._customizing) {
this.enter();
} else if (browser.currentURI.spec != kAboutURI &&
this._customizing) {
this.exit();
}
},
_showPanelCustomizationPlaceholders: function() {
this._removePanelCustomizationPlaceholders();
let doc = this.document;