From e58a5c3434ba6638327521b8d68c24ee49dc91a2 Mon Sep 17 00:00:00 2001 From: "pinkerton%netscape.com" Date: Thu, 2 Sep 1999 03:51:03 +0000 Subject: [PATCH] exposing drag and drop events to JS. --- content/events/src/nsDOMEvent.cpp | 15 +++++- content/events/src/nsDOMEvent.h | 7 ++- content/events/src/nsEventListenerManager.cpp | 48 ++++++++++++++++++- content/events/src/nsEventListenerManager.h | 7 ++- layout/events/src/nsDOMEvent.cpp | 15 +++++- layout/events/src/nsDOMEvent.h | 7 ++- layout/events/src/nsEventListenerManager.cpp | 48 ++++++++++++++++++- layout/events/src/nsEventListenerManager.h | 7 ++- 8 files changed, 142 insertions(+), 12 deletions(-) diff --git a/content/events/src/nsDOMEvent.cpp b/content/events/src/nsDOMEvent.cpp index 2d929c0aa425..96af8c01f475 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 dcbc865123a6..1c640b3a2a89 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 9c02cb960fb6..03913bc4bd9d 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 b1a6cf6b452a..83f1c5f80587 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 2d929c0aa425..96af8c01f475 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 dcbc865123a6..1c640b3a2a89 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 9c02cb960fb6..03913bc4bd9d 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 b1a6cf6b452a..83f1c5f80587 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