Bug 1399486 - show downloads auto hide panel after changing the pref instead of before, r?mak
Note that we will no longer show the panel if you use the context menu to move the item in one
window and have customize mode open in the other. I don't think that edgecase matters.
MozReview-Commit-ID: 3dzGr3cs2oQ
--- a/browser/components/customizableui/CustomizeMode.jsm
+++ b/browser/components/customizableui/CustomizeMode.jsm
@@ -626,44 +626,50 @@ CustomizeMode.prototype = {
},
addToToolbar(aNode) {
aNode = this._getCustomizableChildForNode(aNode);
if (aNode.localName == "toolbarpaletteitem" && aNode.firstChild) {
aNode = aNode.firstChild;
}
+ CustomizableUI.addWidgetToArea(aNode.id, CustomizableUI.AREA_NAVBAR);
+ if (!this._customizing) {
+ CustomizableUI.dispatchToolboxEvent("customizationchange");
+ }
+
// If the user explicitly moves this item, turn off autohide.
if (aNode.id == "downloads-button") {
Services.prefs.setBoolPref(kDownloadAutoHidePref, false);
- }
-
- CustomizableUI.addWidgetToArea(aNode.id, CustomizableUI.AREA_NAVBAR);
- if (!this._customizing) {
- CustomizableUI.dispatchToolboxEvent("customizationchange");
+ if (this._customizing) {
+ this._showDownloadsAutoHidePanel();
+ }
}
},
addToPanel(aNode) {
aNode = this._getCustomizableChildForNode(aNode);
if (aNode.localName == "toolbarpaletteitem" && aNode.firstChild) {
aNode = aNode.firstChild;
}
- // If the user explicitly moves this item, turn off autohide.
- if (aNode.id == "downloads-button") {
- Services.prefs.setBoolPref(kDownloadAutoHidePref, false);
- }
-
let panel = CustomizableUI.AREA_FIXED_OVERFLOW_PANEL;
CustomizableUI.addWidgetToArea(aNode.id, panel);
if (!this._customizing) {
CustomizableUI.dispatchToolboxEvent("customizationchange");
}
+ // If the user explicitly moves this item, turn off autohide.
+ if (aNode.id == "downloads-button") {
+ Services.prefs.setBoolPref(kDownloadAutoHidePref, false);
+ if (this._customizing) {
+ this._showDownloadsAutoHidePanel();
+ }
+ }
+
if (Services.prefs.getBoolPref("toolkit.cosmeticAnimations.enabled")) {
let overflowButton = this.document.getElementById("nav-bar-overflow-button");
BrowserUtils.setToolbarButtonHeightProperty(overflowButton).then(() => {
overflowButton.setAttribute("animate", "true");
overflowButton.addEventListener("animationend", function onAnimationEnd(event) {
if (event.animationName.startsWith("overflow-animation")) {
this.setAttribute("fade", "true");
} else if (event.animationName == "overflow-fade") {
@@ -676,23 +682,27 @@ CustomizeMode.prototype = {
}
},
removeFromArea(aNode) {
aNode = this._getCustomizableChildForNode(aNode);
if (aNode.localName == "toolbarpaletteitem" && aNode.firstChild) {
aNode = aNode.firstChild;
}
+ CustomizableUI.removeWidgetFromArea(aNode.id);
+ if (!this._customizing) {
+ CustomizableUI.dispatchToolboxEvent("customizationchange");
+ }
+
// If the user explicitly removes this item, turn off autohide.
if (aNode.id == "downloads-button") {
Services.prefs.setBoolPref(kDownloadAutoHidePref, false);
- }
- CustomizableUI.removeWidgetFromArea(aNode.id);
- if (!this._customizing) {
- CustomizableUI.dispatchToolboxEvent("customizationchange");
+ if (this._customizing) {
+ this._showDownloadsAutoHidePanel();
+ }
}
},
populatePalette() {
let fragment = this.document.createDocumentFragment();
let toolboxPalette = this.window.gNavToolbox.palette;
try {
@@ -1200,19 +1210,16 @@ CustomizeMode.prototype = {
// API also does the right thing (and adds it to the palette)
let widgetId = aNodeToChange.id;
let widget = CustomizableUI.getWidget(widgetId);
if (widget.provider == CustomizableUI.PROVIDER_API) {
let paletteItem = this.makePaletteItem(widget, "palette");
this.visiblePalette.appendChild(paletteItem);
}
}
- if (aNodeToChange.id == "downloads-button") {
- this._showDownloadsAutoHidePanel();
- }
},
onWidgetDestroyed(aWidgetId) {
let wrapper = this.document.getElementById("wrapper-" + aWidgetId);
if (wrapper) {
wrapper.remove();
}
},
@@ -1827,16 +1834,17 @@ CustomizeMode.prototype = {
this._applyDrop(aEvent, targetArea, originArea, draggedItemId, targetNode);
} catch (ex) {
log.error(ex, ex.stack);
}
// If the user explicitly moves this item, turn off autohide.
if (draggedItemId == "downloads-button") {
Services.prefs.setBoolPref(kDownloadAutoHidePref, false);
+ this._showDownloadsAutoHidePanel();
}
},
_applyDrop(aEvent, aTargetArea, aOriginArea, aDraggedItemId, aTargetNode) {
let document = aEvent.target.ownerDocument;
let draggedItem = document.getElementById(aDraggedItemId);
draggedItem.hidden = false;
draggedItem.removeAttribute("mousedown");