diff --git a/content/events/src/nsDOMEvent.cpp b/content/events/src/nsDOMEvent.cpp index 3984ef9654e..17949c60851 100644 --- a/content/events/src/nsDOMEvent.cpp +++ b/content/events/src/nsDOMEvent.cpp @@ -50,8 +50,8 @@ static char* mEventNames[] = { "mouseout", "mousemove", "keydown", "keyup", "keypress", "focus", "blur", "load", "unload", "abort", "error", "submit", "reset", "change", "select", "input", "paint" ,"text", - "create", "destroy", "command", "broadcast", "commandupdate", "dragenter", "dragover", "dragexit", - "dragdrop", "draggesture" + "create", "close", "destroy", "command", "broadcast", "commandupdate", + "dragenter", "dragover", "dragexit", "dragdrop", "draggesture" }; nsDOMEvent::nsDOMEvent(nsIPresContext* aPresContext, nsEvent* aEvent) { @@ -855,6 +855,8 @@ const char* nsDOMEvent::GetEventName(PRUint32 aEventType) return mEventNames[eDOMEvents_focus]; case NS_BLUR_CONTENT: return mEventNames[eDOMEvents_blur]; + case NS_XUL_CLOSE: + return mEventNames[eDOMEvents_close]; case NS_PAGE_LOAD: case NS_IMAGE_LOAD: return mEventNames[eDOMEvents_load]; diff --git a/content/events/src/nsDOMEvent.h b/content/events/src/nsDOMEvent.h index 1b564253cb8..decc8be1f40 100644 --- a/content/events/src/nsDOMEvent.h +++ b/content/events/src/nsDOMEvent.h @@ -70,8 +70,9 @@ public: eDOMEvents_select, eDOMEvents_input, eDOMEvents_paint, - eDOMEvents_text, + eDOMEvents_text, eDOMEvents_create, + eDOMEvents_close, eDOMEvents_destroy, eDOMEvents_command, eDOMEvents_broadcast, diff --git a/content/events/src/nsEventListenerManager.cpp b/content/events/src/nsEventListenerManager.cpp index c96aa2f2608..d12ca2aa7b8 100644 --- a/content/events/src/nsEventListenerManager.cpp +++ b/content/events/src/nsEventListenerManager.cpp @@ -388,6 +388,10 @@ nsresult nsEventListenerManager::GetIdentifiersForType(nsIAtom* aType, nsIID& aI aIID = kIDOMMenuListenerIID; *aFlags = NS_EVENT_BITS_MENU_CREATE; } + else if (aType == nsLayoutAtoms::onclose) { + aIID = kIDOMMenuListenerIID; + *aFlags = NS_EVENT_BITS_XUL_CLOSE; + } else if (aType == nsLayoutAtoms::ondestroy) { aIID = kIDOMMenuListenerIID; *aFlags = NS_EVENT_BITS_MENU_DESTROY; @@ -1268,6 +1272,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext* aPresContext, break; case NS_MENU_CREATE: + case NS_XUL_CLOSE: case NS_MENU_DESTROY: case NS_MENU_ACTION: case NS_XUL_BROADCAST: @@ -1289,6 +1294,9 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext* aPresContext, case NS_MENU_CREATE: ret = mMenuListener->Create(*aDOMEvent); break; + case NS_XUL_CLOSE: + ret = mMenuListener->Close(*aDOMEvent); + break; case NS_MENU_DESTROY: ret = mMenuListener->Destroy(*aDOMEvent); break; @@ -1316,6 +1324,12 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext* aPresContext, correctSubType = PR_TRUE; } break; + case NS_XUL_CLOSE: + subType = NS_EVENT_BITS_XUL_CLOSE; + if (ls->mSubType & NS_EVENT_BITS_XUL_CLOSE) { + correctSubType = PR_TRUE; + } + break; case NS_MENU_DESTROY: subType = NS_EVENT_BITS_MENU_DESTROY; if (ls->mSubType & NS_EVENT_BITS_MENU_DESTROY) { diff --git a/content/events/src/nsEventListenerManager.h b/content/events/src/nsEventListenerManager.h index c47d9307fe1..c1773290be1 100644 --- a/content/events/src/nsEventListenerManager.h +++ b/content/events/src/nsEventListenerManager.h @@ -184,10 +184,11 @@ protected: //nsIDOMMenuListener #define NS_EVENT_BITS_MENU_NONE 0x00 #define NS_EVENT_BITS_MENU_CREATE 0x01 -#define NS_EVENT_BITS_MENU_DESTROY 0x02 -#define NS_EVENT_BITS_MENU_ACTION 0x04 -#define NS_EVENT_BITS_XUL_BROADCAST 0x08 -#define NS_EVENT_BITS_XUL_COMMAND_UPDATE 0x10 +#define NS_EVENT_BITS_XUL_CLOSE 0x02 +#define NS_EVENT_BITS_MENU_DESTROY 0x04 +#define NS_EVENT_BITS_MENU_ACTION 0x08 +#define NS_EVENT_BITS_XUL_BROADCAST 0x10 +#define NS_EVENT_BITS_XUL_COMMAND_UPDATE 0x20 //nsIDOMDragListener #define NS_EVENT_BITS_DRAG_NONE 0x00 diff --git a/content/shared/public/nsLayoutAtomList.h b/content/shared/public/nsLayoutAtomList.h index c374090684f..110cfc6213e 100644 --- a/content/shared/public/nsLayoutAtomList.h +++ b/content/shared/public/nsLayoutAtomList.h @@ -117,6 +117,7 @@ LAYOUT_ATOM(onblur, "onblur") LAYOUT_ATOM(onbroadcast, "onbroadcast") LAYOUT_ATOM(onchange, "onchange") LAYOUT_ATOM(onclick, "onclick") +LAYOUT_ATOM(onclose, "onclose") LAYOUT_ATOM(oncommand, "oncommand") LAYOUT_ATOM(oncommandupdate, "oncommandupdate") LAYOUT_ATOM(oncreate, "oncreate") diff --git a/content/xul/templates/src/nsXULContentUtils.cpp b/content/xul/templates/src/nsXULContentUtils.cpp index 4f484dab68e..f5353745c92 100644 --- a/content/xul/templates/src/nsXULContentUtils.cpp +++ b/content/xul/templates/src/nsXULContentUtils.cpp @@ -206,6 +206,7 @@ nsXULContentUtils::kEventHandlerMap[] = { { "onerror", nsnull, &NS_GET_IID(nsIDOMLoadListener) }, { "oncreate", nsnull, &NS_GET_IID(nsIDOMMenuListener) }, + { "onclose", nsnull, &NS_GET_IID(nsIDOMMenuListener) }, { "ondestroy", nsnull, &NS_GET_IID(nsIDOMMenuListener) }, { "oncommand", nsnull, &NS_GET_IID(nsIDOMMenuListener) }, { "onbroadcast", nsnull, &NS_GET_IID(nsIDOMMenuListener) }, diff --git a/dom/public/coreEvents/nsIDOMMenuListener.h b/dom/public/coreEvents/nsIDOMMenuListener.h index 3e24118821c..48ee1780ca4 100644 --- a/dom/public/coreEvents/nsIDOMMenuListener.h +++ b/dom/public/coreEvents/nsIDOMMenuListener.h @@ -37,6 +37,7 @@ public: NS_DEFINE_STATIC_IID_ACCESSOR(NS_IDOMMENULISTENER_IID) NS_IMETHOD Create(nsIDOMEvent* aEvent) = 0; + NS_IMETHOD Close(nsIDOMEvent* aEvent) = 0; NS_IMETHOD Destroy(nsIDOMEvent* aEvent) = 0; NS_IMETHOD Action(nsIDOMEvent* aEvent) = 0; NS_IMETHOD Broadcast(nsIDOMEvent* aEvent) = 0; diff --git a/dom/src/base/nsGlobalWindow.cpp b/dom/src/base/nsGlobalWindow.cpp index f3df82116f9..a4591af7452 100644 --- a/dom/src/base/nsGlobalWindow.cpp +++ b/dom/src/base/nsGlobalWindow.cpp @@ -2696,8 +2696,8 @@ GlobalWindowImpl::CheckForEventListener(JSContext *aContext, nsString& aPropName } } } - else if (aPropName == "onload" || aPropName == "onunload" || aPropName == "onabort" || - aPropName == "onerror") { + else if (aPropName == "onload" || aPropName == "onunload" || aPropName == "onclose" || + aPropName == "onabort" || aPropName == "onerror") { if (NS_OK == GetListenerManager(&mManager)) { nsIScriptContext *mScriptCX = (nsIScriptContext *)JS_GetContextPrivate(aContext); if (NS_OK != mManager->RegisterScriptEventListener(mScriptCX, this, atom, kIDOMLoadListenerIID)) { diff --git a/layout/base/nsLayoutAtomList.h b/layout/base/nsLayoutAtomList.h index c374090684f..110cfc6213e 100644 --- a/layout/base/nsLayoutAtomList.h +++ b/layout/base/nsLayoutAtomList.h @@ -117,6 +117,7 @@ LAYOUT_ATOM(onblur, "onblur") LAYOUT_ATOM(onbroadcast, "onbroadcast") LAYOUT_ATOM(onchange, "onchange") LAYOUT_ATOM(onclick, "onclick") +LAYOUT_ATOM(onclose, "onclose") LAYOUT_ATOM(oncommand, "oncommand") LAYOUT_ATOM(oncommandupdate, "oncommandupdate") LAYOUT_ATOM(oncreate, "oncreate") diff --git a/layout/base/public/nsLayoutAtomList.h b/layout/base/public/nsLayoutAtomList.h index c374090684f..110cfc6213e 100644 --- a/layout/base/public/nsLayoutAtomList.h +++ b/layout/base/public/nsLayoutAtomList.h @@ -117,6 +117,7 @@ LAYOUT_ATOM(onblur, "onblur") LAYOUT_ATOM(onbroadcast, "onbroadcast") LAYOUT_ATOM(onchange, "onchange") LAYOUT_ATOM(onclick, "onclick") +LAYOUT_ATOM(onclose, "onclose") LAYOUT_ATOM(oncommand, "oncommand") LAYOUT_ATOM(oncommandupdate, "oncommandupdate") LAYOUT_ATOM(oncreate, "oncreate") diff --git a/layout/events/src/nsDOMEvent.cpp b/layout/events/src/nsDOMEvent.cpp index 3984ef9654e..17949c60851 100644 --- a/layout/events/src/nsDOMEvent.cpp +++ b/layout/events/src/nsDOMEvent.cpp @@ -50,8 +50,8 @@ static char* mEventNames[] = { "mouseout", "mousemove", "keydown", "keyup", "keypress", "focus", "blur", "load", "unload", "abort", "error", "submit", "reset", "change", "select", "input", "paint" ,"text", - "create", "destroy", "command", "broadcast", "commandupdate", "dragenter", "dragover", "dragexit", - "dragdrop", "draggesture" + "create", "close", "destroy", "command", "broadcast", "commandupdate", + "dragenter", "dragover", "dragexit", "dragdrop", "draggesture" }; nsDOMEvent::nsDOMEvent(nsIPresContext* aPresContext, nsEvent* aEvent) { @@ -855,6 +855,8 @@ const char* nsDOMEvent::GetEventName(PRUint32 aEventType) return mEventNames[eDOMEvents_focus]; case NS_BLUR_CONTENT: return mEventNames[eDOMEvents_blur]; + case NS_XUL_CLOSE: + return mEventNames[eDOMEvents_close]; case NS_PAGE_LOAD: case NS_IMAGE_LOAD: return mEventNames[eDOMEvents_load]; diff --git a/layout/events/src/nsDOMEvent.h b/layout/events/src/nsDOMEvent.h index 1b564253cb8..decc8be1f40 100644 --- a/layout/events/src/nsDOMEvent.h +++ b/layout/events/src/nsDOMEvent.h @@ -70,8 +70,9 @@ public: eDOMEvents_select, eDOMEvents_input, eDOMEvents_paint, - eDOMEvents_text, + eDOMEvents_text, eDOMEvents_create, + eDOMEvents_close, eDOMEvents_destroy, eDOMEvents_command, eDOMEvents_broadcast, diff --git a/layout/events/src/nsEventListenerManager.cpp b/layout/events/src/nsEventListenerManager.cpp index c96aa2f2608..d12ca2aa7b8 100644 --- a/layout/events/src/nsEventListenerManager.cpp +++ b/layout/events/src/nsEventListenerManager.cpp @@ -388,6 +388,10 @@ nsresult nsEventListenerManager::GetIdentifiersForType(nsIAtom* aType, nsIID& aI aIID = kIDOMMenuListenerIID; *aFlags = NS_EVENT_BITS_MENU_CREATE; } + else if (aType == nsLayoutAtoms::onclose) { + aIID = kIDOMMenuListenerIID; + *aFlags = NS_EVENT_BITS_XUL_CLOSE; + } else if (aType == nsLayoutAtoms::ondestroy) { aIID = kIDOMMenuListenerIID; *aFlags = NS_EVENT_BITS_MENU_DESTROY; @@ -1268,6 +1272,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext* aPresContext, break; case NS_MENU_CREATE: + case NS_XUL_CLOSE: case NS_MENU_DESTROY: case NS_MENU_ACTION: case NS_XUL_BROADCAST: @@ -1289,6 +1294,9 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext* aPresContext, case NS_MENU_CREATE: ret = mMenuListener->Create(*aDOMEvent); break; + case NS_XUL_CLOSE: + ret = mMenuListener->Close(*aDOMEvent); + break; case NS_MENU_DESTROY: ret = mMenuListener->Destroy(*aDOMEvent); break; @@ -1316,6 +1324,12 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext* aPresContext, correctSubType = PR_TRUE; } break; + case NS_XUL_CLOSE: + subType = NS_EVENT_BITS_XUL_CLOSE; + if (ls->mSubType & NS_EVENT_BITS_XUL_CLOSE) { + correctSubType = PR_TRUE; + } + break; case NS_MENU_DESTROY: subType = NS_EVENT_BITS_MENU_DESTROY; if (ls->mSubType & NS_EVENT_BITS_MENU_DESTROY) { diff --git a/layout/events/src/nsEventListenerManager.h b/layout/events/src/nsEventListenerManager.h index c47d9307fe1..c1773290be1 100644 --- a/layout/events/src/nsEventListenerManager.h +++ b/layout/events/src/nsEventListenerManager.h @@ -184,10 +184,11 @@ protected: //nsIDOMMenuListener #define NS_EVENT_BITS_MENU_NONE 0x00 #define NS_EVENT_BITS_MENU_CREATE 0x01 -#define NS_EVENT_BITS_MENU_DESTROY 0x02 -#define NS_EVENT_BITS_MENU_ACTION 0x04 -#define NS_EVENT_BITS_XUL_BROADCAST 0x08 -#define NS_EVENT_BITS_XUL_COMMAND_UPDATE 0x10 +#define NS_EVENT_BITS_XUL_CLOSE 0x02 +#define NS_EVENT_BITS_MENU_DESTROY 0x04 +#define NS_EVENT_BITS_MENU_ACTION 0x08 +#define NS_EVENT_BITS_XUL_BROADCAST 0x10 +#define NS_EVENT_BITS_XUL_COMMAND_UPDATE 0x20 //nsIDOMDragListener #define NS_EVENT_BITS_DRAG_NONE 0x00 diff --git a/rdf/content/src/nsXULContentUtils.cpp b/rdf/content/src/nsXULContentUtils.cpp index 4f484dab68e..f5353745c92 100644 --- a/rdf/content/src/nsXULContentUtils.cpp +++ b/rdf/content/src/nsXULContentUtils.cpp @@ -206,6 +206,7 @@ nsXULContentUtils::kEventHandlerMap[] = { { "onerror", nsnull, &NS_GET_IID(nsIDOMLoadListener) }, { "oncreate", nsnull, &NS_GET_IID(nsIDOMMenuListener) }, + { "onclose", nsnull, &NS_GET_IID(nsIDOMMenuListener) }, { "ondestroy", nsnull, &NS_GET_IID(nsIDOMMenuListener) }, { "oncommand", nsnull, &NS_GET_IID(nsIDOMMenuListener) }, { "onbroadcast", nsnull, &NS_GET_IID(nsIDOMMenuListener) }, diff --git a/widget/public/nsGUIEvent.h b/widget/public/nsGUIEvent.h index 6f8d8dfa41c..b3c27cb5e46 100644 --- a/widget/public/nsGUIEvent.h +++ b/widget/public/nsGUIEvent.h @@ -244,18 +244,20 @@ enum nsDragDropEventStatus { // Widget is being created #define NS_CREATE (NS_WINDOW_START) +// Widget may be destroyed +#define NS_XUL_CLOSE (NS_WINDOW_START + 1) // Widget is being destroyed -#define NS_DESTROY (NS_WINDOW_START + 1) +#define NS_DESTROY (NS_WINDOW_START + 2) // Widget was resized -#define NS_SIZE (NS_WINDOW_START + 2) +#define NS_SIZE (NS_WINDOW_START + 3) // Widget gained focus -#define NS_GOTFOCUS (NS_WINDOW_START + 3) +#define NS_GOTFOCUS (NS_WINDOW_START + 4) // Widget lost focus -#define NS_LOSTFOCUS (NS_WINDOW_START + 4) +#define NS_LOSTFOCUS (NS_WINDOW_START + 5) // Widget got activated -#define NS_ACTIVATE (NS_WINDOW_START + 5) +#define NS_ACTIVATE (NS_WINDOW_START + 6) // Widget got deactivated -#define NS_DEACTIVATE (NS_WINDOW_START + 6) +#define NS_DEACTIVATE (NS_WINDOW_START + 7) // Widget needs to be repainted #define NS_PAINT (NS_WINDOW_START + 30) // Key is pressed within a window