fix for 59799, among other things..

Within content areas:
- don't drag form widgets
- don't drag anonymous XBL content
- correctly remove the title from the URL on a drop
r=jag, a=me
This commit is contained in:
alecf%netscape.com 2000-11-13 21:33:05 +00:00
parent 342dcfa209
commit 06460907ac

View File

@ -30,16 +30,16 @@ var gSourceDocument, wasDrag;
var contentAreaDNDObserver = { var contentAreaDNDObserver = {
onDragStart: function (aEvent) onDragStart: function (aEvent)
{ {
if (aEvent.target != aEvent.originalTarget) { // under the assumption that content areas won't contain
// the node is inside an XBL widget, // draggable XBL, we'll ignore the drag if we're dragging XBL
// which means it's likely the scrollbar // anonymous content nodes, like scrollbars, etc.
if (aEvent.target != aEvent.originalTarget)
// throw an exception to avoid the drag throw Components.results.NS_ERROR_FAILURE;
if (aEvent.originalTarget.localName == "thumb")
throw Components.results.NS_ERROR_FAILURE;
dump("Hrm..not sure if I should be dragging this " + aEvent.originalTarget.localName + ".. but I'll try.\n"); // only drag form elements by using the alt key,
} // otherwise buttons and select widgets are hard to use
if ('form' in aEvent.target && !aEvent.altKey)
throw Components.results.NS_ERROR_FAILURE;
var draggedNode = aEvent.target; var draggedNode = aEvent.target;
@ -155,8 +155,7 @@ var contentAreaDNDObserver = {
if (url.length == 0) if (url.length == 0)
return true; return true;
// valid urls don't contain spaces ' '; if we have a space it isn't a valid url so bail out // valid urls don't contain spaces ' '; if we have a space it isn't a valid url so bail out
var urlstr = url.toString(); if ( url.indexOf(" ", 0) != -1 )
if ( urlstr.indexOf(" ", 0) != -1 )
return true; return true;
switch (document.firstChild.getAttribute('windowtype')) { switch (document.firstChild.getAttribute('windowtype')) {
case "navigator:browser": case "navigator:browser":
@ -235,8 +234,15 @@ function retrieveURLFromData (aData)
{ {
switch (aData.flavour) { switch (aData.flavour) {
case "text/unicode": case "text/unicode":
// this might not be a url, but we'll return it anyway
return aData.data.data;
break;
case "text/x-moz-url": case "text/x-moz-url":
return aData.data.data; // XXX this is busted. var data = aData.data.data.toString();
var separator = data.indexOf("\n");
if (separator != -1)
data = data.substr(0, separator);
return data;
break; break;
case "application/x-moz-file": case "application/x-moz-file":
var dataObj = aData.data.data.QueryInterface(Components.interfaces.nsIFile); var dataObj = aData.data.data.QueryInterface(Components.interfaces.nsIFile);