Restrict handling of various things to events coming from the user (not Web content). b=265176 r+sr=jst a=asa

git-svn-id: svn://10.0.0.236/trunk@164179 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
dbaron%dbaron.org 2004-10-22 07:33:41 +00:00
parent 4fd0805428
commit e0fd54717b
4 changed files with 23 additions and 0 deletions

View File

@ -4017,6 +4017,10 @@ function asyncOpenWebPanel(event)
// should always return true for click to go through
function contentAreaClick(event, fieldNormalClicks)
{
if (!event.isTrusted) {
return true;
}
var target = event.target;
var linkNode;

View File

@ -2914,6 +2914,8 @@ nsEventStateManager::CheckForAndDispatchClick(nsPresContext* aPresContext,
event.isControl = aEvent->isControl;
event.isAlt = aEvent->isAlt;
event.isMeta = aEvent->isMeta;
event.internalAppFlags |=
aEvent->internalAppFlags & NS_APP_EVENT_FLAG_TRUSTED;
nsCOMPtr<nsIPresShell> presShell = mPresContext->GetPresShell();
if (presShell) {

View File

@ -101,6 +101,7 @@
#include "nsHTMLAtoms.h"
#include "nsIEventStateManager.h"
#include "nsIDOMEvent.h"
#include "nsIDOMNSEvent.h"
#include "nsIPrivateDOMEvent.h"
#include "nsDOMCID.h"
#include "nsIServiceManager.h"
@ -1402,6 +1403,18 @@ nsGenericHTMLElement::HandleDOMEventForAnchors(nsPresContext* aPresContext,
if (NS_FAILED(ret))
return ret;
// Ensure that this is a trusted DOM event before going further.
// XXXldb Why can aDOMEvent by null?
if (aDOMEvent && *aDOMEvent) {
nsCOMPtr<nsIDOMNSEvent> nsEvent = do_QueryInterface(*aDOMEvent);
NS_ENSURE_TRUE(nsEvent, NS_OK);
PRBool isTrusted;
ret = nsEvent->GetIsTrusted(&isTrusted);
NS_ENSURE_SUCCESS(ret, NS_OK);
if (!isTrusted)
return NS_OK;
}
if ((*aEventStatus == nsEventStatus_eIgnore ||
(*aEventStatus != nsEventStatus_eConsumeNoDefault &&
(aEvent->message == NS_MOUSE_ENTER_SYNTH ||

View File

@ -175,6 +175,10 @@
// should always return true for click to go through
function contentAreaClick(event)
{
if (!event.isTrusted) {
return true;
}
var isKeyPress = (event.type == "keypress");
var href = hrefForClickEvent(event);
if (href) {