From 6c5c70ee0b7593044a00bc06443d8733818a7f96 Mon Sep 17 00:00:00 2001 From: "dveditz%cruzio.com" Date: Wed, 6 Jul 2005 17:42:07 +0000 Subject: [PATCH] bug 298892 redux. additional patch from neil, r=timeless, sr=dveditz, a=jay --- browser/base/content/browser.js | 28 +++------------------------ mail/base/content/contentAreaClick.js | 27 ++------------------------ 2 files changed, 5 insertions(+), 50 deletions(-) diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index 997dad499d4..10dabbbc38c 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -4748,7 +4748,8 @@ function asyncOpenWebPanel(event) linkNode = target; } else { - linkNode = findParentNode(event.originalTarget, "a"); + while (linkNode && !(linkNode instanceof HTMLAnchorElement)) + linkNode = linkNode.parentNode; // cannot be nested. So if we find an anchor without an // href, there is no useful around the target if (linkNode && !linkNode.hasAttribute("href")) @@ -4855,7 +4856,7 @@ function asyncOpenWebPanel(event) } } if (event.button == 1 && - !findParentNode(event.originalTarget, "scrollbar") && + !event.getPreventDefault() && gPrefService.getBoolPref("middlemouse.contentLoadURL")) { middleMousePaste(event); } @@ -4940,29 +4941,6 @@ function makeURLAbsolute( base, url ) return ioService.newURI(baseURI.resolve(url), null, null).spec; } -function findParentNode(node, parentNode) -{ - if (node && node.nodeType == Node.TEXT_NODE) { - node = node.parentNode; - } - while (node) { - if (node.nodeType == Node.DOCUMENT_NODE) { - return null; - } - var nodeName = node.localName; - if (!nodeName) - return null; - nodeName = nodeName.toLowerCase(); - if (nodeName == "body" || nodeName == "html") { - return null; - } - if (nodeName == parentNode) - return node; - node = node.parentNode; - } - return null; -} - /* * Note that most of this routine has been moved into C++ in order to * be available for all tags as well as gecko embedding. See diff --git a/mail/base/content/contentAreaClick.js b/mail/base/content/contentAreaClick.js index 31236d7558a..1b107a2ff4f 100644 --- a/mail/base/content/contentAreaClick.js +++ b/mail/base/content/contentAreaClick.js @@ -62,7 +62,8 @@ linkNode = target; } else if (!(target instanceof HTMLInputElement)) { - linkNode = findParentNode(event.originalTarget, "a"); + while (linkNode && !(linkNode instanceof HTMLAnchorElement)) + linkNode = linkNode.parentNode; // cannot be nested. So if we find an anchor without an // href, there is no useful around the target if (linkNode && !linkNode.hasAttribute("href")) @@ -119,27 +120,3 @@ return ioService.newURI(baseURI.resolve(url), null, null).spec; } - - function findParentNode(node, parentNode) - { - if (node && node.nodeType == Node.TEXT_NODE) { - node = node.parentNode; - } - - while (node) { - var nodeName = node.localName; - if (!nodeName) - return null; - nodeName = nodeName.toLowerCase(); - if (nodeName == "body" || nodeName == "html" || - nodeName == "#document") { - return null; - } - if (nodeName == parentNode) - return node; - node = node.parentNode; - } - - return null; - } -