Bug 456106, use new drag and drop api in browser and toolkit, r=mano
authorNeil Deakin <neil@mozilla.com>
Sat, 20 Jun 2009 20:04:07 -0400
changeset 29418 5b8ff3412c804fec5d0c66f385475bbd577715fe
parent 29417 45cf3a994809f65760d98b6891e46bcf706d8799
child 29419 fa9c9caa388646a4fcc9d4348737440a68e14e0e
push idunknown
push userunknown
push dateunknown
reviewersmano
bugs456106
milestone1.9.2a1pre
Bug 456106, use new drag and drop api in browser and toolkit, r=mano
browser/base/content/browser.js
browser/base/content/browser.xul
browser/base/content/pageinfo/pageInfo.xul
browser/base/content/test/Makefile.in
browser/base/content/test/browser_drag.js
browser/base/content/urlbarBindings.xml
browser/components/search/content/engineManager.js
browser/components/search/content/engineManager.xul
toolkit/components/help/content/help.xul
toolkit/components/viewsource/content/viewPartialSource.xul
toolkit/components/viewsource/content/viewSource.xul
toolkit/content/customizeToolbar.js
toolkit/content/customizeToolbar.xul
toolkit/content/nsDragAndDrop.js
toolkit/content/widgets/findbar.xml
toolkit/mozapps/downloads/content/downloads.js
toolkit/mozapps/downloads/content/downloads.xul
toolkit/mozapps/extensions/content/extensions.js
toolkit/mozapps/extensions/content/extensions.xul
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -2297,26 +2297,16 @@ function PageProxySetIcon (aURL)
     gProxyFavIcon.setAttribute("src", aURL);
 }
 
 function PageProxyClearIcon ()
 {
   gProxyFavIcon.removeAttribute("src");
 }
 
-
-function PageProxyDragGesture(aEvent)
-{
-  if (gProxyFavIcon.getAttribute("pageproxystate") == "valid") {
-    nsDragAndDrop.startDrag(aEvent, proxyIconDNDObserver);
-    return true;
-  }
-  return false;
-}
-
 function PageProxyClickHandler(aEvent)
 {
   if (aEvent.button == 1 && gPrefService.getBoolPref("middlemouse.paste"))
     middleMousePaste(aEvent);
 }
 
 function BrowserImport()
 {
@@ -2663,66 +2653,98 @@ function FillInHTMLTooltip(tipElement)
       tipNode.setAttribute("label", t);
       retVal = true;
     }
   }
 
   return retVal;
 }
 
+var browserDragAndDrop = {
+  getDragURLFromDataTransfer : function (dt)
+  {
+    var types = dt.types;
+    for (var t = 0; t < types.length; t++) {
+      var type = types[t];
+      switch (type) {
+        case "text/uri-list":
+          var url = dt.getData("URL").replace(/^\s+|\s+$/g, "");
+          return [url, url];
+        case "text/plain":
+        case "text/x-moz-text-internal":
+          var url = dt.getData(type).replace(/^\s+|\s+$/g, "");
+          return [url, url];
+        case "text/x-moz-url":
+          var split = dt.getData(type).split("\n");
+          return [split[0], split[1]];
+        case "application/x-moz-file":
+          var file = dt.mozGetDataAt(type, 0);
+          var name = file instanceof Components.interfaces.nsIFile ? file.leafName : "";
+          var ioService = Components.classes["@mozilla.org/network/io-service;1"]
+                                    .getService(Components.interfaces.nsIIOService);
+          var fileHandler = ioService.getProtocolHandler("file")
+                                     .QueryInterface(Components.interfaces.nsIFileProtocolHandler);
+          return [fileHandler.getURLSpecFromFile(file), name];
+      }
+    }
+    return [ , ];
+  },
+
+  dragOver : function (aEvent, statusString)
+  {
+    var types = aEvent.dataTransfer.types;
+    if (types.contains("application/x-moz-file") ||
+        types.contains("text/x-moz-url") ||
+        types.contains("text/uri-list") ||
+        types.contains("text/plain")) {
+      aEvent.preventDefault();
+
+      if (statusString) {
+        var statusTextFld = document.getElementById("statusbar-display");
+        statusTextFld.label = gNavigatorBundle.getString(statusString);
+      }
+    }
+  }
+}
+
+
 var proxyIconDNDObserver = {
   onDragStart: function (aEvent, aXferData, aDragAction)
     {
+      if (gProxyFavIcon.getAttribute("pageproxystate") != "valid")
+        return;
+
       var value = content.location.href;
       var urlString = value + "\n" + content.document.title;
       var htmlString = "<a href=\"" + value + "\">" + value + "</a>";
 
-      aXferData.data = new TransferData();
-      aXferData.data.addDataForFlavour("text/x-moz-url", urlString);
-      aXferData.data.addDataForFlavour("text/unicode", value);
-      aXferData.data.addDataForFlavour("text/html", htmlString);
-
-      // we're copying the URL from the proxy icon, not moving
-      // we specify all of them though, because d&d sucks and OS's
-      // get confused if they don't get the one they want
-      aDragAction.action =
-        Components.interfaces.nsIDragService.DRAGDROP_ACTION_COPY |
-        Components.interfaces.nsIDragService.DRAGDROP_ACTION_MOVE |
-        Components.interfaces.nsIDragService.DRAGDROP_ACTION_LINK;
+      var dt = aEvent.dataTransfer;
+      dt.setData("text/x-moz-url", urlString);
+      dt.setData("text/uri-list", value);
+      dt.setData("text/plain", value);
+      dt.setData("text/html", htmlString);
     }
 }
 
 var homeButtonObserver = {
-  onDrop: function (aEvent, aXferData, aDragSession)
+  onDrop: function (aEvent)
     {
-      var url = transferUtils.retrieveURLFromData(aXferData.data, aXferData.flavour.contentType);
+      let url = browserDragAndDrop.getDragURLFromDataTransfer(aEvent.dataTransfer)[0];
       setTimeout(openHomeDialog, 0, url);
     },
 
-  onDragOver: function (aEvent, aFlavour, aDragSession)
+  onDragOver: function (aEvent)
     {
-      var statusTextFld = document.getElementById("statusbar-display");
-      statusTextFld.label = gNavigatorBundle.getString("droponhomebutton");
-      aDragSession.dragAction = Components.interfaces.nsIDragService.DRAGDROP_ACTION_LINK;
+      browserDragAndDrop.dragOver(aEvent, "droponhomebutton");
+      aEvent.dropEffect = "link";
     },
-
-  onDragExit: function (aEvent, aDragSession)
+  onDragLeave: function (aEvent)
     {
       var statusTextFld = document.getElementById("statusbar-display");
       statusTextFld.label = "";
-    },
-
-  getSupportedFlavours: function ()
-    {
-      var flavourSet = new FlavourSet();
-      flavourSet.appendFlavour("application/x-moz-file", "nsIFile");
-      flavourSet.appendFlavour("text/x-moz-url");
-      flavourSet.appendFlavour("text/unicode");
-      flavourSet.appendFlavour("text/x-moz-text-internal");  // for tabs
-      return flavourSet;
     }
 }
 
 function openHomeDialog(aURL)
 {
   var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
   var promptTitle = gNavigatorBundle.getString("droponhometitle");
   var promptMsg   = gNavigatorBundle.getString("droponhomemsg");
@@ -2741,146 +2763,110 @@ function openHomeDialog(aURL)
       homeButton.setAttribute("tooltiptext", aURL);
     } catch (ex) {
       dump("Failed to set the home page.\n"+ex+"\n");
     }
   }
 }
 
 var bookmarksButtonObserver = {
-  onDrop: function (aEvent, aXferData, aDragSession)
+  onDrop: function (aEvent)
   {
-    var split = aXferData.data.split("\n");
-    var url = split[0];
-    if (url != aXferData.data)  // do nothing if it's not a valid URL
-      PlacesUIUtils.showMinimalAddBookmarkUI(makeURI(url), split[1]);
-  },
-
-  onDragOver: function (aEvent, aFlavour, aDragSession)
+    let [url, name] = browserDragAndDrop.getDragURLFromDataTransfer(aEvent.dataTransfer);
+    try {
+      PlacesUIUtils.showMinimalAddBookmarkUI(makeURI(url), name);
+    } catch(ex) { }
+  },
+
+  onDragOver: function (aEvent)
   {
-    var statusTextFld = document.getElementById("statusbar-display");
-    statusTextFld.label = gNavigatorBundle.getString("droponbookmarksbutton");
-    aDragSession.dragAction = Components.interfaces.nsIDragService.DRAGDROP_ACTION_LINK;
-  },
-
-  onDragExit: function (aEvent, aDragSession)
+    browserDragAndDrop.dragOver(aEvent, "droponbookmarksbutton");
+    aEvent.dropEffect = "link";
+  },
+
+  onDragLeave: function (aEvent)
   {
     var statusTextFld = document.getElementById("statusbar-display");
     statusTextFld.label = "";
-  },
-
-  getSupportedFlavours: function ()
-  {
-    var flavourSet = new FlavourSet();
-    flavourSet.appendFlavour("application/x-moz-file", "nsIFile");
-    flavourSet.appendFlavour("text/x-moz-url");
-    flavourSet.appendFlavour("text/unicode");
-    return flavourSet;
   }
 }
 
 var newTabButtonObserver = {
-  onDragOver: function(aEvent, aFlavour, aDragSession) {
-    var statusTextFld = document.getElementById("statusbar-display");
-    statusTextFld.label = gNavigatorBundle.getString("droponnewtabbutton");
-    return true;
-  },
-  onDragExit: function (aEvent, aDragSession) {
+  onDragOver: function (aEvent)
+  {
+    browserDragAndDrop.dragOver(aEvent, "droponnewtabbutton");
+  },
+
+  onDragLeave: function (aEvent)
+  {
     var statusTextFld = document.getElementById("statusbar-display");
     statusTextFld.label = "";
   },
-  onDrop: function (aEvent, aXferData, aDragSession) {
-    var xferData = aXferData.data.split("\n");
-    var draggedText = xferData[0] || xferData[1];
+
+  onDrop: function (aEvent)
+  {
+    let url = browserDragAndDrop.getDragURLFromDataTransfer(aEvent.dataTransfer)[0];
     var postData = {};
-    var url = getShortcutOrURI(draggedText, postData);
+    url = getShortcutOrURI(url, postData);
     if (url) {
-      nsDragAndDrop.dragDropSecurityCheck(aEvent, aDragSession, url);
+      nsDragAndDrop.dragDropSecurityCheck(aEvent, null, url);
       // allow third-party services to fixup this URL
       openNewTabWith(url, null, postData.value, aEvent, true);
     }
-  },
-  getSupportedFlavours: function () {
-    var flavourSet = new FlavourSet();
-    flavourSet.appendFlavour("text/unicode");
-    flavourSet.appendFlavour("text/x-moz-url");
-    flavourSet.appendFlavour("application/x-moz-file", "nsIFile");
-    return flavourSet;
   }
 }
 
 var newWindowButtonObserver = {
-  onDragOver: function(aEvent, aFlavour, aDragSession)
-    {
-      var statusTextFld = document.getElementById("statusbar-display");
-      statusTextFld.label = gNavigatorBundle.getString("droponnewwindowbutton");
-      return true;
-    },
-  onDragExit: function (aEvent, aDragSession)
-    {
-      var statusTextFld = document.getElementById("statusbar-display");
-      statusTextFld.label = "";
-    },
-  onDrop: function (aEvent, aXferData, aDragSession)
-    {
-      var xferData = aXferData.data.split("\n");
-      var draggedText = xferData[0] || xferData[1];
-      var postData = {};
-      var url = getShortcutOrURI(draggedText, postData);
-      if (url) {
-        nsDragAndDrop.dragDropSecurityCheck(aEvent, aDragSession, url);
-        // allow third-party services to fixup this URL
-        openNewWindowWith(url, null, postData.value, true);
-      }
-    },
-  getSupportedFlavours: function ()
-    {
-      var flavourSet = new FlavourSet();
-      flavourSet.appendFlavour("text/unicode");
-      flavourSet.appendFlavour("text/x-moz-url");
-      flavourSet.appendFlavour("application/x-moz-file", "nsIFile");
-      flavourSet.appendFlavour("text/x-moz-text-internal");  // for tabs
-      return flavourSet;
-    }
+  onDragOver: function (aEvent)
+  {
+    browserDragAndDrop.dragOver(aEvent, "droponnewwindowbutton");
+  },
+  onDragLeave: function (aEvent)
+  {
+    var statusTextFld = document.getElementById("statusbar-display");
+    statusTextFld.label = "";
+  },
+  onDrop: function (aEvent)
+  {
+    let url = browserDragAndDrop.getDragURLFromDataTransfer(aEvent.dataTransfer)[0];
+    var postData = {};
+    url = getShortcutOrURI(url, postData);
+    if (url) {
+      nsDragAndDrop.dragDropSecurityCheck(aEvent, null, url);
+      // allow third-party services to fixup this URL
+      openNewWindowWith(url, null, postData.value, true);
+    }
+  }
 }
 
 var DownloadsButtonDNDObserver = {
   /////////////////////////////////////////////////////////////////////////////
   // nsDragAndDrop
-  onDragOver: function (aEvent, aFlavour, aDragSession)
+  onDragOver: function (aEvent)
   {
     var statusTextFld = document.getElementById("statusbar-display");
     statusTextFld.label = gNavigatorBundle.getString("dropondownloadsbutton");
-    aDragSession.canDrop = (aFlavour.contentType == "text/x-moz-url" ||
-                            aFlavour.contentType == "text/unicode");
-  },
-
-  onDragExit: function (aEvent, aDragSession)
+    var types = aEvent.dataTransfer.types;
+    if (types.contains("text/x-moz-url") ||
+        types.contains("text/uri-list") ||
+        types.contains("text/plain"))
+      aEvent.preventDefault();
+  },
+
+  onDragLeave: function (aEvent)
   {
     var statusTextFld = document.getElementById("statusbar-display");
     statusTextFld.label = "";
   },
 
-  onDrop: function (aEvent, aXferData, aDragSession)
+  onDrop: function (aEvent)
   {
-    var split = aXferData.data.split("\n");
-    var url = split[0];
-    if (url != aXferData.data) {  //do nothing, not a valid URL
-      nsDragAndDrop.dragDropSecurityCheck(aEvent, aDragSession, url);
-
-      var name = split[1];
-      saveURL(url, name, null, true, true);
-    }
-  },
-  getSupportedFlavours: function ()
-  {
-    var flavourSet = new FlavourSet();
-    flavourSet.appendFlavour("text/x-moz-url");
-    flavourSet.appendFlavour("text/unicode");
-    return flavourSet;
+    let [url, name] = browserDragAndDrop.getDragURLFromDataTransfer(aEvent.dataTransfer);
+    nsDragAndDrop.dragDropSecurityCheck(aEvent, null, url);
+    saveURL(url, name, null, true, true);
   }
 }
 
 const DOMLinkHandler = {
   handleEvent: function (event) {
     switch (event.type) {
       case "DOMLinkAdded":
         this.onLinkAdded(event);
@@ -5016,61 +5002,56 @@ function middleMousePaste(event)
  * be available for all <browser> tags as well as gecko embedding. See
  * mozilla/content/base/src/nsContentAreaDragDrop.cpp.
  *
  * Do not add any new fuctionality here other than what is needed for
  * a standalone product.
  */
 
 var contentAreaDNDObserver = {
-  onDrop: function (aEvent, aXferData, aDragSession)
+  onDragOver: function (aEvent)
+    {
+      var types = aEvent.dataTransfer.types;
+      if (types.contains("application/x-moz-file") ||
+          types.contains("text/x-moz-url") ||
+          types.contains("text/uri-list") ||
+          types.contains("text/plain"))
+        aEvent.preventDefault();
+    },
+  onDrop: function (aEvent)
     {
       if (aEvent.getPreventDefault())
         return;
 
-      var dragType = aXferData.flavour.contentType;
-      var dragData = aXferData.data;
-
-      var url = transferUtils.retrieveURLFromData(dragData, dragType);
+      let [url, name] = browserDragAndDrop.getDragURLFromDataTransfer(aEvent.dataTransfer);
 
       // valid urls don't contain spaces ' '; if we have a space it
       // isn't a valid url, or if it's a javascript: or data: url,
       // bail out
       if (!url || !url.length || url.indexOf(" ", 0) != -1 ||
           /^\s*(javascript|data):/.test(url))
         return;
 
-      nsDragAndDrop.dragDropSecurityCheck(aEvent, aDragSession, url);
+      nsDragAndDrop.dragDropSecurityCheck(aEvent, null, url);
 
       switch (document.documentElement.getAttribute('windowtype')) {
         case "navigator:browser":
           var postData = { };
           var uri = getShortcutOrURI(url, postData);
           loadURI(uri, null, postData.value, false);
           break;
         case "navigator:view-source":
           viewSource(url);
           break;
       }
 
       // keep the event from being handled by the dragDrop listeners
       // built-in to gecko if they happen to be above us.
       aEvent.preventDefault();
-    },
-
-  getSupportedFlavours: function ()
-    {
-      var flavourSet = new FlavourSet();
-      flavourSet.appendFlavour(TAB_DROP_TYPE);
-      flavourSet.appendFlavour("text/x-moz-url");
-      flavourSet.appendFlavour("text/plain");
-      flavourSet.appendFlavour("application/x-moz-file", "nsIFile");
-      return flavourSet;
-    }
-
+    }
 };
 
 function MultiplexHandler(event)
 { try {
     var node = event.target;
     var name = node.getAttribute('name');
 
     if (name == 'detectorGroup') {
--- a/browser/base/content/browser.xul
+++ b/browser/base/content/browser.xul
@@ -339,19 +339,20 @@
       <toolbarbutton id="stop-button" class="toolbarbutton-1 chromeclass-toolbar-additional"
                      label="&stopCmd.label;"
                      command="Browser:Stop"
                      tooltiptext="&stopButton.tooltip;"/>
 
       <toolbarbutton id="home-button" class="toolbarbutton-1 chromeclass-toolbar-additional"
                      persist="class"
                      label="&homeButton.label;"
-                     ondragover="nsDragAndDrop.dragOver(event, homeButtonObserver);"
-                     ondragdrop="nsDragAndDrop.drop(event, homeButtonObserver);"
-                     ondragexit="nsDragAndDrop.dragExit(event, homeButtonObserver);"
+                     ondragover="homeButtonObserver.onDragOver(event)"
+                     ondragenter="homeButtonObserver.onDragOver(event)"
+                     ondrop="homeButtonObserver.onDrop(event)"
+                     ondragleave="homeButtonObserver.onDragLeave(event)"
                      onclick="BrowserGoHome(event);"/>
 
       <toolbaritem id="urlbar-container" align="center" flex="400" persist="width"
                    title="&locationItem.title;" class="chromeclass-location">
         <textbox id="urlbar" flex="1"
                  bookmarkhistoryemptytext="&urlbar.bookmarkhistory.emptyText;"
                  bookmarkemptytext="&urlbar.bookmark.emptyText;"
                  historyemptytext="&urlbar.history.emptyText;"
@@ -384,17 +385,17 @@
                onclick="gIdentityHandler.handleIdentityButtonEvent(event);"
                onkeypress="gIdentityHandler.handleIdentityButtonEvent(event);">
             <hbox align="center">
               <stack id="page-proxy-stack"
                      onclick="PageProxyClickHandler(event);">
                 <image id="urlbar-throbber" busy="false"/>
                 <image id="page-proxy-favicon" validate="never"
                        pageproxystate="invalid"
-                       ondraggesture="PageProxyDragGesture(event);"
+                       ondragstart="proxyIconDNDObserver.onDragStart(event);"
                        onerror="this.removeAttribute('src');"/>
               </stack>
               <label id="identity-icon-label" crop="center" flex="1"/>
             </hbox>
           </box>
           <hbox id="urlbar-icons">
             <button type="menu"
                     style="-moz-user-focus: none"
@@ -444,49 +445,52 @@
                onclick="BookmarksEventHandler.onClick(event);"
                oncommand="BookmarksEventHandler.onCommand(event);"
                onpopupshowing="BookmarksEventHandler.onPopupShowing(event);"
                tooltip="btTooltip"/>
       </toolbaritem>
 
         <toolbarbutton id="downloads-button" class="toolbarbutton-1 chromeclass-toolbar-additional"
                        observes="Tools:Downloads"
-                       ondragdrop="nsDragAndDrop.drop(event, DownloadsButtonDNDObserver); event.stopPropagation()"
-                       ondragover="nsDragAndDrop.dragOver(event, DownloadsButtonDNDObserver); event.stopPropagation()"
-                       ondragenter="nsDragAndDrop.dragEnter(event, DownloadsButtonDNDObserver); event.stopPropagation()"
-                       ondragexit="nsDragAndDrop.dragExit(event, DownloadsButtonDNDObserver); event.stopPropagation()"
+                       ondrop="DownloadsButtonDNDObserver.onDrop(event)"
+                       ondragover="DownloadsButtonDNDObserver.onDragOver(event)"
+                       ondragenter="DownloadsButtonDNDObserver.onDragOver(event)"
+                       ondragleave="DownloadsButtonDNDObserver.onDragLeave(event)"
                        label="&downloads.label;"
                        tooltiptext="&downloads.tooltip;"/>
 
         <toolbarbutton id="history-button" class="toolbarbutton-1 chromeclass-toolbar-additional"
                        observes="viewHistorySidebar" label="&historyButton.label;"
                        tooltiptext="&historyButton.tooltip;"/>
 
         <toolbarbutton id="bookmarks-button" class="toolbarbutton-1 chromeclass-toolbar-additional"
                        observes="viewBookmarksSidebar"
                        tooltiptext="&bookmarksButton.tooltip;"
-                       ondragover="nsDragAndDrop.dragOver(event, bookmarksButtonObserver);"
-                       ondragdrop="nsDragAndDrop.drop(event, bookmarksButtonObserver);"
-                       ondragexit="nsDragAndDrop.dragExit(event, bookmarksButtonObserver);"/>
+                       ondrop="bookmarksButtonObserver.onDrop(event)"
+                       ondragover="bookmarksButtonObserver.onDragOver(event)"
+                       ondragenter="bookmarksButtonObserver.onDragOver(event)"
+                       ondragleave="bookmarksButtonObserver.onDragLeave(event)"/>
 
         <toolbarbutton id="new-tab-button" class="toolbarbutton-1 chromeclass-toolbar-additional"
                        label="&tabCmd.label;"
                        command="cmd_newNavigatorTab"
                        tooltiptext="&newTabButton.tooltip;"
-                       ondragover="nsDragAndDrop.dragOver(event, newTabButtonObserver);"
-                       ondragdrop="nsDragAndDrop.drop(event, newTabButtonObserver);"
-                       ondragexit="nsDragAndDrop.dragExit(event, newTabButtonObserver);"/>
+                       ondrop="newTabButtonObserver.onDrop(event)"
+                       ondragover="newTabButtonObserver.onDragOver(event)"
+                       ondragenter="newTabButtonObserver.onDragOver(event)"
+                       ondragleave="newTabButtonObserver.onDragLeave(event)"/>
 
         <toolbarbutton id="new-window-button" class="toolbarbutton-1 chromeclass-toolbar-additional"
                        label="&newNavigatorCmd.label;"
                        command="key_newNavigator"
                        tooltiptext="&newWindowButton.tooltip;"
-                       ondragover="nsDragAndDrop.dragOver(event, newWindowButtonObserver);"
-                       ondragdrop="nsDragAndDrop.drop(event, newWindowButtonObserver);"
-                       ondragexit="nsDragAndDrop.dragExit(event, newWindowButtonObserver);"/>
+                       ondrop="newWindowButtonObserver.onDrop(event)"
+                       ondragover="newWindowButtonObserver.onDragOver(event)"
+                       ondragenter="newWindowButtonObserver.onDragOver(event)"
+                       ondragleave="newWindowButtonObserver.onDragLeave(event)"/>
 
         <toolbarbutton id="cut-button" class="toolbarbutton-1 chromeclass-toolbar-additional"
                        label="&cutCmd.label;"
                        command="cmd_cut"
                        tooltiptext="&cutButton.tooltip;"/>
 
         <toolbarbutton id="copy-button" class="toolbarbutton-1 chromeclass-toolbar-additional"
                        label="&copyCmd.label;"
@@ -552,31 +556,31 @@
 
     <splitter id="sidebar-splitter" class="chromeclass-extrachrome" hidden="true"/>
     <vbox id="appcontent" flex="1">
       <tabbrowser id="content" disablehistory="true"
                   flex="1" contenttooltip="aHTMLTooltip"
                   contentcontextmenu="contentAreaContextMenu"
                   onnewtab="BrowserOpenTab();"
                   autocompletepopup="PopupAutoComplete"
-                  ondrop="nsDragAndDrop.drop(event, contentAreaDNDObserver);"
+                  ondrop="contentAreaDNDObserver.onDrop(event)"
                   onclick="return contentAreaClick(event, false);"/>
     </vbox>
   </hbox>
   <panel id="customizeToolbarSheetPopup" noautohide="true">
     <iframe id="customizeToolbarSheetIFrame"
             style="&dialog.style;"
             hidden="true"/>
   </panel>
 
   <vbox id="browser-bottombox">
     <findbar browserid="content" id="FindToolbar"/>
   
     <statusbar class="chromeclass-status" id="status-bar"
-               ondrop="nsDragAndDrop.drop(event, contentAreaDNDObserver);">
+               ondrop="contentAreaDNDObserver.onDrop(event)">
       <statusbarpanel id="statusbar-display" label="" flex="1"/>
       <statusbarpanel class="statusbarpanel-progress" collapsed="true" id="statusbar-progresspanel">
         <progressmeter class="progressmeter-statusbar" id="statusbar-icon" mode="normal" value="0"/>
       </statusbarpanel>
       <statusbarpanel id="download-monitor" class="statusbarpanel-iconic-text"
                       tooltiptext="&downloadMonitor2.tooltip;" hidden="true"
                       command="Tools:Downloads"/>
       <statusbarpanel id="security-button" class="statusbarpanel-iconic-text"
--- a/browser/base/content/pageinfo/pageInfo.xul
+++ b/browser/base/content/pageinfo/pageInfo.xul
@@ -211,17 +211,17 @@
                   oncommand="onClickMore();"/>
         </hbox>
       </groupbox>
     </vbox>
 
     <!-- Media information -->
     <vbox id="mediaPanel">
       <tree id="imagetree" onselect="onImageSelect();" contextmenu="picontext"
-            ondraggesture="onBeginLinkDrag(event,'image-address','image-alt')">
+            ondragstart="onBeginLinkDrag(event,'image-address','image-alt')">
         <treecols>
           <treecol sortSeparators="true" persist="hidden width" flex="10"
                         width="10" id="image-address" label="&mediaAddress;"/>
           <splitter class="tree-splitter"/>
           <treecol sortSeparators="true" persist="hidden width" flex="2"
                         width="2"  id="image-type"    label="&mediaType;"/>
           <splitter class="tree-splitter"/>
           <treecol sortSeparators="true" hidden="true" persist="hidden width" flex="2"
--- a/browser/base/content/test/Makefile.in
+++ b/browser/base/content/test/Makefile.in
@@ -117,16 +117,17 @@ include $(topsrcdir)/config/rules.mk
                  browser_bug479408.js \
                  browser_bug479408_sample.html \
                  browser_scope.js \
                  browser_overflowScroll.js \
                  browser_sanitizeDialog.js \
                  browser_tabs_owner.js \
                  browser_bug491431.js \
                  browser_bug304198.js \
+                 browser_drag.js \
     $(NULL)
 
 ifeq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
 _BROWSER_FILES += browser_bug462289.js
 else
 _BROWSER_FILES += browser_customize.js
 endif
 
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/browser_drag.js
@@ -0,0 +1,23 @@
+function test()
+{
+  // ---- Test dragging the proxy icon ---
+
+  var value = content.location.href;
+  var urlString = value + "\n" + content.document.title;
+  var htmlString = "<a href=\"" + value + "\">" + value + "</a>";
+
+  var expected = [ [
+    "text/x-moz-url: " + urlString,
+    "text/uri-list: " + value,
+    "text/plain: " + value,
+    "text/html: " + htmlString
+  ] ];
+
+  // set the valid attribute so dropping is allowed
+  var proxyicon = document.getElementById("page-proxy-favicon")
+  var oldstate = proxyicon.getAttribute("pageproxystate");
+  proxyicon.setAttribute("pageproxystate", "valid");
+  var dt = EventUtils.synthesizeDragStart(proxyicon, expected);
+  is(dt, null, "drag on proxy icon");
+  proxyicon.setAttribute("pageproxystate", oldstate);
+}
--- a/browser/base/content/urlbarBindings.xml
+++ b/browser/base/content/urlbarBindings.xml
@@ -233,62 +233,52 @@
             clearTimeout(this._tooltipTimer);
             this._tooltipTimer = 0;
           }
           this._urlTooltip.hidePopup();
         ]]></body>
       </method>
 
       <method name="onDragOver">
+        <parameter name="aEvent"/>
         <body>
-          return true;
+          var types = aEvent.dataTransfer.types;
+          if (types.contains("application/x-moz-file") ||
+              types.contains("text/x-moz-url") ||
+              types.contains("text/uri-list") ||
+              types.contains("text/unicode"))
+            aEvent.preventDefault();
         </body>
       </method>
 
       <method name="onDrop">
         <parameter name="aEvent"/>
-        <parameter name="aXferData"/>
-        <parameter name="aDragSession"/>
         <body><![CDATA[
-          var url = transferUtils.retrieveURLFromData(aXferData.data, aXferData.flavour.contentType);
+          aEvent.stopPropagation();
+          var url = browserDragAndDrop.getDragURLFromDataTransfer(aEvent.dataTransfer)[0];
 
           // The URL bar automatically handles inputs with newline characters,
-          // so we can get away with treating text/x-moz-url flavours as text/unicode.
+          // so we can get away with treating text/x-moz-url flavours as text/plain.
           if (url) {
-            nsDragAndDrop.dragDropSecurityCheck(aEvent, aDragSession, url);
+            nsDragAndDrop.dragDropSecurityCheck(aEvent, null, url);
 
             this.value = url;
             SetPageProxyState("invalid");
             try {
               urlSecurityCheck(this.value,
                                gBrowser.contentPrincipal,
                                Ci.nsIScriptSecurityManager.DISALLOW_INHERIT_PRINCIPAL);
             } catch (ex) {
               return;
             }
             this.handleCommand();
           }
         ]]></body>
       </method>
 
-      <method name="getSupportedFlavours">
-        <body><![CDATA[
-          var flavourSet = new FlavourSet();
-
-          // Favor text/x-moz-url since text/unicode coming from Win32 1.8 branch
-          // drops contains URL\ntext.  The previous comment here said that
-          // plain text drops often come with text/x-moz-url flavor, but I
-          // haven't seen that, so hopefully that behavior has changed.
-          flavourSet.appendFlavour("text/x-moz-url");
-          flavourSet.appendFlavour("text/unicode");
-          flavourSet.appendFlavour("application/x-moz-file", "nsIFile");
-          return flavourSet;
-        ]]></body>
-      </method>
-
       <method name="_getSelectedValueForClipboard">
         <body><![CDATA[
           var val = this.value.substring(this.selectionStart, this.selectionEnd);
 
           // If the entire value is selected and it's a valid non-javascript,
           // non-data URI, encode it.
           if (val == this.value &&
               this.getAttribute("pageproxystate") == "valid") {
@@ -444,18 +434,18 @@
         dt.setData("text/x-moz-url", urlString + "\n" + title);
         dt.setData("text/unicode", urlString);
         dt.setData("text/html", htmlString);
 
         dt.effectAllowed = "copyLink";
         event.stopPropagation();
       ]]></handler>
       <handler event="focus" phase="capturing" action="this._hideURLTooltip();"/>
-      <handler event="dragover" phase="capturing" action="nsDragAndDrop.dragOver(event, this);"/>
-      <handler event="drop" phase="capturing" action="nsDragAndDrop.drop(event, this);"/>
+      <handler event="dragover" phase="capturing" action="this.onDragOver(event, this);"/>
+      <handler event="drop" phase="capturing" action="this.onDrop(event, this);"/>
       <handler event="select"><![CDATA[
         if (!Cc["@mozilla.org/widget/clipboard;1"]
                .getService(Ci.nsIClipboard)
                .supportsSelectionClipboard())
           return;
 
         var val = this._getSelectedValueForClipboard();
         if (!val)
--- a/browser/components/search/content/engineManager.js
+++ b/browser/components/search/content/engineManager.js
@@ -219,32 +219,23 @@ var gEngineManagerDialog = {
 
     document.getElementById("cmd_movedown").setAttribute("disabled",
                                              disableButtons || lastSelected);
     document.getElementById("cmd_editkeyword").setAttribute("disabled",
                                                             noSelection);
   }
 };
 
-var gDragObserver = {
-  onDragStart: function (aEvent, aXferData, aDragAction) {
-    var selectedIndex = gEngineView.selectedIndex;
-    if (selectedIndex == -1)
-      return;
-
-    aXferData.data = new TransferData();
-    aXferData.data.addDataForFlavour(ENGINE_FLAVOR, selectedIndex.toString());
-
-    aDragAction.action = Ci.nsIDragService.DRAGDROP_ACTION_MOVE;
-  },
-  onDrop: function (aEvent, aXferData, aDragSession) { },
-  onDragExit: function (aEvent, aDragSession) { },
-  onDragOver: function (aEvent, aFlavour, aDragSession) { },
-  getSupportedFlavours: function() { return null; }
-};
+function onDragEngineStart(event) {
+  var selectedIndex = gEngineView.selectedIndex;
+  if (selectedIndex > 0) {
+    event.dataTransfer.setData(ENGINE_FLAVOR, selectedIndex.toString());
+    event.dataTransfer.effectAllowed = "move";
+  }
+}
 
 // "Operation" objects
 function EngineMoveOp(aEngineClone, aNewIndex) {
   if (!aEngineClone)
     throw new Error("bad args to new EngineMoveOp!");
   this._engine = aEngineClone.originalEngine;
   this._newIndex = aNewIndex;
 }
--- a/browser/components/search/content/engineManager.xul
+++ b/browser/components/search/content/engineManager.xul
@@ -53,18 +53,16 @@
         ondialogextra2="gEngineManagerDialog.onRestoreDefaults();"
         title="&engineManager.title;"
         style="&engineManager.style;"
         persist="screenX screenY"
         windowtype="Browser:SearchManager">
 
   <script type="application/x-javascript"
           src="chrome://browser/content/search/engineManager.js"/>
-  <script type="application/x-javascript"
-          src="chrome://global/content/nsDragAndDrop.js"/>
 
   <commandset id="engineManagerCommandSet">
     <command id="cmd_remove"
              oncommand="gEngineManagerDialog.remove();"
              disabled="true"/>
     <command id="cmd_moveup"
              oncommand="gEngineManagerDialog.bump(1);"
              disabled="true"/>
@@ -85,17 +83,17 @@
   </stringbundleset>
 
   <description>&engineManager.intro;</description>
   <separator class="thin"/>
   <hbox flex="1">
     <tree id="engineList" flex="1" rows="10" hidecolumnpicker="true"
           seltype="single" onselect="gEngineManagerDialog.onSelect();">
       <treechildren id="engineChildren" flex="1"
-                    ondraggesture="nsDragAndDrop.startDrag(event, gDragObserver);"/>
+                    ondragstart="onDragEngineStart(event)"/>
       <treecols>
         <treecol id="engineName" flex="4" label="&columnLabel.name;"/>
         <treecol id="engineKeyword" flex="1" label="&columnLabel.keyword;"/>
       </treecols>
     </tree>
     <vbox>
       <spacer flex="1"/>
       <button id="edit"
--- a/toolkit/components/help/content/help.xul
+++ b/toolkit/components/help/content/help.xul
@@ -62,17 +62,16 @@
         persist="width height screenX screenY zlevel"
 #else
         persist="width height screenX screenY"
 #endif
         onload="init();"
         onunload="window.XULBrowserWindow.destroy();">
 
   <script type="application/javascript" src="chrome://help/content/help.js"/>
-  <script type="application/javascript" src="chrome://global/content/nsDragAndDrop.js"/>
   <script type="application/javascript" src="chrome://global/content/viewZoomOverlay.js"/>
   <script type="application/javascript" src="chrome://global/content/globalOverlay.js"/>
 
   <menupopup id="backMenu" position="after_start"
              onpopupshowing="return createBackMenu(event);"
              oncommand="gotoHistoryIndex(event);"/>
   <menupopup id="forwardMenu" position="after_start"
              onpopupshowing="return createForwardMenu(event);"
--- a/toolkit/components/viewsource/content/viewPartialSource.xul
+++ b/toolkit/components/viewsource/content/viewPartialSource.xul
@@ -63,17 +63,16 @@
         titlepreface=""
         titlemenuseparator ="&mainWindow.titlemodifierseparator;"  
         windowtype="navigator:view-source"
         width="500" height="300"
         screenX="10" screenY="10"
         persist="screenX screenY width height sizemode">
 
   <script type="application/javascript" src="chrome://global/content/globalOverlay.js"/>
-  <script type="application/javascript" src="chrome://global/content/nsDragAndDrop.js"/>
   <script type="application/javascript" src="chrome://global/content/printUtils.js"/>
   <script type="application/javascript" src="chrome://global/content/viewSource.js"/>
   <script type="application/javascript" src="chrome://global/content/viewPartialSource.js"/>
   <script type="application/javascript" src="chrome://global/content/viewZoomOverlay.js"/>
   <script type="application/javascript" src="chrome://global/content/contentAreaUtils.js"/>
 
   <stringbundle id="viewSourceBundle" src="chrome://global/locale/viewSource.properties"/>
 
@@ -180,17 +179,15 @@
                     label="&menu_wrapLongLines.title;" accesskey="&menu_wrapLongLines.accesskey;"/>
           <menuitem type="checkbox" id="menu_highlightSyntax" command="cmd_highlightSyntax"
                     label="&menu_highlightSyntax.label;" accesskey="&menu_highlightSyntax.accesskey;"/>
         </menupopup>
       </menu>
     </menubar>  
   </toolbox>
 
-  <vbox id="appcontent" flex="1"
-        ondragdrop="nsDragAndDrop.drop(event, contentAreaDNDObserver);">
-
+  <vbox id="appcontent" flex="1" ondrop="contentAreaDNDObserver.drop(event);">
     <browser id="content" type="content-primary" name="content" src="about:blank" flex="1"
              disablehistory="true" context="viewSourceContextMenu"/>
     <findbar id="FindToolbar" browserid="content"/>
   </vbox>
 
 </window>
--- a/toolkit/components/viewsource/content/viewSource.xul
+++ b/toolkit/components/viewsource/content/viewSource.xul
@@ -69,17 +69,16 @@
         screenX="10" screenY="10"
         persist="screenX screenY width height sizemode">
 
   <script type="application/javascript" src="chrome://global/content/globalOverlay.js"/>
   <script type="application/javascript" src="chrome://global/content/printUtils.js"/>
   <script type="application/javascript" src="chrome://global/content/viewSource.js"/>
   <script type="application/javascript" src="chrome://global/content/viewZoomOverlay.js"/>
   <script type="application/javascript" src="chrome://global/content/contentAreaUtils.js"/>
-  <script type="application/javascript" src="chrome://global/content/nsDragAndDrop.js"/>
   
   <stringbundle id="viewSourceBundle" src="chrome://global/locale/viewSource.properties"/>
 
   <command id="cmd_savePage" oncommand="ViewSourceSavePage();"/>
   <command id="cmd_print" oncommand="PrintUtils.print();"/>
   <command id="cmd_printpreview" oncommand="PrintUtils.printPreview(onEnterPP, onExitPP);"/>
   <command id="cmd_pagesetup" oncommand="PrintUtils.showPageSetup();"/>
   <command id="cmd_close" oncommand="window.close();"/>
@@ -230,18 +229,17 @@
                     label="&menu_wrapLongLines.title;" accesskey="&menu_wrapLongLines.accesskey;"/>
           <menuitem type="checkbox" id="menu_highlightSyntax" command="cmd_highlightSyntax"
                     label="&menu_highlightSyntax.label;" accesskey="&menu_highlightSyntax.accesskey;"/>
         </menupopup>
       </menu>
     </menubar>  
   </toolbox>
 
-  <vbox id="appcontent" flex="1"
-       ondragdrop="nsDragAndDrop.drop(event, contentAreaDNDObserver);">
+  <vbox id="appcontent" flex="1" ondrop="contentAreaDNDObserver.drop(event);">
 
     <browser id="content" type="content-primary" name="content" src="about:blank" flex="1"
              context="viewSourceContextMenu" showcaret="true"/>
     <findbar id="FindToolbar" browserid="content"/>
   </vbox> 
 
   <statusbar id="status-bar" class="chromeclass-status">
     <statusbarpanel id="statusbar-line-col" label="" flex="1"/>
--- a/toolkit/content/customizeToolbar.js
+++ b/toolkit/content/customizeToolbar.js
@@ -727,267 +727,224 @@ function isToolbarItem(aElt)
          aElt.localName == "toolbarseparator" ||
          aElt.localName == "toolbarspring" ||
          aElt.localName == "toolbarspacer";
 }
 
 ///////////////////////////////////////////////////////////////////////////
 //// Drag and Drop observers
 
-function onToolbarDragStart(aEvent)
-{
-  nsDragAndDrop.startDrag(aEvent, dragStartObserver);
-}
-
-function onToolbarDragOver(aEvent)
-{
-  nsDragAndDrop.dragOver(aEvent, toolbarDNDObserver);
-}
-
-function onToolbarDrop(aEvent)
-{
-  nsDragAndDrop.drop(aEvent, toolbarDNDObserver);
-}
-
 function onToolbarDragLeave(aEvent)
 {
   if (gCurrentDragOverItem)
     setDragActive(gCurrentDragOverItem, false);
 }
 
-var dragStartObserver =
+function onToolbarDragStart(aEvent)
 {
-  onDragStart: function (aEvent, aXferData, aDragAction) {
-    var documentId = gToolboxDocument.documentElement.id;
-    
-    var item = aEvent.target;
-    while (item && item.localName != "toolbarpaletteitem")
-      item = item.parentNode;
-    
-    item.setAttribute("dragactive", "true");
-    
-    aXferData.data = new TransferDataSet();
-    var data = new TransferData();
-    data.addDataForFlavour("text/toolbarwrapper-id/"+documentId, item.firstChild.id);
-    aXferData.data.push(data);
-    aDragAction.action = Components.interfaces.nsIDragService.DRAGDROP_ACTION_MOVE;
-  }
+  var documentId = gToolboxDocument.documentElement.id;
+
+  var item = aEvent.target;
+  while (item && item.localName != "toolbarpaletteitem")
+    item = item.parentNode;
+
+  item.setAttribute("dragactive", "true");
+
+  var dt = aEvent.dataTransfer;
+  dt.setData("text/toolbarwrapper-id/" + documentId, item.firstChild.id);
+  dt.effectAllowed = "move";
 }
 
-var toolbarDNDObserver =
+function onToolbarDragOver(aEvent)
 {
-  onDragOver: function (aEvent, aFlavour, aDragSession)
-  {
-    var toolbar = aEvent.target;
-    var dropTarget = aEvent.target;
-    while (toolbar && toolbar.localName != "toolbar") {
-      dropTarget = toolbar;
-      toolbar = toolbar.parentNode;
-    }
-    
-    var previousDragItem = gCurrentDragOverItem;
+  var documentId = gToolboxDocument.documentElement.id;
+  if (!aEvent.dataTransfer.types.contains("text/toolbarwrapper-id/" + documentId))
+    return;
 
-    // Make sure we are dragging over a customizable toolbar.
-    if (!isCustomizableToolbar(toolbar)) {
-      gCurrentDragOverItem = null;
-      return;
-    }
-    
-    if (dropTarget.localName == "toolbar") {
-      gCurrentDragOverItem = dropTarget;
-    } else {
-      gCurrentDragOverItem = null;
+  var toolbar = aEvent.target;
+  var dropTarget = aEvent.target;
+  while (toolbar && toolbar.localName != "toolbar") {
+    dropTarget = toolbar;
+    toolbar = toolbar.parentNode;
+  }
+  
+  var previousDragItem = gCurrentDragOverItem;
+
+  // Make sure we are dragging over a customizable toolbar.
+  if (!isCustomizableToolbar(toolbar)) {
+    gCurrentDragOverItem = null;
+    return;
+  }
+  
+  if (dropTarget.localName == "toolbar") {
+    gCurrentDragOverItem = dropTarget;
+  } else {
+    gCurrentDragOverItem = null;
 
-      var direction = window.getComputedStyle(dropTarget.parentNode, null).direction;
-      var dropTargetCenter = dropTarget.boxObject.x + (dropTarget.boxObject.width / 2);
-      var dragAfter;
-      if (direction == "ltr")
-        dragAfter = aEvent.clientX > dropTargetCenter;
-      else
-        dragAfter = aEvent.clientX < dropTargetCenter;
-        
-      if (dragAfter) {
-        gCurrentDragOverItem = dropTarget.nextSibling;
-        if (!gCurrentDragOverItem)
-          gCurrentDragOverItem = toolbar;
-      } else
-        gCurrentDragOverItem = dropTarget;
-    }    
+    var direction = window.getComputedStyle(dropTarget.parentNode, null).direction;
+    var dropTargetCenter = dropTarget.boxObject.x + (dropTarget.boxObject.width / 2);
+    var dragAfter;
+    if (direction == "ltr")
+      dragAfter = aEvent.clientX > dropTargetCenter;
+    else
+      dragAfter = aEvent.clientX < dropTargetCenter;
+      
+    if (dragAfter) {
+      gCurrentDragOverItem = dropTarget.nextSibling;
+      if (!gCurrentDragOverItem)
+        gCurrentDragOverItem = toolbar;
+    } else
+      gCurrentDragOverItem = dropTarget;
+  }    
+
+  if (previousDragItem && gCurrentDragOverItem != previousDragItem) {
+    setDragActive(previousDragItem, false);
+  }
+
+  setDragActive(gCurrentDragOverItem, true);
+
+  aEvent.preventDefault();
+}
 
-    if (previousDragItem && gCurrentDragOverItem != previousDragItem) {
-      setDragActive(previousDragItem, false);
-    }
-    
-    setDragActive(gCurrentDragOverItem, true);
-    
-    aDragSession.canDrop = true;
-  },
-  
-  onDrop: function (aEvent, aXferData, aDragSession)
-  {
-    if (!gCurrentDragOverItem)
+function onToolbarDrop(aEvent)
+{
+  if (!gCurrentDragOverItem)
+    return;
+
+  setDragActive(gCurrentDragOverItem, false);
+
+  var documentId = gToolboxDocument.documentElement.id;
+  var draggedItemId = aEvent.dataTransfer.getData("text/toolbarwrapper-id/" + documentId);
+  if (gCurrentDragOverItem.id == draggedItemId)
+    return;
+
+  var toolbar = aEvent.target;
+  while (toolbar.localName != "toolbar")
+    toolbar = toolbar.parentNode;
+
+  var draggedPaletteWrapper = document.getElementById("wrapper-"+draggedItemId);       
+  if (!draggedPaletteWrapper) {
+    // The wrapper has been dragged from the toolbar.
+    // Get the wrapper from the toolbar document and make sure that
+    // it isn't being dropped on itself.
+    var wrapper = gToolboxDocument.getElementById("wrapper-"+draggedItemId);
+    if (wrapper == gCurrentDragOverItem)
+       return;
+
+    // Don't allow static kids (e.g., the menubar) to move.
+    if (wrapper.parentNode.firstPermanentChild && wrapper.parentNode.firstPermanentChild.id == wrapper.firstChild.id)
       return;
-    
-    setDragActive(gCurrentDragOverItem, false);
-
-    var draggedItemId = aXferData.data;
-    if (gCurrentDragOverItem.id == draggedItemId)
+    if (wrapper.parentNode.lastPermanentChild && wrapper.parentNode.lastPermanentChild.id == wrapper.firstChild.id)
       return;
 
-    var toolbar = aEvent.target;
-    while (toolbar.localName != "toolbar")
-      toolbar = toolbar.parentNode;
+    // Remove the item from its place in the toolbar.
+    wrapper.parentNode.removeChild(wrapper);
 
-    var draggedPaletteWrapper = document.getElementById("wrapper-"+draggedItemId);       
-    if (!draggedPaletteWrapper) {
-      // The wrapper has been dragged from the toolbar.
-      
-      // Get the wrapper from the toolbar document and make sure that
-      // it isn't being dropped on itself.
-      var wrapper = gToolboxDocument.getElementById("wrapper-"+draggedItemId);
-      if (wrapper == gCurrentDragOverItem)
-        return;
-
-      // Don't allow static kids (e.g., the menubar) to move.
-      if (wrapper.parentNode.firstPermanentChild && wrapper.parentNode.firstPermanentChild.id == wrapper.firstChild.id)
-        return;
-      if (wrapper.parentNode.lastPermanentChild && wrapper.parentNode.lastPermanentChild.id == wrapper.firstChild.id)
-        return;
+    // Determine which toolbar we are dropping on.
+    var dropToolbar = null;
+    if (gCurrentDragOverItem.localName == "toolbar")
+      dropToolbar = gCurrentDragOverItem;
+    else
+      dropToolbar = gCurrentDragOverItem.parentNode;
 
-      // Remove the item from its place in the toolbar.
-      wrapper.parentNode.removeChild(wrapper);
+    // Insert the item into the toolbar.
+    if (gCurrentDragOverItem != dropToolbar)
+      dropToolbar.insertBefore(wrapper, gCurrentDragOverItem);
+    else
+      dropToolbar.appendChild(wrapper);
+  } else {
+    // The item has been dragged from the palette
 
-      // Determine which toolbar we are dropping on.
-      var dropToolbar = null;
-      if (gCurrentDragOverItem.localName == "toolbar")
-        dropToolbar = gCurrentDragOverItem;
-      else
-        dropToolbar = gCurrentDragOverItem.parentNode;
-      
-      // Insert the item into the toolbar.
-      if (gCurrentDragOverItem != dropToolbar)
-        dropToolbar.insertBefore(wrapper, gCurrentDragOverItem);
-      else
-        dropToolbar.appendChild(wrapper);
-    } else {
-      // The item has been dragged from the palette
-      
-      // Create a new wrapper for the item. We don't know the id yet.
-      var wrapper = createWrapper("", gToolboxDocument);
+    // Create a new wrapper for the item. We don't know the id yet.
+    var wrapper = createWrapper("", gToolboxDocument);
+
+    // Ask the toolbar to clone the item's template, place it inside the wrapper, and insert it in the toolbar.
+    var newItem = toolbar.insertItem(draggedItemId, gCurrentDragOverItem == toolbar ? null : gCurrentDragOverItem, wrapper);
+
+    // Prepare the item and wrapper to look good on the toolbar.
+    cleanupItemForToolbar(newItem, wrapper);
+    wrapper.id = "wrapper-"+newItem.id;
+    wrapper.flex = newItem.flex;
 
-      // Ask the toolbar to clone the item's template, place it inside the wrapper, and insert it in the toolbar.
-      var newItem = toolbar.insertItem(draggedItemId, gCurrentDragOverItem == toolbar ? null : gCurrentDragOverItem, wrapper);
-      
-      // Prepare the item and wrapper to look good on the toolbar.
-      cleanupItemForToolbar(newItem, wrapper);
-      wrapper.id = "wrapper-"+newItem.id;
-      wrapper.flex = newItem.flex;
+    // Remove the wrapper from the palette.
+    var currentRow = draggedPaletteWrapper.parentNode;
+    if (draggedItemId != "separator" &&
+        draggedItemId != "spring" &&
+        draggedItemId != "spacer")
+    {
+      currentRow.removeChild(draggedPaletteWrapper);
 
-      // Remove the wrapper from the palette.
-      var currentRow = draggedPaletteWrapper.parentNode;
-      if (draggedItemId != "separator" &&
-          draggedItemId != "spring" &&
-          draggedItemId != "spacer")
-      {
-        currentRow.removeChild(draggedPaletteWrapper);
+      while (currentRow) {
+        // Pull the first child of the next row up
+        // into this row.
+        var nextRow = currentRow.nextSibling;
 
-        while (currentRow) {
-          // Pull the first child of the next row up
-          // into this row.
-          var nextRow = currentRow.nextSibling;
-          
-          if (!nextRow) {
-            var last = currentRow.lastChild;
-            var first = currentRow.firstChild;
-            if (first == last) {
-              // Kill the row.
-              currentRow.parentNode.removeChild(currentRow);
-              break;
-            }
+        if (!nextRow) {
+          var last = currentRow.lastChild;
+          var first = currentRow.firstChild;
+          if (first == last) {
+            // Kill the row.
+            currentRow.parentNode.removeChild(currentRow);
+             break;
+           }
 
-            if (last.localName == "spacer") {
-              var flex = last.getAttribute("flex");
-              last.setAttribute("flex", ++flex);
-              // Reflow doesn't happen for some reason.  Trigger it with a hide/show. ICK! -dwh
-              last.hidden = true;
-              last.hidden = false;
-              break;
-            } else {
-              // Make a spacer and give it a flex of 1.
-              var spacer = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
-                                                    "spacer");
-              spacer.setAttribute("flex", "1");
-              currentRow.appendChild(spacer);
-            }
+          if (last.localName == "spacer") {
+            var flex = last.getAttribute("flex");
+            last.setAttribute("flex", ++flex);
+            // Reflow doesn't happen for some reason.  Trigger it with a hide/show. ICK! -dwh
+            last.hidden = true;
+            last.hidden = false;
             break;
+          } else {
+            // Make a spacer and give it a flex of 1.
+            var spacer = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
+                                                  "spacer");
+            spacer.setAttribute("flex", "1");
+            currentRow.appendChild(spacer);
           }
-          
-          currentRow.appendChild(nextRow.firstChild);
-          currentRow = currentRow.nextSibling;
+          break;
         }
+
+        currentRow.appendChild(nextRow.firstChild);
+        currentRow = currentRow.nextSibling;
       }
     }
-    
-    gCurrentDragOverItem = null;
-
-    toolboxChanged();
-  },
-  
-  _flavourSet: null,
+  }
   
-  getSupportedFlavours: function ()
-  {
-    if (!this._flavourSet) {
-      this._flavourSet = new FlavourSet();
-      var documentId = gToolboxDocument.documentElement.id;
-      this._flavourSet.appendFlavour("text/toolbarwrapper-id/"+documentId);
-    }
-    return this._flavourSet;
-  }
+  gCurrentDragOverItem = null;
+ 
+  toolboxChanged();
+};
+
+function onPaletteDragOver(aEvent)
+{
+  var documentId = gToolboxDocument.documentElement.id;
+  if (aEvent.dataTransfer.types.contains("text/toolbarwrapper-id/" + documentId))
+    aEvent.preventDefault();
 }
 
-var paletteDNDObserver =
-{
-  onDragOver: function (aEvent, aFlavour, aDragSession)
-  {
-    aDragSession.canDrop = true;
-  },
-  
-  onDrop: function(aEvent, aXferData, aDragSession)
-  {
-    var itemId = aXferData.data;
-    
-    var wrapper = gToolboxDocument.getElementById("wrapper-"+itemId);
-    if (wrapper) {
-      // Don't allow static kids (e.g., the menubar) to move.
-      if (wrapper.parentNode.firstPermanentChild && wrapper.parentNode.firstPermanentChild.id == wrapper.firstChild.id)
-        return;
-      if (wrapper.parentNode.lastPermanentChild && wrapper.parentNode.lastPermanentChild.id == wrapper.firstChild.id)
-        return;
+function onPaletteDrop(aEvent)
+ {
+  var documentId = gToolboxDocument.documentElement.id;
+  var itemId = aEvent.dataTransfer.getData("text/toolbarwrapper-id/" + documentId);
+
+  var wrapper = gToolboxDocument.getElementById("wrapper-"+itemId);
+  if (wrapper) {
+    // Don't allow static kids (e.g., the menubar) to move.
+    if (wrapper.parentNode.firstPermanentChild && wrapper.parentNode.firstPermanentChild.id == wrapper.firstChild.id)
+      return;
+    if (wrapper.parentNode.lastPermanentChild && wrapper.parentNode.lastPermanentChild.id == wrapper.firstChild.id)
+      return;
 
-      var wrapperType = wrapper.getAttribute("type");
-      if (wrapperType != "separator" &&
-          wrapperType != "spacer" &&
-          wrapperType != "spring") {
-        appendPaletteItem(document.importNode(wrapper.firstChild, true));
-        gToolbox.palette.appendChild(wrapper.firstChild);
-      }
-
-      // The item was dragged out of the toolbar.
-      wrapper.parentNode.removeChild(wrapper);
+    var wrapperType = wrapper.getAttribute("type");
+    if (wrapperType != "separator" &&
+        wrapperType != "spacer" &&
+        wrapperType != "spring") {
+      appendPaletteItem(document.importNode(wrapper.firstChild, true));
+      gToolbox.palette.appendChild(wrapper.firstChild);
     }
-    
-    toolboxChanged();
-  },
-  
-  _flavourSet: null,
-  
-  getSupportedFlavours: function ()
-  {
-    if (!this._flavourSet) {
-      this._flavourSet = new FlavourSet();
-      var documentId = gToolboxDocument.documentElement.id;
-      this._flavourSet.appendFlavour("text/toolbarwrapper-id/"+documentId);
-    }
-    return this._flavourSet;
-  }
+
+    // The item was dragged out of the toolbar.
+    wrapper.parentNode.removeChild(wrapper);
+  } 
+
+  toolboxChanged();
 }
-
--- a/toolkit/content/customizeToolbar.xul
+++ b/toolkit/content/customizeToolbar.xul
@@ -52,35 +52,34 @@
         title="&dialog.title;"
         onload="onLoad();"
         onunload="onUnload();"
         style="&dialog.style;"
         persist="width height"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 
 <script type="application/javascript" src="chrome://global/content/customizeToolbar.js"/>
-<script type="application/javascript" src="chrome://global/content/nsDragAndDrop.js"/>
 
 <stringbundle id="stringBundle" src="chrome://global/locale/customizeToolbar.properties"/>
 
 <keyset id="CustomizeToolbarKeyset">
   <key id="cmd_close1" keycode="VK_ESCAPE" oncommand="onClose();"/>
   <key id="cmd_close2" keycode="VK_RETURN" oncommand="onClose();"/>
   <key id="cmd_close3" keycode="VK_ENTER"  oncommand="onClose();"/>
 </keyset>
 
 <vbox id="main-box" flex="1">
   <description id="instructions">
   &instructions.description;
   </description>
 
   <vbox flex="1" id="palette-box"
-        ondraggesture="nsDragAndDrop.startDrag(event, dragStartObserver);"
-        ondragover="nsDragAndDrop.dragOver(event, paletteDNDObserver);"
-        ondragdrop="nsDragAndDrop.drop(event, paletteDNDObserver);"/>
+        ondragstart="onToolbarDragStart(event)"
+        ondragover="onPaletteDragOver(event)"
+        ondrop="onPaletteDrop(event)"/>
 
   <box align="center">
     <label value="&show.label;"/>
     <menulist id="modelist" value="icons" oncommand="updateToolbarMode(this.value);">
       <menupopup>
         <menuitem value="full" label="&iconsAndText.label;"/>
         <menuitem value="icons" label="&icons.label;"/>
         <menuitem value="text" label="&text.label;"/>
--- a/toolkit/content/nsDragAndDrop.js
+++ b/toolkit/content/nsDragAndDrop.js
@@ -32,16 +32,27 @@
 # use your version of this file under the terms of the MPL, indicate your
 # decision by deleting the provisions above and replace them with the notice
 # and other provisions required by the GPL or the LGPL. If you do not delete
 # the provisions above, a recipient may use your version of this file under
 # the terms of any one of the MPL, the GPL or the LGPL.
 #
 # ***** END LICENSE BLOCK *****
 
+////////////////////////////////////////////////////////////////////////
+//
+// USE OF THIS API FOR DRAG AND DROP IS DEPRECATED!
+// Do not use this file for new code.
+//
+// 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 nsTransferable = {
@@ -569,16 +580,19 @@ var nsDragAndDrop = {
    * @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: function (aEvent, aDragSession, aDraggedText)
     {
+      if (!aDragSession)
+        aDragSession = this.mDragService.getCurrentSession();
+
       var sourceDoc = aDragSession.sourceDocument;
       if (!sourceDoc)
         return;
 
       // 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
--- a/toolkit/content/widgets/findbar.xml
+++ b/toolkit/content/widgets/findbar.xml
@@ -63,34 +63,16 @@
       <field name="_findbar">null</field>
       <property name="findbar" readonly="true">
         <getter>
           return this._findbar ?
                  this._findbar : this._findbar = document.getBindingParent(this);
         </getter>
       </property>
 
-      <method name="getSupportedFlavours">
-        <body><![CDATA[
-          var flavourSet = new FlavourSet();
-          flavourSet.appendFlavour("text/unicode");
-          return flavourSet;
-        ]]></body>
-      </method>
-
-      <method name="onDrop">
-        <parameter name="aEvent"/>
-        <parameter name="aXferData"/>
-        <parameter name="aDragSession"/>
-        <body><![CDATA[
-          this.value = aXferData.data;
-          this.findbar._find(aXferData.data);
-        ]]></body>
-      </method>
-
       <method name="_handleEnter">
         <parameter name="aEvent"/>
         <body><![CDATA[
           if (this.findbar._findMode == this.findbar.FIND_NORMAL) {
             var findString = this.findbar._findField;
             if (!findString.value)
               return;
 #ifdef XP_MACOSX
@@ -201,17 +183,20 @@
         var findbar = this.findbar;
         findbar._isIMEComposing = false;
         if (findbar._findMode != findbar.FIND_NORMAL &&
             !findbar.hidden)
           findbar._setFindCloseTimeout();
       ]]></handler>
 
       <handler event="drop" phase="capturing"><![CDATA[
-        nsDragAndDrop.drop(event, this);
+        var value = event.dataTransfer.getData("text/plain");
+        this.value = value;
+        this.findbar._find(value);
+        event.stopPropagation();
       ]]></handler>
     </handlers>
   </binding>
 
   <binding id="findbar"
            extends="chrome://global/content/bindings/toolbar.xml#toolbar">
     <resources>
       <stylesheet src="chrome://global/skin/findBar.css"/>
--- a/toolkit/mozapps/downloads/content/downloads.js
+++ b/toolkit/mozapps/downloads/content/downloads.js
@@ -669,39 +669,36 @@ function buildContextMenu(aEvent)
   return false;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 //// Drag and Drop
 
 var gDownloadDNDObserver =
 {
-  onDragOver: function (aEvent, aFlavour, aDragSession)
+  onDragOver: function (aEvent)
   {
-    aDragSession.canDrop = true;
+    var types = aEvent.dataTransfer.types;
+    if (types.contains("text/uri-list") ||
+        types.contains("text/x-moz-url") ||
+        types.contains("text/plain"))
+      aEvent.preventDefault();
   },
 
-  onDrop: function(aEvent, aXferData, aDragSession)
+  onDrop: function(aEvent)
   {
-    var split = aXferData.data.split("\n");
-    var url = split[0];
-    if (url != aXferData.data) {  //do nothing, not a valid URL
-      var name = split[1];
-      saveURL(url, name, null, true, true);
+    var dt = aEvent.dataTransfer;
+    var url = dt.getData("URL");
+    var name;
+    if (!url) {
+      url = dt.getData("text/x-moz-url") || dt.getData("text/plain");
+      [url, name] = url.split("\n");
     }
-  },
-  _flavourSet: null,
-  getSupportedFlavours: function ()
-  {
-    if (!this._flavourSet) {
-      this._flavourSet = new FlavourSet();
-      this._flavourSet.appendFlavour("text/x-moz-url");
-      this._flavourSet.appendFlavour("text/unicode");
-    }
-    return this._flavourSet;
+    if (url)
+      saveURL(url, name ? name : url, null, true, true);
   }
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 //// Command Updating and Command Handlers
 
 var gDownloadViewController = {
   isCommandEnabled: function(aCommand, aItem)
--- a/toolkit/mozapps/downloads/content/downloads.xul
+++ b/toolkit/mozapps/downloads/content/downloads.xul
@@ -65,17 +65,16 @@
         width="&window.width2;" height="&window.height;" screenX="10" screenY="10"
         persist="width height screenX screenY sizemode"
         onload="Startup();" onunload="Shutdown();"
         onclose="return closeWindow(false);">
       
   <script type="application/javascript" src="chrome://mozapps/content/downloads/downloads.js"/>
   <script type="application/javascript" src="chrome://mozapps/content/downloads/DownloadProgressListener.js"/>
   <script type="application/javascript" src="chrome://global/content/contentAreaUtils.js"/>
-  <script type="application/javascript" src="chrome://global/content/nsDragAndDrop.js"/>
   <script type="application/javascript" src="chrome://global/content/globalOverlay.js"/>
   
   <stringbundleset id="downloadSet">
     <stringbundle id="brandStrings" src="chrome://branding/locale/brand.properties"/>
     <stringbundle id="downloadStrings" src="chrome://mozapps/locale/downloads/downloads.properties"/>
   </stringbundleset>
 
   <!-- Use this commandset for command which do not depened on focus or selection -->
@@ -174,18 +173,18 @@
               command="cmd_selectAllDownloads"/>
   </vbox>
   
   <menupopup id="downloadContextMenu" onpopupshowing="return buildContextMenu(event);"/>
 
   <richlistbox id="downloadView" seltype="multiple" flex="1"
                context="downloadContextMenu"
                ondblclick="onDownloadDblClick(event);"
-               ondragover="nsDragAndDrop.dragOver(event, gDownloadDNDObserver);"
-               ondragdrop="nsDragAndDrop.drop(event, gDownloadDNDObserver);">
+               ondragover="gDownloadDNDObserver.onDragOver(event)"
+               ondrop="gDownloadDNDObserver.onDrop(event)">
   </richlistbox>
 
   <windowdragbox id="search" align="center">
     <button id="clearListButton" command="cmd_clearList"
             label="&cmd.clearList.label;"
             accesskey="&cmd.clearList.accesskey;"
             tooltiptext="&cmd.clearList.tooltip;"/>
     <spacer flex="1"/>
--- a/toolkit/mozapps/extensions/content/extensions.js
+++ b/toolkit/mozapps/extensions/content/extensions.js
@@ -1883,51 +1883,57 @@ function buildContextMenu(aEvent)
 }
 
 ///////////////////////////////////////////////////////////////////////////////
 // Drag and Drop
 
 var gExtensionsDNDObserver =
 {
   _ioServ: null,
-  _canDrop: false,
 
   _ensureServices: function ()
   {
     if (!this._ioServ)
       this._ioServ = Components.classes["@mozilla.org/network/io-service;1"]
                                .getService(nsIIOService);
   },
 
   // returns a JS object whose properties are used by xpinstall
-  _getDataFromDragSession: function (aDragSession, aPosition)
+  _getDragData: function (dataTransfer, aIndex)
   {
     var fileData = { };
     // if this fails we do not have valid data to drop
     try {
-      var xfer = Components.classes["@mozilla.org/widget/transferable;1"]
-                           .createInstance(Components.interfaces.nsITransferable);
-      xfer.addDataFlavor("text/x-moz-url");
-      xfer.addDataFlavor("application/x-moz-file", "nsIFile");
-      aDragSession.getData(xfer, aPosition);
+      var url = dataTransfer.mozGetDataAt("text/uri-list", aIndex);
+      if (!url) {
+        url = dataTransfer.mozGetDataAt("text/x-moz-url", aIndex);
+        url = url ? url.split("\n")[0] : null;
+        if (!url) {
+          var file = dataTransfer.mozGetDataAt("application/x-moz-file", aIndex);
 
-      var flavour = { }, data = { }, length = { };
-      xfer.getAnyTransferData(flavour, data, length);
-      var selectedFlavour = this.getSupportedFlavours().flavourTable[flavour.value];
-      var xferData = new FlavourData(data.value, length.value, selectedFlavour);
+          var ioService = Components.classes["@mozilla.org/network/io-service;1"]
+                                     .getService(Components.interfaces.nsIIOService);
+          var fileHandler = this._ioServ.getProtocolHandler("file")
+                                .QueryInterface(Components.interfaces.nsIFileProtocolHandler);
+          url = fileHandler.getURLSpecFromFile(file);
+        }
+      }
 
-      var fileURL = transferUtils.retrieveURLFromData(xferData.data,
-                                                      xferData.flavour.contentType);
-      fileData.fileURL = fileURL;
+      if (!url) {
+        url = dataTransfer.mozGetDataAt("text/plain", aIndex)
+        if (!url)
+          return null;
+      }
 
-      var uri = this._ioServ.newURI(fileURL, null, null);
-      var url = uri.QueryInterface(nsIURL);
-      fileData.fileName = url.fileName;
+      fileData.fileURL = url;
 
-      switch (url.fileExtension) {
+      var uri = this._ioServ.newURI(url, null, null).QueryInterface(nsIURL);
+      fileData.fileName = uri.fileName;
+
+      switch (uri.fileExtension) {
         case "xpi":
           fileData.type = nsIUpdateItem.TYPE_EXTENSION;
           break;
         case "jar":
           fileData.type = nsIUpdateItem.TYPE_THEME;
           break;
         default:
           return null;
@@ -1935,81 +1941,57 @@ var gExtensionsDNDObserver =
     }
     catch (e) {
       return null;
     }
 
     return fileData;
   },
 
-  canDrop: function (aEvent, aDragSession) { return this._canDrop; },
-
-  onDragEnter: function (aEvent, aDragSession)
+  onDragOver: function (aEvent)
   {
-    // XXXrstrong - bug 269568, GTK2 drag and drop is returning invalid data for
-    // dragenter and dragover. To workaround this we always set canDrop to true
-    // and just use the xfer data returned in ondrop which is valid.
-#ifndef MOZ_WIDGET_GTK2
-    this._ensureServices();
-
-    var count = aDragSession.numDropItems;
-    for (var i = 0; i < count; ++i) {
-      var fileData = this._getDataFromDragSession(aDragSession, i);
-      if (!fileData) {
-        this._canDrop = false;
-        return;
-      }
-    }
-#endif
-    this._canDrop = true;
+    var types = aEvent.dataTransfer.types;
+    if (types.contains("text/uri-list") ||
+        types.contains("text/x-moz-url") ||
+        types.contains("application/x-moz-file"))
+      aEvent.preventDefault();
   },
 
-  onDragOver: function (aEvent, aFlavor, aDragSession) { },
-
-  onDrop: function(aEvent, aXferData, aDragSession)
+  onDrop: function(aEvent)
   {
     if (!isXPInstallEnabled())
       return;
 
     this._ensureServices();
 
     var xpinstallObj = { };
     var themes = { };
     var xpiCount = 0;
     var themeCount = 0;
 
-    var count = aDragSession.numDropItems;
+    var dataTransfer = aEvent.dataTransfer; 
+    var count = dataTransfer.mozItemCount;
     for (var i = 0; i < count; ++i) {
-      var fileData = this._getDataFromDragSession(aDragSession, i);
+      var fileData = this._getDragData(dataTransfer, i);
       if (!fileData)
         continue;
 
       xpinstallObj[fileData.fileName] = {
         URL: fileData.fileURL,
         toString: function() { return this.URL; }
       };
       ++xpiCount;
       if (fileData.type == nsIUpdateItem.TYPE_THEME)
         xpinstallObj[fileData.fileName].IconURL = URI_GENERIC_ICON_THEME;
       else
         xpinstallObj[fileData.fileName].IconURL = URI_GENERIC_ICON_XPINSTALL;
     }
 
     if (xpiCount > 0)
       InstallTrigger.install(xpinstallObj);
-  },
-  _flavourSet: null,
-  getSupportedFlavours: function ()
-  {
-    if (!this._flavourSet) {
-      this._flavourSet = new FlavourSet();
-      this._flavourSet.appendFlavour("text/x-moz-url");
-      this._flavourSet.appendFlavour("application/x-moz-file", "nsIFile");
-    }
-    return this._flavourSet;
   }
 };
 
 ///////////////////////////////////////////////////////////////////////////////
 // Notification Messages
 const gAddonsMsgObserver = {
   observe: function (aSubject, aTopic, aData)
   {
--- a/toolkit/mozapps/extensions/content/extensions.xul
+++ b/toolkit/mozapps/extensions/content/extensions.xul
@@ -60,17 +60,16 @@
         screenX="10" screenY="10" width="&em.width;" height="&em.height;"
         persist="width height screenX screenY sizemode"
         onload="Startup();" onunload="Shutdown();"
         onclose="return closeWindow(false);">
 
   <script type="application/javascript" src="chrome://global/content/globalOverlay.js"/>
   <script type="application/javascript" src="chrome://global/content/contentAreaUtils.js"/>
   <script type="application/javascript" src="chrome://mozapps/content/extensions/extensions.js"/>
-  <script type="application/javascript" src="chrome://global/content/nsDragAndDrop.js"/>
 
   <stringbundleset id="extensionsSet">
     <stringbundle id="brandStrings" src="chrome://branding/locale/brand.properties"/>
     <stringbundle id="extensionsStrings" src="chrome://mozapps/locale/extensions/extensions.properties"/>
     <stringbundle id="xpinstallStrings" src="chrome://global/locale/xpinstall/xpinstall.properties"/>
   </stringbundleset>
 
   <keyset id="extensionsKeys">
@@ -195,19 +194,19 @@
         <spacer flex="1"/>
         <label id="browseAddons" class="text-link" value="&browseAddons.label;"
                onclick="if (event.button == 0) { openURL(this.getAttribute('homepageURL')); }"/>
       </hbox>
       
       <hbox flex="1">
         <richlistbox id="extensionsView" flex="1" 
                      datasources="rdf:null" context="addonContextMenu"
-                     ondragenter="nsDragAndDrop.dragEnter(event, gExtensionsDNDObserver);"
-                     ondragover="nsDragAndDrop.dragOver(event, gExtensionsDNDObserver);"
-                     ondragdrop="nsDragAndDrop.drop(event, gExtensionsDNDObserver);"
+                     ondragenter="gExtensionsDNDObserver.onDragOver(event)"
+                     ondragover="gExtensionsDNDObserver.onDragOver(event)"
+                     ondrop="gExtensionsDNDObserver.onDrop(event)"
                      ondblclick="onViewDoubleClick(event);"/>
   
         <splitter id="themeSplitter" hidden="true" collapse="none" persist="state"/>
   
         <vbox id="themePreviewArea" hidden="true" width="220" flex="1" persist="width">
           <deck id="previewImageDeck" flex="1">
             <vbox id="noThemeSelected" pack="center" align="center">
               <label class="previewText">&previewNoThemeSelected.label;</label>