Bug 1354145 - Make customize mode deal with drops in the padding around the panel contents, r?mikedeboer draft
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Wed, 28 Jun 2017 23:46:15 +0100
changeset 601990 72322305b4d7b1e9e1321b356a3fee93f252aa9d
parent 601989 2ecb386fb4112f7ee6e49534e9ae8aaad6aee6fb
child 601991 68d201ab3838538381cf268eee47cb791558cd01
push id66228
push usergijskruitbosch@gmail.com
push dateThu, 29 Jun 2017 08:56:09 +0000
reviewersmikedeboer
bugs1354145
milestone56.0a1
Bug 1354145 - Make customize mode deal with drops in the padding around the panel contents, r?mikedeboer MozReview-Commit-ID: BCi7odA3sth
browser/components/customizableui/CustomizeMode.jsm
--- 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;