--- a/browser/components/customizableui/CustomizeMode.jsm
+++ b/browser/components/customizableui/CustomizeMode.jsm
@@ -37,19 +37,16 @@ XPCOMUtils.defineLazyModuleGetter(this,
"resource://gre/modules/LightweightThemeManager.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "SessionStore",
"resource:///modules/sessionstore/SessionStore.jsm");
XPCOMUtils.defineLazyGetter(this, "gWidgetsBundle", function() {
const kUrl = "chrome://browser/locale/customizableui/customizableWidgets.properties";
return Services.strings.createBundle(kUrl);
});
-XPCOMUtils.defineLazyPreferenceGetter(this, "gPhotonStructure",
- "browser.photon.structure.enabled", false);
-
let gDebug;
XPCOMUtils.defineLazyGetter(this, "log", () => {
let scope = {};
Cu.import("resource://gre/modules/Console.jsm", scope);
gDebug = Services.prefs.getBoolPref(kPrefCustomizationDebug, false);
let consoleOptions = {
maxLogLevel: gDebug ? "all" : "log",
prefix: "CustomizeMode",
@@ -136,20 +133,16 @@ CustomizeMode.prototype = {
// restore gNavToolbox.palette to its original state after exiting
// customization mode.
_stowedPalette: null,
_dragOverItem: null,
_customizing: false,
_skipSourceNodeCheck: null,
_mainViewContext: null,
- get panelUIContents() {
- return this.document.getElementById("PanelUI-contents");
- },
-
get _handler() {
return this.window.CustomizationHandler;
},
uninit() {
if (AppConstants.CAN_DRAW_IN_TITLEBAR) {
Services.prefs.removeObserver(kDrawInTitlebarPref, this);
}
@@ -284,90 +277,24 @@ CustomizeMode.prototype = {
// customization mode when pressing ESC.
document.addEventListener("keypress", this);
// Same goes for the menu button - if we're customizing, a click on the
// menu button means a quick exit from customization mode.
window.PanelUI.hide();
let panelHolder = document.getElementById("customization-panelHolder");
- let panelContainer = document.getElementById("customization-panel-container");
- let customizationContainer = document.getElementById("customization-container");
- let paletteContainer = document.getElementById("customization-palette-container");
- let contentContainer = document.getElementById("customization-content-container");
- let footer = document.getElementById("customization-footer");
- let doneButton = document.getElementById("customization-done-button");
let panelContextMenu = document.getElementById(kPanelItemContextMenu);
this._previousPanelContextMenuParent = panelContextMenu.parentNode;
document.getElementById("mainPopupSet").appendChild(panelContextMenu);
- if (gPhotonStructure) {
- if (!customizationContainer.hasAttribute("photon")) {
- contentContainer.appendChild(paletteContainer);
- contentContainer.appendChild(panelContainer);
- customizationContainer.appendChild(footer);
- customizationContainer.setAttribute("photon", "true");
- doneButton.hidden = false;
- }
- panelHolder.appendChild(window.PanelUI.overflowFixedList);
- window.PanelUI.overflowFixedList.setAttribute("customizing", true);
- window.PanelUI.menuButton.disabled = true;
- document.getElementById("nav-bar-overflow-button").disabled = true;
- } else {
- if (customizationContainer.hasAttribute("photon")) {
- customizationContainer.insertBefore(paletteContainer, contentContainer);
- customizationContainer.appendChild(panelContainer);
- paletteContainer.appendChild(footer);
- customizationContainer.removeAttribute("photon");
- doneButton.hidden = true;
- }
- window.PanelUI.menuButton.addEventListener("command", this);
- window.PanelUI.menuButton.open = true;
- window.PanelUI.beginBatchUpdate();
+ panelHolder.appendChild(window.PanelUI.overflowFixedList);
- // The menu panel is lazy, and registers itself when the popup shows.
- // If it hasn't been opened yet, we need to force the menu panel to
- // register itself, or else customization is not going to work.
- // We pass "true" to ensureReady to indicate that we're handling
- // calling startBatchUpdate and endBatchUpdate.
- if (!window.PanelUI.isReady) {
- await window.PanelUI.ensureReady(true);
- // Up to now, it will have been hidden, and its XBL bindings won't have
- // been constructed. Unhiding it won't trigger the construction of
- // those bindings immediately, but the next layout flush will.
- // Because we don't want to sync flush layout, we wait for the next
- // natural style/layout flush.
- await new Promise(resolve => window.requestIdleCallback(resolve));
- }
-
- // Hide the palette before starting the transition for increased perf.
- this.visiblePalette.hidden = true;
- this.visiblePalette.removeAttribute("showing");
-
- if (!AppConstants.MOZ_PHOTON_THEME) {
- // Disable the button-text fade-out mask
- // during the transition for increased perf.
- window.PanelUI.contents.setAttribute("customize-transitioning", "true");
- }
-
- // Move the mainView in the panel to the holder so that we can see it
- // while customizing.
- let mainView = window.PanelUI.mainView;
- panelHolder.appendChild(mainView);
-
- let customizeButton = document.getElementById("PanelUI-customize");
- customizeButton.setAttribute("enterLabel", customizeButton.getAttribute("label"));
- customizeButton.setAttribute("label", customizeButton.getAttribute("exitLabel"));
- customizeButton.setAttribute("enterTooltiptext", customizeButton.getAttribute("tooltiptext"));
- customizeButton.setAttribute("tooltiptext", customizeButton.getAttribute("exitTooltiptext"));
-
- this._mainViewContext = mainView.getAttribute("context");
- if (this._mainViewContext) {
- mainView.removeAttribute("context");
- }
- }
+ window.PanelUI.overflowFixedList.setAttribute("customizing", true);
+ window.PanelUI.menuButton.disabled = true;
+ document.getElementById("nav-bar-overflow-button").disabled = true;
this._transitioning = true;
let customizer = document.getElementById("customization-container");
customizer.parentNode.selectedPanel = customizer;
customizer.hidden = false;
this._wrapToolbarItemSync(CustomizableUI.AREA_TABSTRIP);
@@ -378,42 +305,30 @@ CustomizeMode.prototype = {
await this._doTransition(true);
Services.obs.addObserver(this, "lightweight-theme-window-updated");
// Let everybody in this window know that we're about to customize.
CustomizableUI.dispatchToolboxEvent("customizationstarting", {}, window);
- if (!gPhotonStructure) {
- this._showPanelCustomizationPlaceholders();
- }
-
await this._wrapToolbarItems();
this.populatePalette();
this._addDragHandlers(this.visiblePalette);
window.gNavToolbox.addEventListener("toolbarvisibilitychange", this);
- if (!gPhotonStructure) {
- document.getElementById("PanelUI-help").setAttribute("disabled", true);
- document.getElementById("PanelUI-quit").setAttribute("disabled", true);
- }
-
this._updateResetButton();
this._updateUndoResetButton();
this._skipSourceNodeCheck = Services.prefs.getPrefType(kSkipSourceNodePref) == Ci.nsIPrefBranch.PREF_BOOL &&
Services.prefs.getBoolPref(kSkipSourceNodePref);
CustomizableUI.addListener(this);
- if (!gPhotonStructure) {
- window.PanelUI.endBatchUpdate();
- }
this._customizing = true;
this._transitioning = false;
// Show the palette now that the transition has finished.
this.visiblePalette.hidden = false;
window.setTimeout(() => {
// Force layout reflow to ensure the animation runs,
// and make it async so it doesn't affect the timing.
@@ -423,36 +338,24 @@ CustomizeMode.prototype = {
this._updateEmptyPaletteNotice();
this._updateLWThemeButtonIcon();
if (!AppConstants.MOZ_PHOTON_THEME) {
this.maybeShowTip(panelHolder);
}
this._handler.isEnteringCustomizeMode = false;
- if (!gPhotonStructure) {
- window.PanelUI.contents.removeAttribute("customize-transitioning");
- }
CustomizableUI.dispatchToolboxEvent("customizationready", {}, window);
- this._enableOutlinesTimeout = window.setTimeout(() => {
- this.document.getElementById("nav-bar").setAttribute("showoutline", "true");
- if (!gPhotonStructure) {
- this.panelUIContents.setAttribute("showoutline", "true");
- }
- delete this._enableOutlinesTimeout;
- }, 0);
if (!this._wantToBeInCustomizeMode) {
this.exit();
}
})().catch(e => {
log.error("Error entering customize mode", e);
- // We should ensure this has been called, and calling it again doesn't hurt:
- window.PanelUI.endBatchUpdate();
this._handler.isEnteringCustomizeMode = false;
// Exit customize mode to ensure proper clean-up when entering failed.
this.exit();
});
},
exit() {
this._wantToBeInCustomizeMode = false;
@@ -473,52 +376,30 @@ CustomizeMode.prototype = {
"We'll exit after resetting has finished.");
return;
}
this.hideTip();
this._handler.isExitingCustomizeMode = true;
- if (this._enableOutlinesTimeout) {
- this.window.clearTimeout(this._enableOutlinesTimeout);
- } else {
- this.document.getElementById("nav-bar").removeAttribute("showoutline");
- this.panelUIContents.removeAttribute("showoutline");
- }
-
this._removeExtraToolbarsIfEmpty();
CustomizableUI.removeListener(this);
this.document.removeEventListener("keypress", this);
- if (!gPhotonStructure) {
- this.window.PanelUI.menuButton.removeEventListener("command", this);
- this.window.PanelUI.menuButton.open = false;
-
- this.window.PanelUI.beginBatchUpdate();
-
- this._removePanelCustomizationPlaceholders();
- }
let window = this.window;
let document = this.document;
// Hide the palette before starting the transition for increased perf.
this.visiblePalette.hidden = true;
this.visiblePalette.removeAttribute("showing");
this.paletteEmptyNotice.hidden = true;
- if (!gPhotonStructure) {
- // Disable the button-text fade-out mask
- // during the transition for increased perf.
- let panelContents = window.PanelUI.contents;
- panelContents.setAttribute("customize-transitioning", "true");
- }
-
// Disable the reset and undo reset buttons while transitioning:
let resetButton = this.document.getElementById("customization-reset-button");
let undoResetButton = this.document.getElementById("customization-undo-reset-button");
undoResetButton.hidden = resetButton.disabled = true;
this._transitioning = true;
(async () => {
@@ -559,74 +440,43 @@ CustomizeMode.prototype = {
// And drop all area references.
this.areas.clear();
// Let everybody in this window know that we're starting to
// exit customization mode.
CustomizableUI.dispatchToolboxEvent("customizationending", {}, window);
window.PanelUI.menuButton.disabled = false;
- if (gPhotonStructure) {
- let overflowContainer = document.getElementById("widget-overflow-scroller");
- overflowContainer.appendChild(window.PanelUI.overflowFixedList);
- document.getElementById("nav-bar-overflow-button").disabled = false;
- } else {
- window.PanelUI.setMainView(window.PanelUI.mainView);
-
- let customizeButton = document.getElementById("PanelUI-customize");
- customizeButton.setAttribute("exitLabel", customizeButton.getAttribute("label"));
- customizeButton.setAttribute("label", customizeButton.getAttribute("enterLabel"));
- customizeButton.setAttribute("exitTooltiptext", customizeButton.getAttribute("tooltiptext"));
- customizeButton.setAttribute("tooltiptext", customizeButton.getAttribute("enterTooltiptext"));
-
- // We have to use setAttribute/removeAttribute here instead of the
- // property because the XBL property will be set later, and right
- // now we'd be setting an expando, which breaks the XBL property.
- document.getElementById("PanelUI-help").removeAttribute("disabled");
- document.getElementById("PanelUI-quit").removeAttribute("disabled");
- this.panelUIContents.removeAttribute("customize-transitioning");
- }
+ let overflowContainer = document.getElementById("widget-overflow-scroller");
+ overflowContainer.appendChild(window.PanelUI.overflowFixedList);
+ document.getElementById("nav-bar-overflow-button").disabled = false;
let panelContextMenu = document.getElementById(kPanelItemContextMenu);
this._previousPanelContextMenuParent.appendChild(panelContextMenu);
// We need to set this._customizing to false before removing the tab
// or the TabSelect event handler will think that we are exiting
// customization mode for a second time.
this._customizing = false;
- if (!gPhotonStructure) {
- let mainView = window.PanelUI.mainView;
- if (this._mainViewContext) {
- mainView.setAttribute("context", this._mainViewContext);
- }
- }
-
let customizableToolbars = document.querySelectorAll("toolbar[customizable=true]:not([autohide=true])");
for (let toolbar of customizableToolbars)
toolbar.removeAttribute("customizing");
- if (!gPhotonStructure) {
- this.window.PanelUI.endBatchUpdate();
- }
delete this._lastLightweightTheme;
this._changed = false;
this._transitioning = false;
this._handler.isExitingCustomizeMode = false;
CustomizableUI.dispatchToolboxEvent("aftercustomization", {}, window);
CustomizableUI.notifyEndCustomizing(window);
if (this._wantToBeInCustomizeMode) {
this.enter();
}
})().catch(e => {
log.error("Error exiting customize mode", e);
- if (!gPhotonStructure) {
- // We should ensure this has been called, and calling it again doesn't hurt:
- window.PanelUI.endBatchUpdate();
- }
this._handler.isExitingCustomizeMode = false;
});
},
/**
* The customize mode transition has 4 phases when entering:
* 1) Pre-customization mode
* This is the starting phase of the browser.
@@ -805,18 +655,17 @@ CustomizeMode.prototype = {
}
},
addToPanel(aNode) {
aNode = this._getCustomizableChildForNode(aNode);
if (aNode.localName == "toolbarpaletteitem" && aNode.firstChild) {
aNode = aNode.firstChild;
}
- let panel = gPhotonStructure ? CustomizableUI.AREA_FIXED_OVERFLOW_PANEL
- : CustomizableUI.AREA_PANEL;
+ let panel = CustomizableUI.AREA_FIXED_OVERFLOW_PANEL;
CustomizableUI.addWidgetToArea(aNode.id, panel);
if (!this._customizing) {
CustomizableUI.dispatchToolboxEvent("customizationchange");
}
if (AppConstants.MOZ_PHOTON_ANIMATIONS &&
Services.prefs.getBoolPref("toolkit.cosmeticAnimations.enabled")) {
let overflowButton = this.document.getElementById("nav-bar-overflow-button");
@@ -855,20 +704,18 @@ CustomizeMode.prototype = {
for (let widget of unusedWidgets) {
let paletteItem = this.makePaletteItem(widget, "palette");
if (!paletteItem) {
continue;
}
fragment.appendChild(paletteItem);
}
- if (gPhotonStructure) {
- let flexSpace = CustomizableUI.createSpecialWidget("spring", this.document);
- fragment.appendChild(this.wrapToolbarItem(flexSpace, "palette"));
- }
+ let flexSpace = CustomizableUI.createSpecialWidget("spring", this.document);
+ fragment.appendChild(this.wrapToolbarItem(flexSpace, "palette"));
this.visiblePalette.appendChild(fragment);
this._stowedPalette = this.window.gNavToolbox.palette;
this.window.gNavToolbox.palette = this.visiblePalette;
} catch (ex) {
log.error(ex);
}
},
@@ -1159,17 +1006,17 @@ CustomizeMode.prototype = {
async _wrapToolbarItems() {
for (let area of CustomizableUI.areas) {
await this._wrapToolbarItem(area);
}
},
_addDragHandlers(aTarget) {
// Allow dropping on the padding of the arrow panel.
- if (gPhotonStructure && aTarget.id == CustomizableUI.AREA_FIXED_OVERFLOW_PANEL) {
+ if (aTarget.id == CustomizableUI.AREA_FIXED_OVERFLOW_PANEL) {
aTarget = this.document.getElementById("customization-panelHolder");
}
aTarget.addEventListener("dragstart", this, true);
aTarget.addEventListener("dragover", this, true);
aTarget.addEventListener("dragexit", this, true);
aTarget.addEventListener("drop", this, true);
aTarget.addEventListener("dragend", this, true);
},
@@ -1180,17 +1027,17 @@ CustomizeMode.prototype = {
this.wrapToolbarItem(child, CustomizableUI.getPlaceForItem(child));
}
}
},
_removeDragHandlers(aTarget) {
// Remove handler from different target if it was added to
// allow dropping on the padding of the arrow panel.
- if (gPhotonStructure && aTarget.id == CustomizableUI.AREA_FIXED_OVERFLOW_PANEL) {
+ if (aTarget.id == CustomizableUI.AREA_FIXED_OVERFLOW_PANEL) {
aTarget = this.document.getElementById("customization-panelHolder");
}
aTarget.removeEventListener("dragstart", this, true);
aTarget.removeEventListener("dragover", this, true);
aTarget.removeEventListener("dragexit", this, true);
aTarget.removeEventListener("drop", this, true);
aTarget.removeEventListener("dragend", this, true);
},
@@ -1244,45 +1091,42 @@ CustomizeMode.prototype = {
reset() {
this.resetting = true;
// Disable the reset button temporarily while resetting:
let btn = this.document.getElementById("customization-reset-button");
BrowserUITelemetry.countCustomizationEvent("reset");
btn.disabled = true;
return (async () => {
- this._removePanelCustomizationPlaceholders();
await this.depopulatePalette();
await this._unwrapToolbarItems();
CustomizableUI.reset();
this._updateLWThemeButtonIcon();
await this._wrapToolbarItems();
this.populatePalette();
this.persistCurrentSets(true);
this._updateResetButton();
this._updateUndoResetButton();
this._updateEmptyPaletteNotice();
- this._showPanelCustomizationPlaceholders();
this.resetting = false;
if (!this._wantToBeInCustomizeMode) {
this.exit();
}
})().catch(log.error);
},
undoReset() {
this.resetting = true;
return (async () => {
- this._removePanelCustomizationPlaceholders();
await this.depopulatePalette();
await this._unwrapToolbarItems();
CustomizableUI.undoReset();
this._updateLWThemeButtonIcon();
await this._wrapToolbarItems();
@@ -1319,19 +1163,16 @@ CustomizeMode.prototype = {
onWidgetRemoved(aWidgetId, aArea) {
this._onUIChange();
},
onWidgetBeforeDOMChange(aNodeToChange, aSecondaryNode, aContainer) {
if (aContainer.ownerGlobal != this.window || this.resetting) {
return;
}
- if (aContainer.id == CustomizableUI.AREA_PANEL) {
- this._removePanelCustomizationPlaceholders();
- }
// If we get called for widgets that aren't in the window yet, they might not have
// a parentNode at all.
if (aNodeToChange.parentNode) {
this.unwrapToolbarItem(aNodeToChange.parentNode);
}
if (aSecondaryNode) {
this.unwrapToolbarItem(aSecondaryNode.parentNode);
}
@@ -1357,29 +1198,22 @@ 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 (aContainer.id == CustomizableUI.AREA_PANEL) {
- this._showPanelCustomizationPlaceholders();
- }
},
onWidgetDestroyed(aWidgetId) {
let wrapper = this.document.getElementById("wrapper-" + aWidgetId);
if (wrapper) {
- let wasInPanel = wrapper.parentNode == this.panelUIContents;
wrapper.remove();
- if (wasInPanel) {
- this._showPanelCustomizationPlaceholders();
- }
}
},
onWidgetAfterCreation(aWidgetId, aArea) {
// If the node was added to an area, we would have gotten an onWidgetAdded notification,
// plus associated DOM change notifications, so only do stuff for the palette:
if (!aArea) {
let widgetNode = this.document.getElementById(aWidgetId);
@@ -1391,26 +1225,24 @@ CustomizeMode.prototype = {
}
}
},
onAreaNodeRegistered(aArea, aContainer) {
if (aContainer.ownerDocument == this.document) {
this._wrapItemsInArea(aContainer);
this._addDragHandlers(aContainer);
- DragPositionManager.add(this.window, aArea, aContainer);
this.areas.add(aContainer);
}
},
onAreaNodeUnregistered(aArea, aContainer, aReason) {
if (aContainer.ownerDocument == this.document && aReason == CustomizableUI.REASON_AREA_UNREGISTERED) {
this._unwrapItemsInArea(aContainer);
this._removeDragHandlers(aContainer);
- DragPositionManager.remove(this.window, aArea, aContainer);
this.areas.delete(aContainer);
}
},
openAddonsManagerThemes(aEvent) {
aEvent.target.parentNode.parentNode.hidePopup();
this.window.BrowserOpenAddonsMgr("addons://list/theme");
},
@@ -1675,22 +1507,16 @@ CustomizeMode.prototype = {
this._onDragDrop(aEvent);
break;
case "dragexit":
this._onDragExit(aEvent);
break;
case "dragend":
this._onDragEnd(aEvent);
break;
- case "command":
- if (aEvent.originalTarget == this.window.PanelUI.menuButton) {
- this.exit();
- aEvent.preventDefault();
- }
- break;
case "mousedown":
this._onMouseDown(aEvent);
break;
case "mouseup":
this._onMouseUp(aEvent);
break;
case "keypress":
if (aEvent.keyCode == aEvent.DOM_VK_ESCAPE) {
@@ -1794,20 +1620,18 @@ CustomizeMode.prototype = {
// Hack needed so that the dragimage will still show the
// item as it appeared before it was hidden.
this._initializeDragAfterMove = () => {
// For automated tests, we sometimes start exiting customization mode
// before this fires, which leaves us with placeholders inserted after
// we've exited. So we need to check that we are indeed customizing.
if (this._customizing && !this._transitioning) {
item.hidden = true;
- this._showPanelCustomizationPlaceholders();
DragPositionManager.start(this.window);
- let canUsePrevSibling = placeForItem == "toolbar" ||
- (placeForItem == "panel" && gPhotonStructure);
+ let canUsePrevSibling = placeForItem == "toolbar" || placeForItem == "panel";
if (item.nextSibling) {
this._setDragActive(item.nextSibling, "before", draggedItem.id, placeForItem);
this._dragOverItem = item.nextSibling;
} else if (canUsePrevSibling && item.previousSibling) {
this._setDragActive(item.previousSibling, "after", draggedItem.id, placeForItem);
this._dragOverItem = item.previousSibling;
}
}
@@ -1887,17 +1711,17 @@ CustomizeMode.prototype = {
let existingDir = dragOverItem.getAttribute("dragover");
if (existingDir == "before") {
dropTargetCenter += (parseInt(dragOverItem.style.borderInlineStartWidth) || 0) / 2;
} else {
dropTargetCenter -= (parseInt(dragOverItem.style.borderInlineEndWidth) || 0) / 2;
}
let before = this._dir == "ltr" ? aEvent.clientX < dropTargetCenter : aEvent.clientX > dropTargetCenter;
dragValue = before ? "before" : "after";
- } else if (targetAreaType == "menu-panel" && gPhotonStructure) {
+ } else if (targetAreaType == "menu-panel") {
let itemRect = this._dwu.getBoundsWithoutFlushing(dragOverItem);
let dropTargetCenter = itemRect.top + (itemRect.height / 2);
let existingDir = dragOverItem.getAttribute("dragover");
if (existingDir == "before") {
dropTargetCenter += (parseInt(dragOverItem.style.borderBlockStartWidth) || 0) / 2;
} else {
dropTargetCenter -= (parseInt(dragOverItem.style.borderBlockEndWidth) || 0) / 2;
}
@@ -1910,18 +1734,16 @@ CustomizeMode.prototype = {
if (this._dragOverItem && dragOverItem != this._dragOverItem) {
this._cancelDragActive(this._dragOverItem, dragOverItem);
}
if (dragOverItem != this._dragOverItem || dragValue != dragOverItem.getAttribute("dragover")) {
if (dragOverItem != targetArea.customizationTarget) {
this._setDragActive(dragOverItem, dragValue, draggedItemId, targetAreaType);
- } else if (targetAreaType == "toolbar") {
- this._updateToolbarCustomizationOutline(this.window, targetArea);
}
this._dragOverItem = dragOverItem;
}
aEvent.preventDefault();
aEvent.stopPropagation();
},
@@ -1962,25 +1784,22 @@ CustomizeMode.prototype = {
while (targetNode.classList.contains(kPlaceholderClass) && targetNode.nextSibling) {
targetNode = targetNode.nextSibling;
}
if (targetNode.tagName == "toolbarpaletteitem") {
targetNode = targetNode.firstChild;
}
this._cancelDragActive(this._dragOverItem, null, true);
- this._removePanelCustomizationPlaceholders();
try {
this._applyDrop(aEvent, targetArea, originArea, draggedItemId, targetNode);
} catch (ex) {
log.error(ex, ex.stack);
}
-
- this._showPanelCustomizationPlaceholders();
},
_applyDrop(aEvent, aTargetArea, aOriginArea, aDraggedItemId, aTargetNode) {
let document = aEvent.target.ownerDocument;
let draggedItem = document.getElementById(aDraggedItemId);
draggedItem.hidden = false;
draggedItem.removeAttribute("mousedown");
@@ -2160,18 +1979,16 @@ CustomizeMode.prototype = {
draggedWrapper.hidden = false;
draggedWrapper.removeAttribute("mousedown");
}
if (this._dragOverItem) {
this._cancelDragActive(this._dragOverItem);
this._dragOverItem = null;
}
- this._updateToolbarCustomizationOutline(this.window);
- this._showPanelCustomizationPlaceholders();
DragPositionManager.stop();
},
_isUnwantedDragDrop(aEvent) {
// The simulated events generated by synthesizeDragStart/synthesizeDrop in
// mochitests are used only for testing whether the right data is being put
// into the dataTransfer. Neither cause a real drop to occur, so they don't
// set the source node. There isn't a means of testing real drag and drops,
@@ -2199,21 +2016,20 @@ CustomizeMode.prototype = {
if (aAreaType == "panel") {
aAreaType = "menu-panel";
}
if (aItem.getAttribute("dragover") != aValue) {
aItem.setAttribute("dragover", aValue);
let window = aItem.ownerGlobal;
let draggedItem = window.document.getElementById(aDraggedItemId);
- if (aAreaType == "palette" || (aAreaType == "menu-panel" && !gPhotonStructure)) {
+ if (aAreaType == "palette") {
this._setGridDragActive(aItem, draggedItem, aValue);
} else {
let targetArea = this._getCustomizableParent(aItem);
- this._updateToolbarCustomizationOutline(window, targetArea);
let makeSpaceImmediately = false;
if (!gDraggingInToolbars.has(targetArea.id)) {
gDraggingInToolbars.add(targetArea.id);
let draggedWrapper = this.document.getElementById("wrapper-" + aDraggedItemId);
let originArea = this._getCustomizableParent(draggedWrapper);
makeSpaceImmediately = originArea == targetArea;
}
let propertyToMeasure = aAreaType == "toolbar" ? "width" : "height";
@@ -2237,24 +2053,22 @@ CustomizeMode.prototype = {
// Force a layout flush:
aItem.getBoundingClientRect();
aItem.removeAttribute("notransition");
}
}
}
},
_cancelDragActive(aItem, aNextItem, aNoTransition) {
- this._updateToolbarCustomizationOutline(aItem.ownerGlobal);
let currentArea = this._getCustomizableParent(aItem);
if (!currentArea) {
return;
}
let areaType = CustomizableUI.getAreaType(currentArea.id);
- let needPositionManager = !areaType || (areaType == "menu-panel" && !gPhotonStructure);
- if (!needPositionManager) {
+ if (areaType) {
if (aNoTransition) {
aItem.setAttribute("notransition", "true");
}
aItem.removeAttribute("dragover");
// Remove all property values in the case that the end padding
// had been set.
aItem.style.removeProperty("border-inline-start-width");
aItem.style.removeProperty("border-inline-end-width");
@@ -2347,17 +2161,17 @@ CustomizeMode.prototype = {
CustomizableUI.onWidgetDrag(aDraggedItem.id);
} else {
aDraggedItem.parentNode.hidden = true;
}
return size;
},
_getCustomizableParent(aElement) {
- if (gPhotonStructure && aElement) {
+ if (aElement) {
// Deal with drag/drop on the padding of the panel in photon.
let containingPanelHolder = aElement.closest("#customization-panelHolder");
if (containingPanelHolder) {
return containingPanelHolder.firstChild;
}
}
let areas = CustomizableUI.areas;
@@ -2392,17 +2206,17 @@ CustomizeMode.prototype = {
if (boundsContainer == this.panelUIContents) {
boundsContainer = boundsContainer.parentNode;
}
let bounds = boundsContainer.getBoundingClientRect();
dragX = Math.min(bounds.right, Math.max(dragX, bounds.left));
dragY = Math.min(bounds.bottom, Math.max(dragY, bounds.top));
let targetNode;
- if (aAreaType == "toolbar" || (aAreaType == "menu-panel" && gPhotonStructure)) {
+ if (aAreaType == "toolbar" || aAreaType == "menu-panel") {
targetNode = aAreaElement.ownerDocument.elementFromPoint(dragX, dragY);
while (targetNode && targetNode.parentNode != expectedParent) {
targetNode = targetNode.parentNode;
}
} else {
let positionManager = DragPositionManager.getManagerForArea(aAreaElement);
// Make it relative to the container:
dragX -= bounds.left;
@@ -2451,99 +2265,27 @@ CustomizeMode.prototype = {
while (aElement && aElement.localName != "toolbarpaletteitem") {
if (aElement.localName == "toolbar")
return null;
aElement = aElement.parentNode;
}
return aElement;
},
- _showPanelCustomizationPlaceholders() {
- let doc = this.document;
- let contents = this.panelUIContents;
- let narrowItemsAfterWideItem = 0;
- let node = contents.lastChild;
- while (node && !node.classList.contains(CustomizableUI.WIDE_PANEL_CLASS) &&
- (!node.firstChild || !node.firstChild.classList.contains(CustomizableUI.WIDE_PANEL_CLASS))) {
- if (!node.hidden && !node.classList.contains(kPlaceholderClass)) {
- narrowItemsAfterWideItem++;
- }
- node = node.previousSibling;
- }
-
- let orphanedItems = narrowItemsAfterWideItem % CustomizableUI.PANEL_COLUMN_COUNT;
- let placeholders = CustomizableUI.PANEL_COLUMN_COUNT - orphanedItems;
-
- let currentPlaceholderCount = contents.querySelectorAll("." + kPlaceholderClass).length;
- if (placeholders > currentPlaceholderCount) {
- while (placeholders-- > currentPlaceholderCount) {
- let placeholder = doc.createElement("toolbarpaletteitem");
- placeholder.classList.add(kPlaceholderClass);
- // XXXjaws The toolbarbutton child here is only necessary to get
- // the styling right here.
- let placeholderChild = doc.createElement("toolbarbutton");
- placeholderChild.classList.add(kPlaceholderClass + "-child");
- placeholder.appendChild(placeholderChild);
- contents.appendChild(placeholder);
- }
- } else if (placeholders < currentPlaceholderCount) {
- while (placeholders++ < currentPlaceholderCount) {
- contents.querySelectorAll("." + kPlaceholderClass)[0].remove();
- }
- }
- },
-
- _removePanelCustomizationPlaceholders() {
- let contents = this.panelUIContents;
- let oldPlaceholders = contents.getElementsByClassName(kPlaceholderClass);
- while (oldPlaceholders.length) {
- contents.removeChild(oldPlaceholders[0]);
- }
- },
-
- /**
- * Update toolbar customization targets during drag events to add or remove
- * outlines to indicate that an area is customizable.
- *
- * @param aWindow The XUL window in which outlines should be updated.
- * @param {Element} [aToolbarArea=null] The element of the customizable toolbar area to add the
- * outline to. If aToolbarArea is falsy, the outline will be
- * removed from all toolbar areas.
- */
- _updateToolbarCustomizationOutline(aWindow, aToolbarArea = null) {
- // Remove the attribute from existing customization targets
- for (let area of CustomizableUI.areas) {
- if (CustomizableUI.getAreaType(area) != CustomizableUI.TYPE_TOOLBAR) {
- continue;
- }
- let target = CustomizableUI.getCustomizeTargetForArea(area, aWindow);
- target.removeAttribute("customizing-dragovertarget");
- }
-
- // Now set the attribute on the desired target
- if (aToolbarArea) {
- if (CustomizableUI.getAreaType(aToolbarArea.id) != CustomizableUI.TYPE_TOOLBAR)
- return;
- let target = CustomizableUI.getCustomizeTargetForArea(aToolbarArea.id, aWindow);
- target.setAttribute("customizing-dragovertarget", true);
- }
- },
-
_findVisiblePreviousSiblingNode(aReferenceNode) {
while (aReferenceNode &&
aReferenceNode.localName == "toolbarpaletteitem" &&
aReferenceNode.firstChild.hidden) {
aReferenceNode = aReferenceNode.previousSibling;
}
return aReferenceNode;
},
onPanelContextMenuShowing(event) {
- let inPermanentArea = !gPhotonStructure ||
- !!event.target.triggerNode.closest("#widget-overflow-fixed-list");
+ let inPermanentArea = !!event.target.triggerNode.closest("#widget-overflow-fixed-list");
let doc = event.target.ownerDocument;
doc.getElementById("customizationPanelItemContextMenuUnpin").hidden = !inPermanentArea;
doc.getElementById("customizationPanelItemContextMenuPin").hidden = inPermanentArea;
},
};
function __dumpDragData(aEvent, caller) {
if (!gDebug) {