Bug 397457 - context menu code cleanup, remove things we don't use, get rid of a failing security check on any click and replace it with a working one on right-click, catch up with 'API' changes around linkURI in Fx, do less string manipulation of URI specs, r=mkmelin, sr=mscott

This commit is contained in:
philringnalda%gmail.com 2007-10-08 20:27:03 +00:00
Родитель 0e58e32cf2
Коммит 3a203a2e28
5 изменённых файлов: 698 добавлений и 916 удалений

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

@ -40,26 +40,21 @@
#
# ***** END LICENSE BLOCK *****
/*
* - [ Dependencies ] ---------------------------------------------------------
* utilityOverlay.js:
* - gatherTextUnder
*/
var pref = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
var pref = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
/**
* extract the href from the link click event.
* Extract the href from the link click event.
* We look for HTMLAnchorElement, HTMLAreaElement, HTMLLinkElement,
* HTMLInputElement.form.action, and nested anchor tags.
*
* @return href for the url being clicked
*/
function hRefForClickEvent(event)
function hRefForClickEvent(aEvent)
{
var target = event.target;
var target = aEvent.target;
var href;
var isKeyPress = (event.type == "keypress");
var isKeyPress = (aEvent.type == "keypress");
if (target instanceof HTMLAnchorElement ||
target instanceof HTMLAreaElement ||
@ -76,7 +71,7 @@
else
{
// we may be nested inside of a link node
var linkNode = event.originalTarget;
var linkNode = aEvent.originalTarget;
while (linkNode && !(linkNode instanceof HTMLAnchorElement))
linkNode = linkNode.parentNode;
@ -87,7 +82,7 @@
return href;
}
function messagePaneOnResize(event)
function messagePaneOnResize(aEvent)
{
// scale any overflowing images
var messagepane = document.getElementById("messagepane");
@ -117,20 +112,18 @@
}
// Called whenever the user clicks in the content area,
// except when left-clicking on links (special case)
// should always return true for click to go through
function contentAreaClick(event)
function contentAreaClick(aEvent)
{
var href = hRefForClickEvent(event);
if (href)
var href = hRefForClickEvent(aEvent);
if (href && !aEvent.button) // left click on link only
{
handleLinkClick(event, href, null);
if (!event.button) // left click only
return gPhishingDetector.warnOnSuspiciousLinkClick(href); // let the phishing detector check the link
// let the phishing detector check the link
return gPhishingDetector.warnOnSuspiciousLinkClick(href);
}
else if (!event.button)
if (!aEvent.button)
{
var target = event.target;
var target = aEvent.target;
// is this an image that we might want to scale?
const Ci = Components.interfaces;
if (target instanceof Ci.nsIImageLoadingContent)
@ -163,7 +156,7 @@
return true;
}
function openNewTabOrWindow(event, href, sendReferrer)
function openNewTabOrWindow(aEvent, aHref, aSendReferrer)
{
// always return false for stand alone mail (MOZ_THUNDERBIRD)
// let someone else deal with it
@ -172,30 +165,22 @@
function getContentFrameURI(aFocusedWindow)
{
var contentFrame = isContentFrame(aFocusedWindow) ? aFocusedWindow : window.content;
var contentFrame =
isContentFrame(aFocusedWindow) ? aFocusedWindow : window.content;
return contentFrame.location.href;
}
function handleLinkClick(event, href, linkNode)
{
// Make sure we are allowed to open this URL
var focusedWindow = document.commandDispatcher.focusedWindow;
var sourceURL = getContentFrameURI(focusedWindow);
urlSecurityCheck(href, sourceURL);
return false;
}
function middleMousePaste( event )
function middleMousePaste(aEvent)
{
return false;
}
function makeURLAbsolute( base, url )
function makeURLAbsolute(aBase, aUrl)
{
// Construct nsIURL.
var ioService = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
var baseURI = ioService.newURI(base, null, null);
var ioService = Components.classes["@mozilla.org/network/io-service;1"].
getService(Components.interfaces.nsIIOService);
var baseURI = ioService.newURI(aBase, null, null);
return ioService.newURI(baseURI.resolve(url), null, null).spec;
return ioService.newURI(baseURI.resolve(aUrl), null, null).spec;
}

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

@ -802,7 +802,7 @@ function IsMenuItemShowing(menuID)
// message pane context menu helper methods
function addEmail()
{
var url = gContextMenu.linkURL();
var url = gContextMenu.linkURL;
var addresses = getEmail(url);
window.openDialog("chrome://messenger/content/addressbook/abNewCardDialog.xul",
"",
@ -812,7 +812,7 @@ function addEmail()
function composeEmailTo ()
{
var url = gContextMenu.linkURL();
var url = gContextMenu.linkURL;
var addresses = getEmail(url);
var fields = Components.classes["@mozilla.org/messengercompose/composefields;1"].createInstance(Components.interfaces.nsIMsgCompFields);
var params = Components.classes["@mozilla.org/messengercompose/composeparams;1"].createInstance(Components.interfaces.nsIMsgComposeParams);

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

@ -60,6 +60,8 @@ var mailSession;
var gMessengerBundle;
var gBrandBundle;
var gContextMenu;
var datasourceContractIDPrefix = "@mozilla.org/rdf/datasource;1?name=";
var accountManagerDSContractID = datasourceContractIDPrefix + "msgaccountmanager";
var folderDSContractID = datasourceContractIDPrefix + "mailnewsfolders";

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

@ -1125,7 +1125,7 @@
oncommand="gContextMenu.saveImage();"/>
<menuseparator id="messagePaneContext-sep-reportPhishing"/>
<menuitem id="reportPhishingURL" label="&reportPhishingURL.label;" accesskey="&reportPhishingURL.accesskey;"
oncommand="gPhishingDetector.reportPhishingURL(gContextMenu.linkURL());"/>
oncommand="gPhishingDetector.reportPhishingURL(gContextMenu.linkURL);"/>
</popup>
<popup id="toolbar-context-menu">

Разница между файлами не показана из-за своего большого размера Загрузить разницу