зеркало из https://github.com/mozilla/pjs.git
Fixes for Create/Init/Dispatch of new DOM events. Bugs 25889, 71544, 52129, 61022, 71823. sr:jst, hyatt
This commit is contained in:
Родитель
4c5669ae9b
Коммит
9d040706bd
|
@ -2790,11 +2790,17 @@ nsresult nsDocument::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
nsEventStatus* aEventStatus)
|
||||
{
|
||||
nsresult mRet = NS_OK;
|
||||
PRBool externalDOMEvent = PR_FALSE;
|
||||
|
||||
nsIDOMEvent* domEvent = nsnull;
|
||||
|
||||
if (NS_EVENT_FLAG_INIT & aFlags) {
|
||||
if (!aDOMEvent) {
|
||||
if (aDOMEvent) {
|
||||
if (*aDOMEvent) {
|
||||
externalDOMEvent = PR_TRUE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
aDOMEvent = &domEvent;
|
||||
}
|
||||
aEvent->flags = aFlags;
|
||||
|
@ -2821,7 +2827,7 @@ nsresult nsDocument::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
|
||||
if (NS_EVENT_FLAG_INIT & aFlags) {
|
||||
// We're leaving the DOM event loop so if we created a DOM event, release here.
|
||||
if (nsnull != *aDOMEvent) {
|
||||
if (*aDOMEvent && !externalDOMEvent) {
|
||||
nsrefcnt rc;
|
||||
NS_RELEASE2(*aDOMEvent, rc);
|
||||
if (0 != rc) {
|
||||
|
@ -2833,8 +2839,8 @@ nsresult nsDocument::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
NS_RELEASE(mPrivateEvent);
|
||||
}
|
||||
}
|
||||
aDOMEvent = nsnull;
|
||||
}
|
||||
aDOMEvent = nsnull;
|
||||
}
|
||||
|
||||
return mRet;
|
||||
|
|
|
@ -1384,11 +1384,17 @@ nsGenericElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
{
|
||||
nsresult ret = NS_OK;
|
||||
PRBool retarget = PR_FALSE;
|
||||
PRBool externalDOMEvent = PR_FALSE;
|
||||
nsCOMPtr<nsIDOMEventTarget> oldTarget;
|
||||
|
||||
nsIDOMEvent* domEvent = nsnull;
|
||||
if (NS_EVENT_FLAG_INIT & aFlags) {
|
||||
if (!aDOMEvent) {
|
||||
if (aDOMEvent) {
|
||||
if (*aDOMEvent) {
|
||||
externalDOMEvent = PR_TRUE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
aDOMEvent = &domEvent;
|
||||
}
|
||||
aEvent->flags = aFlags;
|
||||
|
@ -1537,8 +1543,9 @@ nsGenericElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
|
||||
if (NS_EVENT_FLAG_INIT & aFlags) {
|
||||
// We're leaving the DOM event loop so if we created a DOM event,
|
||||
// release here.
|
||||
if (nsnull != *aDOMEvent) {
|
||||
// release here. If externalDOMEvent is set the event was passed in
|
||||
// and we don't own it
|
||||
if (*aDOMEvent && !externalDOMEvent) {
|
||||
nsrefcnt rc;
|
||||
NS_RELEASE2(*aDOMEvent, rc);
|
||||
if (0 != rc) {
|
||||
|
@ -1552,8 +1559,8 @@ nsGenericElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
NS_RELEASE(privateEvent);
|
||||
}
|
||||
}
|
||||
aDOMEvent = nsnull;
|
||||
}
|
||||
aDOMEvent = nsnull;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -45,12 +45,6 @@ class nsIEventListenerManager : public nsISupports {
|
|||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IEVENTLISTENERMANAGER_IID; return iid; }
|
||||
|
||||
/**
|
||||
* Retrieves events listeners of all types.
|
||||
* @param
|
||||
*/
|
||||
virtual nsresult GetEventListeners(nsVoidArray **aListeners, const nsIID& aIID) = 0;
|
||||
|
||||
/**
|
||||
* Sets events listeners of all types.
|
||||
* @param an event listener
|
||||
|
|
|
@ -42,7 +42,8 @@
|
|||
#include "prmem.h"
|
||||
#include "nsLayoutAtoms.h"
|
||||
#include "nsMutationEvent.h"
|
||||
|
||||
#include "nsIDOMKeyEvent.h"
|
||||
#include "nsIDOMMutationEvent.h"
|
||||
|
||||
static char* mEventNames[] = {
|
||||
"mousedown", "mouseup", "click", "dblclick", "mouseover",
|
||||
|
@ -162,6 +163,8 @@ nsDOMEvent::nsDOMEvent(nsIPresContext* aPresContext, nsEvent* aEvent, const nsAR
|
|||
mOriginalTarget = nsnull;
|
||||
mText = nsnull;
|
||||
mTextRange = nsnull;
|
||||
mButton = -1;
|
||||
mScreenPoint.x = mScreenPoint.y = mClientPoint.x = mClientPoint.y = 0;
|
||||
|
||||
if (aEvent && aEvent->eventStructType == NS_TEXT_EVENT) {
|
||||
//
|
||||
|
@ -212,6 +215,9 @@ nsDOMEvent::~nsDOMEvent()
|
|||
NS_IF_RELEASE(mTextRange);
|
||||
|
||||
if (mEventIsInternal) {
|
||||
if (mEvent->userType) {
|
||||
delete mEvent->userType;
|
||||
}
|
||||
PR_DELETE(mEvent);
|
||||
}
|
||||
|
||||
|
@ -231,6 +237,7 @@ NS_INTERFACE_MAP_BEGIN(nsDOMEvent)
|
|||
NS_INTERFACE_MAP_ENTRY(nsIPrivateDOMEvent)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIPrivateTextEvent)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIPrivateCompositionEvent)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIScriptObjectOwner)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMMouseEvent)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
|
@ -239,10 +246,16 @@ NS_METHOD nsDOMEvent::GetType(nsAWritableString& aType)
|
|||
{
|
||||
const char* mName = GetEventName(mEvent->message);
|
||||
|
||||
if (nsnull != mName) {
|
||||
if (mName) {
|
||||
aType.Assign(NS_ConvertASCIItoUCS2(mName));
|
||||
return NS_OK;
|
||||
}
|
||||
else {
|
||||
if (mEvent->message == NS_USER_DEFINED_EVENT && mEvent->userType) {
|
||||
aType.Assign(NS_STATIC_CAST(nsStringKey*, mEvent->userType)->GetString());
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -520,8 +533,10 @@ NS_METHOD nsDOMEvent::GetScreenX(PRInt32* aScreenX)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
if (!((nsGUIEvent*)mEvent)->widget )
|
||||
return NS_ERROR_FAILURE;
|
||||
if (!((nsGUIEvent*)mEvent)->widget ) {
|
||||
*aScreenX = mScreenPoint.x;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsRect bounds, offset;
|
||||
bounds.x = mEvent->refPoint.x;
|
||||
|
@ -540,8 +555,10 @@ NS_METHOD nsDOMEvent::GetScreenY(PRInt32* aScreenY)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
if (!((nsGUIEvent*)mEvent)->widget )
|
||||
return NS_ERROR_FAILURE;
|
||||
if (!((nsGUIEvent*)mEvent)->widget ) {
|
||||
*aScreenY = mScreenPoint.y;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsRect bounds, offset;
|
||||
bounds.y = mEvent->refPoint.y;
|
||||
|
@ -560,6 +577,11 @@ NS_METHOD nsDOMEvent::GetClientX(PRInt32* aClientX)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
if (!((nsGUIEvent*)mEvent)->widget ) {
|
||||
*aClientX = mClientPoint.x;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//My god, man, there *must* be a better way to do this.
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
nsIWidget* rootWidget = nsnull;
|
||||
|
@ -600,6 +622,11 @@ NS_METHOD nsDOMEvent::GetClientY(PRInt32* aClientY)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
if (!((nsGUIEvent*)mEvent)->widget ) {
|
||||
*aClientY = mClientPoint.y;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//My god, man, there *must* be a better way to do this.
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
nsIWidget* rootWidget = nsnull;
|
||||
|
@ -707,27 +734,33 @@ NS_METHOD nsDOMEvent::GetButton(PRUint16* aButton)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
switch (mEvent->message) {
|
||||
case NS_MOUSE_LEFT_BUTTON_UP:
|
||||
case NS_MOUSE_LEFT_BUTTON_DOWN:
|
||||
case NS_MOUSE_LEFT_CLICK:
|
||||
case NS_MOUSE_LEFT_DOUBLECLICK:
|
||||
*aButton = 0;
|
||||
break;
|
||||
case NS_MOUSE_MIDDLE_BUTTON_UP:
|
||||
case NS_MOUSE_MIDDLE_BUTTON_DOWN:
|
||||
case NS_MOUSE_MIDDLE_CLICK:
|
||||
case NS_MOUSE_MIDDLE_DOUBLECLICK:
|
||||
*aButton = 1;
|
||||
break;
|
||||
case NS_MOUSE_RIGHT_BUTTON_UP:
|
||||
case NS_MOUSE_RIGHT_BUTTON_DOWN:
|
||||
case NS_MOUSE_RIGHT_CLICK:
|
||||
case NS_MOUSE_RIGHT_DOUBLECLICK:
|
||||
*aButton = 2;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
// If button has been set then use that instead.
|
||||
if (mButton > 0) {
|
||||
*aButton = (PRUint16)mButton;
|
||||
}
|
||||
else {
|
||||
switch (mEvent->message) {
|
||||
case NS_MOUSE_LEFT_BUTTON_UP:
|
||||
case NS_MOUSE_LEFT_BUTTON_DOWN:
|
||||
case NS_MOUSE_LEFT_CLICK:
|
||||
case NS_MOUSE_LEFT_DOUBLECLICK:
|
||||
*aButton = 0;
|
||||
break;
|
||||
case NS_MOUSE_MIDDLE_BUTTON_UP:
|
||||
case NS_MOUSE_MIDDLE_BUTTON_DOWN:
|
||||
case NS_MOUSE_MIDDLE_CLICK:
|
||||
case NS_MOUSE_MIDDLE_DOUBLECLICK:
|
||||
*aButton = 1;
|
||||
break;
|
||||
case NS_MOUSE_RIGHT_BUTTON_UP:
|
||||
case NS_MOUSE_RIGHT_BUTTON_DOWN:
|
||||
case NS_MOUSE_RIGHT_CLICK:
|
||||
case NS_MOUSE_RIGHT_DOUBLECLICK:
|
||||
*aButton = 2;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1087,10 +1120,10 @@ nsDOMEvent::SetEventType(const nsAReadableString& aEventTypeArg)
|
|||
}
|
||||
else if (atom == nsLayoutAtoms::onDOMSubtreeModified && mEvent->eventStructType == NS_MUTATION_EVENT) {
|
||||
mEvent->message = NS_MUTATION_SUBTREEMODIFIED;
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
return NS_ERROR_FAILURE;
|
||||
mEvent->message = NS_USER_DEFINED_EVENT;
|
||||
mEvent->userType = nsStringKey(aEventTypeArg).Clone();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1106,27 +1139,60 @@ nsDOMEvent::InitEvent(const nsAReadableString& aEventTypeArg, PRBool aCanBubbleA
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMEvent::InitUIEvent(const nsAReadableString& aTypeArg, PRBool aCanBubbleArg, PRBool aCancelableArg, nsIDOMAbstractView* aViewArg, PRInt32 aDetailArg)
|
||||
nsDOMEvent::InitUIEvent(const nsAReadableString& aTypeArg, PRBool aCanBubbleArg, PRBool aCancelableArg,
|
||||
nsIDOMAbstractView* aViewArg, PRInt32 aDetailArg)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMEvent::InitMouseEvent(const nsAReadableString& aTypeArg, PRBool aCtrlKeyArg, PRBool aAltKeyArg, PRBool aShiftKeyArg, PRBool aMetaKeyArg, PRInt32 aScreenXArg, PRInt32 aScreenYArg, PRInt32 aClientXArg, PRInt32 aClientYArg, PRUint16 aButtonArg, PRUint16 aDetailArg)
|
||||
nsDOMEvent::InitMouseEvent(const nsAReadableString& aTypeArg, PRBool aCtrlKeyArg, PRBool aAltKeyArg,
|
||||
PRBool aShiftKeyArg, PRBool aMetaKeyArg, PRInt32 aScreenXArg, PRInt32 aScreenYArg,
|
||||
PRInt32 aClientXArg, PRInt32 aClientYArg, PRUint16 aButtonArg, PRUint16 aDetailArg)
|
||||
{
|
||||
NS_ENSURE_SUCCESS(SetEventType(aTypeArg), NS_ERROR_FAILURE);
|
||||
//mEvent->flags |= aCanBubbleArg ? NS_EVENT_FLAG_NONE : NS_EVENT_FLAG_CANT_BUBBLE;
|
||||
//mEvent->flags |= aCancelableArg ? NS_EVENT_FLAG_NONE : NS_EVENT_FLAG_CANT_CANCEL;
|
||||
|
||||
if (mEvent->eventStructType = NS_MOUSE_EVENT) {
|
||||
nsMouseEvent* mouseEvent = NS_STATIC_CAST(nsMouseEvent*, mEvent);
|
||||
mouseEvent->isControl = aCtrlKeyArg;
|
||||
mouseEvent->isAlt = aAltKeyArg;
|
||||
mouseEvent->isShift = aShiftKeyArg;
|
||||
mouseEvent->isMeta = aMetaKeyArg;
|
||||
mScreenPoint.x = aScreenXArg;
|
||||
mScreenPoint.y = aScreenYArg;
|
||||
mClientPoint.x = aClientXArg;
|
||||
mClientPoint.y = aClientYArg;
|
||||
mButton = aButtonArg;
|
||||
mouseEvent->clickCount = aDetailArg;
|
||||
}
|
||||
//include a way to set view once we have more than one
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMEvent::InitKeyEvent(const nsAReadableString& aTypeArg, PRBool aCanBubbleArg, PRBool aCancelableArg, PRBool aCtrlKeyArg, PRBool aAltKeyArg, PRBool aShiftKeyArg, PRBool aMetaKeyArg, PRUint32 aKeyCodeArg, PRUint32 aCharCodeArg, nsIDOMAbstractView* aViewArg)
|
||||
nsDOMEvent::InitKeyEvent(const nsAReadableString& aTypeArg, PRBool aCanBubbleArg, PRBool aCancelableArg,
|
||||
PRBool aCtrlKeyArg, PRBool aAltKeyArg, PRBool aShiftKeyArg, PRBool aMetaKeyArg,
|
||||
PRUint32 aKeyCodeArg, PRUint32 aCharCodeArg, nsIDOMAbstractView* aViewArg)
|
||||
{
|
||||
NS_ENSURE_SUCCESS(SetEventType(aTypeArg), NS_ERROR_FAILURE);
|
||||
mEvent->flags |= aCanBubbleArg ? NS_EVENT_FLAG_NONE : NS_EVENT_FLAG_CANT_BUBBLE;
|
||||
mEvent->flags |= aCancelableArg ? NS_EVENT_FLAG_NONE : NS_EVENT_FLAG_CANT_CANCEL;
|
||||
mEvent->internalAppFlags |= NS_APP_EVENT_FLAG_NONE;
|
||||
|
||||
if (mEvent->eventStructType = NS_KEY_EVENT) {
|
||||
nsKeyEvent* keyEvent = NS_STATIC_CAST(nsKeyEvent*, mEvent);
|
||||
keyEvent->isControl = aCtrlKeyArg;
|
||||
keyEvent->isAlt = aAltKeyArg;
|
||||
keyEvent->isShift = aShiftKeyArg;
|
||||
keyEvent->isMeta = aMetaKeyArg;
|
||||
keyEvent->keyCode = aKeyCodeArg;
|
||||
keyEvent->charCode = aCharCodeArg;
|
||||
}
|
||||
//include a way to set view once we have more than one
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1321,6 +1387,28 @@ const char* nsDOMEvent::GetEventName(PRUint32 aEventType)
|
|||
return nsnull;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMEvent::GetScriptObject(nsIScriptContext *aContext, void** aScriptObject)
|
||||
{
|
||||
nsresult res = NS_OK;
|
||||
|
||||
if (nsnull == mScriptObject) {
|
||||
nsISupports *supports = (nsISupports *)(nsIDOMMouseEvent *)this;
|
||||
|
||||
res = NS_NewScriptKeyEvent(aContext, supports, nsnull, (void**)&mScriptObject);
|
||||
}
|
||||
*aScriptObject = mScriptObject;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMEvent::SetScriptObject(void* aScriptObject)
|
||||
{
|
||||
mScriptObject = aScriptObject;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult NS_NewDOMUIEvent(nsIDOMEvent** aInstancePtrResult,
|
||||
nsIPresContext* aPresContext,
|
||||
const nsAReadableString& aEventType,
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "nsIPrivateTextEvent.h"
|
||||
#include "nsIPrivateTextRange.h"
|
||||
#include "nsIDOMEvent.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsPoint.h"
|
||||
|
@ -44,7 +45,8 @@ class nsDOMEvent : public nsIDOMKeyEvent,
|
|||
public nsIDOMNSUIEvent,
|
||||
public nsIPrivateDOMEvent,
|
||||
public nsIPrivateTextEvent,
|
||||
public nsIPrivateCompositionEvent {
|
||||
public nsIPrivateCompositionEvent,
|
||||
public nsIScriptObjectOwner {
|
||||
|
||||
public:
|
||||
// Note: this enum must be kept in sync with mEventNames in nsDOMEvent.cpp
|
||||
|
@ -173,6 +175,10 @@ public:
|
|||
NS_IMETHOD GetCompositionReply(nsTextEventReply** aReply);
|
||||
NS_IMETHOD GetReconversionReply(nsReconversionEventReply** aReply);
|
||||
|
||||
// nsIScriptObjectOwner interface
|
||||
NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject);
|
||||
NS_IMETHOD SetScriptObject(void* aScriptObject);
|
||||
|
||||
/** Overloaded new operator. Initializes the memory to 0.
|
||||
* Relies on a recycler to perform the allocation,
|
||||
* optionally from a pool.
|
||||
|
@ -202,6 +208,7 @@ protected:
|
|||
//Internal helper funcs
|
||||
nsresult GetScrollInfo(nsIScrollableView** aScrollableView, float* aP2T, float* aT2P);
|
||||
nsresult SetEventType(const nsAReadableString& aEventTypeArg);
|
||||
const char* GetEventName(PRUint32 aEventType);
|
||||
|
||||
nsEvent* mEvent;
|
||||
PRBool mEventIsInternal;
|
||||
|
@ -211,7 +218,13 @@ protected:
|
|||
nsIDOMEventTarget* mOriginalTarget;
|
||||
nsString* mText;
|
||||
nsIPrivateTextRangeList* mTextRange;
|
||||
const char* GetEventName(PRUint32 aEventType);
|
||||
|
||||
//These are use for internal data for user created events
|
||||
PRInt16 mButton;
|
||||
nsPoint mScreenPoint;
|
||||
nsPoint mClientPoint;
|
||||
|
||||
void* mScriptObject;
|
||||
};
|
||||
|
||||
#endif // nsDOMEvent_h__
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -28,6 +28,7 @@
|
|||
#include "nsCOMPtr.h"
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsHashtable.h"
|
||||
|
||||
class nsIDOMEvent;
|
||||
class nsIAtom;
|
||||
|
@ -43,6 +44,39 @@ typedef struct {
|
|||
//Flag must live higher than all event flags in nsGUIEvent.h
|
||||
#define NS_PRIV_EVENT_FLAG_SCRIPT 0x80
|
||||
|
||||
//These define the internal type of the EventListenerManager
|
||||
//No listener type defined, should happen only at creation
|
||||
#define NS_ELM_NONE 0
|
||||
//Simple indicates only a single event listener group type (i.e. mouse, key)
|
||||
#define NS_ELM_SINGLE 1
|
||||
//Multi indicates any number of listener group types accessed as member vars
|
||||
#define NS_ELM_MULTI 2
|
||||
//Hash indicates any number of listener group types accessed out of a hash
|
||||
#define NS_ELM_HASH 4
|
||||
|
||||
enum EventArrayType {
|
||||
eEventArrayType_Mouse = 0,
|
||||
eEventArrayType_MouseMotion = 1,
|
||||
eEventArrayType_ContextMenu = 2,
|
||||
eEventArrayType_Key = 3,
|
||||
eEventArrayType_Load = 4,
|
||||
eEventArrayType_Focus = 5,
|
||||
eEventArrayType_Form = 6,
|
||||
eEventArrayType_Drag = 7,
|
||||
eEventArrayType_Paint = 8,
|
||||
eEventArrayType_Text = 9,
|
||||
eEventArrayType_Composition = 10,
|
||||
eEventArrayType_Menu = 11,
|
||||
eEventArrayType_Scroll = 12,
|
||||
eEventArrayType_Mutation = 13,
|
||||
eEventArrayType_Hash,
|
||||
eEventArrayType_None
|
||||
};
|
||||
|
||||
//Keep this in line with event array types, not counting
|
||||
//types HASH and NONE
|
||||
#define EVENT_ARRAY_TYPE_LENGTH 14
|
||||
|
||||
/*
|
||||
* Event listener manager
|
||||
*/
|
||||
|
@ -57,15 +91,6 @@ public:
|
|||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
nsVoidArray** GetListenersByIID(const nsIID& aIID);
|
||||
|
||||
/**
|
||||
* Retrieves events listeners of all types.
|
||||
* @param
|
||||
*/
|
||||
|
||||
virtual nsresult GetEventListeners(nsVoidArray **aListeners, const nsIID& aIID);
|
||||
|
||||
/**
|
||||
* Sets events listeners of all types.
|
||||
* @param an event listener
|
||||
|
@ -108,9 +133,9 @@ public:
|
|||
|
||||
virtual nsresult SetListenerTarget(nsISupports* aTarget);
|
||||
|
||||
virtual nsresult HasMutationListeners(PRBool* aListener) { *aListener = (mMutationListeners != nsnull); return NS_OK; };
|
||||
virtual nsresult HasMutationListeners(PRBool* aListener) { *aListener = (GetListenersByType(eEventArrayType_Mutation, nsnull, PR_FALSE) != nsnull); return NS_OK; };
|
||||
|
||||
static nsresult GetIdentifiersForType(nsIAtom* aType, nsIID& aIID, PRInt32* aSubType);
|
||||
static nsresult GetIdentifiersForType(nsIAtom* aType, EventArrayType* aArrayType, PRInt32* aSubType);
|
||||
|
||||
// nsIDOMEventTarget interface
|
||||
NS_IMETHOD AddEventListener(const nsAReadableString& aType,
|
||||
|
@ -139,32 +164,31 @@ protected:
|
|||
nsIAtom *aName,
|
||||
nsListenerStruct *aListenerStruct,
|
||||
PRUint32 aSubType);
|
||||
nsListenerStruct* FindJSEventListener(REFNSIID aIID);
|
||||
nsListenerStruct* FindJSEventListener(EventArrayType aType);
|
||||
nsresult SetJSEventListener(nsIScriptContext *aContext, nsIScriptObjectOwner *aOwner, nsIAtom* aName, PRBool aIsString);
|
||||
nsresult AddEventListener(nsIDOMEventListener *aListener, const nsIID& aIID, PRInt32 aFlags, PRInt32 aSubType);
|
||||
nsresult RemoveEventListener(nsIDOMEventListener *aListener, const nsIID& aIID, PRInt32 aFlags, PRInt32 aSubType);
|
||||
nsresult AddEventListener(nsIDOMEventListener *aListener,
|
||||
EventArrayType aType,
|
||||
PRInt32 aSubType,
|
||||
nsHashKey* aKey,
|
||||
PRInt32 aFlags);
|
||||
nsresult RemoveEventListener(nsIDOMEventListener *aListener,
|
||||
EventArrayType aType,
|
||||
PRInt32 aSubType,
|
||||
nsHashKey* aKey,
|
||||
PRInt32 aFlags);
|
||||
void ReleaseListeners(nsVoidArray** aListeners, PRBool aScriptOnly);
|
||||
nsresult FlipCaptureBit(PRInt32 aEventTypes, PRBool aInitCapture);
|
||||
nsVoidArray* GetListenersByType(EventArrayType aType, nsHashKey* aKey, PRBool aCreate);
|
||||
EventArrayType GetTypeForIID(const nsIID& aIID);
|
||||
|
||||
nsVoidArray* mEventListeners;
|
||||
nsVoidArray* mMouseListeners;
|
||||
nsVoidArray* mMouseMotionListeners;
|
||||
nsVoidArray* mContextMenuListeners;
|
||||
nsVoidArray* mKeyListeners;
|
||||
nsVoidArray* mLoadListeners;
|
||||
nsVoidArray* mFocusListeners;
|
||||
nsVoidArray* mFormListeners;
|
||||
nsVoidArray* mDragListeners;
|
||||
nsVoidArray* mPaintListeners;
|
||||
nsVoidArray* mTextListeners;
|
||||
nsVoidArray* mCompositionListeners;
|
||||
nsVoidArray* mMenuListeners;
|
||||
nsVoidArray* mScrollListeners;
|
||||
nsVoidArray* mMutationListeners;
|
||||
PRUint8 mManagerType;
|
||||
EventArrayType mSingleListenerType;
|
||||
nsVoidArray* mSingleListener;
|
||||
nsVoidArray* mMultiListeners;
|
||||
nsHashtable* mGenericListeners;
|
||||
PRBool mListenersRemoved;
|
||||
|
||||
nsCOMPtr<nsIPrincipal> mPrincipal;
|
||||
PRBool mDestroyed;
|
||||
|
||||
nsISupports* mTarget; //WEAK
|
||||
};
|
||||
|
||||
|
|
|
@ -501,6 +501,7 @@ NS_IMETHODIMP GlobalWindowImpl::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
nsEventStatus* aEventStatus)
|
||||
{
|
||||
nsresult ret = NS_OK;
|
||||
PRBool externalDOMEvent = PR_FALSE;
|
||||
nsIDOMEvent *domEvent = nsnull;
|
||||
|
||||
/* mChromeEventHandler and mContext go dangling in the middle of this
|
||||
|
@ -528,7 +529,12 @@ NS_IMETHODIMP GlobalWindowImpl::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
}
|
||||
|
||||
if (NS_EVENT_FLAG_INIT & aFlags) {
|
||||
if (!aDOMEvent) {
|
||||
if (aDOMEvent) {
|
||||
if (*aDOMEvent) {
|
||||
externalDOMEvent = PR_TRUE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
aDOMEvent = &domEvent;
|
||||
}
|
||||
aEvent->flags = aFlags;
|
||||
|
@ -584,7 +590,7 @@ NS_IMETHODIMP GlobalWindowImpl::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
|
||||
if (NS_EVENT_FLAG_INIT & aFlags) {
|
||||
// We're leaving the DOM event loop so if we created an event, release here.
|
||||
if (*aDOMEvent) {
|
||||
if (*aDOMEvent && !externalDOMEvent) {
|
||||
nsrefcnt rc;
|
||||
NS_RELEASE2(*aDOMEvent, rc);
|
||||
if (rc) {
|
||||
|
@ -596,8 +602,8 @@ NS_IMETHODIMP GlobalWindowImpl::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
if (privateEvent)
|
||||
privateEvent->DuplicatePrivateData();
|
||||
}
|
||||
aDOMEvent = nsnull;
|
||||
}
|
||||
aDOMEvent = nsnull;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
#include "nsPoint.h"
|
||||
#include "nsRect.h"
|
||||
#include "nsHashtable.h"
|
||||
|
||||
// nsIDOMEvent contains a long enum which includes a member called ERROR,
|
||||
// which conflicts with something that Windows defines somewhere.
|
||||
|
@ -90,6 +91,8 @@ struct nsEvent {
|
|||
PRUint32 flags;
|
||||
// flags for indicating more event state for Mozilla applications.
|
||||
PRUint32 internalAppFlags;
|
||||
// additional type info for user defined events
|
||||
nsHashKey* userType;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -465,10 +468,13 @@ enum nsDragDropEventStatus {
|
|||
#define NS_SCROLLPORT_OVERFLOW (NS_SCROLLPORT_START+1)
|
||||
#define NS_SCROLLPORT_OVERFLOWCHANGED (NS_SCROLLPORT_START+2)
|
||||
|
||||
// Mutation events defined elsewhere starting at 1800
|
||||
|
||||
// accessible events
|
||||
#define NS_ACCESSIBLE_START 1800
|
||||
#define NS_ACCESSIBLE_START 1900
|
||||
#define NS_GETACCESSIBLE (NS_ACCESSIBLE_START)
|
||||
|
||||
#define NS_USER_DEFINED_EVENT 2000
|
||||
|
||||
#define NS_IS_MOUSE_EVENT(evnt) \
|
||||
(((evnt)->message == NS_MOUSE_LEFT_BUTTON_DOWN) || \
|
||||
|
|
Загрузка…
Ссылка в новой задаче