fix for nsbeta3+ bug 41901, link image dragged from one window to another loads the image instead of the linked page.

also tidied up the html string returned in this case so that when dropped into composer, an image enclosed in a link
to the linked page is inserted.
This commit is contained in:
ben%netscape.com 2000-08-09 05:26:44 +00:00
Родитель accfc88901
Коммит 3bd6cf4d68
1 изменённых файлов: 22 добавлений и 6 удалений

Просмотреть файл

@ -283,10 +283,15 @@ var contentAreaDNDObserver = {
case 'IMG':
var imgsrc = aEvent.target.getAttribute("src");
var baseurl = window._content.location.href;
// need to do some stuff with the window._content.location here (path?)
// need to do some stuff with the window._content.location (path?)
// to get base URL for image.
textstring = imgsrc;
htmlstring = "<img src=\"" + textstring + "\">";
if ((linkNode = this.findEnclosingLink(aEvent.target))) {
htmlstring = '<a href="' + linkNode.href + '">' + htmlstring + '</a>';
textstring = linkNode.href;
}
break;
case 'A':
isLink = true;
@ -313,7 +318,6 @@ var contentAreaDNDObserver = {
textstring = node.href;
if (textstring != "")
{
dump("link hit selecting link\n");
htmlstring = "<a href=\"" + textstring + "\">" + textstring + "</a>";
var parent = node.parentNode;
if (parent)
@ -323,14 +327,10 @@ var contentAreaDNDObserver = {
for (index = 0; index<nodelist.length; index++)
{
if (nodelist.item(index) == node)
{
break;
}
}
if (index >= nodelist.length)
{
throw Components.results.NS_ERROR_FAILURE;
}
if (domselection)
{
domselection.collapse(parent,index);
@ -387,6 +387,22 @@ var contentAreaDNDObserver = {
flavourList["application/x-moz-file"] = { width: 2, iid: "nsIFile" };
return flavourList;
},
findEnclosingLink: function (aNode)
{
while (aNode) {
var nodeName = aNode.localName;
if (!nodeName) return null;
nodeName = nodeName.toLowerCase();
if (!nodeName || nodeName == "body" ||
nodeName == "html" || nodeName == "#document")
return null;
if (nodeName == "a" && aNode.href)
return aNode;
aNode = aNode.parentNode;
}
return null;
},
};
//