Bug 437711 - Use new Drag'n'Drop API in Calendar. r=pmorris
authorKhushil Mistry <khushil324@gmail.com>
Thu, 12 Mar 2020 20:07:03 +1300
changeset 38473 9aa142882f1850579cd4262bdbb7263306b2f00a
parent 38472 40262b53174b5cd70a6e5812f79ca5ca4ac1bc80
child 38474 6e05e171547189be7183d9ea611587848ad5c49d
push id400
push userclokep@gmail.com
push dateMon, 04 May 2020 18:56:09 +0000
reviewerspmorris
bugs437711
Bug 437711 - Use new Drag'n'Drop API in Calendar. r=pmorris
calendar/base/content/calendar-dnd-listener.js
calendar/lightning/content/calendar-today-pane.inc.xhtml
mail/base/content/messenger.xhtml
mail/base/content/nsDragAndDrop.js
mail/base/jar.mn
--- a/calendar/base/content/calendar-dnd-listener.js
+++ b/calendar/base/content/calendar-dnd-listener.js
@@ -1,13 +1,12 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-/* import-globals-from ../../../mail/base/content/nsDragAndDrop.js */
 /* import-globals-from calendar-item-editing.js */
 /* import-globals-from calendar-management.js */
 /* import-globals-from import-export.js */
 
 var { cal } = ChromeUtils.import("resource:///modules/calendar/calUtils.jsm");
 var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 var { AppConstants } = ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
 var { MailServices } = ChromeUtils.import("resource:///modules/MailServices.jsm");
@@ -186,31 +185,24 @@ var itemConversion = {
  * A base class for drag and drop observers
  * @class calDNDBaseObserver
  */
 function calDNDBaseObserver() {
   cal.ASSERT(false, "Inheriting objects call calDNDBaseObserver!");
 }
 
 calDNDBaseObserver.prototype = {
-  getSupportedFlavours() {
-    let flavourSet = new FlavourSet();
-    flavourSet.appendFlavour("text/calendar");
-    flavourSet.appendFlavour("text/x-moz-url");
-    flavourSet.appendFlavour("text/x-moz-message");
-    flavourSet.appendFlavour("text/unicode");
-    flavourSet.appendFlavour("application/x-moz-file");
-    return flavourSet;
-  },
-
   /**
    * Action to take when dropping the event.
    */
 
-  onDrop(event, transferData, dragSession) {
+  onDrop(event) {
+    let dragSession = Cc["@mozilla.org/widget/dragservice;1"]
+      .getService(Ci.nsIDragService)
+      .getCurrentSession();
     // Handles text/x-moz-message, text/x-moz-address and text/x-moz-url flavours.
     if (this.onDropEventData(event.dataTransfer)) {
       return;
     }
 
     let transferable = Cc["@mozilla.org/widget/transferable;1"].createInstance(Ci.nsITransferable);
     transferable.init(null);
     transferable.addDataFlavor("text/calendar");
@@ -269,22 +261,24 @@ calDNDBaseObserver.prototype = {
         } finally {
           inputStream.close();
         }
         break;
       }
     }
   },
 
-  onDragStart(aEvent, aTransferData, aDragAction) {},
-  onDragOver(aEvent, aFlavor, aDragSession) {},
-  onDragExit(aEvent, aDragSession) {},
+  onDragStart(event) {},
+  onDragOver(event) {
+    event.preventDefault();
+  },
+  onDragExit(event) {},
 
-  onDropItems(aItems) {},
-  onDropMessage(aMessage) {},
+  onDropItems(items) {},
+  onDropMessage(message) {},
 
   /**
    * Extract the data of dataTransfer object in the drop event if presents. It will
    * extract data of following flavours: text/x-moz-message, text/x-moz-address and
    * text/x-moz-url.
    *
    * @param {Object} dataTransfer - The dataTransfer object from the drop event.
    * @return {boolean} Returns true if we have data from the given flavours.
--- a/calendar/lightning/content/calendar-today-pane.inc.xhtml
+++ b/calendar/lightning/content/calendar-today-pane.inc.xhtml
@@ -139,19 +139,18 @@
                          tooltiptext="&calendar.newevent.button.tooltip;"
                          command="calendar_new_event_todaypane_command"/>
         </hbox>
         <richlistbox id="agenda-listbox" flex="1" context="_child"
                      onblur="agendaListbox.onBlur();"
                      onfocus="agendaListbox.onFocus();"
                      onkeypress="agendaListbox.onKeyPress(event);"
                      ondblclick="agendaListbox.createNewEvent(event);"
-                     ondragstart="nsDragAndDrop.startDrag(event, calendarCalendarButtonDNDObserver);"
-                     ondragover="nsDragAndDrop.dragOver(event, calendarCalendarButtonDNDObserver);"
-                     ondrop="nsDragAndDrop.drop(event, calendarCalendarButtonDNDObserver);">
+                     ondragover="calendarCalendarButtonDNDObserver.onDragOver(event);"
+                     ondrop="calendarCalendarButtonDNDObserver.onDrop(event);">
           <menupopup id="agenda-menupopup" onpopupshowing="return agendaListbox.setupContextMenu(event.target)">
             <menuitem label="&calendar.context.modifyorviewitem.label;"
                       accesskey="&calendar.context.modifyorviewitem.accesskey;"
                       command="agenda_edit_event_command"/>
             <menu id="agenda-context-menu-convert-menu"
                   label="&calendar.context.convertmenu.label;"
                   accesskey="&calendar.context.convertmenu.accesskey.calendar;">
               <menupopup id="agenda-context-menu-convert-menupopup">
@@ -353,19 +352,18 @@
       </vbox>
     </calendar-modevbox>
     <splitter id="today-pane-splitter" persist="hidden"/>
     <calendar-modevbox id="todo-tab-panel"
                        flex="1"
                        mode="mail,calendar,chat,calendarEvent,calendarTask"
                        collapsedinmodes="mail,task,chat,calendarEvent,calendarTask"
                        persist="height collapsedinmodes"
-                       ondragstart="nsDragAndDrop.startDrag(event, calendarTaskButtonDNDObserver);"
-                       ondragover="nsDragAndDrop.dragOver(event, calendarTaskButtonDNDObserver);"
-                       ondrop="nsDragAndDrop.drop(event, calendarTaskButtonDNDObserver);">
+                       ondragover="calendarTaskButtonDNDObserver.onDragOver(event);"
+                       ondrop="calendarTaskButtonDNDObserver.onDrop(event);">
       <!-- This second vbox means all of this is added to the DOM at once,
            so the label's binding doesn't complain about not having a control. -->
       <vbox flex="1">
         <box id="show-completed-checkbox-box" align="center">
           <checkbox id="show-completed-checkbox"
                     label="&calendar.unifinder.showcompletedtodos.label;"
                     flex="1"
                     crop="end"
--- a/mail/base/content/messenger.xhtml
+++ b/mail/base/content/messenger.xhtml
@@ -249,17 +249,16 @@
 <script src="chrome://calendar/content/calendar-month-view.js"/>
 <script src="chrome://calendar/content/calendar-multiday-view.js"/>
 <script src="chrome://calendar/content/calendar-event-column.js"/>
 
 <script src="chrome://calendar/content/calendar-creation.js"/>
 <script src="chrome://calendar/content/calendar-dnd-listener.js"/>
 <script src="chrome://calendar/content/calendar-statusbar.js"/>
 <script src="chrome://calendar/content/widgets/calendar-minimonth.js"/>
-<script src="chrome://global/content/nsDragAndDrop.js"/>
 <script src="chrome://calendar/content/widgets/calendar-modebox.js"/>
 
 <!-- NEEDED FOR TASK VIEW/LIST SUPPORT -->
 <script src="chrome://calendar/content/calendar-task-editing.js"/>
 
 <script src="chrome://calendar/content/calendar-extract.js"/>
 
 <script src="chrome://calendar/content/calendar-invitations-manager.js"/>
deleted file mode 100644
--- a/mail/base/content/nsDragAndDrop.js
+++ /dev/null
@@ -1,606 +0,0 @@
-// -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
-
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-// USE OF THIS API FOR DRAG AND DROP IS DEPRECATED!
-// Do not use this file for new code.
-//
-// Toolkit dropped nsDragAndDrop.js in bug 1162050.
-// Mapped to content/global/nsDragAndDrop.js until we can remove this usage.
-//
-// For documentation about what to use instead, see:
-//   http://developer.mozilla.org/En/DragDrop/Drag_and_Drop
-
-/**
- *  nsTransferable - a wrapper for nsITransferable that simplifies
- *                   javascript clipboard and drag&drop. for use in
- *                   these situations you should use the nsClipboard
- *                   and nsDragAndDrop wrappers for more convenience
- **/
-
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-
-var nsTransferable = {
-  /**
-   * nsITransferable set (TransferData aTransferData) ;
-   *
-   * Creates a transferable with data for a list of supported types ("flavours")
-   *
-   * @param TransferData aTransferData
-   *        a javascript object in the format described above
-   **/
-  set(aTransferDataSet) {
-    var trans = this.createTransferable();
-    for (var i = 0; i < aTransferDataSet.dataList.length; ++i) {
-      var currData = aTransferDataSet.dataList[i];
-      var currFlavour = currData.flavour.contentType;
-      trans.addDataFlavor(currFlavour);
-      var supports = null; // nsISupports data
-      if (currData.flavour.dataIIDKey == "nsISupportsString") {
-        supports = Cc["@mozilla.org/supports-string;1"].createInstance(
-          Ci.nsISupportsString
-        );
-
-        supports.data = currData.supports;
-      } else {
-        // non-string data.
-        supports = currData.supports;
-      }
-      trans.setTransferData(currFlavour, supports);
-    }
-    return trans;
-  },
-
-  /**
-   * TransferData/TransferDataSet get (FlavourSet aFlavourSet,
-   *                                   Function aRetrievalFunc, Boolean aAnyFlag) ;
-   *
-   * Retrieves data from the transferable provided in aRetrievalFunc, formatted
-   * for more convenient access.
-   *
-   * @param FlavourSet aFlavourSet
-   *        a FlavourSet object that contains a list of supported flavours.
-   * @param Function aRetrievalFunc
-   *        a reference to a function that returns a nsIArray of nsITransferables
-   *        for each item from the specified source (clipboard/drag&drop etc)
-   * @param Boolean aAnyFlag
-   *        a flag specifying whether or not a specific flavour is requested. If false,
-   *        data of the type of the first flavour in the flavourlist parameter is returned,
-   *        otherwise the best flavour supported will be returned.
-   **/
-  get(aFlavourSet, aRetrievalFunc, aAnyFlag) {
-    if (!aRetrievalFunc) {
-      throw new Error("No data retrieval handler provided!");
-    }
-
-    var array = aRetrievalFunc(aFlavourSet);
-    var dataArray = [];
-
-    // Iterate over the number of items returned from aRetrievalFunc. For
-    // clipboard operations, this is 1, for drag and drop (where multiple
-    // items may have been dragged) this could be >1.
-    for (let i = 0; i < array.length; i++) {
-      let trans = array.queryElementAt(i, Ci.nsITransferable);
-      if (!trans) {
-        continue;
-      }
-
-      var data = {};
-
-      if (aAnyFlag) {
-        var flavour = {};
-        trans.getAnyTransferData(flavour, data);
-        if (data && flavour) {
-          var selectedFlavour = aFlavourSet.flavourTable[flavour.value];
-          if (selectedFlavour) {
-            dataArray[i] = FlavourToXfer(
-              data.value,
-              data.length,
-              selectedFlavour
-            );
-          }
-        }
-      } else {
-        var firstFlavour = aFlavourSet.flavours[0];
-        trans.getTransferData(firstFlavour, data);
-        if (data && firstFlavour) {
-          dataArray[i] = FlavourToXfer(data.value, data.length, firstFlavour);
-        }
-      }
-    }
-    return new TransferDataSet(dataArray);
-  },
-
-  /**
-   * nsITransferable createTransferable (void) ;
-   *
-   * Creates and returns a transferable object.
-   **/
-  createTransferable() {
-    const kXferableContractID = "@mozilla.org/widget/transferable;1";
-    const kXferableIID = Ci.nsITransferable;
-    var trans = Cc[kXferableContractID].createInstance(kXferableIID);
-    trans.init(null);
-    return trans;
-  },
-};
-
-/**
- * A FlavourSet is a simple type that represents a collection of Flavour objects.
- * FlavourSet is constructed from an array of Flavours, and stores this list as
- * an array and a hashtable. The rationale for the dual storage is as follows:
- *
- * Array: Ordering is important when adding data flavours to a transferable.
- *        Flavours added first are deemed to be 'preferred' by the client.
- * Hash:  Convenient lookup of flavour data using the content type (MIME type)
- *        of data as a key.
- */
-function FlavourSet(aFlavourList) {
-  this.flavours = aFlavourList || [];
-  this.flavourTable = {};
-
-  this._XferID = "FlavourSet";
-
-  for (var i = 0; i < this.flavours.length; ++i) {
-    this.flavourTable[this.flavours[i].contentType] = this.flavours[i];
-  }
-}
-
-FlavourSet.prototype = {
-  appendFlavour(aFlavour, aFlavourIIDKey) {
-    var flavour = new Flavour(aFlavour, aFlavourIIDKey);
-    this.flavours.push(flavour);
-    this.flavourTable[flavour.contentType] = flavour;
-  },
-};
-
-/**
- * A Flavour is a simple type that represents a data type that can be handled.
- * It takes a content type (MIME type) which is used when storing data on the
- * system clipboard/drag and drop, and an IIDKey (string interface name
- * which is used to QI data to an appropriate form. The default interface is
- * assumed to be wide-string.
- */
-function Flavour(aContentType, aDataIIDKey) {
-  this.contentType = aContentType;
-  this.dataIIDKey = aDataIIDKey || "nsISupportsString";
-
-  this._XferID = "Flavour";
-}
-
-function TransferDataBase() {}
-TransferDataBase.prototype = {
-  push(aItems) {
-    this.dataList.push(aItems);
-  },
-
-  get first() {
-    return "dataList" in this && this.dataList.length ? this.dataList[0] : null;
-  },
-};
-
-/**
- * TransferDataSet is a list (array) of TransferData objects, which represents
- * data dragged from one or more elements.
- */
-function TransferDataSet(aTransferDataList) {
-  this.dataList = aTransferDataList || [];
-
-  this._XferID = "TransferDataSet";
-}
-TransferDataSet.prototype = TransferDataBase.prototype;
-
-/**
- * TransferData is a list (array) of FlavourData for all the applicable content
- * types associated with a drag from a single item.
- */
-function TransferData(aFlavourDataList) {
-  this.dataList = aFlavourDataList || [];
-
-  this._XferID = "TransferData";
-}
-TransferData.prototype = {
-  __proto__: TransferDataBase.prototype,
-
-  addDataForFlavour(aFlavourString, aData, aLength, aDataIIDKey) {
-    this.dataList.push(
-      new FlavourData(aData, aLength, new Flavour(aFlavourString, aDataIIDKey))
-    );
-  },
-};
-
-/**
- * FlavourData is a type that represents data retrieved from the system
- * clipboard or drag and drop. It is constructed internally by the Transferable
- * using the raw (nsISupports) data from the clipboard, the length of the data,
- * and an object of type Flavour representing the type. Clients implementing
- * IDragDropObserver receive an object of this type in their implementation of
- * onDrop. They access the 'data' property to retrieve data, which is either data
- * QI'ed to a usable form, or unicode string.
- */
-function FlavourData(aData, aLength, aFlavour) {
-  this.supports = aData;
-  this.contentLength = aLength;
-  this.flavour = aFlavour || null;
-
-  this._XferID = "FlavourData";
-}
-
-FlavourData.prototype = {
-  get data() {
-    if (this.flavour && this.flavour.dataIIDKey != "nsISupportsString") {
-      return this.supports.QueryInterface(Ci[this.flavour.dataIIDKey]);
-    }
-
-    var supports = this.supports;
-    if (supports instanceof Ci.nsISupportsString) {
-      return supports.data.substring(0, this.contentLength / 2);
-    }
-
-    return supports;
-  },
-};
-
-/**
- * Create a TransferData object with a single FlavourData entry. Used when
- * unwrapping data of a specific flavour from the drag service.
- */
-function FlavourToXfer(aData, aLength, aFlavour) {
-  return new TransferData([new FlavourData(aData, aLength, aFlavour)]);
-}
-
-var transferUtils = {
-  retrieveURLFromData(aData, flavour) {
-    switch (flavour) {
-      case "text/unicode":
-      case "text/plain":
-      case "text/x-moz-text-internal":
-        return aData.replace(/^\s+|\s+$/g, "");
-      case "text/x-moz-url":
-        return (aData instanceof Ci.nsISupportsString
-          ? aData.toString()
-          : aData
-        ).split("\n")[0];
-      case "application/x-moz-file":
-        var fileHandler = Services.io
-          .getProtocolHandler("file")
-          .QueryInterface(Ci.nsIFileProtocolHandler);
-        return fileHandler.getURLSpecFromFile(aData);
-    }
-    return null;
-  },
-};
-
-/**
- * nsDragAndDrop - a convenience wrapper for nsTransferable, nsITransferable
- *                 and nsIDragService/nsIDragSession.
- *
- * Use: map the handler functions to the 'ondraggesture', 'ondragover' and
- *   'ondragdrop' event handlers on your XML element, e.g.
- *   <xmlelement ondraggesture="nsDragAndDrop.startDrag(event, observer);"
- *               ondragover="nsDragAndDrop.dragOver(event, observer);"
- *               ondragdrop="nsDragAndDrop.drop(event, observer);"/>
- *
- *   You need to create an observer js object with the following member
- *   functions:
- *     Object onDragStart (event)        // called when drag initiated,
- *                                       // returns flavour list with data
- *                                       // to stuff into transferable
- *     void onDragOver (Object flavour)  // called when element is dragged
- *                                       // over, so that it can perform
- *                                       // any drag-over feedback for provided
- *                                       // flavour
- *     void onDrop (Object data)         // formatted data object dropped.
- *     Object getSupportedFlavours ()    // returns a flavour list so that
- *                                       // nsTransferable can determine
- *                                       // whether or not to accept drop.
- **/
-
-var nsDragAndDrop = {
-  _mDS: null,
-  get mDragService() {
-    if (!this._mDS) {
-      const kDSContractID = "@mozilla.org/widget/dragservice;1";
-      const kDSIID = Ci.nsIDragService;
-      this._mDS = Cc[kDSContractID].getService(kDSIID);
-    }
-    return this._mDS;
-  },
-
-  /**
-   * void startDrag (DOMEvent aEvent, Object aDragDropObserver) ;
-   *
-   * called when a drag on an element is started.
-   *
-   * @param DOMEvent aEvent
-   *        the DOM event fired by the drag init
-   * @param Object aDragDropObserver
-   *        javascript object of format described above that specifies
-   *        the way in which the element responds to drag events.
-   **/
-  startDrag(aEvent, aDragDropObserver) {
-    if (!("onDragStart" in aDragDropObserver)) {
-      return;
-    }
-
-    const kDSIID = Ci.nsIDragService;
-    var dragAction = {
-      action:
-        kDSIID.DRAGDROP_ACTION_COPY +
-        kDSIID.DRAGDROP_ACTION_MOVE +
-        kDSIID.DRAGDROP_ACTION_LINK,
-    };
-
-    var transferData = { data: null };
-    try {
-      aDragDropObserver.onDragStart(aEvent, transferData, dragAction);
-    } catch (e) {
-      return; // not a draggable item, bail!
-    }
-
-    if (!transferData.data) {
-      return;
-    }
-    transferData = transferData.data;
-
-    var dt = aEvent.dataTransfer;
-    var count = 0;
-    do {
-      var tds =
-        transferData._XferID == "TransferData"
-          ? transferData
-          : transferData.dataList[count];
-      for (var i = 0; i < tds.dataList.length; ++i) {
-        var currData = tds.dataList[i];
-        var currFlavour = currData.flavour.contentType;
-        var value = currData.supports;
-        if (value instanceof Ci.nsISupportsString) {
-          value = value.toString();
-        }
-        dt.mozSetDataAt(currFlavour, value, count);
-      }
-
-      count++;
-    } while (
-      transferData._XferID == "TransferDataSet" &&
-      count < transferData.dataList.length
-    );
-
-    dt.effectAllowed = "all";
-    // a drag targeted at a tree should instead use the treechildren so that
-    // the current selection is used as the drag feedback
-    dt.addElement(
-      aEvent.originalTarget.localName == "treechildren"
-        ? aEvent.originalTarget
-        : aEvent.target
-    );
-    aEvent.stopPropagation();
-  },
-
-  /**
-   * void dragOver (DOMEvent aEvent, Object aDragDropObserver) ;
-   *
-   * called when a drag passes over this element
-   *
-   * @param DOMEvent aEvent
-   *        the DOM event fired by passing over the element
-   * @param Object aDragDropObserver
-   *        javascript object of format described above that specifies
-   *        the way in which the element responds to drag events.
-   **/
-  dragOver(aEvent, aDragDropObserver) {
-    if (!("onDragOver" in aDragDropObserver)) {
-      return;
-    }
-    if (!this.checkCanDrop(aEvent, aDragDropObserver)) {
-      return;
-    }
-    var flavourSet = aDragDropObserver.getSupportedFlavours();
-    for (var flavour in flavourSet.flavourTable) {
-      if (this.mDragSession.isDataFlavorSupported(flavour)) {
-        aDragDropObserver.onDragOver(
-          aEvent,
-          flavourSet.flavourTable[flavour],
-          this.mDragSession
-        );
-        aEvent.stopPropagation();
-        aEvent.preventDefault();
-        break;
-      }
-    }
-  },
-
-  mDragSession: null,
-
-  /**
-   * void drop (DOMEvent aEvent, Object aDragDropObserver) ;
-   *
-   * called when the user drops on the element
-   *
-   * @param DOMEvent aEvent
-   *        the DOM event fired by the drop
-   * @param Object aDragDropObserver
-   *        javascript object of format described above that specifies
-   *        the way in which the element responds to drag events.
-   **/
-  drop(aEvent, aDragDropObserver) {
-    if (!("onDrop" in aDragDropObserver)) {
-      return;
-    }
-    if (!this.checkCanDrop(aEvent, aDragDropObserver)) {
-      return;
-    }
-
-    var flavourSet = aDragDropObserver.getSupportedFlavours();
-
-    var dt = aEvent.dataTransfer;
-    var dataArray = [];
-    var count = dt.mozItemCount;
-    for (var i = 0; i < count; ++i) {
-      var types = Array.from(dt.mozTypesAt(i));
-      for (var j = 0; j < flavourSet.flavours.length; j++) {
-        var type = flavourSet.flavours[j].contentType;
-        // dataTransfer uses text/plain but older code used text/unicode, so
-        // switch this for compatibility
-        var modtype = type == "text/unicode" ? "text/plain" : type;
-        if (types.includes(modtype)) {
-          var data = dt.mozGetDataAt(modtype, i);
-          if (data) {
-            // Non-strings need some non-zero value used for their data length.
-            const kNonStringDataLength = 4;
-
-            var length =
-              typeof data == "string" ? data.length : kNonStringDataLength;
-            dataArray[i] = FlavourToXfer(
-              data,
-              length,
-              flavourSet.flavourTable[type]
-            );
-            break;
-          }
-        }
-      }
-    }
-
-    var transferData = new TransferDataSet(dataArray);
-
-    // hand over to the client to respond to dropped data
-    var multiple =
-      "canHandleMultipleItems" in aDragDropObserver &&
-      aDragDropObserver.canHandleMultipleItems;
-    var dropData = multiple ? transferData : transferData.first.first;
-    aDragDropObserver.onDrop(aEvent, dropData, this.mDragSession);
-    aEvent.stopPropagation();
-  },
-
-  /**
-   * void dragExit (DOMEvent aEvent, Object aDragDropObserver) ;
-   *
-   * called when a drag leaves this element
-   *
-   * @param DOMEvent aEvent
-   *        the DOM event fired by leaving the element
-   * @param Object aDragDropObserver
-   *        javascript object of format described above that specifies
-   *        the way in which the element responds to drag events.
-   **/
-  dragExit(aEvent, aDragDropObserver) {
-    if (!this.checkCanDrop(aEvent, aDragDropObserver)) {
-      return;
-    }
-    if ("onDragExit" in aDragDropObserver) {
-      aDragDropObserver.onDragExit(aEvent, this.mDragSession);
-    }
-  },
-
-  /**
-   * void dragEnter (DOMEvent aEvent, Object aDragDropObserver) ;
-   *
-   * called when a drag enters in this element
-   *
-   * @param DOMEvent aEvent
-   *        the DOM event fired by entering in the element
-   * @param Object aDragDropObserver
-   *        javascript object of format described above that specifies
-   *        the way in which the element responds to drag events.
-   **/
-  dragEnter(aEvent, aDragDropObserver) {
-    if (!this.checkCanDrop(aEvent, aDragDropObserver)) {
-      return;
-    }
-    if ("onDragEnter" in aDragDropObserver) {
-      aDragDropObserver.onDragEnter(aEvent, this.mDragSession);
-    }
-  },
-
-  /**
-   * Boolean checkCanDrop (DOMEvent aEvent, Object aDragDropObserver) ;
-   *
-   * Sets the canDrop attribute for the drag session.
-   * returns false if there is no current drag session.
-   *
-   * @param DOMEvent aEvent
-   *        the DOM event fired by the drop
-   * @param Object aDragDropObserver
-   *        javascript object of format described above that specifies
-   *        the way in which the element responds to drag events.
-   **/
-  checkCanDrop(aEvent, aDragDropObserver) {
-    if (!this.mDragSession) {
-      this.mDragSession = this.mDragService.getCurrentSession();
-    }
-    if (!this.mDragSession) {
-      return false;
-    }
-    this.mDragSession.canDrop = this.mDragSession.sourceNode != aEvent.target;
-    if ("canDrop" in aDragDropObserver) {
-      this.mDragSession.canDrop &= aDragDropObserver.canDrop(
-        aEvent,
-        this.mDragSession
-      );
-    }
-    return true;
-  },
-
-  /**
-   * Do a security check for drag n' drop. Make sure the source document
-   * can load the dragged link.
-   *
-   * @param DOMEvent aEvent
-   *        the DOM event fired by leaving the element
-   * @param Object aDragDropObserver
-   *        javascript object of format described above that specifies
-   *        the way in which the element responds to drag events.
-   * @param String aDraggedText
-   *        the text being dragged
-   **/
-  dragDropSecurityCheck(aEvent, aDragSession, aDraggedText) {
-    // Strip leading and trailing whitespace, then try to create a
-    // URI from the dropped string. If that succeeds, we're
-    // dropping a URI and we need to do a security check to make
-    // sure the source document can load the dropped URI. We don't
-    // so much care about creating the real URI here
-    // (i.e. encoding differences etc don't matter), we just want
-    // to know if aDraggedText really is a URI.
-
-    aDraggedText = aDraggedText.replace(/^\s*|\s*$/g, "");
-
-    var uri;
-    try {
-      uri = Services.io.newURI(aDraggedText);
-    } catch (e) {}
-
-    if (!uri) {
-      return;
-    }
-
-    // aDraggedText is a URI, do the security check.
-    var secMan = Services.scriptSecurityManager;
-
-    if (!aDragSession) {
-      aDragSession = this.mDragService.getCurrentSession();
-    }
-
-    var sourceDoc = aDragSession.sourceDocument;
-    // Use "file:///" as the default sourceURI so that drops of file:// URIs
-    // are always allowed.
-    var principal = sourceDoc
-      ? sourceDoc.nodePrincipal
-      : secMan.createContentPrincipal(Services.io.newURI("file:///"), {});
-
-    try {
-      secMan.checkLoadURIStrWithPrincipal(
-        principal,
-        aDraggedText,
-        Ci.nsIScriptSecurityManager.STANDARD
-      );
-    } catch (e) {
-      // Stop event propagation right here.
-      aEvent.stopPropagation();
-
-      throw new Error("Drop of " + aDraggedText + " denied.");
-    }
-  },
-};
--- a/mail/base/jar.mn
+++ b/mail/base/jar.mn
@@ -1,15 +1,14 @@
 #filter substitution
 
 messenger.jar:
 % content messagebody %content/messagebody/ contentaccessible=yes
 % content messenger %content/messenger/ contentaccessible=yes
 % override chrome://browser/skin/preferences/in-content/general.svg chrome://mozapps/skin/extensions/utilities.svg
-% override chrome://global/content/nsDragAndDrop.js chrome://messenger/content/nsDragAndDrop.js
 % override chrome://messagebody/skin/messageBody.css chrome://messenger/skin/messageBody.css
 #ifndef MOZILLA_OFFICIAL
 % override chrome://browser/content/browser-development-helpers.js chrome://messenger/content/browser-development-helpers.js
   content/messenger/browser-development-helpers.js (../../common/src/browser-development-helpers.js)
 #endif
     content/messenger/mailWindow.js                 (content/mailWindow.js)
     content/messenger/messageDisplay.js             (content/messageDisplay.js)
     content/messenger/folderDisplay.js              (content/folderDisplay.js)
@@ -32,17 +31,16 @@ messenger.jar:
     content/messenger/customizeToolbar.js           (../../common/src/customizeToolbar.js)
 *   content/messenger/customizeToolbar.xhtml        (../../common/src/customizeToolbar.xhtml)
     content/messenger/viewSource.js                 (../../common/src/viewSource.js)
 *   content/messenger/viewSource.xhtml              (../../common/src/viewSource.xhtml)
     content/messenger/viewZoomOverlay.js            (../../common/src/viewZoomOverlay.js)
     content/messenger/customizable-toolbar.js       (../../common/bindings/customizable-toolbar.js)
     content/messenger/attachmentList.css            (content/attachmentList.css)
     content/messenger/menulist.css                  (content/menulist.css)
-    content/messenger/nsDragAndDrop.js              (content/nsDragAndDrop.js)
     content/messenger/editContactPanel.js           (content/editContactPanel.js)
     content/messenger/msgMail3PaneWindow.js         (content/msgMail3PaneWindow.js)
     content/messenger/mail3PaneWindowCommands.js    (content/mail3PaneWindowCommands.js)
     content/messenger/mailCommands.js               (content/mailCommands.js)
     content/messenger/mailCore.js                   (content/mailCore.js)
     content/messenger/mailTabs.js                   (content/mailTabs.js)
     content/messenger/commandglue.js                (content/commandglue.js)
 *   content/messenger/SearchDialog.xhtml            (content/SearchDialog.xhtml)