Bug 1354145 - Make customize mode deal with drops in the padding around the panel contents, r?mikedeboer
MozReview-Commit-ID: BCi7odA3sth
--- a/browser/components/customizableui/CustomizeMode.jsm
+++ b/browser/components/customizableui/CustomizeMode.jsm
@@ -1107,32 +1107,41 @@ 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) {
+ 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);
},
_wrapItemsInArea(target) {
for (let child of target.children) {
if (this.isCustomizableItem(child)) {
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) {
+ 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);
},
_unwrapItemsInArea(target) {
@@ -2190,24 +2199,33 @@ CustomizeMode.prototype = {
CustomizableUI.onWidgetDrag(aDraggedItem.id);
} else {
aDraggedItem.parentNode.hidden = true;
}
return size;
},
_getCustomizableParent(aElement) {
+ if (gPhotonStructure && 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;
areas.push(kPaletteId);
while (aElement) {
if (areas.indexOf(aElement.id) != -1) {
return aElement;
}
aElement = aElement.parentNode;
}
+
return null;
},
_getDragOverNode(aEvent, aAreaElement, aAreaType, aDraggedItemId) {
let expectedParent = aAreaElement.customizationTarget || aAreaElement;
// Our tests are stupid. Cope:
if (!aEvent.clientX && !aEvent.clientY) {
return aEvent.target;