Bug 1229123 support for obsoleted buttons, r=Gijs

This commit is contained in:
Shane Caraveo 2015-11-30 13:57:01 -08:00
parent 37a04111b3
commit 1bf0ebbf1b

View File

@ -55,6 +55,13 @@ const kSubviewEvents = [
*/
var kVersion = 4;
/**
* Buttons removed from built-ins by version they were removed. kVersion must be
* bumped any time a new id is added to this. Use the button id as key, and
* version the button is removed in as the value. e.g. "pocket-button": 5
*/
var ObsoleteBuiltinButtons = {};
/**
* gPalette is a map of every widget that CustomizableUI.jsm knows about, keyed
* on their IDs.
@ -154,6 +161,7 @@ var CustomizableUIInternal = {
this._defineBuiltInWidgets();
this.loadSavedState();
this._introduceNewBuiltinWidgets();
this._markObsoleteBuiltinButtonsSeen();
let panelPlacements = [
"edit-controls",
@ -352,6 +360,26 @@ var CustomizableUIInternal = {
}
},
/**
* _markObsoleteBuiltinButtonsSeen
* when upgrading, ensure obsoleted buttons are in seen state.
*/
_markObsoleteBuiltinButtonsSeen: function() {
if (!gSavedState)
return;
let currentVersion = gSavedState.currentVersion;
if (currentVersion >= kVersion)
return;
// we're upgrading, update state if necessary
for (let id in ObsoleteBuiltinButtons) {
let version = ObsoleteBuiltinButtons[id]
if (version == kVersion) {
gSeenWidgets.add(id);
gDirty = true;
}
}
},
_placeNewDefaultWidgetsInArea: function(aArea) {
let futurePlacedWidgets = gFuturePlacements.get(aArea);
let savedPlacements = gSavedState && gSavedState.placements && gSavedState.placements[aArea];
@ -589,7 +617,7 @@ var CustomizableUIInternal = {
legacyState = legacyState.split(",").filter(s => s);
}
// Manually restore the state here, so the legacy state can be converted.
// Manually restore the state here, so the legacy state can be converted.
this.restoreStateForArea(area, legacyState);
placements = gPlacements.get(area);
}
@ -1620,7 +1648,7 @@ var CustomizableUIInternal = {
// We can't use event.target because we might have passed a panelview
// anonymous content boundary as well, and so target points to the
// panelmultiview in that case. Unfortunately, this means we get
// anonymous child nodes instead of the real ones, so looking for the
// anonymous child nodes instead of the real ones, so looking for the
// 'stoooop, don't close me' attributes is more involved.
let target = aEvent.originalTarget;
let closemenu = "auto";
@ -1863,7 +1891,7 @@ var CustomizableUIInternal = {
// Note that this does not populate gPlacements, which is done lazily so that
// the legacy state can be migrated, which is only available once a browser
// window is openned.
// The panel area is an exception here, since it has no legacy state and is
// The panel area is an exception here, since it has no legacy state and is
// built lazily - and therefore wouldn't otherwise result in restoring its
// state immediately when a browser window opens, which is important for
// other consumers of this API.
@ -3843,7 +3871,7 @@ function XULWidgetGroupWrapper(aWidgetId) {
}
/**
* A XULWidgetSingleWrapper is a wrapper around a single instance of a XUL
* A XULWidgetSingleWrapper is a wrapper around a single instance of a XUL
* widget in a particular window.
*/
function XULWidgetSingleWrapper(aWidgetId, aNode, aDocument) {