Bug 304739 Tidy up hrefAndLinkNodeForClickEvent

p=me r=neil.parkwaycc.co.uk sr=bienvenu
This commit is contained in:
bugzilla%arlen.demon.co.uk 2005-08-18 11:25:18 +00:00
Родитель 8df54440d8
Коммит ef5b2de614
3 изменённых файлов: 16 добавлений и 19 удалений

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

@ -232,11 +232,10 @@ function messagePaneOnClick(event)
// try to determine the href for what you are clicking on.
// for example, it might be "" if you aren't left clicking on a link
var ceParams = {event: event, href: "", linkNode: null};
hrefAndLinkNodeForClickEvent(ceParams);
var href = ceParams.href;
if (!href)
var ceParams = hrefAndLinkNodeForClickEvent(event);
if (!ceParams)
return true;
var href = ceParams.href;
// we know that http://, https://, ftp://, file://, chrome://,
// resource://, about:, and gopher:// (as if),
@ -269,7 +268,7 @@ function messagePaneOnClick(event)
// we want to preventDefault, so that in
// nsGenericHTMLElement::HandleDOMEventForAnchors(), we don't try to handle the click again
event.preventDefault();
if (isPhishingURL(ceParams.linkNode, false))
if (isPhishingURL(ceParams.linkNode, false, href))
return false;
openTopBrowserWith(href);

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

@ -87,15 +87,16 @@ function isMsgEmailScam(aUrl)
// the URL is an email scam.
// aLinkNode: the link node to examine
// aSilentMode: don't prompt the user to confirm
// aHref: optional href for XLinks
//////////////////////////////////////////////////////////////////////////////
function isPhishingURL(aLinkNode, aSilentMode)
function isPhishingURL(aLinkNode, aSilentMode, aHref)
{
if (!gPrefBranch.getBoolPref("mail.phishing.detection.enabled"))
return false;
var phishingType = kPhishingNotSuspicious;
var href = aLinkNode.href;
var href = aHref || aLinkNode.href;
if (!href)
return false;

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

@ -110,12 +110,11 @@
}
}
function hrefAndLinkNodeForClickEvent(aParams)
function hrefAndLinkNodeForClickEvent(event)
{
var event = aParams.event;
var target = event.target;
var href = aParams.href;
var linkNode = aParams.linkNode;
var href = "";
var linkNode = null;
var isKeyPress = (event.type == "keypress");
@ -162,8 +161,7 @@
}
}
aParams.href = href;
aParams.linkNode = linkNode;
return linkNode ? {href: href, linkNode: linkNode} : null;
}
// Called whenever the user clicks in the content area,
@ -176,20 +174,19 @@
}
var isKeyPress = (event.type == "keypress");
var ceParams = {event: event, href: "", linkNode: null};
hrefAndLinkNodeForClickEvent(ceParams);
var href = ceParams.href;
if (href) {
var ceParams = hrefAndLinkNodeForClickEvent(event);
if (ceParams) {
var href = ceParams.href;
if (isKeyPress) {
openNewTabWith(href, true, event.shiftKey);
event.preventBubble();
}
else {
handleLinkClick(event, href, null);
handleLinkClick(event, href, ceParams.linkNode);
// if in mailnews block the link left click if we determine
// that this URL is phishy (i.e. a potential email scam)
if ("gMessengerBundle" in this && !event.button)
return !isPhishingURL(ceParams.linkNode, false);
return !isPhishingURL(ceParams.linkNode, false, href);
}
return true;
}