Bug 721417 - Can't drag and drop URL into about:newtab; r=fryn
authorTim Taubert <tim.taubert@gmx.de>
Wed, 08 Feb 2012 02:46:20 +0100
changeset 86421 097b38220aa7c134d97bbeb4cf8febfa9b229264
parent 86313 e0d9c8ddd5bd31cfc5481d47945ffe6e62009704
child 86422 250f556a5d49f67985880370baee1e9ad2de1f56
push id22019
push usertim.taubert@gmx.de
push dateThu, 09 Feb 2012 08:29:49 +0000
treeherdermozilla-central@ca84ab42bd5b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfryn
bugs721417
milestone13.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 721417 - Can't drag and drop URL into about:newtab; r=fryn
browser/base/content/newtab/page.js
--- a/browser/base/content/newtab/page.js
+++ b/browser/base/content/newtab/page.js
@@ -82,20 +82,21 @@ let gPage = {
       this.updateModifiedFlag();
 
       // Initialize and render the grid.
       gGrid.init(this._gridSelector);
 
       // Initialize the drop target shim.
       gDropTargetShim.init();
 
+#ifdef XP_MACOSX
       // Workaround to prevent a delay on MacOSX due to a slow drop animation.
-      let doc = document.documentElement;
-      doc.addEventListener("dragover", this.onDragOver, false);
-      doc.addEventListener("drop", this.onDrop, false);
+      document.addEventListener("dragover", this.onDragOver, false);
+      document.addEventListener("drop", this.onDrop, false);
+#endif
     }.bind(this));
   },
 
   /**
    * Updates the 'page-disabled' attributes of the respective DOM nodes.
    * @param aValue Whether to set or remove attributes.
    */
   _updateAttributes: function Page_updateAttributes(aValue) {
@@ -150,24 +151,24 @@ let gPage = {
   },
 
   /**
    * Handles the 'dragover' event. Workaround to prevent a delay on MacOSX
    * due to a slow drop animation.
    * @param aEvent The 'dragover' event.
    */
   onDragOver: function Page_onDragOver(aEvent) {
-    if (gDrag.isValid(aEvent))
+    if (gDrag.isValid(aEvent) && gDrag.draggedSite)
       aEvent.preventDefault();
   },
 
   /**
    * Handles the 'drop' event. Workaround to prevent a delay on MacOSX due to
    * a slow drop animation.
    * @param aEvent The 'drop' event.
    */
   onDrop: function Page_onDrop(aEvent) {
-    if (gDrag.isValid(aEvent)) {
+    if (gDrag.isValid(aEvent) && gDrag.draggedSite) {
       aEvent.preventDefault();
       aEvent.stopPropagation();
     }
   }
 };