diff --git a/content/events/src/nsDOMEvent.cpp b/content/events/src/nsDOMEvent.cpp index 2d929c0aa42..96af8c01f47 100644 --- a/content/events/src/nsDOMEvent.cpp +++ b/content/events/src/nsDOMEvent.cpp @@ -45,8 +45,9 @@ static char* mEventNames[] = { "mouseout", "mousemove", "keydown", "keyup", "keypress", "focus", "blur", "load", "unload", "abort", "error", "submit", "reset", "change", "select", "paint" ,"text", - "create", "destroy", "command" -}; + "create", "destroy", "command", "dragenter", "dragover", "dragexit", + "dragdrop", "draggesture" +}; nsDOMEvent::nsDOMEvent(nsIPresContext* aPresContext, nsEvent* aEvent) { mPresContext = aPresContext; @@ -680,6 +681,16 @@ const char* nsDOMEvent::GetEventName(PRUint32 aEventType) return mEventNames[eDOMEvents_destroy]; case NS_MENU_ACTION: return mEventNames[eDOMEvents_action]; + case NS_DRAGDROP_ENTER: + return mEventNames[eDOMEvents_dragenter]; + case NS_DRAGDROP_OVER: + return mEventNames[eDOMEvents_dragover]; + case NS_DRAGDROP_EXIT: + return mEventNames[eDOMEvents_dragexit]; + case NS_DRAGDROP_DROP: + return mEventNames[eDOMEvents_dragdrop]; + case NS_DRAGDROP_GESTURE: + return mEventNames[eDOMEvents_draggesture]; default: break; } diff --git a/content/events/src/nsDOMEvent.h b/content/events/src/nsDOMEvent.h index dcbc865123a..1c640b3a2a8 100644 --- a/content/events/src/nsDOMEvent.h +++ b/content/events/src/nsDOMEvent.h @@ -61,7 +61,12 @@ public: eDOMEvents_text, eDOMEvents_create, eDOMEvents_destroy, - eDOMEvents_action + eDOMEvents_action, + eDOMEvents_dragenter, + eDOMEvents_dragover, + eDOMEvents_dragexit, + eDOMEvents_dragdrop, + eDOMEvents_draggesture }; nsDOMEvent(nsIPresContext* aPresContext, nsEvent* aEvent); diff --git a/content/events/src/nsEventListenerManager.cpp b/content/events/src/nsEventListenerManager.cpp index 9c02cb960fb..03913bc4bd9 100644 --- a/content/events/src/nsEventListenerManager.cpp +++ b/content/events/src/nsEventListenerManager.cpp @@ -366,6 +366,26 @@ nsresult nsEventListenerManager::GetIdentifiersForType(const nsString& aType, ns aIID = kIDOMMenuListenerIID; *aFlags = NS_EVENT_BITS_MENU_ACTION; } + else if (aType == "dragenter") { + aIID = NS_GET_IID(nsIDOMDragListener); + *aFlags = NS_EVENT_BITS_DRAG_ENTER; + } + else if (aType == "dragover") { + aIID = NS_GET_IID(nsIDOMDragListener); + *aFlags = NS_EVENT_BITS_DRAG_OVER; + } + else if (aType == "dragexit") { + aIID = NS_GET_IID(nsIDOMDragListener); + *aFlags = NS_EVENT_BITS_DRAG_EXIT; + } + else if (aType == "dragdrop") { + aIID = NS_GET_IID(nsIDOMDragListener); + *aFlags = NS_EVENT_BITS_DRAG_DROP; + } + else if (aType == "draggesture") { + aIID = NS_GET_IID(nsIDOMDragListener); + *aFlags = NS_EVENT_BITS_DRAG_GESTURE; + } else { return NS_ERROR_FAILURE; } @@ -1049,7 +1069,33 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext& aPresContext, NS_RELEASE(dragListener); } else { - ret = ls->mListener->HandleEvent(*aDOMEvent); + PRBool correctSubType = PR_FALSE; + switch(aEvent->message) { + case NS_DRAGDROP_ENTER: + if (ls->mSubType & NS_EVENT_BITS_DRAG_ENTER) + correctSubType = PR_TRUE; + break; + case NS_DRAGDROP_OVER: + if (ls->mSubType & NS_EVENT_BITS_DRAG_OVER) + correctSubType = PR_TRUE; + break; + case NS_DRAGDROP_EXIT: + if (ls->mSubType & NS_EVENT_BITS_DRAG_EXIT) + correctSubType = PR_TRUE; + break; + case NS_DRAGDROP_DROP: + if (ls->mSubType & NS_EVENT_BITS_DRAG_DROP) + correctSubType = PR_TRUE; + break; + case NS_DRAGDROP_GESTURE: + if (ls->mSubType & NS_EVENT_BITS_DRAG_GESTURE) + correctSubType = PR_TRUE; + break; + default: + break; + } + if (correctSubType || ls->mSubType == NS_EVENT_BITS_DRAG_NONE) + ret = ls->mListener->HandleEvent(*aDOMEvent); } } } diff --git a/content/events/src/nsEventListenerManager.h b/content/events/src/nsEventListenerManager.h index b1a6cf6b452..83f1c5f8058 100644 --- a/content/events/src/nsEventListenerManager.h +++ b/content/events/src/nsEventListenerManager.h @@ -172,8 +172,11 @@ protected: //nsIDOMDragListener #define NS_EVENT_BITS_DRAG_NONE 0x00 -#define NS_EVENT_BITS_DRAG_START 0x01 -#define NS_EVENT_BITS_DRAG_DROP 0x02 +#define NS_EVENT_BITS_DRAG_ENTER 0x01 +#define NS_EVENT_BITS_DRAG_OVER 0x02 +#define NS_EVENT_BITS_DRAG_EXIT 0x04 +#define NS_EVENT_BITS_DRAG_DROP 0x08 +#define NS_EVENT_BITS_DRAG_GESTURE 0x10 //nsIDOMPaintListener #define NS_EVENT_BITS_PAINT_NONE 0x00 diff --git a/layout/events/src/nsDOMEvent.cpp b/layout/events/src/nsDOMEvent.cpp index 2d929c0aa42..96af8c01f47 100644 --- a/layout/events/src/nsDOMEvent.cpp +++ b/layout/events/src/nsDOMEvent.cpp @@ -45,8 +45,9 @@ static char* mEventNames[] = { "mouseout", "mousemove", "keydown", "keyup", "keypress", "focus", "blur", "load", "unload", "abort", "error", "submit", "reset", "change", "select", "paint" ,"text", - "create", "destroy", "command" -}; + "create", "destroy", "command", "dragenter", "dragover", "dragexit", + "dragdrop", "draggesture" +}; nsDOMEvent::nsDOMEvent(nsIPresContext* aPresContext, nsEvent* aEvent) { mPresContext = aPresContext; @@ -680,6 +681,16 @@ const char* nsDOMEvent::GetEventName(PRUint32 aEventType) return mEventNames[eDOMEvents_destroy]; case NS_MENU_ACTION: return mEventNames[eDOMEvents_action]; + case NS_DRAGDROP_ENTER: + return mEventNames[eDOMEvents_dragenter]; + case NS_DRAGDROP_OVER: + return mEventNames[eDOMEvents_dragover]; + case NS_DRAGDROP_EXIT: + return mEventNames[eDOMEvents_dragexit]; + case NS_DRAGDROP_DROP: + return mEventNames[eDOMEvents_dragdrop]; + case NS_DRAGDROP_GESTURE: + return mEventNames[eDOMEvents_draggesture]; default: break; } diff --git a/layout/events/src/nsDOMEvent.h b/layout/events/src/nsDOMEvent.h index dcbc865123a..1c640b3a2a8 100644 --- a/layout/events/src/nsDOMEvent.h +++ b/layout/events/src/nsDOMEvent.h @@ -61,7 +61,12 @@ public: eDOMEvents_text, eDOMEvents_create, eDOMEvents_destroy, - eDOMEvents_action + eDOMEvents_action, + eDOMEvents_dragenter, + eDOMEvents_dragover, + eDOMEvents_dragexit, + eDOMEvents_dragdrop, + eDOMEvents_draggesture }; nsDOMEvent(nsIPresContext* aPresContext, nsEvent* aEvent); diff --git a/layout/events/src/nsEventListenerManager.cpp b/layout/events/src/nsEventListenerManager.cpp index 9c02cb960fb..03913bc4bd9 100644 --- a/layout/events/src/nsEventListenerManager.cpp +++ b/layout/events/src/nsEventListenerManager.cpp @@ -366,6 +366,26 @@ nsresult nsEventListenerManager::GetIdentifiersForType(const nsString& aType, ns aIID = kIDOMMenuListenerIID; *aFlags = NS_EVENT_BITS_MENU_ACTION; } + else if (aType == "dragenter") { + aIID = NS_GET_IID(nsIDOMDragListener); + *aFlags = NS_EVENT_BITS_DRAG_ENTER; + } + else if (aType == "dragover") { + aIID = NS_GET_IID(nsIDOMDragListener); + *aFlags = NS_EVENT_BITS_DRAG_OVER; + } + else if (aType == "dragexit") { + aIID = NS_GET_IID(nsIDOMDragListener); + *aFlags = NS_EVENT_BITS_DRAG_EXIT; + } + else if (aType == "dragdrop") { + aIID = NS_GET_IID(nsIDOMDragListener); + *aFlags = NS_EVENT_BITS_DRAG_DROP; + } + else if (aType == "draggesture") { + aIID = NS_GET_IID(nsIDOMDragListener); + *aFlags = NS_EVENT_BITS_DRAG_GESTURE; + } else { return NS_ERROR_FAILURE; } @@ -1049,7 +1069,33 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext& aPresContext, NS_RELEASE(dragListener); } else { - ret = ls->mListener->HandleEvent(*aDOMEvent); + PRBool correctSubType = PR_FALSE; + switch(aEvent->message) { + case NS_DRAGDROP_ENTER: + if (ls->mSubType & NS_EVENT_BITS_DRAG_ENTER) + correctSubType = PR_TRUE; + break; + case NS_DRAGDROP_OVER: + if (ls->mSubType & NS_EVENT_BITS_DRAG_OVER) + correctSubType = PR_TRUE; + break; + case NS_DRAGDROP_EXIT: + if (ls->mSubType & NS_EVENT_BITS_DRAG_EXIT) + correctSubType = PR_TRUE; + break; + case NS_DRAGDROP_DROP: + if (ls->mSubType & NS_EVENT_BITS_DRAG_DROP) + correctSubType = PR_TRUE; + break; + case NS_DRAGDROP_GESTURE: + if (ls->mSubType & NS_EVENT_BITS_DRAG_GESTURE) + correctSubType = PR_TRUE; + break; + default: + break; + } + if (correctSubType || ls->mSubType == NS_EVENT_BITS_DRAG_NONE) + ret = ls->mListener->HandleEvent(*aDOMEvent); } } } diff --git a/layout/events/src/nsEventListenerManager.h b/layout/events/src/nsEventListenerManager.h index b1a6cf6b452..83f1c5f8058 100644 --- a/layout/events/src/nsEventListenerManager.h +++ b/layout/events/src/nsEventListenerManager.h @@ -172,8 +172,11 @@ protected: //nsIDOMDragListener #define NS_EVENT_BITS_DRAG_NONE 0x00 -#define NS_EVENT_BITS_DRAG_START 0x01 -#define NS_EVENT_BITS_DRAG_DROP 0x02 +#define NS_EVENT_BITS_DRAG_ENTER 0x01 +#define NS_EVENT_BITS_DRAG_OVER 0x02 +#define NS_EVENT_BITS_DRAG_EXIT 0x04 +#define NS_EVENT_BITS_DRAG_DROP 0x08 +#define NS_EVENT_BITS_DRAG_GESTURE 0x10 //nsIDOMPaintListener #define NS_EVENT_BITS_PAINT_NONE 0x00