Bug 888571 - Don't load CustomizeMode.jsm upon startup. r=MattN,dao

--HG--
extra : rebase_source : 3faf6d921958e0baae0e9495bba7c6481e1bd790
This commit is contained in:
Jared Wein 2013-06-29 04:25:56 -04:00
parent 6ceaa997c5
commit f965bb3cdb
3 changed files with 22 additions and 50 deletions

View File

@ -20,6 +20,11 @@ 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,8 +1241,6 @@ 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 {
@ -1353,7 +1351,6 @@ var gBrowserInit = {
IndexedDBPromptHelper.uninit();
SocialUI.uninit();
LightweightThemeListener.uninit();
gCustomizeMode.uninit();
PanelUI.uninit();
}
@ -3753,6 +3750,17 @@ 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,6 +31,12 @@ 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 = {
@ -55,22 +61,6 @@ 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;
@ -649,9 +639,6 @@ CustomizeMode.prototype = {
aEvent.preventDefault();
}
break;
case "TabSelect":
this._onTabSelect(aEvent);
break;
}
},
@ -985,34 +972,6 @@ 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;