зеркало из https://github.com/mozilla/pjs.git
exposing drag and drop events to JS.
This commit is contained in:
Родитель
904643ebc5
Коммит
ac764c05e8
|
@ -45,7 +45,8 @@ 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) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -45,7 +45,8 @@ 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) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Загрузка…
Ссылка в новой задаче