Fixing bug 289940. Make chrome event handlers only receive trusted events by default. r=jonas@sicking.cc, sr=peterv@propagandism.org, a=chofmann@mozilla.org

This commit is contained in:
jst%mozilla.jstenback.com 2005-04-28 23:48:28 +00:00
Родитель ce94be71f2
Коммит 50de4a3e1d
123 изменённых файлов: 1288 добавлений и 781 удалений

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

@ -252,9 +252,10 @@ NS_IMETHODIMP nsLinkableAccessible::DoAction(PRUint8 index)
if (IsALink()) {
nsCOMPtr<nsPresContext> presContext(GetPresContext());
if (presContext) {
nsMouseEvent linkClickEvent(NS_MOUSE_LEFT_CLICK);
nsMouseEvent linkClickEvent(PR_TRUE, NS_MOUSE_LEFT_CLICK, nsnull,
nsMouseEvent::eReal);
nsEventStatus eventStatus = nsEventStatus_eIgnore;
nsEventStatus eventStatus = nsEventStatus_eIgnore;
mLinkContent->HandleDOMEvent(presContext,
&linkClickEvent,
nsnull,

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

@ -217,7 +217,8 @@ NS_IMETHODIMP nsXULMenuitemAccessible::GetChildCount(PRInt32 *aAccChildCount)
}
// fire a popup dom event
nsEventStatus status = nsEventStatus_eIgnore;
nsMouseEvent event(NS_XUL_POPUP_SHOWING);
nsMouseEvent event(PR_TRUE, NS_XUL_POPUP_SHOWING, nsnull,
nsMouseEvent::eReal);
nsCOMPtr<nsIPresShell> presShell(do_QueryReferent(mWeakShell));
nsCOMPtr<nsIContent> content(do_QueryInterface(childNode));

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

@ -629,6 +629,7 @@ NS_INTERFACE_MAP_BEGIN(nsDocument)
NS_INTERFACE_MAP_ENTRY(nsIDOMEventReceiver)
NS_INTERFACE_MAP_ENTRY(nsIDOMEventTarget)
NS_INTERFACE_MAP_ENTRY(nsIDOM3EventTarget)
NS_INTERFACE_MAP_ENTRY(nsIDOMNSEventTarget)
NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
NS_INTERFACE_MAP_ENTRY(nsIDOM3Node)
NS_INTERFACE_MAP_ENTRY(nsIDOM3Document)
@ -1989,8 +1990,12 @@ nsDocument::EndLoad()
nsCOMPtr<nsIDOMEvent> event;
CreateEvent(NS_LITERAL_STRING("Events"), getter_AddRefs(event));
if (event) {
nsCOMPtr<nsIPrivateDOMEvent> privateEvent(do_QueryInterface(event));
if (privateEvent) {
event->InitEvent(NS_LITERAL_STRING("DOMContentLoaded"), PR_TRUE, PR_TRUE);
privateEvent->SetTrusted(PR_TRUE);
PRBool defaultActionEnabled;
DispatchEvent(event, &defaultActionEnabled);
}
@ -2036,8 +2041,6 @@ nsDocument::EndLoad()
break;
}
nsCOMPtr<nsIPrivateDOMEvent> private_event;
nsCOMPtr<nsIDOMDocumentEvent> document_event =
do_QueryInterface(ancestor_doc);
@ -2045,14 +2048,15 @@ nsDocument::EndLoad()
document_event->CreateEvent(NS_LITERAL_STRING("Events"),
getter_AddRefs(event));
private_event = do_QueryInterface(event);
privateEvent = do_QueryInterface(event);
}
if (event && private_event) {
if (event && privateEvent) {
event->InitEvent(NS_LITERAL_STRING("DOMFrameContentLoaded"), PR_TRUE,
PR_TRUE);
private_event->SetTarget(target_frame);
privateEvent->SetTarget(target_frame);
privateEvent->SetTrusted(PR_TRUE);
// To dispatch this event we must manually call
// HandleDOMEvent() on the ancestor document since the target
@ -2061,7 +2065,7 @@ nsDocument::EndLoad()
// dispatching code.
nsEvent* innerEvent;
private_event->GetInternalNSEvent(&innerEvent);
privateEvent->GetInternalNSEvent(&innerEvent);
if (innerEvent) {
nsEventStatus status = nsEventStatus_eIgnore;
@ -4044,6 +4048,24 @@ nsDocument::IsRegisteredHere(const nsAString & type, PRBool *_retval)
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsDocument::AddEventListener(const nsAString& aType,
nsIDOMEventListener *aListener,
PRBool aUseCapture, PRBool aWantsUntrusted)
{
nsCOMPtr<nsIEventListenerManager> manager;
nsresult rv = GetListenerManager(getter_AddRefs(manager));
NS_ENSURE_SUCCESS(rv, rv);
PRInt32 flags = aUseCapture ? NS_EVENT_FLAG_CAPTURE : NS_EVENT_FLAG_BUBBLE;
if (aWantsUntrusted) {
flags |= NS_PRIV_EVENT_UNTRUSTED_PERMITTED;
}
return manager->AddEventListenerByType(aListener, aType, flags, nsnull);
}
NS_IMETHODIMP
nsDocument::CreateEvent(const nsAString& aEventType, nsIDOMEvent** aReturn)
{

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

@ -55,6 +55,7 @@
#include "nsStubDocumentObserver.h"
#include "nsIDOMEventReceiver.h"
#include "nsIDOM3EventTarget.h"
#include "nsIDOMNSEventTarget.h"
#include "nsIDOMStyleSheetList.h"
#include "nsIScriptGlobalObject.h"
#include "nsIDOMEventTarget.h"
@ -194,6 +195,7 @@ class nsDocument : public nsIDocument,
public nsSupportsWeakReference,
public nsIDOMEventReceiver,
public nsIDOM3EventTarget,
public nsIDOMNSEventTarget,
public nsIScriptObjectPrincipal,
public nsIRadioGroupContainer
{
@ -500,6 +502,9 @@ public:
// nsIDOM3EventTarget
NS_DECL_NSIDOM3EVENTTARGET
// nsIDOMNSEventTarget
NS_DECL_NSIDOMNSEVENTTARGET
// nsIScriptObjectPrincipal
// virtual nsIPrincipal* GetPrincipal();
// Already declared in nsIDocument

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

@ -87,6 +87,8 @@ NS_INTERFACE_MAP_BEGIN(nsGenericDOMDataNode)
nsDOMEventRTTearoff::Create(this))
NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOM3EventTarget,
nsDOMEventRTTearoff::Create(this))
NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOMNSEventTarget,
nsDOMEventRTTearoff::Create(this))
NS_INTERFACE_MAP_ENTRY(nsIContent)
// No nsITextContent since all subclasses might not want that.
NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOM3Node, new nsNode3Tearoff(this))
@ -1095,7 +1097,7 @@ nsGenericDOMDataNode::SetText(const PRUnichar* aBuffer,
if (haveMutationListeners) {
nsCOMPtr<nsIDOMEventTarget> node(do_QueryInterface(this));
nsMutationEvent mutation(NS_MUTATION_CHARACTERDATAMODIFIED, node);
nsMutationEvent mutation(PR_TRUE, NS_MUTATION_CHARACTERDATAMODIFIED, node);
mutation.mPrevAttrValue = oldValue;
if (aLength > 0) {
@ -1141,7 +1143,7 @@ nsGenericDOMDataNode::SetText(const char* aBuffer, PRUint32 aLength,
if (haveMutationListeners) {
nsCOMPtr<nsIDOMEventTarget> node(do_QueryInterface(this));
nsMutationEvent mutation(NS_MUTATION_CHARACTERDATAMODIFIED, node);
nsMutationEvent mutation(PR_TRUE, NS_MUTATION_CHARACTERDATAMODIFIED, node);
mutation.mPrevAttrValue = oldValue;
if (aLength > 0) {
@ -1176,14 +1178,14 @@ nsGenericDOMDataNode::SetText(const nsAString& aStr,
if (haveMutationListeners) {
oldValue = GetCurrentValueAtom();
}
mText = aStr;
SetBidiStatus();
if (haveMutationListeners) {
nsCOMPtr<nsIDOMEventTarget> node(do_QueryInterface(this));
nsMutationEvent mutation(NS_MUTATION_CHARACTERDATAMODIFIED, node);
nsMutationEvent mutation(PR_TRUE, NS_MUTATION_CHARACTERDATAMODIFIED, node);
mutation.mPrevAttrValue = oldValue;
if (!aStr.IsEmpty())

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

@ -498,6 +498,7 @@ NS_INTERFACE_MAP_BEGIN(nsDOMEventRTTearoff)
NS_INTERFACE_MAP_ENTRY(nsIDOMEventTarget)
NS_INTERFACE_MAP_ENTRY(nsIDOMEventReceiver)
NS_INTERFACE_MAP_ENTRY(nsIDOM3EventTarget)
NS_INTERFACE_MAP_ENTRY(nsIDOMNSEventTarget)
NS_INTERFACE_MAP_END_AGGREGATED(mContent)
NS_IMPL_ADDREF(nsDOMEventRTTearoff)
@ -700,6 +701,27 @@ nsDOMEventRTTearoff::IsRegisteredHere(const nsAString & type, PRBool *_retval)
return NS_ERROR_NOT_IMPLEMENTED;
}
// nsIDOMNSEventTarget
NS_IMETHODIMP
nsDOMEventRTTearoff::AddEventListener(const nsAString& aType,
nsIDOMEventListener *aListener,
PRBool aUseCapture,
PRBool aWantsUntrusted)
{
nsCOMPtr<nsIEventListenerManager> listener_manager;
nsresult rv = mContent->GetListenerManager(getter_AddRefs(listener_manager));
NS_ENSURE_SUCCESS(rv, rv);
PRInt32 flags = aUseCapture ? NS_EVENT_FLAG_CAPTURE : NS_EVENT_FLAG_BUBBLE;
if (aWantsUntrusted) {
flags |= NS_PRIV_EVENT_UNTRUSTED_PERMITTED;
}
return listener_manager->AddEventListenerByType(aListener, aType, flags,
nsnull);
}
//----------------------------------------------------------------------
nsDOMSlots::nsDOMSlots(PtrBits aFlags)
@ -2680,7 +2702,7 @@ nsGenericElement::InsertChildAt(nsIContent* aKid,
}
if (HasMutationListeners(this, NS_EVENT_BITS_MUTATION_NODEINSERTED)) {
nsMutationEvent mutation(NS_MUTATION_NODEINSERTED, aKid);
nsMutationEvent mutation(PR_TRUE, NS_MUTATION_NODEINSERTED, aKid);
mutation.mRelatedNode = do_QueryInterface(this);
nsEventStatus status = nsEventStatus_eIgnore;
@ -2722,7 +2744,7 @@ nsGenericElement::AppendChildTo(nsIContent* aKid, PRBool aNotify)
}
if (HasMutationListeners(this, NS_EVENT_BITS_MUTATION_NODEINSERTED)) {
nsMutationEvent mutation(NS_MUTATION_NODEINSERTED, aKid);
nsMutationEvent mutation(PR_TRUE, NS_MUTATION_NODEINSERTED, aKid);
mutation.mRelatedNode = do_QueryInterface(this);
nsEventStatus status = nsEventStatus_eIgnore;
@ -2742,7 +2764,7 @@ nsGenericElement::RemoveChildAt(PRUint32 aIndex, PRBool aNotify)
mozAutoDocUpdate updateBatch(document, UPDATE_CONTENT_MODEL, aNotify);
if (HasMutationListeners(this, NS_EVENT_BITS_MUTATION_NODEREMOVED)) {
nsMutationEvent mutation(NS_MUTATION_NODEREMOVED, oldKid);
nsMutationEvent mutation(PR_TRUE, NS_MUTATION_NODEREMOVED, oldKid);
mutation.mRelatedNode = do_QueryInterface(this);
nsEventStatus status = nsEventStatus_eIgnore;
@ -3241,6 +3263,8 @@ NS_INTERFACE_MAP_BEGIN(nsGenericElement)
nsDOMEventRTTearoff::Create(this))
NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOM3EventTarget,
nsDOMEventRTTearoff::Create(this))
NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOMNSEventTarget,
nsDOMEventRTTearoff::Create(this))
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIContent)
NS_INTERFACE_MAP_END
@ -3342,7 +3366,21 @@ nsGenericElement::AddScriptEventListener(nsIAtom* aAttribute,
}
if (manager) {
rv = manager->AddScriptEventListener(target, aAttribute, aValue, defer);
nsIDocument *ownerDoc = GetOwnerDoc();
PRBool permitUntrustedEvents = PR_FALSE;
nsIURI *docUri;
if (ownerDoc && (docUri = ownerDoc->GetDocumentURI())) {
PRBool isChrome = PR_TRUE;
rv = docUri->SchemeIs("chrome", &isChrome);
NS_ENSURE_SUCCESS(rv, rv);
permitUntrustedEvents = !isChrome;
}
rv = manager->AddScriptEventListener(target, aAttribute, aValue, defer,
permitUntrustedEvents);
}
return rv;
@ -3512,8 +3550,9 @@ nsGenericElement::SetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
binding->AttributeChanged(aName, aNamespaceID, PR_FALSE, aNotify);
if (HasMutationListeners(this, NS_EVENT_BITS_MUTATION_ATTRMODIFIED)) {
nsCOMPtr<nsIDOMEventTarget> node(do_QueryInterface(NS_STATIC_CAST(nsIContent *, this)));
nsMutationEvent mutation(NS_MUTATION_ATTRMODIFIED, node);
nsCOMPtr<nsIDOMEventTarget> node =
do_QueryInterface(NS_STATIC_CAST(nsIContent *, this));
nsMutationEvent mutation(PR_TRUE, NS_MUTATION_ATTRMODIFIED, node);
nsAutoString attrName;
aName->ToString(attrName);
@ -3609,8 +3648,9 @@ nsGenericElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
}
if (HasMutationListeners(this, NS_EVENT_BITS_MUTATION_ATTRMODIFIED)) {
nsCOMPtr<nsIDOMEventTarget> node(do_QueryInterface(NS_STATIC_CAST(nsIContent *, this)));
nsMutationEvent mutation(NS_MUTATION_ATTRMODIFIED, node);
nsCOMPtr<nsIDOMEventTarget> node =
do_QueryInterface(NS_STATIC_CAST(nsIContent *, this));
nsMutationEvent mutation(PR_TRUE, NS_MUTATION_ATTRMODIFIED, node);
nsAutoString attrName;
aName->ToString(attrName);

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

@ -45,6 +45,7 @@
#include "nsIDOMEventReceiver.h"
#include "nsIDOM3EventTarget.h"
#include "nsIDOM3Node.h"
#include "nsIDOMNSEventTarget.h"
#include "nsILinkHandler.h"
#include "nsGenericDOMNodeList.h"
#include "nsIEventListenerManager.h"
@ -281,7 +282,8 @@ private:
*/
class nsDOMEventRTTearoff : public nsIDOMEventReceiver,
public nsIDOM3EventTarget
public nsIDOM3EventTarget,
public nsIDOMNSEventTarget
{
private:
// This class uses a caching scheme so we don't let users of this
@ -337,6 +339,9 @@ public:
NS_IMETHOD HandleEvent(nsIDOMEvent *aEvent);
NS_IMETHOD GetSystemEventGroup(nsIDOMEventGroup** aGroup);
// nsIDOMNSEventTarget
NS_DECL_NSIDOMNSEVENTTARGET
private:
/**
* Strong reference back to the content object from where an instance of this

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

@ -642,7 +642,7 @@ HandleImagePLEvent(PLEvent* aEvent)
eventMsg = NS_IMAGE_ERROR;
}
nsEvent event(eventMsg);
nsEvent event(PR_TRUE, eventMsg);
evt->mContent->HandleDOMEvent(evt->mPresContext, &event, nsnull,
NS_EVENT_FLAG_INIT, &estatus);

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

@ -102,15 +102,18 @@ public:
NS_IMETHOD AddScriptEventListener(nsISupports *aObject,
nsIAtom *aName,
const nsAString& aFunc,
PRBool aDeferCompilation) = 0;
PRBool aDeferCompilation,
PRBool aPermitUntrustedEvents) = 0;
NS_IMETHOD RemoveScriptEventListener(nsIAtom *aName) = 0;
/**
* Registers an event listener that already exists on the given
* script object with the event listener manager.
* @param an event listener
* script object with the event listener manager. If the event
* listener is registerd from chrome code, the event listener will
* only ever receive trusted events.
* @param the name of an event listener
*/
NS_IMETHOD RegisterScriptEventListener(nsIScriptContext *aContext,
nsISupports *aObject,

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

@ -52,10 +52,10 @@ class nsPresContext;
class nsIDOMEventTarget;
class nsIDOMEvent;
struct nsEvent;
class nsIPrivateDOMEvent : public nsISupports {
class nsEvent;
class nsIPrivateDOMEvent : public nsISupports
{
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IPRIVATEDOMEVENT_IID)
@ -70,20 +70,20 @@ public:
};
nsresult
NS_NewDOMEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, struct nsEvent *aEvent);
NS_NewDOMEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, nsEvent *aEvent);
nsresult
NS_NewDOMUIEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, struct nsGUIEvent *aEvent);
NS_NewDOMUIEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, class nsGUIEvent *aEvent);
nsresult
NS_NewDOMMouseEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, struct nsInputEvent *aEvent);
NS_NewDOMMouseEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, class nsInputEvent *aEvent);
nsresult
NS_NewDOMKeyboardEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, struct nsKeyEvent *aEvent);
NS_NewDOMKeyboardEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, class nsKeyEvent *aEvent);
nsresult
NS_NewDOMMutationEvent(nsIDOMEvent** aResult, nsPresContext* aPresContext, struct nsMutationEvent* aEvent);
NS_NewDOMMutationEvent(nsIDOMEvent** aResult, nsPresContext* aPresContext, class nsMutationEvent* aEvent);
nsresult
NS_NewDOMPopupBlockedEvent(nsIDOMEvent** aResult, nsPresContext* aPresContext, struct nsPopupBlockedEvent* aEvent);
NS_NewDOMPopupBlockedEvent(nsIDOMEvent** aResult, nsPresContext* aPresContext, class nsPopupBlockedEvent* aEvent);
nsresult
NS_NewDOMTextEvent(nsIDOMEvent** aResult, nsPresContext* aPresContext, struct nsTextEvent* aEvent);
NS_NewDOMTextEvent(nsIDOMEvent** aResult, nsPresContext* aPresContext, class nsTextEvent* aEvent);
nsresult
NS_NewDOMBeforeUnloadEvent(nsIDOMEvent** aResult, nsPresContext* aPresContext, struct nsBeforePageUnloadEvent* aEvent);
NS_NewDOMBeforeUnloadEvent(nsIDOMEvent** aResult, nsPresContext* aPresContext, class nsBeforePageUnloadEvent* aEvent);
#endif // nsIPrivateDOMEvent_h__

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

@ -44,29 +44,26 @@
#include "nsIDOMEventTarget.h"
#include "nsIContent.h"
struct nsMutationEvent : public nsEvent
{
nsMutationEvent(PRUint32 msg = 0, PRUint8 structType = NS_MUTATION_EVENT)
: nsEvent(msg, structType),
class nsMutationEvent : public nsEvent
{
public:
nsMutationEvent(PRBool isTrusted, PRUint32 msg)
: nsEvent(isTrusted, msg, NS_MUTATION_EVENT),
mAttrChange(0)
{
flags |= NS_EVENT_FLAG_CANT_CANCEL;
}
nsMutationEvent(PRUint32 msg,
nsIDOMEventTarget *target,
PRUint8 structType = NS_MUTATION_EVENT)
: nsEvent(msg, structType),
nsMutationEvent(PRBool isTrusted, PRUint32 msg, nsIDOMEventTarget *target)
: nsEvent(isTrusted, msg, NS_MUTATION_EVENT),
mTarget(target),
mAttrChange(0)
{
flags |= NS_EVENT_FLAG_CANT_CANCEL;
}
nsMutationEvent(PRUint32 msg,
nsIContent *target,
PRUint8 structType = NS_MUTATION_EVENT)
: nsEvent(msg, structType),
nsMutationEvent(PRBool isTrusted, PRUint32 msg, nsIContent *target)
: nsEvent(isTrusted, msg, NS_MUTATION_EVENT),
mTarget(do_QueryInterface(target)),
mAttrChange(0)
{

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

@ -41,7 +41,9 @@
nsDOMBeforeUnloadEvent::nsDOMBeforeUnloadEvent(nsPresContext* aPresContext,
nsBeforePageUnloadEvent* aEvent)
: nsDOMEvent(aPresContext, aEvent ? aEvent : new nsBeforePageUnloadEvent(NS_BEFORE_PAGE_UNLOAD))
: nsDOMEvent(aPresContext, aEvent ? aEvent :
new nsBeforePageUnloadEvent(PR_FALSE,
NS_BEFORE_PAGE_UNLOAD_EVENT))
{
NS_ASSERTION(mEvent->eventStructType == NS_BEFORE_PAGE_UNLOAD_EVENT,
"event type mismatch");

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

@ -106,7 +106,7 @@ nsDOMEvent::nsDOMEvent(nsPresContext* aPresContext, nsEvent* aEvent)
...
}
*/
mEvent = new nsEvent();
mEvent = new nsEvent(PR_FALSE, 0);
mEvent->time = PR_Now();
}
@ -364,7 +364,7 @@ nsDOMEvent::PreventCapture()
NS_IMETHODIMP
nsDOMEvent::GetIsTrusted(PRBool *aIsTrusted)
{
*aIsTrusted = (mEvent->internalAppFlags & NS_APP_EVENT_FLAG_TRUSTED) != 0;
*aIsTrusted = NS_IS_TRUSTED_EVENT(mEvent);
return NS_OK;
}
@ -633,7 +633,7 @@ nsDOMEvent::GetEventPopupControlState(nsEvent *aEvent)
}
break;
case NS_KEY_EVENT :
if (aEvent->internalAppFlags & NS_APP_EVENT_FLAG_TRUSTED) {
if (NS_IS_TRUSTED_EVENT(aEvent)) {
PRUint32 key = NS_STATIC_CAST(nsKeyEvent *, aEvent)->keyCode;
switch(aEvent->message) {
case NS_KEY_PRESS :
@ -658,7 +658,7 @@ nsDOMEvent::GetEventPopupControlState(nsEvent *aEvent)
}
break;
case NS_MOUSE_EVENT :
if (aEvent->internalAppFlags & NS_APP_EVENT_FLAG_TRUSTED) {
if (NS_IS_TRUSTED_EVENT(aEvent)) {
switch(aEvent->message) {
case NS_MOUSE_LEFT_BUTTON_UP :
if (::PopupAllowedForEvent("mouseup"))

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

@ -41,8 +41,10 @@
#include "nsContentUtils.h"
nsDOMKeyboardEvent::nsDOMKeyboardEvent(nsPresContext* aPresContext, nsKeyEvent* aEvent)
: nsDOMUIEvent(aPresContext, aEvent ? aEvent : new nsKeyEvent())
nsDOMKeyboardEvent::nsDOMKeyboardEvent(nsPresContext* aPresContext,
nsKeyEvent* aEvent)
: nsDOMUIEvent(aPresContext, aEvent ? aEvent :
new nsKeyEvent(PR_FALSE, 0, nsnull))
{
NS_ASSERTION(mEvent->eventStructType == NS_KEY_EVENT, "event type mismatch");

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

@ -43,8 +43,12 @@
#include "nsIEventStateManager.h"
#include "nsContentUtils.h"
nsDOMMouseEvent::nsDOMMouseEvent(nsPresContext* aPresContext, nsInputEvent* aEvent)
: nsDOMUIEvent(aPresContext, aEvent ? aEvent : new nsMouseEvent()), mButton(-1)
nsDOMMouseEvent::nsDOMMouseEvent(nsPresContext* aPresContext,
nsInputEvent* aEvent)
: nsDOMUIEvent(aPresContext, aEvent ? aEvent :
new nsMouseEvent(PR_FALSE, 0, nsnull,
nsMouseEvent::eReal)),
mButton(-1)
{
// There's no way to make this class' ctor allocate an nsMouseScrollEvent.
// It's not that important, though, since a scroll event is not a real

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

@ -42,8 +42,10 @@
class nsPresContext;
nsDOMMutationEvent::nsDOMMutationEvent(nsPresContext* aPresContext, nsMutationEvent* aEvent)
:nsDOMEvent(aPresContext, aEvent ? aEvent : new nsMutationEvent())
nsDOMMutationEvent::nsDOMMutationEvent(nsPresContext* aPresContext,
nsMutationEvent* aEvent)
: nsDOMEvent(aPresContext, aEvent ? aEvent :
new nsMutationEvent(PR_FALSE, 0))
{
if ( aEvent ) {
mEventIsInternal = PR_FALSE;

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

@ -41,8 +41,10 @@
#include "nsIURI.h"
#include "nsContentUtils.h"
nsDOMPopupBlockedEvent::nsDOMPopupBlockedEvent(nsPresContext* aPresContext, nsPopupBlockedEvent* aEvent)
: nsDOMEvent(aPresContext, aEvent ? aEvent : new nsPopupBlockedEvent())
nsDOMPopupBlockedEvent::nsDOMPopupBlockedEvent(nsPresContext* aPresContext,
nsPopupBlockedEvent* aEvent)
: nsDOMEvent(aPresContext, aEvent ? aEvent :
new nsPopupBlockedEvent(PR_FALSE, 0))
{
NS_ASSERTION(mEvent->eventStructType == NS_POPUPBLOCKED_EVENT, "event type mismatch");

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

@ -40,8 +40,10 @@
#include "nsContentUtils.h"
#include "nsPrivateTextRange.h"
nsDOMTextEvent::nsDOMTextEvent(nsPresContext* aPresContext, nsTextEvent* aEvent)
: nsDOMUIEvent(aPresContext, aEvent ? aEvent : new nsTextEvent())
nsDOMTextEvent::nsDOMTextEvent(nsPresContext* aPresContext,
nsTextEvent* aEvent)
: nsDOMUIEvent(aPresContext, aEvent ? aEvent :
new nsTextEvent(PR_FALSE, 0, nsnull))
{
NS_ASSERTION(mEvent->eventStructType == NS_TEXT_EVENT, "event type mismatch");

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

@ -53,8 +53,9 @@
#include "nsIFrame.h"
nsDOMUIEvent::nsDOMUIEvent(nsPresContext* aPresContext, nsGUIEvent* aEvent)
: nsDOMEvent(aPresContext, aEvent ? NS_STATIC_CAST(nsEvent*, aEvent)
: NS_STATIC_CAST(nsEvent*, new nsUIEvent()))
: nsDOMEvent(aPresContext, aEvent ?
NS_STATIC_CAST(nsEvent *, aEvent) :
NS_STATIC_CAST(nsEvent *, new nsUIEvent(PR_FALSE, 0, 0)))
{
if (aEvent) {
mEventIsInternal = PR_FALSE;
@ -64,7 +65,8 @@ nsDOMUIEvent::nsDOMUIEvent(nsPresContext* aPresContext, nsGUIEvent* aEvent)
mEvent->time = PR_Now();
}
// Fill mDetail and mView according to the mEvent (widget-generated event) we've got
// Fill mDetail and mView according to the mEvent (widget-generated
// event) we've got
switch(mEvent->eventStructType)
{
case NS_UI_EVENT:
@ -413,9 +415,8 @@ NS_IMETHODIMP
nsDOMUIEvent::GetPreventDefault(PRBool* aReturn)
{
NS_ENSURE_ARG_POINTER(aReturn);
*aReturn = mEvent ?
((mEvent->flags & NS_EVENT_FLAG_NO_DEFAULT) ? PR_TRUE : PR_FALSE) :
PR_FALSE;
*aReturn = mEvent && (mEvent->flags & NS_EVENT_FLAG_NO_DEFAULT);
return NS_OK;
}

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

@ -407,7 +407,8 @@ nsEventListenerManager::~nsEventListenerManager()
}
}
nsresult nsEventListenerManager::RemoveAllListeners(PRBool aScriptOnly)
nsresult
nsEventListenerManager::RemoveAllListeners(PRBool aScriptOnly)
{
if (!aScriptOnly) {
mListenersRemoved = PR_TRUE;
@ -421,7 +422,7 @@ nsresult nsEventListenerManager::RemoveAllListeners(PRBool aScriptOnly)
if (mMultiListeners) {
// XXX probably should just be i < Count()
for (int i=0; i<EVENT_ARRAY_TYPE_LENGTH && i < mMultiListeners->Count(); i++) {
for (PRInt32 i=0; i<EVENT_ARRAY_TYPE_LENGTH && i < mMultiListeners->Count(); i++) {
nsVoidArray* listeners;
listeners = NS_STATIC_CAST(nsVoidArray*, mMultiListeners->ElementAt(i));
ReleaseListeners(&listeners, aScriptOnly);
@ -447,7 +448,8 @@ nsresult nsEventListenerManager::RemoveAllListeners(PRBool aScriptOnly)
return NS_OK;
}
void nsEventListenerManager::Shutdown()
void
nsEventListenerManager::Shutdown()
{
sAddListenerID = JSVAL_VOID;
@ -467,9 +469,9 @@ NS_INTERFACE_MAP_BEGIN(nsEventListenerManager)
NS_INTERFACE_MAP_END
nsVoidArray* nsEventListenerManager::GetListenersByType(EventArrayType aType,
nsHashKey* aKey,
PRBool aCreate)
nsVoidArray*
nsEventListenerManager::GetListenersByType(EventArrayType aType,
nsHashKey* aKey, PRBool aCreate)
{
NS_ASSERTION(aType >= 0,"Negative EventListenerType?");
//Look for existing listeners
@ -571,7 +573,8 @@ nsVoidArray* nsEventListenerManager::GetListenersByType(EventArrayType aType,
return nsnull;
}
EventArrayType nsEventListenerManager::GetTypeForIID(const nsIID& aIID)
EventArrayType
nsEventListenerManager::GetTypeForIID(const nsIID& aIID)
{
if (aIID.Equals(NS_GET_IID(nsIDOMMouseListener)))
return eEventArrayType_Mouse;
@ -621,7 +624,9 @@ EventArrayType nsEventListenerManager::GetTypeForIID(const nsIID& aIID)
return eEventArrayType_None;
}
void nsEventListenerManager::ReleaseListeners(nsVoidArray** aListeners, PRBool aScriptOnly)
void
nsEventListenerManager::ReleaseListeners(nsVoidArray** aListeners,
PRBool aScriptOnly)
{
if (nsnull != *aListeners) {
PRInt32 i, count = (*aListeners)->Count();
@ -707,7 +712,7 @@ nsEventListenerManager::AddEventListener(nsIDOMEventListener *aListener,
PRBool found = PR_FALSE;
nsListenerStruct* ls;
for (int i=0; i<listeners->Count(); i++) {
for (PRInt32 i=0; i<listeners->Count(); i++) {
ls = (nsListenerStruct*)listeners->ElementAt(i);
if (ls->mListener == aListener && ls->mFlags == aFlags &&
ls->mGroupFlags == group) {
@ -751,7 +756,7 @@ nsEventListenerManager::RemoveEventListener(nsIDOMEventListener *aListener,
nsListenerStruct* ls;
PRBool listenerRemoved = PR_FALSE;
for (int i=0; i<listeners->Count(); i++) {
for (PRInt32 i=0; i<listeners->Count(); i++) {
ls = (nsListenerStruct*)listeners->ElementAt(i);
if (ls->mListener == aListener && ls->mFlags == aFlags) {
ls->mSubType &= ~aSubType;
@ -1064,9 +1069,10 @@ nsEventListenerManager::FindJSEventListener(EventArrayType aType)
{
nsVoidArray *listeners = GetListenersByType(aType, nsnull, PR_FALSE);
if (listeners) {
//Run through the listeners for this IID and see if a script listener is registered
// Run through the listeners for this type and see if a script
// listener is registered
nsListenerStruct *ls;
for (int i=0; i<listeners->Count(); i++) {
for (PRInt32 i=0; i < listeners->Count(); i++) {
ls = (nsListenerStruct*)listeners->ElementAt(i);
if (ls->mFlags & NS_PRIV_EVENT_FLAG_SCRIPT) {
return ls;
@ -1081,7 +1087,8 @@ nsresult
nsEventListenerManager::SetJSEventListener(nsIScriptContext *aContext,
nsISupports *aObject,
nsIAtom* aName,
PRBool aIsString)
PRBool aIsString,
PRBool aPermitUntrustedEvents)
{
nsresult rv = NS_OK;
nsListenerStruct *ls;
@ -1094,8 +1101,8 @@ nsEventListenerManager::SetJSEventListener(nsIScriptContext *aContext,
ls = FindJSEventListener(arrayType);
if (nsnull == ls) {
//If we didn't find a script listener or no listeners existed
//create and add a new one.
// If we didn't find a script listener or no listeners existed
// create and add a new one.
nsCOMPtr<nsIDOMScriptObjectFactory> factory =
do_GetService(kDOMScriptObjectFactoryCID);
NS_ENSURE_TRUE(factory, NS_ERROR_FAILURE);
@ -1120,8 +1127,12 @@ nsEventListenerManager::SetJSEventListener(nsIScriptContext *aContext,
ls->mHandlerIsString &= ~flags;
}
//Set subtype flags based on event
// Set subtype flags based on event
ls->mSubType |= flags;
if (aPermitUntrustedEvents) {
ls->mFlags |= NS_PRIV_EVENT_UNTRUSTED_PERMITTED;
}
}
return rv;
@ -1131,7 +1142,8 @@ NS_IMETHODIMP
nsEventListenerManager::AddScriptEventListener(nsISupports *aObject,
nsIAtom *aName,
const nsAString& aBody,
PRBool aDeferCompilation)
PRBool aDeferCompilation,
PRBool aPermitUntrustedEvents)
{
nsIScriptContext *context = nsnull;
JSContext* cx = nsnull;
@ -1267,7 +1279,8 @@ nsEventListenerManager::AddScriptEventListener(nsISupports *aObject,
}
}
return SetJSEventListener(context, objiSupp, aName, aDeferCompilation);
return SetJSEventListener(context, objiSupp, aName, aDeferCompilation,
aPermitUntrustedEvents);
}
nsresult
@ -1344,7 +1357,8 @@ nsEventListenerManager::RegisterScriptEventListener(nsIScriptContext *aContext,
nsCOMPtr<nsIClassInfo> classInfo = do_QueryInterface(aObject);
if (sAddListenerID == JSVAL_VOID && cx) {
sAddListenerID = STRING_TO_JSVAL(::JS_InternString(cx, "addEventListener"));
sAddListenerID =
STRING_TO_JSVAL(::JS_InternString(cx, "addEventListener"));
rv = nsContentUtils::GetSecurityManager()->
CheckPropertyAccess(cx, jsobj,
@ -1357,7 +1371,10 @@ nsEventListenerManager::RegisterScriptEventListener(nsIScriptContext *aContext,
}
}
return SetJSEventListener(aContext, wrapper->Native(), aName, PR_FALSE);
// Untrusted events are always permitted for non-chrome script
// handlers.
return SetJSEventListener(aContext, wrapper->Native(), aName, PR_FALSE,
!nsContentUtils::IsCallerChrome());
}
nsresult
@ -1554,12 +1571,12 @@ nsEventListenerManager::HandleEventSubType(nsListenerStruct* aListenerStruct,
* @param an event listener
*/
nsresult nsEventListenerManager::HandleEvent(nsPresContext* aPresContext,
nsEvent* aEvent,
nsIDOMEvent** aDOMEvent,
nsIDOMEventTarget* aCurrentTarget,
PRUint32 aFlags,
nsEventStatus* aEventStatus)
nsresult
nsEventListenerManager::HandleEvent(nsPresContext* aPresContext,
nsEvent* aEvent, nsIDOMEvent** aDOMEvent,
nsIDOMEventTarget* aCurrentTarget,
PRUint32 aFlags,
nsEventStatus* aEventStatus)
{
NS_ENSURE_ARG_POINTER(aEventStatus);
nsresult ret = NS_OK;
@ -1598,9 +1615,9 @@ nsresult nsEventListenerManager::HandleEvent(nsPresContext* aPresContext,
if (aEvent->message == NS_USER_DEFINED_EVENT) {
listeners = GetListenersByType(eEventArrayType_Hash, aEvent->userType, PR_FALSE);
} else {
for (int i = 0; i < eEventArrayType_Hash; ++i) {
for (PRInt32 i = 0; i < eEventArrayType_Hash; ++i) {
typeData = &sEventTypes[i];
for (int j = 0; j < typeData->numEvents; ++j) {
for (PRInt32 j = 0; j < typeData->numEvents; ++j) {
dispData = &(typeData->events[j]);
if (aEvent->message == dispData->message) {
listeners = GetListenersByType((EventArrayType)i, nsnull, PR_FALSE);
@ -1623,10 +1640,14 @@ nsresult nsEventListenerManager::HandleEvent(nsPresContext* aPresContext,
nsAutoPopupStatePusher popupStatePusher(nsDOMEvent::GetEventPopupControlState(aEvent));
for (int k = 0; !mListenersRemoved && listeners && k < count; ++k) {
for (PRInt32 k = 0; !mListenersRemoved && listeners && k < count; ++k) {
nsListenerStruct* ls = NS_STATIC_CAST(nsListenerStruct*, originalListeners.FastElementAt(k));
// Don't fire the listener if it's been removed
if (listeners->IndexOf(ls) != -1 && ls->mFlags & aFlags && ls->mGroupFlags == currentGroup) {
if (listeners->IndexOf(ls) != -1 && ls->mFlags & aFlags &&
ls->mGroupFlags == currentGroup &&
(NS_IS_TRUSTED_EVENT(aEvent) ||
ls->mFlags & NS_PRIV_EVENT_UNTRUSTED_PERMITTED)) {
// Try the type-specific listener interface
PRBool hasInterface = PR_FALSE;
if (typeData)
@ -1636,10 +1657,11 @@ nsresult nsEventListenerManager::HandleEvent(nsPresContext* aPresContext,
// If it doesn't implement that, call the generic HandleEvent()
if (!hasInterface && (ls->mSubType == NS_EVENT_BITS_NONE ||
ls->mSubType & dispData->bits))
ls->mSubType & dispData->bits)) {
HandleEventSubType(ls, *aDOMEvent, aCurrentTarget,
dispData ? dispData->bits : NS_EVENT_BITS_NONE,
aFlags);
}
}
}
}
@ -2106,10 +2128,11 @@ nsEventListenerManager::FixContextMenuEvent(nsPresContext* aPresContext,
// Get coordinates relative to root view for element,
// first ensuring the element is onscreen
void nsEventListenerManager::GetCoordinatesFor(nsIDOMElement *aCurrentEl,
nsPresContext *aPresContext,
nsIPresShell *aPresShell,
nsPoint& aTargetPt)
void
nsEventListenerManager::GetCoordinatesFor(nsIDOMElement *aCurrentEl,
nsPresContext *aPresContext,
nsIPresShell *aPresShell,
nsPoint& aTargetPt)
{
nsCOMPtr<nsIContent> focusedContent(do_QueryInterface(aCurrentEl));
nsIFrame *frame = nsnull;

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

@ -126,7 +126,8 @@ public:
NS_IMETHOD AddScriptEventListener(nsISupports *aObject,
nsIAtom *aName,
const nsAString& aFunc,
PRBool aDeferCompilation);
PRBool aDeferCompilation,
PRBool aPermitUntrustedEvents);
NS_IMETHOD RegisterScriptEventListener(nsIScriptContext *aContext,
nsISupports *aObject,
nsIAtom* aName);
@ -199,7 +200,7 @@ protected:
nsListenerStruct* FindJSEventListener(EventArrayType aType);
nsresult SetJSEventListener(nsIScriptContext *aContext,
nsISupports *aObject, nsIAtom* aName,
PRBool aIsString);
PRBool aIsString, PRBool aPermitUntrustedEvents);
nsresult AddEventListener(nsIDOMEventListener *aListener,
EventArrayType aType,
PRInt32 aSubType,

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

@ -530,7 +530,7 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext,
// Fire the blur event on the previously focused document.
nsEventStatus blurstatus = nsEventStatus_eIgnore;
nsEvent blurevent(NS_BLUR_CONTENT);
nsEvent blurevent(PR_TRUE, NS_BLUR_CONTENT);
gLastFocusedDocument->HandleDOMEvent(gLastFocusedPresContext,
&blurevent,
@ -582,10 +582,9 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext,
// Now we should fire the focus event. We fire it on the document,
// then the content node, then the window.
nsEventStatus status = nsEventStatus_eIgnore;
nsEvent focusevent(NS_FOCUS_CONTENT);
nsCOMPtr<nsIScriptGlobalObject> globalObject =
mDocument->GetScriptGlobalObject();
nsCOMPtr<nsIScriptGlobalObject> globalObject = mDocument->GetScriptGlobalObject();
if (globalObject) {
// We don't want there to be a focused content node while we're
// dispatching the focus event.
@ -594,6 +593,9 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext,
// "leak" this reference, but we take it back later
SetFocusedContent(nsnull);
nsEventStatus status = nsEventStatus_eIgnore;
nsEvent focusevent(PR_TRUE, NS_FOCUS_CONTENT);
if (gLastFocusedDocument != mDocument) {
mDocument->HandleDOMEvent(aPresContext, &focusevent, nsnull,
NS_EVENT_FLAG_INIT, &status);
@ -681,7 +683,7 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext,
// and window.
nsEventStatus status = nsEventStatus_eIgnore;
nsEvent event(NS_BLUR_CONTENT);
nsEvent event(PR_TRUE, NS_BLUR_CONTENT);
if (gLastFocusedDocument && gLastFocusedPresContext) {
if (gLastFocusedContent) {
@ -837,7 +839,7 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext,
if (gLastFocusedDocument && gLastFocusedDocument == mDocument) {
nsEventStatus status = nsEventStatus_eIgnore;
nsEvent event(NS_BLUR_CONTENT);
nsEvent event(PR_TRUE, NS_BLUR_CONTENT);
if (gLastFocusedContent) {
nsIPresShell *shell = gLastFocusedDocument->GetShellAt(0);
@ -999,14 +1001,14 @@ nsEventStateManager::HandleAccessKey(nsPresContext* aPresContext,
if (sKeyCausesActivation) {
// B) Click on it if the users prefs indicate to do so.
nsEventStatus status = nsEventStatus_eIgnore;
nsMouseEvent event(NS_MOUSE_LEFT_CLICK);
// Propagate trusted state to the new event.
event.internalAppFlags |=
aEvent->internalAppFlags & NS_APP_EVENT_FLAG_TRUSTED;
nsEventStatus status = nsEventStatus_eIgnore;
nsMouseEvent event(NS_IS_TRUSTED_EVENT(aEvent), NS_MOUSE_LEFT_CLICK,
nsnull, nsMouseEvent::eReal);
nsAutoPopupStatePusher popupStatePusher(aEvent->internalAppFlags & NS_APP_EVENT_FLAG_TRUSTED ? openAllowed : openAbused);
nsAutoPopupStatePusher popupStatePusher(NS_IS_TRUSTED_EVENT(aEvent) ?
openAllowed : openAbused);
nsCOMPtr<nsIContent> oldTargetContent = mCurrentTargetContent;
mCurrentTargetContent = content;
@ -1114,7 +1116,7 @@ nsEventStateManager::CreateClickHoldTimer(nsPresContext* inPresContext,
nsIFrame* inDownFrame,
nsGUIEvent* inMouseDownEvent)
{
if (!(inMouseDownEvent->internalAppFlags & NS_APP_EVENT_FLAG_TRUSTED))
if (!NS_IS_TRUSTED_EVENT(inMouseDownEvent))
return;
// just to be anal (er, safe)
@ -1273,9 +1275,11 @@ nsEventStateManager::FireContextClick()
frameSel->SetMouseDownState(PR_FALSE);
}
nsMouseEvent event(NS_CONTEXTMENU, mCurrentTarget->GetWindow());
nsMouseEvent event(PR_TRUE, NS_CONTEXTMENU,
mCurrentTarget->GetWindow(),
nsMouseEvent::eReal);
event.clickCount = 1;
FillInEventFromGestureDown(&event, PR_TRUE);
FillInEventFromGestureDown(&event);
// dispatch to DOM
mGestureDownContent->HandleDOMEvent(mPresContext, &event, nsnull,
@ -1387,8 +1391,7 @@ nsEventStateManager::GetSelection(nsIFrame* inFrame,
} // GetSelection
void
nsEventStateManager::FillInEventFromGestureDown(nsMouseEvent* aEvent,
PRBool aIsTrusted)
nsEventStateManager::FillInEventFromGestureDown(nsMouseEvent* aEvent)
{
NS_ASSERTION(aEvent->widget == mCurrentTarget->GetWindow(),
"Incorrect widget in event");
@ -1424,9 +1427,6 @@ nsEventStateManager::FillInEventFromGestureDown(nsMouseEvent* aEvent,
aEvent->isControl = mGestureDownControl;
aEvent->isAlt = mGestureDownAlt;
aEvent->isMeta = mGestureDownMeta;
if (aIsTrusted) {
aEvent->internalAppFlags |= NS_APP_EVENT_FLAG_TRUSTED;
}
}
//
@ -1502,9 +1502,9 @@ nsEventStateManager::GenerateDragGesture(nsPresContext* aPresContext,
// get the widget from the target frame
nsEventStatus status = nsEventStatus_eIgnore;
nsMouseEvent event(NS_DRAGDROP_GESTURE, mCurrentTarget->GetWindow());
FillInEventFromGestureDown(&event,
(aEvent->internalAppFlags & NS_APP_EVENT_FLAG_TRUSTED) != 0);
nsMouseEvent event(NS_IS_TRUSTED_EVENT(aEvent), NS_DRAGDROP_GESTURE,
mCurrentTarget->GetWindow(), nsMouseEvent::eReal);
FillInEventFromGestureDown(&event);
// Dispatch to the DOM. By setting mCurrentTarget we are faking
// out the ESM and telling it that the current target frame is
@ -1660,6 +1660,13 @@ nsEventStateManager::DoScrollText(nsPresContext* aPresContext,
aEvent->isControl, aEvent->isAlt,
aEvent->isShift, aEvent->isMeta,
0, nsnull);
nsCOMPtr<nsIPrivateDOMEvent> privateEvent(do_QueryInterface(mouseEvent));
if (privateEvent && NS_IS_TRUSTED_EVENT(aEvent)) {
privateEvent->SetTrusted(PR_TRUE);
}
nsCOMPtr<nsIDOMEventTarget> target(do_QueryInterface(targetContent));
if (target) {
PRBool defaultActionEnabled;
@ -2489,7 +2496,8 @@ nsEventStateManager::DispatchMouseEvent(nsGUIEvent* aEvent, PRUint32 aMessage,
nsIContent* aRelatedContent)
{
nsEventStatus status = nsEventStatus_eIgnore;
nsMouseEvent event(aMessage, aEvent->widget);
nsMouseEvent event(NS_IS_TRUSTED_EVENT(aEvent), aMessage, aEvent->widget,
nsMouseEvent::eReal);
event.point = aEvent->point;
event.refPoint = aEvent->refPoint;
event.isShift = ((nsMouseEvent*)aEvent)->isShift;
@ -2497,8 +2505,6 @@ nsEventStateManager::DispatchMouseEvent(nsGUIEvent* aEvent, PRUint32 aMessage,
event.isAlt = ((nsMouseEvent*)aEvent)->isAlt;
event.isMeta = ((nsMouseEvent*)aEvent)->isMeta;
event.nativeMsg = ((nsMouseEvent*)aEvent)->nativeMsg;
event.internalAppFlags |=
aEvent->internalAppFlags & NS_APP_EVENT_FLAG_TRUSTED;
mCurrentTargetContent = aTargetContent;
mCurrentRelatedContent = aRelatedContent;
@ -2603,13 +2609,14 @@ nsEventStateManager::NotifyMouseOver(nsGUIEvent* aEvent, nsIContent* aContent)
nsIPresShell *parentShell = parentDoc->GetShellAt(0);
if (parentShell) {
nsEventStateManager* parentESM =
NS_STATIC_CAST(nsEventStateManager*, parentShell->GetPresContext()->EventStateManager());
NS_STATIC_CAST(nsEventStateManager*,
parentShell->GetPresContext()->EventStateManager());
parentESM->NotifyMouseOver(aEvent, docContent);
}
}
}
// Firing the DOM event in the parent document could cause all kinds of havoc.
// Reverify and take care.
// Firing the DOM event in the parent document could cause all kinds
// of havoc. Reverify and take care.
if (mLastMouseOverElement == aContent)
return;
@ -2690,15 +2697,15 @@ nsEventStateManager::GenerateDragDropEnterExit(nsPresContext* aPresContext,
if ( mLastDragOverFrame ) {
//fire drag exit
nsEventStatus status = nsEventStatus_eIgnore;
nsMouseEvent event(NS_DRAGDROP_EXIT_SYNTH, aEvent->widget);
nsMouseEvent event(NS_IS_TRUSTED_EVENT(aEvent),
NS_DRAGDROP_EXIT_SYNTH, aEvent->widget,
nsMouseEvent::eReal);
event.point = aEvent->point;
event.refPoint = aEvent->refPoint;
event.isShift = ((nsMouseEvent*)aEvent)->isShift;
event.isControl = ((nsMouseEvent*)aEvent)->isControl;
event.isAlt = ((nsMouseEvent*)aEvent)->isAlt;
event.isMeta = ((nsMouseEvent*)aEvent)->isMeta;
event.internalAppFlags |=
aEvent->internalAppFlags & NS_APP_EVENT_FLAG_TRUSTED;
//The frame has change but the content may not have. Check before dispatching to content
mLastDragOverFrame->GetContentForEvent(aPresContext, aEvent, getter_AddRefs(lastContent));
@ -2725,15 +2732,14 @@ nsEventStateManager::GenerateDragDropEnterExit(nsPresContext* aPresContext,
//fire drag enter
nsEventStatus status = nsEventStatus_eIgnore;
nsMouseEvent event(NS_DRAGDROP_ENTER, aEvent->widget);
nsMouseEvent event(NS_IS_TRUSTED_EVENT(aEvent), NS_DRAGDROP_ENTER,
aEvent->widget, nsMouseEvent::eReal);
event.point = aEvent->point;
event.refPoint = aEvent->refPoint;
event.isShift = ((nsMouseEvent*)aEvent)->isShift;
event.isControl = ((nsMouseEvent*)aEvent)->isControl;
event.isAlt = ((nsMouseEvent*)aEvent)->isAlt;
event.isMeta = ((nsMouseEvent*)aEvent)->isMeta;
event.internalAppFlags |=
aEvent->internalAppFlags & NS_APP_EVENT_FLAG_TRUSTED;
mCurrentTargetContent = targetContent;
mCurrentRelatedContent = lastContent;
@ -2768,15 +2774,14 @@ nsEventStateManager::GenerateDragDropEnterExit(nsPresContext* aPresContext,
// fire mouseout
nsEventStatus status = nsEventStatus_eIgnore;
nsMouseEvent event(NS_DRAGDROP_EXIT_SYNTH, aEvent->widget);
nsMouseEvent event(NS_IS_TRUSTED_EVENT(aEvent), NS_DRAGDROP_EXIT_SYNTH,
aEvent->widget, nsMouseEvent::eReal);
event.point = aEvent->point;
event.refPoint = aEvent->refPoint;
event.isShift = ((nsMouseEvent*)aEvent)->isShift;
event.isControl = ((nsMouseEvent*)aEvent)->isControl;
event.isAlt = ((nsMouseEvent*)aEvent)->isAlt;
event.isMeta = ((nsMouseEvent*)aEvent)->isMeta;
event.internalAppFlags |=
aEvent->internalAppFlags & NS_APP_EVENT_FLAG_TRUSTED;
// dispatch to content via DOM
nsCOMPtr<nsIContent> lastContent;
@ -2894,7 +2899,8 @@ nsEventStateManager::CheckForAndDispatchClick(nsPresContext* aPresContext,
break;
}
nsMouseEvent event(eventMsg, aEvent->widget);
nsMouseEvent event(NS_IS_TRUSTED_EVENT(aEvent), eventMsg, aEvent->widget,
nsMouseEvent::eReal);
event.point = aEvent->point;
event.refPoint = aEvent->refPoint;
event.clickCount = aEvent->clickCount;
@ -2902,8 +2908,6 @@ 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) {
@ -2926,7 +2930,8 @@ nsEventStateManager::CheckForAndDispatchClick(nsPresContext* aPresContext,
break;
}
nsMouseEvent event2(eventMsg, aEvent->widget);
nsMouseEvent event2(NS_IS_TRUSTED_EVENT(aEvent), eventMsg,
aEvent->widget, nsMouseEvent::eReal);
event2.point = aEvent->point;
event2.refPoint = aEvent->refPoint;
event2.clickCount = aEvent->clickCount;
@ -2934,10 +2939,9 @@ nsEventStateManager::CheckForAndDispatchClick(nsPresContext* aPresContext,
event2.isControl = aEvent->isControl;
event2.isAlt = aEvent->isAlt;
event2.isMeta = aEvent->isMeta;
event2.internalAppFlags |=
aEvent->internalAppFlags & NS_APP_EVENT_FLAG_TRUSTED;
ret = presShell->HandleEventWithTarget(&event2, mCurrentTarget, mouseContent, flags, aStatus);
ret = presShell->HandleEventWithTarget(&event2, mCurrentTarget,
mouseContent, flags, aStatus);
}
}
}
@ -3473,7 +3477,7 @@ nsEventStateManager::GetNextTabbableMapArea(PRBool aForward,
// We skip the case where mCurrentFocus has tabindex == mCurrentTabIndex
// since the next tab ordered element might be before it
// (or after for backwards) in the child list.
index = aForward? -1 : count;
index = aForward ? -1 : (PRInt32)count;
}
// GetChildAt will return nsnull if our index < 0 or index >= count
@ -3990,16 +3994,19 @@ nsEventStateManager::SendFocusBlur(nsPresContext* aPresContext,
//fire blur
nsEventStatus status = nsEventStatus_eIgnore;
nsEvent event(NS_BLUR_CONTENT);
nsEvent event(PR_TRUE, NS_BLUR_CONTENT);
EnsureDocument(presShell);
// Make sure we're not switching command dispatchers, if so, surpress the blurred one
// Make sure we're not switching command dispatchers, if so,
// surpress the blurred one
if(gLastFocusedDocument && mDocument) {
nsIFocusController *newFocusController = nsnull;
nsIFocusController *oldFocusController = nsnull;
nsCOMPtr<nsPIDOMWindow> newWindow = do_QueryInterface(mDocument->GetScriptGlobalObject());
nsCOMPtr<nsPIDOMWindow> oldWindow = do_QueryInterface(gLastFocusedDocument->GetScriptGlobalObject());
nsCOMPtr<nsPIDOMWindow> newWindow =
do_QueryInterface(mDocument->GetScriptGlobalObject());
nsCOMPtr<nsPIDOMWindow> oldWindow =
do_QueryInterface(gLastFocusedDocument->GetScriptGlobalObject());
if(newWindow)
newFocusController = newWindow->GetRootFocusController();
if(oldWindow)
@ -4045,9 +4052,10 @@ nsEventStateManager::SendFocusBlur(nsPresContext* aPresContext,
if (gLastFocusedDocument && (gLastFocusedDocument != mDocument) && globalObject) {
nsEventStatus status = nsEventStatus_eIgnore;
nsEvent event(NS_BLUR_CONTENT);
nsEvent event(PR_TRUE, NS_BLUR_CONTENT);
// Make sure we're not switching command dispatchers, if so, surpress the blurred one
// Make sure we're not switching command dispatchers, if so,
// surpress the blurred one
if (mDocument) {
nsIFocusController *newFocusController = nsnull;
nsIFocusController *oldFocusController = nsnull;
@ -4129,7 +4137,7 @@ nsEventStateManager::SendFocusBlur(nsPresContext* aPresContext,
//fire focus
nsEventStatus status = nsEventStatus_eIgnore;
nsEvent event(NS_FOCUS_CONTENT);
nsEvent event(PR_TRUE, NS_FOCUS_CONTENT);
if (nsnull != mPresContext) {
nsCxPusher pusher(aContent);
@ -4150,7 +4158,7 @@ nsEventStateManager::SendFocusBlur(nsPresContext* aPresContext,
//fire focus on document even if the content isn't focusable (ie. text)
//see bugzilla bug 93521
nsEventStatus status = nsEventStatus_eIgnore;
nsEvent event(NS_FOCUS_CONTENT);
nsEvent event(PR_TRUE, NS_FOCUS_CONTENT);
if (nsnull != mPresContext && mDocument) {
nsCxPusher pusher(mDocument);

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

@ -252,9 +252,8 @@ protected:
* that were set when the user first pressed the mouse button (stored by
* BeginTrackingDragGesture). aEvent->widget must be
* mCurrentTarget->GetWindow().
* @param aIsTrusted if true, we set the trusted flag in the event
*/
void FillInEventFromGestureDown(nsMouseEvent* aEvent, PRBool aIsTrusted);
void FillInEventFromGestureDown(nsMouseEvent* aEvent);
PRBool mSuppressFocusChange; // Used only for Ender text fields to suppress a focus firing on mouse down

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

@ -1426,7 +1426,8 @@ nsGenericHTMLElement::DispatchClickEvent(nsPresContext* aPresContext,
NS_PRECONDITION(aSourceEvent, "Must have source event");
NS_PRECONDITION(aStatus, "Null out param?");
nsMouseEvent event(NS_MOUSE_LEFT_CLICK, aSourceEvent->widget);
nsMouseEvent event(NS_IS_TRUSTED_EVENT(aSourceEvent), NS_MOUSE_LEFT_CLICK,
aSourceEvent->widget, nsMouseEvent::eReal);
event.point = aSourceEvent->point;
event.refPoint = aSourceEvent->refPoint;
PRUint32 clickCount = 1;
@ -1438,8 +1439,6 @@ nsGenericHTMLElement::DispatchClickEvent(nsPresContext* aPresContext,
event.isControl = aSourceEvent->isControl;
event.isAlt = aSourceEvent->isAlt;
event.isMeta = aSourceEvent->isMeta;
event.internalAppFlags |=
aSourceEvent->internalAppFlags & NS_APP_EVENT_FLAG_TRUSTED;
return DispatchEvent(aPresContext, &event, aTarget, aFullDispatch, aStatus);
}
@ -1555,7 +1554,8 @@ nsGenericHTMLElement::HandleDOMEventForAnchors(nsPresContext* aPresContext,
// The default action is simply to dispatch DOMActivate
nsIPresShell *shell = aPresContext->GetPresShell();
if (shell) {
nsUIEvent actEvent(NS_UI_ACTIVATE, 1); // single-click
// single-click
nsUIEvent actEvent(NS_IS_TRUSTED_EVENT(aEvent), NS_UI_ACTIVATE, 1);
nsEventStatus status = nsEventStatus_eIgnore;
ret = shell->HandleDOMEventWithTarget(this, &actEvent, &status);
@ -1766,7 +1766,7 @@ nsGenericHTMLElement::SetAttrAndNotify(PRInt32 aNamespaceID,
if (aFireMutation) {
nsCOMPtr<nsIDOMEventTarget> node =
do_QueryInterface(NS_STATIC_CAST(nsIContent *, this));
nsMutationEvent mutation(NS_MUTATION_ATTRMODIFIED, node);
nsMutationEvent mutation(PR_TRUE, NS_MUTATION_ATTRMODIFIED, node);
nsAutoString attrName;
aAttribute->ToString(attrName);

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

@ -203,8 +203,13 @@ nsHTMLButtonElement::Click()
if (shell) {
nsCOMPtr<nsPresContext> context = shell->GetPresContext();
if (context) {
// Click() is never called from native code, but it may be
// called from chrome JS. Mark this event trusted if Click()
// is called from chrome code.
nsMouseEvent event(nsContentUtils::IsCallerChrome(),
NS_MOUSE_LEFT_CLICK, nsnull,
nsMouseEvent::eReal);
nsEventStatus status = nsEventStatus_eIgnore;
nsMouseEvent event(NS_MOUSE_LEFT_CLICK);
HandleDOMEvent(context, &event, nsnull,
NS_EVENT_FLAG_INIT, &status);
}
@ -349,7 +354,10 @@ nsHTMLButtonElement::HandleDOMEvent(nsPresContext* aPresContext,
if ((keyEvent->keyCode == NS_VK_RETURN && NS_KEY_PRESS == aEvent->message) ||
keyEvent->keyCode == NS_VK_SPACE && NS_KEY_UP == aEvent->message) {
nsEventStatus status = nsEventStatus_eIgnore;
nsMouseEvent event(NS_MOUSE_LEFT_CLICK);
nsMouseEvent event(NS_IS_TRUSTED_EVENT(aEvent),
NS_MOUSE_LEFT_CLICK, nsnull,
nsMouseEvent::eReal);
rv = HandleDOMEvent(aPresContext, &event, nsnull,
NS_EVENT_FLAG_INIT, &status);
}
@ -360,7 +368,8 @@ nsHTMLButtonElement::HandleDOMEvent(nsPresContext* aPresContext,
{
nsIPresShell *presShell = aPresContext->GetPresShell();
if (presShell) {
nsUIEvent event(NS_UI_ACTIVATE, 1); // single-click
// single-click
nsUIEvent event(NS_IS_TRUSTED_EVENT(aEvent), NS_UI_ACTIVATE, 1);
nsEventStatus status = nsEventStatus_eIgnore;
presShell->HandleDOMEventWithTarget(this, &event, &status);
@ -371,22 +380,22 @@ nsHTMLButtonElement::HandleDOMEvent(nsPresContext* aPresContext,
case NS_UI_ACTIVATE:
{
if (mForm) {
if (mType == NS_FORM_BUTTON_SUBMIT || mType == NS_FORM_BUTTON_RESET) {
nsFormEvent event((mType == NS_FORM_BUTTON_RESET)
? NS_FORM_RESET : NS_FORM_SUBMIT);
event.originator = this;
nsEventStatus status = nsEventStatus_eIgnore;
if (mForm && (mType == NS_FORM_BUTTON_SUBMIT ||
mType == NS_FORM_BUTTON_RESET)) {
nsFormEvent event(PR_TRUE,
(mType == NS_FORM_BUTTON_RESET)
? NS_FORM_RESET : NS_FORM_SUBMIT);
event.originator = this;
nsEventStatus status = nsEventStatus_eIgnore;
nsIPresShell *presShell = aPresContext->GetPresShell();
// If |nsIPresShell::Destroy| has been called due to
// handling the event (base class HandleDOMEvent, above),
// the pres context will return a null pres shell. See
// bug 125624.
if (presShell) {
nsCOMPtr<nsIContent> form(do_QueryInterface(mForm));
presShell->HandleDOMEventWithTarget(form, &event, &status);
}
nsIPresShell *presShell = aPresContext->GetPresShell();
// If |nsIPresShell::Destroy| has been called due to
// handling the event (base class HandleDOMEvent, above),
// the pres context will return a null pres shell. See
// bug 125624.
if (presShell) {
nsCOMPtr<nsIContent> form(do_QueryInterface(mForm));
presShell->HandleDOMEventWithTarget(form, &event, &status);
}
}
}

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

@ -582,7 +582,7 @@ nsHTMLFormElement::Reset()
// the frame does not exist. This does not have an effect right now, but
// If PresShell::HandleEventWithTarget() ever starts to work for elements
// without frames, that should be called instead.
nsFormEvent event(NS_FORM_RESET);
nsFormEvent event(PR_TRUE, NS_FORM_RESET);
nsEventStatus status = nsEventStatus_eIgnore;
HandleDOMEvent(presContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status);
}

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

@ -957,13 +957,14 @@ nsHTMLInputElement::MaybeSubmitForm(nsPresContext* aPresContext)
if (submitControl) {
// Fire the button's onclick handler and let the button handle
// submitting the form.
nsMouseEvent event(NS_MOUSE_LEFT_CLICK);
nsMouseEvent event(PR_TRUE, NS_MOUSE_LEFT_CLICK, nsnull,
nsMouseEvent::eReal);
nsEventStatus status = nsEventStatus_eIgnore;
shell->HandleDOMEventWithTarget(submitControl, &event, &status);
} else if (numTextControlsFound == 1) {
// If there's only one text control, just submit the form
nsCOMPtr<nsIContent> form = do_QueryInterface(mForm);
nsFormEvent event(NS_FORM_SUBMIT);
nsFormEvent event(PR_TRUE, NS_FORM_SUBMIT);
nsEventStatus status = nsEventStatus_eIgnore;
shell->HandleDOMEventWithTarget(form, &event, &status);
}
@ -1023,7 +1024,7 @@ nsHTMLInputElement::FireOnChange()
// Since the value is changing, send out an onchange event (bug 23571)
//
nsEventStatus status = nsEventStatus_eIgnore;
nsEvent event(NS_FORM_CHANGE);
nsEvent event(PR_TRUE, NS_FORM_CHANGE);
nsCOMPtr<nsPresContext> presContext = GetPresContext();
HandleDOMEvent(presContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status);
}
@ -1134,8 +1135,8 @@ nsHTMLInputElement::Select()
//If already handling select event, don't dispatch a second.
if (!GET_BOOLBIT(mBitField, BF_HANDLING_SELECT_EVENT)) {
nsEvent event(NS_FORM_SELECTED);
nsEvent event(nsContentUtils::IsCallerChrome(), NS_FORM_SELECTED);
SET_BOOLBIT(mBitField, BF_HANDLING_SELECT_EVENT, PR_TRUE);
rv = HandleDOMEvent(presContext, &event, nsnull, NS_EVENT_FLAG_INIT,
&status);
@ -1223,8 +1224,13 @@ nsHTMLInputElement::Click()
nsCOMPtr<nsPresContext> context = shell->GetPresContext();
if (context) {
// Click() is never called from native code, but it may be
// called from chrome JS. Mark this event trusted if Click()
// is called from chrome code.
nsMouseEvent event(nsContentUtils::IsCallerChrome(),
NS_MOUSE_LEFT_CLICK, nsnull,
nsMouseEvent::eReal);
nsEventStatus status = nsEventStatus_eIgnore;
nsMouseEvent event(NS_MOUSE_LEFT_CLICK);
SET_BOOLBIT(mBitField, BF_HANDLING_CLICK, PR_TRUE);
@ -1379,7 +1385,7 @@ nsHTMLInputElement::HandleDOMEvent(nsPresContext* aPresContext,
if (*aEventStatus != nsEventStatus_eConsumeNoDefault &&
!(aFlags & NS_EVENT_FLAG_SYSTEM_EVENT) &&
aEvent->message == NS_MOUSE_LEFT_CLICK && mType != NS_FORM_INPUT_TEXT) {
nsUIEvent actEvent(NS_UI_ACTIVATE, 1);
nsUIEvent actEvent(NS_IS_TRUSTED_EVENT(aEvent), NS_UI_ACTIVATE, 1);
nsIPresShell *shell = aPresContext->GetPresShell();
if (shell) {
@ -1490,8 +1496,11 @@ nsHTMLInputElement::HandleDOMEvent(nsPresContext* aPresContext,
case NS_FORM_INPUT_SUBMIT:
case NS_FORM_INPUT_IMAGE: // Bug 34418
{
nsMouseEvent event(NS_IS_TRUSTED_EVENT(aEvent),
NS_MOUSE_LEFT_CLICK, nsnull,
nsMouseEvent::eReal);
nsEventStatus status = nsEventStatus_eIgnore;
nsMouseEvent event(NS_MOUSE_LEFT_CLICK);
rv = HandleDOMEvent(aPresContext, &event, nsnull,
NS_EVENT_FLAG_INIT, &status);
} // case
@ -1519,7 +1528,9 @@ nsHTMLInputElement::HandleDOMEvent(nsPresContext* aPresContext,
rv = selectedRadioButton->Focus();
if (NS_SUCCEEDED(rv)) {
nsEventStatus status = nsEventStatus_eIgnore;
nsMouseEvent event(NS_MOUSE_LEFT_CLICK);
nsMouseEvent event(NS_IS_TRUSTED_EVENT(aEvent),
NS_MOUSE_LEFT_CLICK, nsnull,
nsMouseEvent::eReal);
rv = radioContent->HandleDOMEvent(aPresContext, &event,
nsnull, NS_EVENT_FLAG_INIT,
&status);
@ -1635,7 +1646,7 @@ nsHTMLInputElement::HandleDOMEvent(nsPresContext* aPresContext,
case NS_FORM_INPUT_SUBMIT:
case NS_FORM_INPUT_IMAGE:
if (mForm) {
nsFormEvent event((mType == NS_FORM_INPUT_RESET) ?
nsFormEvent event(PR_TRUE, (mType == NS_FORM_INPUT_RESET) ?
NS_FORM_RESET : NS_FORM_SUBMIT);
event.originator = this;
nsEventStatus status = nsEventStatus_eIgnore;
@ -2045,9 +2056,16 @@ nsHTMLInputElement::FireEventForAccessibility(nsPresContext* aPresContext,
nsCOMPtr<nsIEventListenerManager> manager;
GetListenerManager(getter_AddRefs(manager));
if (manager &&
NS_SUCCEEDED(manager->CreateEvent(aPresContext, nsnull, NS_LITERAL_STRING("Events"), getter_AddRefs(event)))) {
NS_SUCCEEDED(manager->CreateEvent(aPresContext, nsnull,
NS_LITERAL_STRING("Events"),
getter_AddRefs(event)))) {
event->InitEvent(aEventType, PR_TRUE, PR_TRUE);
nsCOMPtr<nsIPrivateDOMEvent> privateEvent(do_QueryInterface(event));
if (privateEvent) {
privateEvent->SetTrusted(PR_TRUE);
}
nsISupports *target = NS_STATIC_CAST(nsIDOMHTMLInputElement*, this);
PRBool defaultActionEnabled;
aPresContext->EventStateManager()->DispatchNewEvent(target, event,

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

@ -261,7 +261,7 @@ nsHTMLLabelElement::HandleDOMEvent(nsPresContext* aPresContext,
// Since focus doesn't bubble, this is basically the second part
// of redirecting |SetFocus|.
{
nsEvent event(NS_FOCUS_CONTENT);
nsEvent event(NS_IS_TRUSTED_EVENT(aEvent), NS_FOCUS_CONTENT);
nsEventStatus status = *aEventStatus;
rv = DispatchEvent(aPresContext, &event, content, PR_TRUE, &status);
// Do we care about the status this returned? I don't think we do...

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

@ -552,7 +552,7 @@ nsHTMLScriptElement::ScriptAvailable(nsresult aResult,
{
if (!aIsInline && NS_FAILED(aResult)) {
nsEventStatus status = nsEventStatus_eIgnore;
nsScriptErrorEvent event(NS_SCRIPT_ERROR);
nsScriptErrorEvent event(PR_TRUE, NS_SCRIPT_ERROR);
event.lineNr = aLineNo;
@ -585,7 +585,8 @@ nsHTMLScriptElement::ScriptEvaluated(nsresult aResult,
nsresult rv = NS_OK;
if (!aIsInline) {
nsEventStatus status = nsEventStatus_eIgnore;
nsEvent event(NS_SUCCEEDED(aResult) ? NS_SCRIPT_LOAD : NS_SCRIPT_ERROR);
nsEvent event(PR_TRUE,
NS_SUCCEEDED(aResult) ? NS_SCRIPT_LOAD : NS_SCRIPT_ERROR);
nsCOMPtr<nsPresContext> presContext = GetPresContext();
rv = HandleDOMEvent(presContext, &event, nsnull, NS_EVENT_FLAG_INIT,
&status);

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

@ -61,6 +61,7 @@
#include "nsIDOMHTMLOptionsCollection.h"
#include "nsIDOMNSHTMLOptionCollectn.h"
#include "nsGUIEvent.h"
#include "nsIPrivateDOMEvent.h"
#include "nsIBoxObject.h"
#include "nsIDOMNSDocument.h"
#include "nsIDOMDocumentEvent.h"
@ -2002,9 +2003,15 @@ nsHTMLSelectElement::DispatchDOMEvent(const nsAString& aName)
nsCOMPtr<nsIDOMDocumentEvent> domDoc = do_QueryInterface(GetOwnerDoc());
if (domDoc) {
nsCOMPtr<nsIDOMEvent> selectEvent;
domDoc->CreateEvent(NS_LITERAL_STRING("Events"), getter_AddRefs(selectEvent));
if (selectEvent) {
domDoc->CreateEvent(NS_LITERAL_STRING("Events"),
getter_AddRefs(selectEvent));
nsCOMPtr<nsIPrivateDOMEvent> privateEvent(do_QueryInterface(selectEvent));
if (privateEvent) {
selectEvent->InitEvent(aName, PR_TRUE, PR_TRUE);
privateEvent->SetTrusted(PR_TRUE);
nsCOMPtr<nsIDOMEventTarget> target =
do_QueryInterface(NS_STATIC_CAST(nsIDOMNode*, this));
PRBool defaultActionEnabled;

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

@ -278,8 +278,9 @@ nsHTMLTextAreaElement::Select()
nsCOMPtr<nsPresContext> presContext = GetPresContext();
nsEventStatus status = nsEventStatus_eIgnore;
nsGUIEvent event(NS_FORM_SELECTED);
rv = HandleDOMEvent(presContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status);
nsGUIEvent event(PR_TRUE, NS_FORM_SELECTED, nsnull);
rv = HandleDOMEvent(presContext, &event, nsnull, NS_EVENT_FLAG_INIT,
&status);
// If the DOM event was not canceled (e.g. by a JS event handler
// returning false)

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

@ -230,8 +230,19 @@ nsSVGElement::SetAttr(PRInt32 aNamespaceID, nsIAtom* aName, nsIAtom* aPrefix,
nsCOMPtr<nsIEventListenerManager> manager;
GetListenerManager(getter_AddRefs(manager));
if (manager) {
nsIDocument *ownerDoc = GetOwnerDoc();
PRBool permitUntrustedEvents = PR_FALSE;
nsIURI *docUri;
if (ownerDoc && (docUri = ownerDoc->GetDocumentURI())) {
PRBool isChrome = PR_TRUE;
rv = docUri->SchemeIs("chrome", &isChrome);
permitUntrustedEvents = NS_SUCCEEDED(rv) && !isChrome;
}
manager->AddScriptEventListener(NS_STATIC_CAST(nsIContent*, this), aName,
aValue, PR_TRUE);
aValue, PR_TRUE, permitUntrustedEvents);
}
}
@ -665,7 +676,7 @@ nsSVGElement::SetAttrAndNotify(PRInt32 aNamespaceID, nsIAtom* aAttribute,
if (aFireMutation) {
nsCOMPtr<nsIDOMEventTarget> node = do_QueryInterface(NS_STATIC_CAST(nsIContent *, this));
nsMutationEvent mutation(NS_MUTATION_ATTRMODIFIED, node);
nsMutationEvent mutation(PR_TRUE, NS_MUTATION_ATTRMODIFIED, node);
nsAutoString attrName;
aAttribute->ToString(attrName);

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

@ -238,7 +238,7 @@ nsSVGScriptElement::ScriptAvailable(nsresult aResult,
}
nsEventStatus status = nsEventStatus_eIgnore;
nsScriptErrorEvent event(NS_SCRIPT_ERROR);
nsScriptErrorEvent event(PR_TRUE, NS_SCRIPT_ERROR);
event.lineNr = aLineNo;
@ -279,7 +279,8 @@ nsSVGScriptElement::ScriptEvaluated(nsresult aResult,
}
nsEventStatus status = nsEventStatus_eIgnore;
nsEvent event(NS_SUCCEEDED(aResult) ? NS_SCRIPT_LOAD : NS_SCRIPT_ERROR);
nsEvent event(PR_TRUE,
NS_SUCCEEDED(aResult) ? NS_SCRIPT_LOAD : NS_SCRIPT_ERROR);
rv = HandleDOMEvent(presContext, &event, nsnull, NS_EVENT_FLAG_INIT,
&status);
}

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

@ -357,7 +357,8 @@ nsXMLElement::HandleDOMEvent(nsPresContext* aPresContext,
//fire click
nsGUIEvent* guiEvent = NS_STATIC_CAST(nsGUIEvent*, aEvent);
nsMouseEvent event(NS_MOUSE_LEFT_CLICK, guiEvent->widget);
nsMouseEvent event(NS_IS_TRUSTED_EVENT(aEvent), NS_MOUSE_LEFT_CLICK,
guiEvent->widget, nsMouseEvent::eReal);
event.point = aEvent->point;
event.refPoint = aEvent->refPoint;
event.clickCount = 1;

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

@ -1003,7 +1003,7 @@ nsXMLContentSink::HandleEndElement(const PRUnichar *aName)
if (content->GetNameSpaceID() == kNameSpaceID_SVG &&
content->HasAttr(kNameSpaceID_None, nsSVGAtoms::onload)) {
nsEventStatus status = nsEventStatus_eIgnore;
nsEvent event(NS_PAGE_LOAD);
nsEvent event(PR_TRUE, NS_PAGE_LOAD);
nsIPresShell *presShell = mDocument->GetShellAt(0);
if (presShell)
presShell->HandleDOMEventWithTarget(content, &event, &status);

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

@ -632,10 +632,11 @@ nsXMLDocument::EndLoad()
mLoopingForSyncLoad = PR_FALSE;
if (mLoadedAsData || mLoadedAsInteractiveData) {
// Generate a document load event for the case when an XML document was loaded
// as pure data without any presentation attached to it.
// Generate a document load event for the case when an XML
// document was loaded as pure data without any presentation
// attached to it.
nsEvent event(PR_TRUE, NS_PAGE_LOAD);
nsEventStatus status = nsEventStatus_eIgnore;
nsEvent event(NS_PAGE_LOAD);
nsIScriptGlobalObject* sgo = nsnull;
nsCOMPtr<nsIScriptGlobalObjectOwner> container =

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

@ -188,9 +188,6 @@ nsICSSOMFactory* nsXULElement::gCSSOMFactory = nsnull;
//----------------------------------------------------------------------
static NS_DEFINE_CID(kEventListenerManagerCID, NS_EVENTLISTENERMANAGER_CID);
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
static NS_DEFINE_CID(kXULPopupListenerCID, NS_XULPOPUPLISTENER_CID);
static NS_DEFINE_CID(kCSSOMFactoryCID, NS_CSSOMFACTORY_CID);
@ -674,7 +671,19 @@ nsXULElement::AddScriptEventListener(nsIAtom* aName, const nsAString& aValue)
if (NS_FAILED(rv)) return rv;
return manager->AddScriptEventListener(target, aName, aValue, defer);
nsIURI *uri = doc->GetDocumentURI();
PRBool isChromeElement;
if (uri) {
if (NS_FAILED(uri->SchemeIs("chrome", &isChromeElement))) {
isChromeElement = PR_FALSE;
}
} else {
isChromeElement = PR_FALSE;
}
return manager->AddScriptEventListener(target, aName, aValue, defer,
!isChromeElement);
}
nsresult
@ -1177,7 +1186,7 @@ nsXULElement::InsertChildAt(nsIContent* aKid, PRUint32 aIndex, PRBool aNotify)
if (HasMutationListeners(this,
NS_EVENT_BITS_MUTATION_NODEINSERTED)) {
nsMutationEvent mutation(NS_MUTATION_NODEINSERTED, aKid);
nsMutationEvent mutation(PR_TRUE, NS_MUTATION_NODEINSERTED, aKid);
mutation.mRelatedNode =
do_QueryInterface(NS_STATIC_CAST(nsIStyledContent*, this));
@ -1227,7 +1236,7 @@ nsXULElement::AppendChildTo(nsIContent* aKid, PRBool aNotify)
if (HasMutationListeners(this,
NS_EVENT_BITS_MUTATION_NODEINSERTED)) {
nsMutationEvent mutation(NS_MUTATION_NODEINSERTED, aKid);
nsMutationEvent mutation(PR_TRUE, NS_MUTATION_NODEINSERTED, aKid);
mutation.mRelatedNode =
do_QueryInterface(NS_STATIC_CAST(nsIStyledContent*, this));
@ -1252,7 +1261,7 @@ nsXULElement::RemoveChildAt(PRUint32 aIndex, PRBool aNotify)
mozAutoDocUpdate updateBatch(doc, UPDATE_CONTENT_MODEL, aNotify);
if (HasMutationListeners(this, NS_EVENT_BITS_MUTATION_NODEREMOVED)) {
nsMutationEvent mutation(NS_MUTATION_NODEREMOVED, oldKid);
nsMutationEvent mutation(PR_TRUE, NS_MUTATION_NODEREMOVED, oldKid);
mutation.mRelatedNode =
do_QueryInterface(NS_STATIC_CAST(nsIStyledContent*, this));
@ -1349,8 +1358,12 @@ nsXULElement::RemoveChildAt(PRUint32 aIndex, PRBool aNotify)
nsCOMPtr<nsIDOMDocumentEvent> docEvent(do_QueryInterface(doc));
nsCOMPtr<nsIDOMEvent> event;
docEvent->CreateEvent(NS_LITERAL_STRING("Events"), getter_AddRefs(event));
if (event) {
nsCOMPtr<nsIPrivateDOMEvent> privateEvent(do_QueryInterface(event));
if (privateEvent) {
event->InitEvent(NS_LITERAL_STRING("select"), PR_FALSE, PR_TRUE);
privateEvent->SetTrusted(PR_TRUE);
nsCOMPtr<nsIDOMEventTarget> target =
do_QueryInterface(NS_STATIC_CAST(nsIContent *, this));
NS_ENSURE_TRUE(target, NS_ERROR_FAILURE);
@ -1540,7 +1553,7 @@ nsXULElement::SetAttrAndNotify(PRInt32 aNamespaceID,
if (aFireMutation) {
nsCOMPtr<nsIDOMEventTarget> node =
do_QueryInterface(NS_STATIC_CAST(nsIContent *, this));
nsMutationEvent mutation(NS_MUTATION_ATTRMODIFIED, node);
nsMutationEvent mutation(PR_TRUE, NS_MUTATION_ATTRMODIFIED, node);
nsAutoString attrName;
aAttribute->ToString(attrName);
@ -1728,7 +1741,7 @@ nsXULElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, PRBool aNotify)
if (doc) {
if (hasMutationListeners) {
nsCOMPtr<nsIDOMEventTarget> node(do_QueryInterface(NS_STATIC_CAST(nsIContent *, this)));
nsMutationEvent mutation(NS_MUTATION_ATTRMODIFIED, node);
nsMutationEvent mutation(PR_TRUE, NS_MUTATION_ATTRMODIFIED, node);
mutation.mRelatedNode = attrNode;
mutation.mAttrName = aName;
@ -2138,11 +2151,12 @@ nsXULElement::HandleDOMEvent(nsPresContext* aPresContext, nsEvent* aEvent,
nsAutoString empty;
if (NS_FAILED(ret = listenerManager->CreateEvent(aPresContext, aEvent, empty, aDOMEvent)))
return ret;
if (!*aDOMEvent) {
return NS_ERROR_FAILURE;
}
}
if (!*aDOMEvent) {
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIPrivateDOMEvent> privateEvent = do_QueryInterface(*aDOMEvent);
if (!privateEvent) {
return NS_ERROR_FAILURE;
@ -2738,9 +2752,14 @@ nsXULElement::Click()
nsIPresShell *shell = doc->GetShellAt(i);
context = shell->GetPresContext();
nsMouseEvent eventDown(NS_MOUSE_LEFT_BUTTON_DOWN),
eventUp(NS_MOUSE_LEFT_BUTTON_UP),
eventClick(NS_XUL_CLICK);
PRBool isCallerChrome = nsContentUtils::IsCallerChrome();
nsMouseEvent eventDown(isCallerChrome, NS_MOUSE_LEFT_BUTTON_DOWN,
nsnull, nsMouseEvent::eReal);
nsMouseEvent eventUp(isCallerChrome, NS_MOUSE_LEFT_BUTTON_UP,
nsnull, nsMouseEvent::eReal);
nsMouseEvent eventClick(isCallerChrome, NS_XUL_CLICK, nsnull,
nsMouseEvent::eReal);
// send mouse down
nsEventStatus status = nsEventStatus_eIgnore;
@ -2776,7 +2795,8 @@ nsXULElement::DoCommand()
context = shell->GetPresContext();
nsEventStatus status = nsEventStatus_eIgnore;
nsMouseEvent event(NS_XUL_COMMAND);
nsMouseEvent event(PR_TRUE, NS_XUL_COMMAND, nsnull,
nsMouseEvent::eReal);
HandleDOMEvent(context, &event, nsnull, NS_EVENT_FLAG_INIT,
&status);
}

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

@ -379,7 +379,9 @@ nsXULCommandDispatcher::UpdateCommands(const nsAString& aEventName)
// Handle the DOM event
nsEventStatus status = nsEventStatus_eIgnore;
nsEvent event(NS_XUL_COMMAND_UPDATE);
nsEvent event(PR_TRUE, NS_XUL_COMMAND_UPDATE);
content->HandleDOMEvent(context, &event, nsnull, NS_EVENT_FLAG_INIT, &status);
}
}

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

@ -1052,7 +1052,7 @@ nsXULDocument::ExecuteOnBroadcastHandlerFor(nsIContent* aBroadcaster,
// This is the right <observes> element. Execute the
// |onbroadcast| event handler
nsEvent event(NS_XUL_BROADCAST);
nsEvent event(PR_TRUE, NS_XUL_BROADCAST);
PRInt32 j = mPresShells.Count();
while (--j >= 0) {

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

@ -66,6 +66,7 @@ XPIDLSRCS = \
nsIDOMNSUIEvent.idl \
nsIDOMPopupBlockedEvent.idl \
nsIDOMBeforeUnloadEvent.idl \
nsIDOMNSEventTarget.idl \
$(NULL)
include $(topsrcdir)/config/rules.mk

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

@ -0,0 +1,71 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* The Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2005
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Johnny Stenback <jst@mozilla.org> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "domstubs.idl"
/**
* The nsIDOMNSEventTarget interface is an extension to the standard
* nsIDOMEventTarget interface, implemented by all event targets in
* the Document Object Model.
*/
[scriptable, uuid(6cbbbf64-212f-4ef8-9ad4-7240dbb8d6ac)]
interface nsIDOMNSEventTarget : nsISupports
{
/**
* This method is the same as the addEventListener() method defined
* in nsIDOMEventTarget, but it takes one additional argument which
* lets callers control whether or not they want to receive
* untrusted events (synthetic events generated by untrusted code)
*
* @param type See the type argument to the same method in
* nsIDOMEventTarget.
* @param listener See the listener argument to the same method in
* nsIDOMEventTarget.
* @param useCapture See the listener argument to the same method in
* nsIDOMEventTarget.
* @param wantsUntrusted If false, the listener will not receive any
* untrusted events (see above), if true, the
* listener will receive events whether or not
* they're trusted
*/
void addEventListener(in DOMString type,
in nsIDOMEventListener listener,
in boolean useCapture,
in boolean wantsUntrusted);
};

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

@ -158,6 +158,7 @@
// Event related includes
#include "nsIEventListenerManager.h"
#include "nsIDOMEventReceiver.h"
#include "nsIDOMNSEventTarget.h"
// CSS related includes
#include "nsIDOMStyleSheet.h"
@ -1074,6 +1075,7 @@ jsval nsDOMClassInfo::sOpener_id = JSVAL_VOID;
jsval nsDOMClassInfo::sAdd_id = JSVAL_VOID;
jsval nsDOMClassInfo::sAll_id = JSVAL_VOID;
jsval nsDOMClassInfo::sTags_id = JSVAL_VOID;
jsval nsDOMClassInfo::sAddEventListener_id= JSVAL_VOID;
const JSClass *nsDOMClassInfo::sObjectClass = nsnull;
@ -1169,7 +1171,6 @@ GetInternedJSVal(JSContext *cx, const char *str)
return STRING_TO_JSVAL(s);
}
// static
nsresult
nsDOMClassInfo::DefineStaticJSVals(JSContext *cx)
@ -1247,6 +1248,7 @@ nsDOMClassInfo::DefineStaticJSVals(JSContext *cx)
SET_JSVAL_TO_STRING(sAdd_id, cx, "add");
SET_JSVAL_TO_STRING(sAll_id, cx, "all");
SET_JSVAL_TO_STRING(sTags_id, cx, "tags");
SET_JSVAL_TO_STRING(sAddEventListener_id,cx, "addEventListener");
return NS_OK;
}
@ -1507,7 +1509,6 @@ nsDOMClassInfo::RegisterExternalClasses()
DOM_CLASSINFO_MAP_ENTRY(nsIDOM3Document) \
DOM_CLASSINFO_MAP_ENTRY(nsIDOM3Node)
#define DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES \
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSHTMLElement) \
DOM_CLASSINFO_MAP_ENTRY(nsIDOMElementCSSInlineStyle) \
@ -5561,15 +5562,116 @@ nsEventReceiverSH::ReallyIsEventName(jsval id, jschar aFirstChar)
return PR_FALSE;
}
// static
JSBool JS_DLL_CALLBACK
nsEventReceiverSH::AddEventListenerHelper(JSContext *cx, JSObject *obj,
uintN argc, jsval *argv, jsval *rval)
{
if (argc < 3 || argc > 4) {
ThrowJSException(cx, NS_ERROR_XPC_NOT_ENOUGH_ARGS);
return JS_FALSE;
}
nsCOMPtr<nsIXPConnectWrappedNative> wrapper;
nsresult rv =
sXPConnect->GetWrappedNativeOfJSObject(cx, obj, getter_AddRefs(wrapper));
if (NS_FAILED(rv)) {
nsDOMClassInfo::ThrowJSException(cx, rv);
return JS_FALSE;
}
if (JSVAL_IS_PRIMITIVE(argv[1])) {
// The second argument must be a function, or a
// nsIDOMEventListener. Throw an error.
ThrowJSException(cx, NS_ERROR_XPC_BAD_CONVERT_JS);
return JS_FALSE;
}
JSString* jsstr = JS_ValueToString(cx, argv[0]);
if (!jsstr) {
nsDOMClassInfo::ThrowJSException(cx, NS_ERROR_OUT_OF_MEMORY);
return JS_FALSE;
}
nsDependentJSString type(jsstr);
nsCOMPtr<nsIDOMEventListener> listener;
{
nsCOMPtr<nsISupports> tmp;
sXPConnect->WrapJS(cx, JSVAL_TO_OBJECT(argv[1]),
NS_GET_IID(nsIDOMEventListener), getter_AddRefs(tmp));
listener = do_QueryInterface(tmp, &rv);
if (NS_FAILED(rv)) {
ThrowJSException(cx, rv);
return JS_FALSE;
}
}
JSBool useCapture;
if (!JS_ValueToBoolean(cx, argv[2], &useCapture)) {
return JS_FALSE;
}
if (argc == 4) {
JSBool wantsUntrusted;
if (!JS_ValueToBoolean(cx, argv[3], &wantsUntrusted)) {
return JS_FALSE;
}
nsresult rv;
nsCOMPtr<nsIDOMNSEventTarget> eventTarget(do_QueryWrappedNative(wrapper,
&rv));
if (NS_FAILED(rv)) {
ThrowJSException(cx, rv);
return JS_FALSE;
}
rv = eventTarget->AddEventListener(type, listener, useCapture,
wantsUntrusted);
if (NS_FAILED(rv)) {
ThrowJSException(cx, rv);
return JS_FALSE;
}
} else {
nsresult rv;
nsCOMPtr<nsIDOMEventTarget> eventTarget(do_QueryWrappedNative(wrapper,
&rv));
if (NS_FAILED(rv)) {
ThrowJSException(cx, rv);
return JS_FALSE;
}
rv = eventTarget->AddEventListener(type, listener, useCapture);
if (NS_FAILED(rv)) {
ThrowJSException(cx, rv);
return JS_FALSE;
}
}
return JS_TRUE;
}
nsresult
nsEventReceiverSH::RegisterCompileHandler(nsIXPConnectWrappedNative *wrapper,
JSContext *cx, JSObject *obj,
jsval id, PRBool compile,
PRBool remove,
PRBool *did_compile)
PRBool *did_define)
{
NS_PRECONDITION(!compile || !remove, "Can't both compile and remove at the same time");
*did_compile = PR_FALSE;
NS_PRECONDITION(!compile || !remove,
"Can't both compile and remove at the same time");
*did_define = PR_FALSE;
if (!IsEventName(id)) {
return NS_OK;
@ -5582,7 +5684,6 @@ nsEventReceiverSH::RegisterCompileHandler(nsIXPConnectWrappedNative *wrapper,
NS_ENSURE_TRUE(receiver, NS_ERROR_UNEXPECTED);
nsCOMPtr<nsIEventListenerManager> manager;
receiver->GetListenerManager(getter_AddRefs(manager));
NS_ENSURE_TRUE(manager, NS_ERROR_UNEXPECTED);
@ -5593,7 +5694,7 @@ nsEventReceiverSH::RegisterCompileHandler(nsIXPConnectWrappedNative *wrapper,
if (compile) {
rv = manager->CompileScriptEventListener(script_cx, receiver, atom,
did_compile);
did_define);
} else if (remove) {
rv = manager->RemoveScriptEventListener(atom);
} else {
@ -5614,13 +5715,23 @@ nsEventReceiverSH::NewResolve(nsIXPConnectWrappedNative *wrapper,
return NS_OK;
}
PRBool did_compile = PR_FALSE;
if (id == sAddEventListener_id && !(flags & JSRESOLVE_ASSIGNING)) {
JSString *str = JSVAL_TO_STRING(id);
JSFunction *fnc =
::JS_DefineFunction(cx, obj, ::JS_GetStringBytes(str),
AddEventListenerHelper, 0, JSPROP_ENUMERATE);
*objp = obj;
return fnc ? NS_OK : NS_ERROR_UNEXPECTED;
}
PRBool did_define = PR_FALSE;
nsresult rv = RegisterCompileHandler(wrapper, cx, obj, id, PR_TRUE, PR_FALSE,
&did_compile);
&did_define);
NS_ENSURE_SUCCESS(rv, rv);
if (did_compile) {
if (did_define) {
*objp = obj;
}
@ -5634,7 +5745,7 @@ nsEventReceiverSH::SetProperty(nsIXPConnectWrappedNative *wrapper,
jsval *vp, PRBool *_retval)
{
if ((::JS_TypeOfValue(cx, *vp) != JSTYPE_FUNCTION && !JSVAL_IS_NULL(*vp)) ||
!JSVAL_IS_STRING(id)) {
!JSVAL_IS_STRING(id) || id == sAddEventListener_id) {
return NS_OK;
}

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

@ -300,6 +300,7 @@ protected:
static jsval sAdd_id;
static jsval sAll_id;
static jsval sTags_id;
static jsval sAddEventListener_id;
static const JSClass *sObjectClass;
@ -339,10 +340,15 @@ protected:
return PR_FALSE;
}
static JSBool JS_DLL_CALLBACK AddEventListenerHelper(JSContext *cx,
JSObject *obj,
uintN argc, jsval *argv,
jsval *rval);
nsresult RegisterCompileHandler(nsIXPConnectWrappedNative *wrapper,
JSContext *cx, JSObject *obj, jsval id,
PRBool compile, PRBool remove,
PRBool *did_compile);
PRBool *did_define);
public:
NS_IMETHOD NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,

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

@ -327,6 +327,7 @@ NS_INTERFACE_MAP_BEGIN(nsGlobalWindow)
NS_INTERFACE_MAP_ENTRY(nsIDOMEventReceiver)
NS_INTERFACE_MAP_ENTRY(nsIDOMEventTarget)
NS_INTERFACE_MAP_ENTRY(nsIDOM3EventTarget)
NS_INTERFACE_MAP_ENTRY(nsIDOMNSEventTarget)
NS_INTERFACE_MAP_ENTRY(nsPIDOMWindow)
NS_INTERFACE_MAP_ENTRY(nsIDOMViewCSS)
NS_INTERFACE_MAP_ENTRY(nsIDOMAbstractView)
@ -949,7 +950,7 @@ nsGlobalWindow::HandleDOMEvent(nsPresContext* aPresContext, nsEvent* aEvent,
// onload event for the frame element.
nsEventStatus status = nsEventStatus_eIgnore;
nsEvent event(NS_PAGE_LOAD);
nsEvent event(NS_IS_TRUSTED_EVENT(aEvent), NS_PAGE_LOAD);
// Most of the time we could get a pres context to pass in here,
// but not always (i.e. if this window is not shown there won't
@ -4153,6 +4154,25 @@ nsGlobalWindow::IsRegisteredHere(const nsAString & type, PRBool *_retval)
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsGlobalWindow::AddEventListener(const nsAString& aType,
nsIDOMEventListener *aListener,
PRBool aUseCapture, PRBool aWantsUntrusted)
{
nsCOMPtr<nsIEventListenerManager> manager;
nsresult rv = GetListenerManager(getter_AddRefs(manager));
NS_ENSURE_SUCCESS(rv, rv);
PRInt32 flags = aUseCapture ? NS_EVENT_FLAG_CAPTURE : NS_EVENT_FLAG_BUBBLE;
if (aWantsUntrusted) {
flags |= NS_PRIV_EVENT_UNTRUSTED_PERMITTED;
}
return manager->AddEventListenerByType(aListener, aType, flags, nsnull);
}
//*****************************************************************************
// nsGlobalWindow::nsIDOMEventReceiver
//*****************************************************************************
@ -4398,7 +4418,7 @@ nsGlobalWindow::Activate()
nsEventStatus status;
nsGUIEvent guiEvent(NS_ACTIVATE, widget);
nsGUIEvent guiEvent(PR_TRUE, NS_ACTIVATE, widget);
guiEvent.time = PR_IntervalNow();
vm->DispatchEvent(&guiEvent, &status);
@ -4426,7 +4446,7 @@ nsGlobalWindow::Deactivate()
nsEventStatus status;
nsGUIEvent guiEvent(NS_DEACTIVATE, widget);
nsGUIEvent guiEvent(PR_TRUE, NS_DEACTIVATE, widget);
guiEvent.time = PR_IntervalNow();
vm->DispatchEvent(&guiEvent, &status);

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

@ -61,6 +61,7 @@
#include "nsIDOMViewCSS.h"
#include "nsIDOMEventReceiver.h"
#include "nsIDOM3EventTarget.h"
#include "nsIDOMNSEventTarget.h"
#include "nsIDOMNavigator.h"
#include "nsIDOMNSLocation.h"
#include "nsIDOMWindowInternal.h"
@ -121,6 +122,7 @@ class nsGlobalWindow : public nsIScriptGlobalObject,
public nsIScriptObjectPrincipal,
public nsIDOMEventReceiver,
public nsIDOM3EventTarget,
public nsIDOMNSEventTarget,
public nsIDOMViewCSS,
public nsSupportsWeakReference,
public nsIInterfaceRequestor
@ -174,6 +176,9 @@ public:
// nsIDOM3EventTarget
NS_DECL_NSIDOM3EVENTTARGET
// nsIDOMNSEventTarget
NS_DECL_NSIDOMNSEVENTTARGET
// nsIDOMEventReceiver
NS_IMETHOD AddEventListenerByIID(nsIDOMEventListener *aListener,
const nsIID& aIID);

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

@ -191,7 +191,7 @@ NS_ScriptErrorReporter(JSContext *cx,
docShell->GetPresContext(getter_AddRefs(presContext));
if (presContext && errorDepth < 2) {
nsScriptErrorEvent errorevent(NS_SCRIPT_ERROR);
nsScriptErrorEvent errorevent(PR_TRUE, NS_SCRIPT_ERROR);
errorevent.fileName = fileName.get();
errorevent.errorMsg = msg.get();

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

@ -71,7 +71,13 @@ nsWindowRoot::~nsWindowRoot()
{
}
NS_IMPL_ISUPPORTS5(nsWindowRoot, nsIDOMEventReceiver, nsIChromeEventHandler, nsPIWindowRoot, nsIDOMEventTarget, nsIDOM3EventTarget)
NS_IMPL_ISUPPORTS6(nsWindowRoot,
nsIDOMEventReceiver,
nsIChromeEventHandler,
nsPIWindowRoot,
nsIDOMEventTarget,
nsIDOM3EventTarget,
nsIDOMNSEventTarget)
NS_IMETHODIMP
nsWindowRoot::AddEventListener(const nsAString& aType, nsIDOMEventListener* aListener, PRBool aUseCapture)
@ -147,6 +153,24 @@ nsWindowRoot::IsRegisteredHere(const nsAString & type, PRBool *_retval)
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsWindowRoot::AddEventListener(const nsAString& aType,
nsIDOMEventListener *aListener,
PRBool aUseCapture, PRBool aWantsUntrusted)
{
nsCOMPtr<nsIEventListenerManager> manager;
nsresult rv = GetListenerManager(getter_AddRefs(manager));
NS_ENSURE_SUCCESS(rv, rv);
PRInt32 flags = aUseCapture ? NS_EVENT_FLAG_CAPTURE : NS_EVENT_FLAG_BUBBLE;
if (aWantsUntrusted) {
flags |= NS_PRIV_EVENT_UNTRUSTED_PERMITTED;
}
return manager->AddEventListenerByType(aListener, aType, flags, nsnull);
}
NS_IMETHODIMP
nsWindowRoot::AddEventListenerByIID(nsIDOMEventListener *aListener, const nsIID& aIID)
{

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

@ -48,13 +48,18 @@ class nsIDOMEvent;
#include "nsGUIEvent.h"
#include "nsIDOMEventReceiver.h"
#include "nsIDOM3EventTarget.h"
#include "nsIDOMNSEventTarget.h"
#include "nsIChromeEventHandler.h"
#include "nsIEventListenerManager.h"
#include "nsPIWindowRoot.h"
#include "nsIFocusController.h"
#include "nsIDOMEventTarget.h"
class nsWindowRoot : public nsIDOMEventReceiver, public nsIDOM3EventTarget, public nsIChromeEventHandler, public nsPIWindowRoot
class nsWindowRoot : public nsIDOMEventReceiver,
public nsIDOM3EventTarget,
public nsIDOMNSEventTarget,
public nsIChromeEventHandler,
public nsPIWindowRoot
{
public:
nsWindowRoot(nsIDOMWindow* aWindow);
@ -63,6 +68,7 @@ public:
NS_DECL_ISUPPORTS
NS_DECL_NSIDOMEVENTTARGET
NS_DECL_NSIDOM3EVENTTARGET
NS_DECL_NSIDOMNSEVENTTARGET
NS_IMETHOD HandleChromeEvent(nsPresContext* aPresContext,
nsEvent* aEvent, nsIDOMEvent** aDOMEvent,

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

@ -107,6 +107,10 @@ nsXFormsDispatchElement::HandleAction(nsIDOMEvent* aEvent,
nsCOMPtr<nsIDOMEvent> event;
docEvent->CreateEvent(NS_LITERAL_STRING("Events"), getter_AddRefs(event));
event->InitEvent(name, bubbles, cancelable);
// XXX: What about uiEvent->SetTrusted(?), should these events be
// trusted or not?
nsCOMPtr<nsIDOMEventTarget> targetEl = do_QueryInterface(el);
if (targetEl) {
PRBool defaultActionEnabled;

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

@ -276,6 +276,9 @@ nsXFormsTriggerElement::HandleDefault(nsIDOMEvent *aEvent, PRBool *aHandled)
aView,
1); // Simple click
// XXX: What about uiEvent->SetTrusted(?), should these events be
// trusted or not?
PRBool cancelled;
return target->DispatchEvent(uiEvent, &cancelled);
}

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

@ -720,6 +720,9 @@ nsXFormsUtils::DispatchEvent(nsIDOMNode* aTarget, nsXFormsEvent aEvent)
event->InitEvent(NS_ConvertUTF8toUTF16(data->name),
data->canBubble, data->canCancel);
// XXX: What about event->SetTrusted(?) here? Should all these
// events be trusted? Right now they're never trusted.
nsCOMPtr<nsIDOMEventTarget> target = do_QueryInterface(aTarget);
NS_ENSURE_STATE(target);

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

@ -777,6 +777,13 @@ nsXMLHttpRequest::CreateEvent(nsEvent* aEvent, nsIDOMEvent** aDOMEvent)
privevent->SetCurrentTarget(this);
privevent->SetOriginalTarget(this);
// We're not marking these events trusted as there is no way for us
// to tell if we're called through the code that normally calls us
// (i.e. necko) or if script on a webpage QI'd this object to say,
// nsIProgressEventSink and called onProgress(...).
//
// privevent->SetTrusted(?);
return NS_OK;
}
@ -1339,7 +1346,7 @@ nsXMLHttpRequest::RequestCompleted()
}
// We need to create the event before nulling out mDocument
nsEvent evt(NS_PAGE_LOAD);
nsEvent evt(PR_TRUE, NS_PAGE_LOAD);
nsCOMPtr<nsIDOMEvent> domevent;
rv = CreateEvent(&evt, getter_AddRefs(domevent));
@ -1711,7 +1718,7 @@ nsXMLHttpRequest::Error(nsIDOMEvent* aEvent)
// We need to create the event before nulling out mDocument
nsCOMPtr<nsIDOMEvent> event(do_QueryInterface(aEvent));
// There is no NS_PAGE_ERROR event but NS_SCRIPT_ERROR should be ok.
nsEvent evt(NS_SCRIPT_ERROR);
nsEvent evt(PR_TRUE, NS_SCRIPT_ERROR);
if (!event) {
CreateEvent(&evt, getter_AddRefs(event));
}
@ -1836,7 +1843,7 @@ nsXMLHttpRequest::OnProgress(nsIRequest *aRequest, nsISupports *aContext, PRUint
if (mOnProgressListener)
{
nsCOMPtr<nsIDOMEvent> event;
nsEvent evt(NS_EVENT_NULL ); // what name do we make up here?
nsEvent evt(PR_TRUE, NS_EVENT_NULL); // what name do we make up here?
nsresult rv = CreateEvent(&evt, getter_AddRefs(event));
NS_ENSURE_SUCCESS(rv, rv);

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

@ -981,7 +981,7 @@ DocumentViewerImpl::LoadComplete(nsresult aStatus)
// Now, fire either an OnLoad or OnError event to the document...
if(NS_SUCCEEDED(aStatus)) {
nsEventStatus status = nsEventStatus_eIgnore;
nsEvent event(NS_PAGE_LOAD);
nsEvent event(PR_TRUE, NS_PAGE_LOAD);
rv = global->HandleDOMEvent(mPresContext, &event, nsnull,
NS_EVENT_FLAG_INIT, &status);
@ -1060,7 +1060,7 @@ DocumentViewerImpl::PermitUnload(PRBool *aPermitUnload)
// Now, fire an BeforeUnload event to the document and see if it's ok
// to unload...
nsEventStatus status = nsEventStatus_eIgnore;
nsBeforePageUnloadEvent event(NS_BEFORE_PAGE_UNLOAD);
nsBeforePageUnloadEvent event(PR_TRUE, NS_BEFORE_PAGE_UNLOAD);
nsresult rv = NS_OK;
{
@ -1160,7 +1160,7 @@ DocumentViewerImpl::Unload()
// Now, fire an Unload event to the document...
nsEventStatus status = nsEventStatus_eIgnore;
nsEvent event(NS_PAGE_UNLOAD);
nsEvent event(PR_TRUE, NS_PAGE_UNLOAD);
// Never permit popups from the unload handler, no matter how we get
// here.

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

@ -3079,7 +3079,7 @@ PresShell::FireResizeEvent()
return;
//Send resize event from here.
nsEvent event(NS_RESIZE_EVENT);
nsEvent event(PR_TRUE, NS_RESIZE_EVENT);
nsEventStatus status = nsEventStatus_eIgnore;
nsCOMPtr<nsIScriptGlobalObject> globalObj = mDocument->GetScriptGlobalObject();

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

@ -590,7 +590,9 @@ nsComboboxControlFrame::ShowPopup(PRBool aShowPopup)
// fire a popup dom event
nsEventStatus status = nsEventStatus_eIgnore;
nsMouseEvent event(aShowPopup ? NS_XUL_POPUP_SHOWING : NS_XUL_POPUP_HIDING);
nsMouseEvent event(PR_TRUE, aShowPopup ?
NS_XUL_POPUP_SHOWING : NS_XUL_POPUP_HIDING, nsnull,
nsMouseEvent::eReal);
nsIPresShell *shell = mPresContext->GetPresShell();
if (shell)
@ -637,16 +639,6 @@ nsComboboxControlFrame::ShowList(nsPresContext* aPresContext, PRBool aShowList)
}
//-------------------------------------------------------------
// this is in response to the MouseClick from the containing browse button
// XXX: TODO still need to get filters from accept attribute
void
nsComboboxControlFrame::MouseClicked(nsPresContext* aPresContext)
{
//ToggleList(aPresContext);
}
nsresult
nsComboboxControlFrame::ReflowComboChildFrame(nsIFrame* aFrame,
nsPresContext* aPresContext,
@ -2490,6 +2482,10 @@ void nsComboboxControlFrame::FireValueChangeEvent()
if (manager &&
NS_SUCCEEDED(manager->CreateEvent(presContext, nsnull, NS_LITERAL_STRING("Events"), getter_AddRefs(event)))) {
event->InitEvent(NS_LITERAL_STRING("ValueChange"), PR_TRUE, PR_TRUE);
nsCOMPtr<nsIPrivateDOMEvent> privateEvent(do_QueryInterface(event));
privateEvent->SetTrusted(PR_TRUE);
PRBool defaultActionEnabled;
presContext->EventStateManager()->DispatchNewEvent(mContent, event,
&defaultActionEnabled);

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

@ -163,9 +163,6 @@ public:
nscoord aInnerWidth,
nscoord aCharWidth) const;
// nsIFormMouseListener
virtual void MouseClicked(nsPresContext* aPresContext);
//nsIComboboxControlFrame
NS_IMETHOD IsDroppedDown(PRBool * aDoDropDown) { *aDoDropDown = mDroppedDown; return NS_OK; }
NS_IMETHOD ShowDropDown(PRBool aDoDropDown);

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

@ -69,8 +69,6 @@ public:
return nsAreaFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow);
}
virtual void MouseClicked(nsPresContext* aPresContext) {}
NS_IMETHOD Paint(nsPresContext* aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,

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

@ -697,19 +697,12 @@ nsFormControlFrame::HandleEvent(nsPresContext* aPresContext,
// unfortunately native widgets don't seem to handle this right.
// so use the old code for native stuff. -EDV
switch (aEvent->message) {
case NS_MOUSE_LEFT_CLICK:
MouseClicked(aPresContext);
break;
case NS_KEY_DOWN:
if (NS_KEY_EVENT == aEvent->eventStructType) {
nsKeyEvent* keyEvent = (nsKeyEvent*)aEvent;
if (NS_VK_RETURN == keyEvent->keyCode) {
EnterPressed(aPresContext);
}
//else if (NS_VK_SPACE == keyEvent->keyCode) {
// MouseClicked(aPresContext);
//}
}
break;
}

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

@ -160,11 +160,6 @@ public:
*/
virtual void EnterPressed(nsPresContext* aPresContext) {}
/**
* Respond to a mouse click (e.g. mouse enter, mouse down, mouse up)
*/
virtual void MouseClicked(nsPresContext* aPresContext) {}
/**
* Respond to a control change (e.g. combo box close-up)
*/

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

@ -384,9 +384,6 @@ nsGfxButtonControlFrame::HandleEvent(nsPresContext* aPresContext,
// Override the HandleEvent to prevent the nsFrame::HandleEvent
// from being called. The nsFrame::HandleEvent causes the button label
// to be selected (Drawn with an XOR rectangle over the label)
// Do nothing here, nsHTMLInputElement::HandleDOMEvent
// takes cares of calling MouseClicked for us.
// do we have user-input style?
const nsStyleUserInterface* uiStyle = GetStyleUserInterface();

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

@ -244,14 +244,6 @@ nsHTMLButtonControlFrame::IsSubmit(PRInt32 type)
}
}
void
nsHTMLButtonControlFrame::MouseClicked(nsPresContext* aPresContext)
{
// This is no longer called; click events are handled in
// nsHTMLInputElement::HandleDOMEvent().
}
void
nsHTMLButtonControlFrame::SetFocus(PRBool aOn, PRBool aRepaint)
{

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

@ -128,7 +128,6 @@ public:
NS_IMETHOD_(PRInt32) GetFormControlType() const;
NS_IMETHOD GetName(nsAString* aName);
NS_IMETHOD GetValue(nsAString* aName);
virtual void MouseClicked(nsPresContext* aPresContext);
NS_IMETHOD OnContentReset();
void SetFocus(PRBool aOn, PRBool aRepaint);

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

@ -69,8 +69,6 @@ public:
virtual void ScrollIntoView(nsPresContext* aPresContext) = 0;
virtual void MouseClicked(nsPresContext* aPresContext) = 0;
/**
* Set the suggested size for the form element.
* This is used to control the size of the element during reflow if it hasn't had it's size

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

@ -98,8 +98,6 @@ public:
NS_IMETHOD GetCursor(const nsPoint& aPoint,
nsIFrame::Cursor& aCursor);
virtual void MouseClicked(nsPresContext* aPresContext);
NS_IMETHOD_(PRInt32) GetFormControlType() const;
NS_IMETHOD GetName(nsAString* aName);
@ -317,13 +315,6 @@ nsImageControlFrame::GetCursor(const nsPoint& aPoint,
return NS_OK;
}
void
nsImageControlFrame::MouseClicked(nsPresContext* aPresContext)
{
// This is no longer called; click events are handled in
// nsHTMLInputElement::HandleDOMEvent().
}
NS_IMETHODIMP
nsImageControlFrame::GetFormContent(nsIContent*& aContent) const
{

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

@ -1748,14 +1748,6 @@ nsListControlFrame::GetFormControlType() const
return NS_FORM_SELECT;
}
//---------------------------------------------------------
void
nsListControlFrame::MouseClicked(nsPresContext* aPresContext)
{
}
NS_IMETHODIMP
nsListControlFrame::OnContentReset()
{
@ -2153,7 +2145,7 @@ nsListControlFrame::FireOnChange()
// Dispatch the NS_FORM_CHANGE event
nsEventStatus status = nsEventStatus_eIgnore;
nsEvent event(NS_FORM_CHANGE);
nsEvent event(PR_TRUE, NS_FORM_CHANGE);
nsIPresShell *presShell = GetPresContext()->GetPresShell();
if (presShell) {
@ -2561,6 +2553,10 @@ nsListControlFrame::FireMenuItemActiveEvent()
if (manager &&
NS_SUCCEEDED(manager->CreateEvent(presContext, nsnull, NS_LITERAL_STRING("Events"), getter_AddRefs(event)))) {
event->InitEvent(NS_LITERAL_STRING("DOMMenuItemActive"), PR_TRUE, PR_TRUE);
nsCOMPtr<nsIPrivateDOMEvent> privateEvent(do_QueryInterface(event));
privateEvent->SetTrusted(PR_TRUE);
PRBool defaultActionEnabled;
presContext->EventStateManager()->DispatchNewEvent(optionContent, event,
&defaultActionEnabled);

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

@ -139,7 +139,6 @@ public:
virtual void SetFocus(PRBool aOn = PR_TRUE, PRBool aRepaint = PR_FALSE);
virtual void ScrollIntoView(nsPresContext* aPresContext);
virtual void MouseClicked(nsPresContext* aPresContext);
virtual nscoord GetVerticalInsidePadding(nsPresContext* aPresContext,
float aPixToTwip,
nscoord aInnerHeight) const;

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

@ -278,7 +278,7 @@ nsTextInputListener::NotifySelectionChanged(nsIDOMDocument* aDoc, nsISelection*
if (presShell)
{
nsEventStatus status = nsEventStatus_eIgnore;
nsEvent event(NS_FORM_SELECTED);
nsEvent event(PR_TRUE, NS_FORM_SELECTED);
presShell->HandleEventWithTarget(&event,mFrame,content,NS_EVENT_FLAG_INIT,&status);
}
@ -2275,8 +2275,6 @@ void nsTextControlFrame::ScrollIntoView(nsPresContext* aPresContext)
}
}
void nsTextControlFrame::MouseClicked(nsPresContext* aPresContext){}
nscoord
nsTextControlFrame::GetVerticalInsidePadding(nsPresContext* aPresContext,
float aPixToTwip,
@ -2943,7 +2941,7 @@ nsTextControlFrame::FireOnInput()
// Dispatch the "input" event
nsEventStatus status = nsEventStatus_eIgnore;
nsGUIEvent event(NS_FORM_INPUT);
nsGUIEvent event(PR_TRUE, NS_FORM_INPUT, nsnull);
// Have the content handle the event, propagating it according to normal
// DOM rules.
@ -2985,7 +2983,7 @@ nsTextControlFrame::FireOnChange()
if (NS_SUCCEEDED(GetFormContent(*getter_AddRefs(content))))
{
nsEventStatus status = nsEventStatus_eIgnore;
nsInputEvent event(NS_FORM_CHANGE);
nsInputEvent event(PR_TRUE, NS_FORM_CHANGE, nsnull);
// Have the content handle the event.
nsWeakPtr &shell = mTextSelImpl->GetPresShell();

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

@ -132,7 +132,6 @@ public:
NS_IMETHOD GetName(nsAString* aName);//*
virtual void SetFocus(PRBool aOn , PRBool aRepaint);
virtual void ScrollIntoView(nsPresContext* aPresContext);
virtual void MouseClicked(nsPresContext* aPresContext);
virtual nscoord GetVerticalInsidePadding(nsPresContext* aPresContext,
float aPixToTwip,
nscoord aInnerHeight) const;

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

@ -53,7 +53,7 @@ struct nsHTMLReflowState;
struct nsSize;
class nsIAtom;
class nsHTMLFramesetBorderFrame;
struct nsGUIEvent;
class nsGUIEvent;
class nsHTMLFramesetFrame;
#define NS_IFRAMESETFRAME_IID \

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

@ -1463,9 +1463,10 @@ nsGfxScrollFrameInner::ScrollToRestoredPosition()
void
nsGfxScrollFrameInner::PostScrollPortEvent(PRBool aOverflow, nsScrollPortEvent::orientType aType)
{
nsScrollPortEvent* event = new nsScrollPortEvent(aOverflow ?
nsScrollPortEvent* event = new nsScrollPortEvent(PR_TRUE, aOverflow ?
NS_SCROLLPORT_OVERFLOW :
NS_SCROLLPORT_UNDERFLOW);
NS_SCROLLPORT_UNDERFLOW,
nsnull);
event->orient = aType;
mOuter->GetPresContext()->PresShell()->PostDOMEvent(mOuter->GetContent(), event);
}
@ -1713,7 +1714,7 @@ void nsGfxScrollFrameInner::CurPosAttributeChanged(nsIContent* aContent, PRInt32
// Fire the onScroll event now that we have scrolled
nsIPresShell *presShell = mOuter->GetPresContext()->GetPresShell();
if (presShell) {
nsScrollbarEvent event(NS_SCROLL_EVENT);
nsScrollbarEvent event(PR_TRUE, NS_SCROLL_EVENT, nsnull);
nsEventStatus status = nsEventStatus_eIgnore;
// note if hcontent is non-null then hframe must be non-null.
// likewise for vcontent and vframe. Thus targetFrame will always

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

@ -600,6 +600,9 @@ FirePluginNotFoundEvent(nsIContent *aTarget)
rv = event->InitEvent(NS_LITERAL_STRING("PluginNotFound"), PR_TRUE,
PR_TRUE);
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsIPrivateDOMEvent> privateEvent(do_QueryInterface(event));
privateEvent->SetTrusted(PR_TRUE);
PRBool defaultActionEnabled;
target->DispatchEvent(event, &defaultActionEnabled);
}
@ -3504,7 +3507,9 @@ nsresult nsPluginInstanceOwner::DispatchFocusToPlugin(nsIDOMEvent* aFocusEvent)
nsEvent * theEvent;
privateEvent->GetInternalNSEvent(&theEvent);
if (theEvent) {
nsGUIEvent focusEvent(theEvent->message); // we only care about the message in ProcessEvent
// we only care about the message in ProcessEvent
nsGUIEvent focusEvent(NS_IS_TRUSTED_EVENT(theEvent), theEvent->message,
nsnull);
nsEventStatus rv = ProcessEvent(focusEvent);
if (nsEventStatus_eConsumeNoDefault == rv) {
aFocusEvent->PreventDefault();

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

@ -890,6 +890,7 @@ nsSelectionIterator::IsDone()
////////////BEGIN nsSelection methods
nsSelection::nsSelection()
: mDelayedMouseEvent(PR_FALSE, 0, nsnull, nsMouseEvent::eReal)
{
PRInt32 i;
for (i = 0;i<nsISelectionController::NUM_SELECTIONTYPES;i++){
@ -2564,7 +2565,7 @@ printf(" * TakeFocus - moving into new cell\n");
#endif
nsCOMPtr<nsIDOMNode> parent;
nsCOMPtr<nsIContent> parentContent;
nsMouseEvent event;
nsMouseEvent event(PR_FALSE, 0, nsnull, nsMouseEvent::eReal);
nsresult result;
// Start selecting in the cell we were in before

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

@ -100,6 +100,7 @@
#include "nsIEventListenerManager.h"
#include "nsIEventStateManager.h"
#include "nsIDOMEvent.h"
#include "nsIPrivateDOMEvent.h"
#include "nsContentUtils.h"
// Needed for Print Preview
@ -2573,6 +2574,10 @@ nsBoxFrame::FireDOMEvent(const nsAString& aDOMEventName, nsIContent *aContent)
NS_LITERAL_STRING("Events"),
getter_AddRefs(event)))) {
event->InitEvent(aDOMEventName, PR_TRUE, PR_TRUE);
nsCOMPtr<nsIPrivateDOMEvent> privateEvent(do_QueryInterface(event));
privateEvent->SetTrusted(PR_TRUE);
PRBool defaultActionEnabled;
mPresContext->EventStateManager()->
DispatchNewEvent(content, event, &defaultActionEnabled);

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

@ -150,7 +150,7 @@ nsButtonBoxFrame::HandleEvent(nsPresContext* aPresContext,
}
void
nsButtonBoxFrame::MouseClicked (nsPresContext* aPresContext, nsGUIEvent* aEvent)
nsButtonBoxFrame::MouseClicked(nsPresContext* aPresContext, nsGUIEvent* aEvent)
{
// Don't execute if we're disabled.
nsAutoString disabled;
@ -160,7 +160,8 @@ nsButtonBoxFrame::MouseClicked (nsPresContext* aPresContext, nsGUIEvent* aEvent)
// Execute the oncommand event handler.
nsEventStatus status = nsEventStatus_eIgnore;
nsMouseEvent event(NS_XUL_COMMAND);
nsMouseEvent event(aEvent ? NS_IS_TRUSTED_EVENT(aEvent) : PR_FALSE,
NS_XUL_COMMAND, nsnull, nsMouseEvent::eReal);
if(aEvent) {
event.isShift = ((nsInputEvent*)(aEvent))->isShift;
event.isControl = ((nsInputEvent*)(aEvent))->isControl;

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

@ -122,7 +122,7 @@ HandleImagePLEvent(nsIContent *aContent, PRUint32 aMessage, PRUint32 aFlags)
}
nsEventStatus status = nsEventStatus_eIgnore;
nsEvent event(aMessage);
nsEvent event(PR_TRUE, aMessage);
aContent->HandleDOMEvent(pres_context, &event, nsnull, aFlags, &status);
}

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

@ -1606,7 +1606,12 @@ nsMenuFrame::Execute(nsGUIEvent *aEvent)
nsEventStatus status = nsEventStatus_eIgnore;
nsMouseEvent event(NS_XUL_COMMAND);
// Create a trusted event if the triggering event was trusted, or if
// we're called from chrome code (since at least one of our caller
// passes in a null event).
nsMouseEvent event(aEvent ? NS_IS_TRUSTED_EVENT(aEvent) :
nsContentUtils::IsCallerChrome(), NS_XUL_COMMAND, nsnull,
nsMouseEvent::eReal);
if (aEvent && (aEvent->eventStructType == NS_MOUSE_EVENT ||
aEvent->eventStructType == NS_KEY_EVENT ||
aEvent->eventStructType == NS_ACCESSIBLE_EVENT)) {
@ -1651,8 +1656,9 @@ PRBool
nsMenuFrame::OnCreate()
{
nsEventStatus status = nsEventStatus_eIgnore;
nsMouseEvent event(NS_XUL_POPUP_SHOWING);
nsMouseEvent event(PR_TRUE, NS_XUL_POPUP_SHOWING, nsnull,
nsMouseEvent::eReal);
nsCOMPtr<nsIContent> child;
GetMenuChildrenElement(getter_AddRefs(child));
@ -1740,8 +1746,9 @@ PRBool
nsMenuFrame::OnCreated()
{
nsEventStatus status = nsEventStatus_eIgnore;
nsMouseEvent event(NS_XUL_POPUP_SHOWN);
nsMouseEvent event(PR_TRUE, NS_XUL_POPUP_SHOWN, nsnull,
nsMouseEvent::eReal);
nsCOMPtr<nsIContent> child;
GetMenuChildrenElement(getter_AddRefs(child));
@ -1766,8 +1773,9 @@ PRBool
nsMenuFrame::OnDestroy()
{
nsEventStatus status = nsEventStatus_eIgnore;
nsMouseEvent event(NS_XUL_POPUP_HIDING);
nsMouseEvent event(PR_TRUE, NS_XUL_POPUP_HIDING, nsnull,
nsMouseEvent::eReal);
nsCOMPtr<nsIContent> child;
GetMenuChildrenElement(getter_AddRefs(child));
@ -1792,8 +1800,9 @@ PRBool
nsMenuFrame::OnDestroyed()
{
nsEventStatus status = nsEventStatus_eIgnore;
nsMouseEvent event(NS_XUL_POPUP_HIDDEN);
nsMouseEvent event(PR_TRUE, NS_XUL_POPUP_HIDDEN, nsnull,
nsMouseEvent::eReal);
nsCOMPtr<nsIContent> child;
GetMenuChildrenElement(getter_AddRefs(child));

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

@ -583,7 +583,8 @@ PRBool
nsPopupSetFrame::OnCreate(PRInt32 aX, PRInt32 aY, nsIContent* aPopupContent)
{
nsEventStatus status = nsEventStatus_eIgnore;
nsMouseEvent event(NS_XUL_POPUP_SHOWING);
nsMouseEvent event(PR_TRUE, NS_XUL_POPUP_SHOWING, nsnull,
nsMouseEvent::eReal);
event.point.x = aX;
event.point.y = aY;
@ -660,7 +661,8 @@ PRBool
nsPopupSetFrame::OnCreated(PRInt32 aX, PRInt32 aY, nsIContent* aPopupContent)
{
nsEventStatus status = nsEventStatus_eIgnore;
nsMouseEvent event(NS_XUL_POPUP_SHOWN);
nsMouseEvent event(PR_TRUE, NS_XUL_POPUP_SHOWN, nsnull,
nsMouseEvent::eReal);
event.point.x = aX;
event.point.y = aY;
@ -682,8 +684,9 @@ PRBool
nsPopupSetFrame::OnDestroy(nsIContent* aPopupContent)
{
nsEventStatus status = nsEventStatus_eIgnore;
nsMouseEvent event(NS_XUL_POPUP_HIDING);
nsMouseEvent event(PR_TRUE, NS_XUL_POPUP_HIDING, nsnull,
nsMouseEvent::eReal);
if (aPopupContent) {
nsIPresShell *shell = mPresContext->GetPresShell();
if (shell) {
@ -701,7 +704,8 @@ PRBool
nsPopupSetFrame::OnDestroyed(nsIContent* aPopupContent)
{
nsEventStatus status = nsEventStatus_eIgnore;
nsMouseEvent event(NS_XUL_POPUP_HIDDEN);
nsMouseEvent event(PR_TRUE, NS_XUL_POPUP_HIDDEN, nsnull,
nsMouseEvent::eReal);
if (aPopupContent) {
nsIPresShell *shell = mPresContext->GetPresShell();

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

@ -245,7 +245,7 @@ nsResizerFrame::HandleEvent(nsPresContext* aPresContext,
case NS_MOUSE_LEFT_CLICK:
MouseClicked(aPresContext);
MouseClicked(aPresContext, aEvent);
break;
}
@ -349,10 +349,14 @@ nsResizerFrame::AttributeChanged(nsIContent* aChild,
void
nsResizerFrame::MouseClicked (nsPresContext* aPresContext)
nsResizerFrame::MouseClicked(nsPresContext* aPresContext, nsGUIEvent *aEvent)
{
// Execute the oncommand event handler.
nsEventStatus status = nsEventStatus_eIgnore;
nsMouseEvent event(NS_XUL_COMMAND);
mContent->HandleDOMEvent(aPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status);
nsMouseEvent event(aEvent ? NS_IS_TRUSTED_EVENT(aEvent) : PR_FALSE,
NS_XUL_COMMAND, nsnull, nsMouseEvent::eReal);
mContent->HandleDOMEvent(aPresContext, &event, nsnull, NS_EVENT_FLAG_INIT,
&status);
}

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

@ -77,7 +77,7 @@ public:
nsIAtom* aAttribute,
PRInt32 aModType);
virtual void MouseClicked (nsPresContext* aPresContext);
virtual void MouseClicked(nsPresContext* aPresContext, nsGUIEvent *aEvent);
protected:
PRBool GetInitialDirection(eDirection& aDirection);

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

@ -99,8 +99,8 @@ nsScrollbarButtonFrame::QueryInterface(REFNSIID aIID, void** aInstancePtr)
NS_IMETHODIMP
nsScrollbarButtonFrame::HandleEvent(nsPresContext* aPresContext,
nsGUIEvent* aEvent,
nsEventStatus* aEventStatus)
nsGUIEvent* aEvent,
nsEventStatus* aEventStatus)
{
// XXX hack until handle release is actually called in nsframe.
if (aEvent->message == NS_MOUSE_EXIT_SYNTH|| aEvent->message == NS_MOUSE_RIGHT_BUTTON_UP || aEvent->message == NS_MOUSE_LEFT_BUTTON_UP)
@ -112,8 +112,8 @@ nsScrollbarButtonFrame::HandleEvent(nsPresContext* aPresContext,
NS_IMETHODIMP
nsScrollbarButtonFrame::HandlePress(nsPresContext* aPresContext,
nsGUIEvent* aEvent,
nsEventStatus* aEventStatus)
nsGUIEvent* aEvent,
nsEventStatus* aEventStatus)
{
MouseClicked();
nsRepeatService::GetInstance()->Start(this);
@ -122,8 +122,8 @@ nsScrollbarButtonFrame::HandlePress(nsPresContext* aPresContext,
NS_IMETHODIMP
nsScrollbarButtonFrame::HandleRelease(nsPresContext* aPresContext,
nsGUIEvent* aEvent,
nsEventStatus* aEventStatus)
nsGUIEvent* aEvent,
nsEventStatus* aEventStatus)
{
nsRepeatService::GetInstance()->Stop();
return NS_OK;

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

@ -189,7 +189,7 @@ nsTitleBarFrame::HandleEvent(nsPresContext* aPresContext,
case NS_MOUSE_LEFT_CLICK:
MouseClicked(aPresContext);
MouseClicked(aPresContext, aEvent);
break;
}
@ -229,10 +229,14 @@ nsTitleBarFrame::CaptureMouseEvents(nsPresContext* aPresContext,PRBool aGrabMous
void
nsTitleBarFrame::MouseClicked (nsPresContext* aPresContext)
nsTitleBarFrame::MouseClicked(nsPresContext* aPresContext, nsGUIEvent* aEvent)
{
// Execute the oncommand event handler.
nsEventStatus status = nsEventStatus_eIgnore;
nsMouseEvent event(NS_XUL_COMMAND);
mContent->HandleDOMEvent(aPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status);
nsMouseEvent event(aEvent ? NS_IS_TRUSTED_EVENT(aEvent) : PR_FALSE,
NS_XUL_COMMAND, nsnull, nsMouseEvent::eReal);
mContent->HandleDOMEvent(aPresContext, &event, nsnull, NS_EVENT_FLAG_INIT,
&status);
}

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

@ -64,7 +64,7 @@ public:
NS_IMETHOD GetMouseThrough(PRBool& aMouseThrough);
virtual void MouseClicked (nsPresContext* aPresContext);
virtual void MouseClicked(nsPresContext* aPresContext, nsGUIEvent* aEvent);
protected:

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

@ -775,8 +775,8 @@ nsTreeBodyFrame::CheckVerticalOverflow()
}
if (verticalOverflowChanged) {
nsScrollPortEvent event(mVerticalOverflow ? NS_SCROLLPORT_OVERFLOW
: NS_SCROLLPORT_UNDERFLOW);
nsScrollPortEvent event(PR_TRUE, mVerticalOverflow ? NS_SCROLLPORT_OVERFLOW
: NS_SCROLLPORT_UNDERFLOW, nsnull);
event.orient = nsScrollPortEvent::vertical;
nsEventStatus status = nsEventStatus_eIgnore;

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

@ -753,7 +753,7 @@ nsTreeSelection::FireOnSelectHandler()
nsCOMPtr<nsPresContext> aPresContext = shell->GetPresContext();
nsEventStatus status = nsEventStatus_eIgnore;
nsEvent event(NS_FORM_SELECTED);
nsEvent event(PR_TRUE, NS_FORM_SELECTED);
content->HandleDOMEvent(aPresContext, &event, nsnull, NS_EVENT_FLAG_INIT,
&status);

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

@ -53,6 +53,7 @@
#include "nsIContentViewer.h"
#include "nsIDOMEventTarget.h"
#include "nsIDOMKeyEvent.h"
#include "nsIPrivateDOMEvent.h"
#include "nsIDOMCompositionListener.h"
#include "nsIDOMDocument.h"
#include "nsIDOMElement.h"
@ -453,6 +454,15 @@ nsFormFillController::OnTextEntered(PRBool *_retval)
}
event->InitEvent(NS_LITERAL_STRING("DOMAutoComplete"), PR_TRUE, PR_TRUE);
nsCOMPtr<nsIPrivateDOMEvent> privateEvent(do_QueryInterface(event));
if (privateEvent) {
// XXXjst: We mark this event as a trusted event, it's up to the
// callers of this to ensure that it's only called from trusted
// code.
privateEvent->SetTrusted(PR_TRUE);
}
nsCOMPtr<nsIDOMEventTarget> targ = do_QueryInterface(mFocusedInput);
PRBool defaultActionEnabled;

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

@ -43,7 +43,7 @@
class nsIRenderingContext;
struct nsRect;
struct nsGUIEvent;
class nsGUIEvent;
#define NS_IVIEWOBSERVER_IID \
{ 0x0f4bc34a, 0xc93b, 0x4699, \

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

@ -1915,11 +1915,6 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsEventStatus *aS
{
*aStatus = nsEventStatus_eIgnore;
// Mark all events coming through here as trusted events, as the
// only code that calls this is the widget code that translates OS
// events into mozilla events.
aEvent->internalAppFlags |= NS_APP_EVENT_FLAG_TRUSTED;
switch(aEvent->message)
{
case NS_SIZE:
@ -4424,7 +4419,7 @@ nsViewManager::ProcessSynthMouseMoveEvent(PRBool aFromScroll)
this, mMouseLocation.x, mMouseLocation.y);
#endif
nsMouseEvent event(NS_MOUSE_MOVE, mRootView->GetWidget(),
nsMouseEvent event(PR_TRUE, NS_MOUSE_MOVE, mRootView->GetWidget(),
nsMouseEvent::eSynthesized);
event.point = mMouseLocation;
event.time = PR_IntervalNow();

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

@ -44,7 +44,7 @@ class nsIDocShell;
class nsIRequest;
class nsIContent;
class nsString;
struct nsGUIEvent;
class nsGUIEvent;
// Interface ID for nsILinkHandler
#define NS_ILINKHANDLER_IID \

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

@ -57,25 +57,25 @@ enum nsEventStatus {
nsEventStatus_eConsumeDoDefault
};
struct nsEvent;
class nsEvent;
struct nsGUIEvent;
struct nsSizeEvent;
struct nsSizeModeEvent;
struct nsZLevelEvent;
struct nsPaintEvent;
struct nsScrollbarEvent;
struct nsScrollPortEvent;
struct nsInputEvent;
struct nsMouseEvent;
struct nsAccessibleEvent;
struct nsKeyEvent;
struct nsTextEvent;
struct nsCompositionEvent;
struct nsMouseScrollEvent;
struct nsReconversionEvent;
struct nsTooltipEvent;
struct nsMenuEvent;
class nsGUIEvent;
class nsSizeEvent;
class nsSizeModeEvent;
class nsZLevelEvent;
class nsPaintEvent;
class nsScrollbarEvent;
class nsScrollPortEvent;
class nsInputEvent;
class nsMouseEvent;
class nsAccessibleEvent;
class nsKeyEvent;
class nsTextEvent;
class nsCompositionEvent;
class nsMouseScrollEvent;
class nsReconversionEvent;
class nsTooltipEvent;
class nsMenuEvent;
struct nsTextEventReply;
struct nsReconversionEventReply;

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

@ -105,6 +105,7 @@ class nsIURI;
#define NS_EVENT_FLAG_NO_CONTENT_DISPATCH 0x0100
#define NS_EVENT_FLAG_SYSTEM_EVENT 0x0200
#define NS_EVENT_FLAG_STOP_DISPATCH_IMMEDIATELY 0x0400 // @see nsIDOM3Event::stopImmediatePropagation()
#define NS_PRIV_EVENT_UNTRUSTED_PERMITTED 0x0800
#define NS_EVENT_CAPTURE_MASK (~(NS_EVENT_FLAG_INIT | NS_EVENT_FLAG_BUBBLE | NS_EVENT_FLAG_NO_CONTENT_DISPATCH))
#define NS_EVENT_BUBBLE_MASK (~(NS_EVENT_FLAG_INIT | NS_EVENT_FLAG_CAPTURE | NS_EVENT_FLAG_NO_CONTENT_DISPATCH))
@ -349,34 +350,54 @@ enum nsWindowZ {
* General event
*/
struct nsEvent {
nsEvent(PRUint32 msg = 0, PRUint8 structType = NS_EVENT)
class nsEvent
{
protected:
nsEvent(PRBool isTrusted, PRUint32 msg, PRUint8 structType)
: eventStructType(structType),
message(msg),
point(0, 0),
refPoint(0, 0),
time(0),
flags(0),
internalAppFlags(NS_APP_EVENT_FLAG_NONE),
internalAppFlags(isTrusted ? NS_APP_EVENT_FLAG_TRUSTED :
NS_APP_EVENT_FLAG_NONE),
userType(0)
{
}
/// See event struct types
public:
nsEvent(PRBool isTrusted, PRUint32 msg)
: eventStructType(NS_EVENT),
message(msg),
point(0, 0),
refPoint(0, 0),
time(0),
flags(0),
internalAppFlags(isTrusted ? NS_APP_EVENT_FLAG_TRUSTED :
NS_APP_EVENT_FLAG_NONE),
userType(0)
{
}
// See event struct types
PRUint8 eventStructType;
/// See GUI MESSAGES,
// See GUI MESSAGES,
PRUint32 message;
/// in widget relative coordinates, modified to be relative to current view in layout.
// In widget relative coordinates, modified to be relative to
// current view in layout.
nsPoint point;
// in widget relative coordinates, not modified by layout code.
// In widget relative coordinates, not modified by layout code.
nsPoint refPoint;
/// elapsed time, in milliseconds, from the time the system was started to the time the message was created
// Elapsed time, in milliseconds, from the time the system was
// started to the time the message was created
PRUint32 time;
// flags to hold event flow stage and capture/bubble cancellation status
// Flags to hold event flow stage and capture/bubble cancellation
// status
PRUint32 flags;
// flags for indicating more event state for Mozilla applications.
// Flags for indicating more event state for Mozilla applications.
PRUint32 internalAppFlags;
// additional type info for user defined events
// Additional type info for user defined events
nsHashKey* userType;
};
@ -384,12 +405,18 @@ struct nsEvent {
* General graphic user interface event
*/
struct nsGUIEvent : public nsEvent
class nsGUIEvent : public nsEvent
{
nsGUIEvent(PRUint32 msg = 0,
nsIWidget *w = nsnull,
PRUint8 structType = NS_GUI_EVENT)
: nsEvent(msg, structType),
protected:
nsGUIEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w, PRUint8 structType)
: nsEvent(isTrusted, msg, structType),
widget(w), nativeMsg(nsnull)
{
}
public:
nsGUIEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
: nsEvent(isTrusted, msg, NS_GUI_EVENT),
widget(w), nativeMsg(nsnull)
{
}
@ -404,11 +431,11 @@ struct nsGUIEvent : public nsEvent
* Script error event
*/
struct nsScriptErrorEvent : public nsEvent
class nsScriptErrorEvent : public nsEvent
{
nsScriptErrorEvent(PRUint32 msg = 0,
PRUint8 structType = NS_SCRIPT_ERROR_EVENT)
: nsEvent(msg, structType),
public:
nsScriptErrorEvent(PRBool isTrusted, PRUint32 msg)
: nsEvent(isTrusted, msg, NS_SCRIPT_ERROR_EVENT),
lineNr(0), errorMsg(nsnull), fileName(nsnull)
{
}
@ -418,10 +445,11 @@ struct nsScriptErrorEvent : public nsEvent
const PRUnichar* fileName;
};
struct nsBeforePageUnloadEvent : public nsEvent
class nsBeforePageUnloadEvent : public nsEvent
{
nsBeforePageUnloadEvent(PRUint32 msg)
: nsEvent(msg, NS_BEFORE_PAGE_UNLOAD_EVENT)
public:
nsBeforePageUnloadEvent(PRBool isTrusted, PRUint32 msg)
: nsEvent(isTrusted, msg, NS_BEFORE_PAGE_UNLOAD_EVENT)
{
}
@ -432,12 +460,11 @@ struct nsBeforePageUnloadEvent : public nsEvent
* Window resize event
*/
struct nsSizeEvent : public nsGUIEvent
class nsSizeEvent : public nsGUIEvent
{
nsSizeEvent(PRUint32 msg = 0,
nsIWidget *w = nsnull,
PRUint8 structType = NS_SIZE_EVENT)
: nsGUIEvent(msg, w, structType),
public:
nsSizeEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
: nsGUIEvent(isTrusted, msg, w, NS_SIZE_EVENT),
windowSize(nsnull), mWinWidth(0), mWinHeight(0)
{
}
@ -454,12 +481,11 @@ struct nsSizeEvent : public nsGUIEvent
* Window size mode event
*/
struct nsSizeModeEvent : public nsGUIEvent
class nsSizeModeEvent : public nsGUIEvent
{
nsSizeModeEvent(PRUint32 msg = 0,
nsIWidget *w = nsnull,
PRUint8 structType = NS_SIZEMODE_EVENT)
: nsGUIEvent(msg, w, structType),
public:
nsSizeModeEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
: nsGUIEvent(isTrusted, msg, w, NS_SIZEMODE_EVENT),
mSizeMode(nsSizeMode_Normal)
{
}
@ -471,12 +497,11 @@ struct nsSizeModeEvent : public nsGUIEvent
* Window z-level event
*/
struct nsZLevelEvent : public nsGUIEvent
class nsZLevelEvent : public nsGUIEvent
{
nsZLevelEvent(PRUint32 msg = 0,
nsIWidget *w = nsnull,
PRUint8 structType = NS_ZLEVEL_EVENT)
: nsGUIEvent(msg, w, structType),
public:
nsZLevelEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
: nsGUIEvent(isTrusted, msg, w, NS_ZLEVEL_EVENT),
mPlacement(nsWindowZTop), mReqBelow(nsnull), mActualBelow(nsnull),
mImmediate(PR_FALSE), mAdjusted(PR_FALSE)
{
@ -493,12 +518,11 @@ struct nsZLevelEvent : public nsGUIEvent
* Window repaint event
*/
struct nsPaintEvent : public nsGUIEvent
class nsPaintEvent : public nsGUIEvent
{
nsPaintEvent(PRUint32 msg = 0,
nsIWidget *w = nsnull,
PRUint8 structType = NS_PAINT_EVENT)
: nsGUIEvent(msg, w, structType),
public:
nsPaintEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
: nsGUIEvent(isTrusted, msg, w, NS_PAINT_EVENT),
renderingContext(nsnull), region(nsnull), rect(nsnull)
{
}
@ -515,12 +539,11 @@ struct nsPaintEvent : public nsGUIEvent
* Scrollbar event
*/
struct nsScrollbarEvent : public nsGUIEvent
class nsScrollbarEvent : public nsGUIEvent
{
nsScrollbarEvent(PRUint32 msg = 0,
nsIWidget *w = nsnull,
PRUint8 structType = NS_SCROLLBAR_EVENT)
: nsGUIEvent(msg, w, structType),
public:
nsScrollbarEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
: nsGUIEvent(isTrusted, msg, w, NS_SCROLLBAR_EVENT),
position(0)
{
}
@ -529,18 +552,17 @@ struct nsScrollbarEvent : public nsGUIEvent
PRUint32 position;
};
struct nsScrollPortEvent : public nsGUIEvent
class nsScrollPortEvent : public nsGUIEvent
{
public:
enum orientType {
vertical = 0,
horizontal = 1,
both = 2
};
nsScrollPortEvent(PRUint32 msg = 0,
nsIWidget *w = nsnull,
PRUint8 structType = NS_SCROLLPORT_EVENT)
: nsGUIEvent(msg, w, structType),
nsScrollPortEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
: nsGUIEvent(isTrusted, msg, w, NS_SCROLLPORT_EVENT),
orient(vertical)
{
}
@ -548,12 +570,19 @@ struct nsScrollPortEvent : public nsGUIEvent
orientType orient;
};
struct nsInputEvent : public nsGUIEvent
class nsInputEvent : public nsGUIEvent
{
nsInputEvent(PRUint32 msg = 0,
nsIWidget *w = nsnull,
PRUint8 structType = NS_INPUT_EVENT)
: nsGUIEvent(msg, w, structType),
protected:
nsInputEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w,
PRUint8 structType)
: nsGUIEvent(isTrusted, msg, w, structType),
isShift(PR_FALSE), isControl(PR_FALSE), isAlt(PR_FALSE), isMeta(PR_FALSE)
{
}
public:
nsInputEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
: nsGUIEvent(isTrusted, msg, w, NS_INPUT_EVENT),
isShift(PR_FALSE), isControl(PR_FALSE), isAlt(PR_FALSE), isMeta(PR_FALSE)
{
}
@ -572,15 +601,14 @@ struct nsInputEvent : public nsGUIEvent
* Mouse event
*/
struct nsMouseEvent : public nsInputEvent
class nsMouseEvent : public nsInputEvent
{
public:
enum reasonType { eReal, eSynthesized };
nsMouseEvent(PRUint32 msg = 0,
nsIWidget *w = nsnull,
reasonType aReason = eReal,
PRUint8 structType = NS_MOUSE_EVENT)
: nsInputEvent(msg, w, structType),
nsMouseEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w,
reasonType aReason)
: nsInputEvent(isTrusted, msg, w, NS_MOUSE_EVENT),
clickCount(0), acceptActivation(PR_FALSE), reason(aReason)
{
if (msg == NS_MOUSE_MOVE) {
@ -600,29 +628,27 @@ struct nsMouseEvent : public nsInputEvent
* Accessible event
*/
struct nsAccessibleEvent : public nsInputEvent
class nsAccessibleEvent : public nsInputEvent
{
nsAccessibleEvent(PRUint32 msg = 0,
nsIWidget *w = nsnull,
PRUint8 structType = NS_ACCESSIBLE_EVENT)
: nsInputEvent(msg, w, structType),
public:
nsAccessibleEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
: nsInputEvent(isTrusted, msg, w, NS_ACCESSIBLE_EVENT),
accessible(nsnull)
{
}
nsIAccessible* accessible;
nsIAccessible* accessible;
};
/**
* Keyboard event
*/
struct nsKeyEvent : public nsInputEvent
class nsKeyEvent : public nsInputEvent
{
nsKeyEvent(PRUint32 msg = 0,
nsIWidget *w = nsnull,
PRUint8 structType = NS_KEY_EVENT)
: nsInputEvent(msg, w, structType),
public:
nsKeyEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
: nsInputEvent(isTrusted, msg, w, NS_KEY_EVENT),
keyCode(0), charCode(0), isChar(0)
{
}
@ -638,7 +664,8 @@ struct nsKeyEvent : public nsInputEvent
/**
* IME Related Events
*/
struct nsTextRange {
struct nsTextRange
{
nsTextRange()
: mStartOffset(0), mEndOffset(0), mRangeType(0)
{
@ -651,7 +678,8 @@ struct nsTextRange {
typedef nsTextRange* nsTextRangeArray;
struct nsTextEventReply {
struct nsTextEventReply
{
nsTextEventReply()
: mCursorIsCollapsed(PR_FALSE)
{
@ -663,12 +691,11 @@ struct nsTextEventReply {
typedef struct nsTextEventReply nsTextEventReply;
struct nsTextEvent : public nsInputEvent
class nsTextEvent : public nsInputEvent
{
nsTextEvent(PRUint32 msg = 0,
nsIWidget *w = nsnull,
PRUint8 structType = NS_TEXT_EVENT)
: nsInputEvent(msg, w, structType),
public:
nsTextEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
: nsInputEvent(isTrusted, msg, w, NS_TEXT_EVENT),
theText(nsnull), rangeCount(0), rangeArray(nsnull), isChar(PR_FALSE)
{
}
@ -680,30 +707,28 @@ struct nsTextEvent : public nsInputEvent
PRBool isChar;
};
struct nsCompositionEvent : public nsInputEvent
class nsCompositionEvent : public nsInputEvent
{
nsCompositionEvent(PRUint32 msg = 0,
nsIWidget *w = nsnull,
PRUint8 structType = NS_COMPOSITION_EVENT)
: nsInputEvent(msg, w, structType)
public:
nsCompositionEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
: nsInputEvent(isTrusted, msg, w, NS_COMPOSITION_EVENT)
{
}
nsTextEventReply theReply;
};
struct nsMouseScrollEvent : public nsInputEvent
class nsMouseScrollEvent : public nsInputEvent
{
public:
enum nsMouseScrollFlags {
kIsFullPage = 1 << 0,
kIsVertical = 1 << 1,
kIsHorizontal = 1 << 2
};
nsMouseScrollEvent(PRUint32 msg = 0,
nsIWidget *w = nsnull,
PRUint8 structType = NS_MOUSE_SCROLL_EVENT)
: nsInputEvent(msg, w, structType),
nsMouseScrollEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
: nsInputEvent(isTrusted, msg, w, NS_MOUSE_SCROLL_EVENT),
scrollFlags(0), delta(0)
{
}
@ -721,19 +746,19 @@ struct nsReconversionEventReply {
PRUnichar *mReconversionString;
};
struct nsReconversionEvent : public nsInputEvent
class nsReconversionEvent : public nsInputEvent
{
nsReconversionEvent(PRUint32 msg = 0,
nsIWidget *w = nsnull,
PRUint8 structType = NS_RECONVERSION_EVENT)
: nsInputEvent(msg, w, structType)
public:
nsReconversionEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
: nsInputEvent(isTrusted, msg, w, NS_RECONVERSION_EVENT)
{
}
nsReconversionEventReply theReply;
};
struct nsQueryCaretRectEventReply {
struct nsQueryCaretRectEventReply
{
nsQueryCaretRectEventReply()
: mRectIsValid(PR_FALSE)
{
@ -743,12 +768,11 @@ struct nsQueryCaretRectEventReply {
nsRect mCaretRect;
};
struct nsQueryCaretRectEvent : public nsInputEvent
class nsQueryCaretRectEvent : public nsInputEvent
{
nsQueryCaretRectEvent(PRUint32 msg = 0,
nsIWidget *w = nsnull,
PRUint8 structType = NS_QUERYCARETRECT_EVENT)
: nsInputEvent(msg, w, structType)
public:
nsQueryCaretRectEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
: nsInputEvent(isTrusted, msg, w, NS_QUERYCARETRECT_EVENT)
{
}
@ -762,12 +786,11 @@ struct nsQueryCaretRectEvent : public nsInputEvent
* for the event
*/
struct nsMenuEvent : public nsGUIEvent
class nsMenuEvent : public nsGUIEvent
{
nsMenuEvent(PRUint32 msg = 0,
nsIWidget *w = nsnull,
PRUint8 structType = NS_MENU_EVENT)
: nsGUIEvent(msg, w, structType),
public:
nsMenuEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
: nsGUIEvent(isTrusted, msg, w, NS_MENU_EVENT),
mMenuItem(nsnull), mCommand(0)
{
}
@ -783,10 +806,11 @@ struct nsMenuEvent : public nsGUIEvent
* originator is a weak pointer (does not hold a strong reference).
*/
struct nsFormEvent : public nsEvent
class nsFormEvent : public nsEvent
{
nsFormEvent(PRUint32 msg = 0, PRUint8 structType = NS_FORM_EVENT)
: nsEvent(msg, structType),
public:
nsFormEvent(PRBool isTrusted, PRUint32 msg)
: nsEvent(isTrusted, msg, NS_FORM_EVENT),
originator(nsnull)
{
}
@ -797,12 +821,11 @@ struct nsFormEvent : public nsEvent
/**
* Focus event
*/
struct nsFocusEvent : public nsGUIEvent
class nsFocusEvent : public nsGUIEvent
{
nsFocusEvent(PRUint32 msg = 0,
nsIWidget *w = nsnull,
PRUint8 structType = NS_FOCUS_EVENT)
: nsGUIEvent(msg, w, structType),
public:
nsFocusEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
: nsGUIEvent(isTrusted, msg, w, NS_FOCUS_EVENT),
isMozWindowTakingFocus(PR_FALSE)
{
}
@ -816,12 +839,11 @@ struct nsFocusEvent : public nsGUIEvent
* Custom commands from the operating system. eg. WM_APPCOMMAND on Windows
*/
struct nsAppCommandEvent : public nsInputEvent
class nsAppCommandEvent : public nsInputEvent
{
nsAppCommandEvent(PRUint32 msg = 0,
nsIWidget *w = nsnull,
PRUint8 structType = NS_APPCOMMAND_EVENT)
: nsInputEvent(msg, w, structType),
public:
nsAppCommandEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
: nsInputEvent(isTrusted, msg, w, NS_APPCOMMAND_EVENT),
appCommand(0)
{
}
@ -832,11 +854,11 @@ struct nsAppCommandEvent : public nsInputEvent
/**
* blocked popup window event
*/
struct nsPopupBlockedEvent : public nsEvent
class nsPopupBlockedEvent : public nsEvent
{
nsPopupBlockedEvent(PRUint32 msg = 0,
PRUint8 structType = NS_POPUPBLOCKED_EVENT)
: nsEvent(msg, structType),
public:
nsPopupBlockedEvent(PRBool isTrusted, PRUint32 msg)
: nsEvent(isTrusted, msg, NS_POPUPBLOCKED_EVENT),
mRequestingWindowURI(nsnull), mPopupWindowURI(nsnull)
{
}
@ -849,11 +871,11 @@ struct nsPopupBlockedEvent : public nsEvent
/**
* DOM UIEvent
*/
struct nsUIEvent : public nsEvent {
nsUIEvent(PRUint32 msg = 0,
PRInt32 d = 0,
PRUint8 structType = NS_UI_EVENT)
: nsEvent(msg, structType),
class nsUIEvent : public nsEvent
{
public:
nsUIEvent(PRBool isTrusted, PRUint32 msg, PRInt32 d)
: nsEvent(isTrusted, msg, NS_UI_EVENT),
detail(d)
{
}
@ -924,6 +946,11 @@ enum nsDragDropEventStatus {
((evnt)->message == NS_DEACTIVATE) || \
((evnt)->message == NS_PLUGIN_ACTIVATE))
#define NS_IS_TRUSTED_EVENT(event) \
(((event)->internalAppFlags & NS_APP_EVENT_FLAG_TRUSTED) != 0)
/*
* Virtual key bindings for keyboard events.
* These come from nsIDOMKeyEvent.h, which is generated from MouseKeyEvent.idl.

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

@ -40,7 +40,7 @@
#include "nsISupports.h"
struct nsGUIEvent;
class nsGUIEvent;
/**
* Event listener interface.

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

@ -62,7 +62,7 @@ struct nsFont;
class nsIMenuBar;
class nsIEventListener;
class nsIRollupListener;
struct nsGUIEvent;
class nsGUIEvent;
struct nsColorMap;
class imgIContainer;

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

@ -305,7 +305,7 @@ PRBool nsWindow::DispatchWindowEvent(nsGUIEvent* event)
PRBool nsWindow::DispatchStandardEvent(PRUint32 aMsg)
{
nsGUIEvent event(aMsg, this);
nsGUIEvent event(PR_TRUE, aMsg, this);
InitEvent(event);
PRBool result = DispatchWindowEvent(&event);
@ -1797,7 +1797,7 @@ bool nsWindow::CallMethod(MethodInfo *info)
return false;
NS_ASSERTION(info->nArgs == 1, "Wrong number of arguments to CallMethod");
nsMouseScrollEvent scrollEvent(NS_MOUSE_SCROLL, this);
nsMouseScrollEvent scrollEvent(PR_TRUE, NS_MOUSE_SCROLL, this);
scrollEvent.scrollFlags = nsMouseScrollEvent::kIsVertical;
@ -2264,7 +2264,7 @@ PRBool nsWindow::OnKeyUp(PRUint32 aEventType, const char *bytes,
PRBool nsWindow::DispatchKeyEvent(PRUint32 aEventType, PRUint32 aCharCode,
PRUint32 aKeyCode, PRUint32 aFlags)
{
nsKeyEvent event(aEventType, this);
nsKeyEvent event(PR_TRUE, aEventType, this);
nsPoint point;
point.x = 0;
@ -2341,7 +2341,7 @@ void nsWindow::OnDestroy()
//-------------------------------------------------------------------------
PRBool nsWindow::OnMove(PRInt32 aX, PRInt32 aY)
{
nsGUIEvent event(NS_MOVE, this);
nsGUIEvent event(PR_TRUE, NS_MOVE, this);
InitEvent(event);
event.point.x = aX;
event.point.y = aY;
@ -2370,7 +2370,7 @@ PRBool nsWindow::OnPaint(nsRect &r)
mView->ConstrainClippingRegion(&invalid);
mView->Flush();
mView->UnlockLooper();
nsPaintEvent event(NS_PAINT, this);
nsPaintEvent event(PR_TRUE, NS_PAINT, this);
InitEvent(event);
event.region = nsnull;
@ -2408,7 +2408,7 @@ PRBool nsWindow::OnResize(nsRect &aWindowRect)
// call the event callback
if (mEventCallback)
{
nsSizeEvent event(NS_SIZE, this);
nsSizeEvent event(PR_TRUE, NS_SIZE, this);
InitEvent(event);
event.windowSize = &aWindowRect;
if(mView && mView->LockLooper())
@ -2441,7 +2441,7 @@ PRBool nsWindow::DispatchMouseEvent(PRUint32 aEventType, nsPoint aPoint, PRUint3
PRBool result = PR_FALSE;
if(nsnull != mEventCallback || nsnull != mMouseListener)
{
nsMouseEvent event(aEventType, this);
nsMouseEvent event(PR_TRUE, aEventType, this, nsMouseEvent::eReal);
InitEvent (event, &aPoint);
event.isShift = mod & B_SHIFT_KEY;
event.isControl = mod & B_CONTROL_KEY;

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

@ -1500,7 +1500,7 @@ nsChildView::UpdateWidget(nsRect& aRect, nsIRenderingContext* aContext)
StPortSetter port(curPort);
// initialize the paint event
nsPaintEvent paintEvent(NS_PAINT, this);
nsPaintEvent paintEvent(PR_TRUE, NS_PAINT, this);
paintEvent.renderingContext = aContext; // nsPaintEvent
paintEvent.rect = &aRect;
@ -1791,7 +1791,7 @@ PRBool nsChildView::DispatchMouseEvent(nsMouseEvent &aEvent)
PRBool nsChildView::ReportDestroyEvent()
{
// nsEvent
nsGUIEvent event(NS_DESTROY, this);
nsGUIEvent event(PR_TRUE, NS_DESTROY, this);
event.time = PR_IntervalNow();
// dispatch event
@ -1805,7 +1805,7 @@ PRBool nsChildView::ReportDestroyEvent()
PRBool nsChildView::ReportMoveEvent()
{
// nsEvent
nsGUIEvent moveEvent(NS_MOVE, this);
nsGUIEvent moveEvent(PR_TRUE, NS_MOVE, this);
moveEvent.point.x = mBounds.x;
moveEvent.point.y = mBounds.y;
moveEvent.time = PR_IntervalNow();
@ -1821,7 +1821,7 @@ PRBool nsChildView::ReportMoveEvent()
PRBool nsChildView::ReportSizeEvent()
{
// nsEvent
nsSizeEvent sizeEvent(NS_SIZE, this);
nsSizeEvent sizeEvent(PR_TRUE, NS_SIZE, this);
sizeEvent.time = PR_IntervalNow();
// nsSizeEvent
@ -2131,7 +2131,7 @@ nsChildView::DragEvent(PRUint32 aMessage, PRInt16 aMouseGlobalX, PRInt16 aMouseG
return NS_OK;
}
nsMouseEvent geckoEvent;
nsMouseEvent geckoEvent(PR_TRUE, 0, nsnull, nsMouseEvent::eReal);
// we're given the point in global coordinates. We need to convert it to
// window coordinates for convert:message:toGeckoEvent
@ -2192,7 +2192,7 @@ nsChildView::Idle()
-(NSMenu*)menuForEvent:(NSEvent*)theEvent
{
// Fire the context menu event into Gecko.
nsMouseEvent geckoEvent;
nsMouseEvent geckoEvent(PR_TRUE, 0, nsnull, nsMouseEvent::eReal);
[self convert:theEvent message:NS_CONTEXTMENU toGeckoEvent:&geckoEvent];
// send event into Gecko by going directly to the
@ -2580,7 +2580,7 @@ nsChildView::Idle()
[self performSelector:@selector(clickHoldCallback:) withObject:theEvent afterDelay:2.0];
#endif
nsMouseEvent geckoEvent;
nsMouseEvent geckoEvent(PR_TRUE, 0, nsnull, nsMouseEvent::eReal);
[self convert:theEvent message:NS_MOUSE_LEFT_BUTTON_DOWN toGeckoEvent:&geckoEvent];
geckoEvent.clickCount = [theEvent clickCount];
@ -2610,7 +2610,7 @@ nsChildView::Idle()
[self stopHandScroll:theEvent];
return;
}
nsMouseEvent geckoEvent;
nsMouseEvent geckoEvent(PR_TRUE, 0, nsnull, nsMouseEvent::eReal);
[self convert:theEvent message:NS_MOUSE_LEFT_BUTTON_UP toGeckoEvent:&geckoEvent];
NSPoint mouseLoc = [theEvent locationInWindow];
@ -2645,7 +2645,7 @@ nsChildView::Idle()
if ([ChildView areHandScrollModifiers:[theEvent modifierFlags]]) {
return;
}
nsMouseEvent geckoEvent;
nsMouseEvent geckoEvent(PR_TRUE, 0, nsnull, nsMouseEvent::eReal);
[self convert:theEvent message:NS_MOUSE_MOVE toGeckoEvent:&geckoEvent];
NSPoint mouseLoc = [theEvent locationInWindow];
@ -2673,7 +2673,7 @@ nsChildView::Idle()
[self updateHandScroll:theEvent];
return;
}
nsMouseEvent geckoEvent;
nsMouseEvent geckoEvent(PR_TRUE, 0, nsnull, nsMouseEvent::eReal);
[self convert:theEvent message:NS_MOUSE_MOVE toGeckoEvent:&geckoEvent];
EventRecord macEvent;
@ -2717,7 +2717,7 @@ nsChildView::Idle()
{
// The right mouse went down. Fire off a right mouse down and
// then send the context menu event.
nsMouseEvent geckoEvent;
nsMouseEvent geckoEvent(PR_TRUE, 0, nsnull, nsMouseEvent::eReal);
[self convert: theEvent message: NS_MOUSE_RIGHT_BUTTON_DOWN toGeckoEvent:&geckoEvent];
@ -2738,7 +2738,7 @@ nsChildView::Idle()
- (void)rightMouseUp:(NSEvent *)theEvent
{
nsMouseEvent geckoEvent;
nsMouseEvent geckoEvent(PR_TRUE, 0, nsnull, nsMouseEvent::eReal);
[self convert: theEvent message: NS_MOUSE_RIGHT_BUTTON_UP toGeckoEvent:&geckoEvent];
@ -2759,7 +2759,7 @@ nsChildView::Idle()
- (void)otherMouseDown:(NSEvent *)theEvent
{
nsMouseEvent geckoEvent;
nsMouseEvent geckoEvent(PR_TRUE, 0, nsnull, nsMouseEvent::eReal);
[self convert:theEvent message:NS_MOUSE_MIDDLE_BUTTON_DOWN toGeckoEvent:&geckoEvent];
geckoEvent.clickCount = [theEvent clickCount];
@ -2772,7 +2772,7 @@ nsChildView::Idle()
- (void)otherMouseUp:(NSEvent *)theEvent
{
nsMouseEvent geckoEvent;
nsMouseEvent geckoEvent(PR_TRUE, 0, nsnull, nsMouseEvent::eReal);
[self convert:theEvent message:NS_MOUSE_MIDDLE_BUTTON_UP toGeckoEvent:&geckoEvent];
// send event into Gecko by going directly to the
@ -2789,7 +2789,7 @@ const PRInt32 kNumLines = 4;
// Gecko as the number of lines to scroll. We go ahead and use a
// default kNumLines of 4 for now (until I learn how we can get settings from
// the OS). --dwh
nsMouseScrollEvent geckoEvent;
nsMouseScrollEvent geckoEvent(PR_TRUE, 0, nsnull);
[self convert:theEvent message:NS_MOUSE_SCROLL toGeckoEvent:&geckoEvent];
PRInt32 incomingDeltaX = (PRInt32)[theEvent deltaX];
@ -2930,7 +2930,7 @@ static void ConvertCocoaKeyEventToMacEvent(NSEvent* cocoaEvent, EventRecord& mac
#endif
// static void init_composition_event( *aEvent, int aType)
nsCompositionEvent event(aEventType, mGeckoChild);
nsCompositionEvent event(PR_TRUE, aEventType, mGeckoChild);
event.time = PR_IntervalNow();
mGeckoChild->DispatchWindowEvent(event);
return event.theReply.mCursorPosition;
@ -2947,7 +2947,7 @@ static void ConvertCocoaKeyEventToMacEvent(NSEvent* cocoaEvent, EventRecord& mac
NSLog(@" markRange = %d, %d; selRange = %d, %d\n", markRange.location, markRange.length, selRange.location, selRange.length);
#endif
nsTextEvent textEvent(NS_TEXT_TEXT, mGeckoChild);
nsTextEvent textEvent(PR_TRUE, NS_TEXT_TEXT, mGeckoChild);
textEvent.time = PR_IntervalNow();
textEvent.theText = aBuffer;
if (!doCommit)
@ -2981,7 +2981,7 @@ static void ConvertCocoaKeyEventToMacEvent(NSEvent* cocoaEvent, EventRecord& mac
if (len == 1 && !mInComposition)
{
// dispatch keypress event with char instead of textEvent
nsKeyEvent geckoEvent(NS_KEY_PRESS, mGeckoChild);
nsKeyEvent geckoEvent(PR_TRUE, NS_KEY_PRESS, mGeckoChild);
geckoEvent.time = PR_IntervalNow();
geckoEvent.charCode = bufPtr[0]; // gecko expects OS-translated unicode
geckoEvent.isChar = PR_TRUE;
@ -3116,7 +3116,8 @@ static void ConvertCocoaKeyEventToMacEvent(NSEvent* cocoaEvent, EventRecord& mac
NSLog(@" selectedRange = %d, %d\n", mSelectedRange.location, mSelectedRange.length);
#endif
nsReconversionEvent reconversionEvent(NS_RECONVERSION_QUERY, mGeckoChild);
nsReconversionEvent reconversionEvent(PR_TRUE, NS_RECONVERSION_QUERY,
mGeckoChild);
reconversionEvent.time = PR_IntervalNow();
nsresult rv = mGeckoChild->DispatchWindowEvent(reconversionEvent);
@ -3235,7 +3236,7 @@ static void ConvertCocoaKeyEventToMacEvent(NSEvent* cocoaEvent, EventRecord& mac
if (!isARepeat && nonDeadKeyPress)
{
// Fire a key down.
nsKeyEvent geckoEvent;
nsKeyEvent geckoEvent(PR_TRUE, 0, nsnull);
geckoEvent.point.x = geckoEvent.point.y = 0;
[self convert: theEvent message: NS_KEY_DOWN
isChar: &isChar
@ -3264,7 +3265,7 @@ static void ConvertCocoaKeyEventToMacEvent(NSEvent* cocoaEvent, EventRecord& mac
if (nonDeadKeyPress)
{
// Fire a key press.
nsKeyEvent geckoEvent;
nsKeyEvent geckoEvent(PR_TRUE, 0, nsnull);
geckoEvent.point.x = geckoEvent.point.y = 0;
isChar = PR_FALSE;
[self convert: theEvent message: NS_KEY_PRESS
@ -3319,7 +3320,7 @@ static void ConvertCocoaKeyEventToMacEvent(NSEvent* cocoaEvent, EventRecord& mac
return;
// Fire a key up.
nsKeyEvent geckoEvent;
nsKeyEvent geckoEvent(PR_TRUE, 0, nsnull);
geckoEvent.point.x = geckoEvent.point.y = 0;
PRBool isChar;
[self convert: theEvent message: NS_KEY_UP
@ -3363,7 +3364,7 @@ static void ConvertCocoaKeyEventToMacEvent(NSEvent* cocoaEvent, EventRecord& mac
// This method is called when we are about to be focused.
- (BOOL)becomeFirstResponder
{
nsFocusEvent event(NS_GOTFOCUS, mGeckoChild);
nsFocusEvent event(PR_TRUE, NS_GOTFOCUS, mGeckoChild);
mGeckoChild->DispatchWindowEvent(event);
return [super becomeFirstResponder];
@ -3372,7 +3373,7 @@ static void ConvertCocoaKeyEventToMacEvent(NSEvent* cocoaEvent, EventRecord& mac
// This method is called when are are about to lose focus.
- (BOOL)resignFirstResponder
{
nsFocusEvent event(NS_LOSTFOCUS, mGeckoChild);
nsFocusEvent event(PR_TRUE, NS_LOSTFOCUS, mGeckoChild);
mGeckoChild->DispatchWindowEvent(event);

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

@ -1498,7 +1498,7 @@ PRBool nsCocoaWindow::DragEvent ( unsigned int aMessage, Point aMouseGlobal, UIn
//-------------------------------------------------------------------------
void nsCocoaWindow::ComeToFront() {
#if 0
nsZLevelEvent event(NS_SETZLEVEL, this);
nsZLevelEvent event(PR_TRUE, NS_SETZLEVEL, this);
event.point.x = mBounds.x;
event.point.y = mBounds.y;
@ -1564,7 +1564,8 @@ nsCocoaWindow::DispatchEvent ( void* anEvent, void* aView, PRBool *_retval )
ChildView* view = NS_REINTERPRET_CAST(ChildView*, aView);
nsMouseEvent geckoEvent(0, view ? [view widget] : this)
nsMouseEvent geckoEvent(PR_TRUE, 0, view ? [view widget] : this,
nsMouseEvent::eReal)
geckoEvent.nativeMsg = anEvent;
geckoEvent.time = PR_IntervalNow();
@ -1660,7 +1661,7 @@ void
nsCocoaWindow::ReportSizeEvent()
{
// nsEvent
nsSizeEvent sizeEvent(NS_SIZE, this);
nsSizeEvent sizeEvent(PR_TRUE, NS_SIZE, this);
sizeEvent.time = PR_IntervalNow();
// nsSizeEvent

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

@ -401,7 +401,7 @@ nsMenuBarX :: ExecuteCommand ( nsIContent* inDispatchTo )
nsCOMPtr<nsPresContext> presContext;
MenuHelpersX::DocShellToPresContext(docShell, getter_AddRefs(presContext));
nsMouseEvent event(NS_XUL_COMMAND);
nsMouseEvent event(PR_TRUE, NS_XUL_COMMAND, nsnull, nsMouseEvent::eReal);
inDispatchTo->HandleDOMEvent(presContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status);
}
@ -489,7 +489,7 @@ nsMenuBarX::MenuConstruct( const nsMenuEvent & aMenuEvent, nsIWidget* aParentWin
nsAutoString menuIDstring;
menu->GetAttr(kNameSpaceID_None, nsWidgetAtoms::id, menuIDstring);
if ( menuIDstring.EqualsLiteral("menu_Help") ) {
nsMenuEvent event;
nsMenuEvent event(PR_TRUE, 0, nsnull);
MenuHandle handle = nsnull;
#if !TARGET_CARBON
::HMGetHelpMenuHandle(&handle);

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

@ -261,7 +261,7 @@ NS_METHOD nsMenuItemX::DoCommand()
MenuHelpersX::DocShellToPresContext(docShell, getter_AddRefs(presContext));
nsEventStatus status = nsEventStatus_eIgnore;
nsMouseEvent event(NS_XUL_COMMAND);
nsMouseEvent event(PR_TRUE, NS_XUL_COMMAND, nsnull, nsMouseEvent::eReal);
// See if we have a command element. If so, we execute on the command instead
// of on our content element.

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

@ -747,7 +747,7 @@ static pascal OSStatus MyMenuEventHandler(EventHandlerCallRef myHandler, EventRe
if (listener) {
MenuRef menuRef;
::GetEventParameter(event, kEventParamDirectObject, typeMenuRef, NULL, sizeof(menuRef), NULL, &menuRef);
nsMenuEvent menuEvent(NS_MENU_SELECTED);
nsMenuEvent menuEvent(PR_TRUE, NS_MENU_SELECTED, nsnull);
menuEvent.time = PR_IntervalNow();
menuEvent.mCommand = (PRUint32) menuRef;
if (kind == kEventMenuOpening) {
@ -973,8 +973,9 @@ PRBool
nsMenuX::OnCreate()
{
nsEventStatus status = nsEventStatus_eIgnore;
nsMouseEvent event(NS_XUL_POPUP_SHOWING);
nsMouseEvent event(PR_TRUE, NS_XUL_POPUP_SHOWING, nsnull,
nsMouseEvent::eReal);
nsCOMPtr<nsIContent> popupContent;
GetMenuPopupContent(getter_AddRefs(popupContent));
@ -1056,7 +1057,7 @@ PRBool
nsMenuX::OnCreated()
{
nsEventStatus status = nsEventStatus_eIgnore;
nsMouseEvent event(NS_XUL_POPUP_SHOWN);
nsMouseEvent event(PR_TRUE, NS_XUL_POPUP_SHOWN, nsnull, nsMouseEvent::eReal);
nsCOMPtr<nsIContent> popupContent;
GetMenuPopupContent(getter_AddRefs(popupContent));
@ -1092,7 +1093,8 @@ nsMenuX::OnDestroy()
return PR_TRUE;
nsEventStatus status = nsEventStatus_eIgnore;
nsMouseEvent event(NS_XUL_POPUP_HIDING);
nsMouseEvent event(PR_TRUE, NS_XUL_POPUP_HIDING, nsnull,
nsMouseEvent::eReal);
nsCOMPtr<nsIDocShell> docShell = do_QueryReferent(mDocShellWeakRef);
if (!docShell) {
@ -1122,7 +1124,8 @@ PRBool
nsMenuX::OnDestroyed()
{
nsEventStatus status = nsEventStatus_eIgnore;
nsMouseEvent event(NS_XUL_POPUP_HIDDEN);
nsMouseEvent event(PR_TRUE, NS_XUL_POPUP_HIDDEN, nsnull,
nsMouseEvent::eReal);
nsCOMPtr<nsIDocShell> docShell = do_QueryReferent(mDocShellWeakRef);
if (!docShell) {

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

@ -452,7 +452,7 @@ void InitKeyPressEvent(GdkEventKey *aGEK,
void handle_size_allocate(GtkWidget *w, GtkAllocation *alloc, gpointer p)
{
nsWindow *widget = (nsWindow *)p;
nsSizeEvent event(NS_SIZE, widget);
nsSizeEvent event(PR_TRUE, NS_SIZE, widget);
InitAllocationEvent(alloc, event);
NS_ADDREF(widget);
@ -475,7 +475,7 @@ gint handle_key_press_event_for_text(GtkObject *w, GdkEventKey* event,
return PR_FALSE;
NS_ADDREF(win);
nsKeyEvent keyDownEvent(NS_KEY_DOWN, win);
nsKeyEvent keyDownEvent(PR_TRUE, NS_KEY_DOWN, win);
InitKeyEvent(event, keyDownEvent);
PRBool noDefault = win->OnKey(keyDownEvent);
@ -496,7 +496,7 @@ gint handle_key_press_event_for_text(GtkObject *w, GdkEventKey* event,
// character code. Note we have to check for modifier keys, since
// gtk returns a character value for them
//
nsKeyEvent keyPressEvent(NS_KEY_PRESS, win);
nsKeyEvent keyPressEvent(PR_TRUE, NS_KEY_PRESS, win);
InitKeyPressEvent(event, keyPressEvent);
if (noDefault) { // If prevent default set for onkeydown, do the same for onkeypress
keyPressEvent.flags |= NS_EVENT_FLAG_NO_DEFAULT;
@ -518,7 +518,7 @@ gint handle_key_release_event_for_text(GtkObject *w, GdkEventKey* event,
gpointer p)
{
nsTextWidget* win = (nsTextWidget*)p;
nsKeyEvent kevent(NS_KEY_UP, win);
nsKeyEvent kevent(PR_TRUE, NS_KEY_UP, win);
InitKeyEvent(event, kevent);
NS_ADDREF(win);
win->OnKey(kevent);
@ -557,7 +557,7 @@ gint handle_key_press_event(GtkObject *w, GdkEventKey* event, gpointer p)
// window that currently has focus inside our app...
//
PRBool noDefault = PR_FALSE;
nsKeyEvent keyDownEvent(NS_KEY_DOWN, win);
nsKeyEvent keyDownEvent(PR_TRUE, NS_KEY_DOWN, win);
InitKeyEvent(event, keyDownEvent);
// if we need to suppress this NS_KEY_DOWN event, reset the flag
if (suppressNextKeyDown == PR_TRUE)
@ -583,7 +583,7 @@ gint handle_key_press_event(GtkObject *w, GdkEventKey* event, gpointer p)
//
// Call nsConvertCharCodeToUnicode() here to get kevent.charCode
nsKeyEvent keyPressEvent(NS_KEY_PRESS, win);
nsKeyEvent keyPressEvent(PR_TRUE, NS_KEY_PRESS, win);
InitKeyPressEvent(event, keyPressEvent);
if (noDefault) { // If prevent default set for onkeydown, do the same for onkeypress
keyPressEvent.flags |= NS_EVENT_FLAG_NO_DEFAULT;
@ -652,7 +652,7 @@ gint handle_key_release_event(GtkObject *w, GdkEventKey* event, gpointer p)
if (nsWidget::sFocusWindow)
win = nsWidget::sFocusWindow;
nsKeyEvent kevent(NS_KEY_UP, win);
nsKeyEvent kevent(PR_TRUE, NS_KEY_UP, win);
InitKeyEvent(event, kevent);
NS_ADDREF(win);

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

@ -96,7 +96,7 @@ PRBool nsWidget::OnKey(nsKeyEvent &aEvent)
// before we dispatch a key, check if it's the context menu key.
// If so, send a context menu key event instead.
if (IsContextMenuKey(aEvent)) {
nsMouseEvent contextMenuEvent;
nsMouseEvent contextMenuEvent(PR_TRUE, 0, nsnull, nsMouseEvent::eReal);
ConvertKeyEventToContextMenuEvent(&aEvent, &contextMenuEvent);
ret = DispatchWindowEvent(&contextMenuEvent);
}
@ -678,7 +678,7 @@ PRBool nsWidget::OnResize(nsSizeEvent *event)
PRBool nsWidget::OnResize(nsRect &aRect)
{
nsSizeEvent event(NS_SIZE, this);
nsSizeEvent event(PR_TRUE, NS_SIZE, this);
InitEvent(event);
@ -718,7 +718,7 @@ PRBool nsWidget::OnMove(PRInt32 aX, PRInt32 aY)
ResetInternalVisibility();
nsGUIEvent event(NS_MOVE, this);
nsGUIEvent event(PR_TRUE, NS_MOVE, this);
InitEvent(event);
event.point.x = aX;
event.point.y = aY;
@ -1456,7 +1456,7 @@ PRBool nsWidget::DispatchWindowEvent(nsGUIEvent* event)
PRBool nsWidget::DispatchStandardEvent(PRUint32 aMsg)
{
nsGUIEvent event(aMsg, this);
nsGUIEvent event(PR_TRUE, aMsg, this);
InitEvent(event);
PRBool result = DispatchWindowEvent(&event);
return result;
@ -1727,7 +1727,7 @@ nsWidget::OnMotionNotifySignal(GdkEventMotion * aGdkMotionEvent)
if (mIsDestroying)
return;
nsMouseEvent event(NS_MOUSE_MOVE);
nsMouseEvent event(PR_TRUE, NS_MOUSE_MOVE, nsnull, nsMouseEvent::eReal);
// If there is a button motion target, use that instead of the
// current widget
@ -1822,7 +1822,7 @@ nsWidget::OnEnterNotifySignal(GdkEventCrossing * aGdkCrossingEvent)
return;
}
nsMouseEvent event(NS_MOUSE_ENTER, this);
nsMouseEvent event(PR_TRUE, NS_MOUSE_ENTER, this, nsMouseEvent::eReal);
if (aGdkCrossingEvent != NULL)
{
@ -1856,7 +1856,7 @@ nsWidget::OnLeaveNotifySignal(GdkEventCrossing * aGdkCrossingEvent)
return;
}
nsMouseEvent event(NS_MOUSE_EXIT, this);
nsMouseEvent event(PR_TRUE, NS_MOUSE_EXIT, this, nsMouseEvent::eReal);
if (aGdkCrossingEvent != NULL)
{
@ -1877,7 +1877,7 @@ nsWidget::OnLeaveNotifySignal(GdkEventCrossing * aGdkCrossingEvent)
/* virtual */ void
nsWidget::OnButtonPressSignal(GdkEventButton * aGdkButtonEvent)
{
nsMouseScrollEvent scrollEvent(NS_MOUSE_SCROLL, this);
nsMouseScrollEvent scrollEvent(PR_TRUE, NS_MOUSE_SCROLL, this);
PRUint32 eventType = 0;
// If you double click in GDK, it will actually generate a single
@ -1958,7 +1958,7 @@ nsWidget::OnButtonPressSignal(GdkEventButton * aGdkButtonEvent)
break;
}
nsMouseEvent event(eventType, this);
nsMouseEvent event(PR_TRUE, eventType, this, nsMouseEvent::eReal);
InitMouseEvent(aGdkButtonEvent, event);
// Set the button motion target and remeber the widget and root coords
@ -1984,7 +1984,8 @@ nsWidget::OnButtonPressSignal(GdkEventButton * aGdkButtonEvent)
// if we're a right-button-down on linux, we're trying to
// popup a context menu. send that event to gecko also.
if (eventType == NS_MOUSE_RIGHT_BUTTON_DOWN) {
nsMouseEvent contextMenuEvent(NS_CONTEXTMENU, this);
nsMouseEvent contextMenuEvent(PR_TRUE, NS_CONTEXTMENU, this,
nsMouseEvent::eReal);
InitMouseEvent(aGdkButtonEvent, contextMenuEvent);
DispatchMouseEvent(contextMenuEvent);
}
@ -2025,7 +2026,7 @@ nsWidget::OnButtonReleaseSignal(GdkEventButton * aGdkButtonEvent)
break;
}
nsMouseEvent event(eventType, this);
nsMouseEvent event(PR_TRUE, eventType, this, nsMouseEvent::eReal);
InitMouseEvent(aGdkButtonEvent, event);
if (sButtonMotionTarget) {
@ -2064,7 +2065,7 @@ nsWidget::OnFocusInSignal(GdkEventFocus * aGdkFocusEvent)
GTK_WIDGET_SET_FLAGS(mWidget, GTK_HAS_FOCUS);
nsFocusEvent event(NS_GOTFOCUS, this);
nsFocusEvent event(PR_TRUE, NS_GOTFOCUS, this);
// event.time = aGdkFocusEvent->time;;
// event.time = PR_Now();
@ -2084,7 +2085,7 @@ nsWidget::OnFocusOutSignal(GdkEventFocus * aGdkFocusEvent)
GTK_WIDGET_UNSET_FLAGS(mWidget, GTK_HAS_FOCUS);
nsFocusEvent event(NS_LOSTFOCUS, this);
nsFocusEvent event(PR_TRUE, NS_LOSTFOCUS, this);
// event.time = aGdkFocusEvent->time;;
// event.time = PR_Now();
@ -2128,7 +2129,7 @@ nsWidget::InstallSignal(GtkWidget * aWidget,
//////////////////////////////////////////////////////////////////
void
nsWidget::InitMouseEvent(GdkEventButton * aGdkButtonEvent,
nsMouseEvent &anEvent)
nsMouseEvent &anEvent)
{
if (aGdkButtonEvent != NULL) {
anEvent.point.x = nscoord(aGdkButtonEvent->x);

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше