Bug 664058: Remove Add/RemoveEventListenerByIID from nsXULPopupManager. r=smaug

This commit is contained in:
Jonas Sicking 2011-06-29 11:07:48 -07:00
Родитель 4441608eb1
Коммит 38dc6d21c4
2 изменённых файлов: 40 добавлений и 14 удалений

Просмотреть файл

@ -46,7 +46,7 @@
#include "nsIContent.h"
#include "nsIRollupListener.h"
#include "nsIMenuRollup.h"
#include "nsIDOMKeyListener.h"
#include "nsIDOMEventListener.h"
#include "nsPoint.h"
#include "nsCOMPtr.h"
#include "nsTArray.h"
@ -55,6 +55,11 @@
#include "nsThreadUtils.h"
#include "nsStyleConsts.h"
// X.h defines KeyPress
#ifdef KeyPress
#undef KeyPress
#endif
/**
* There are two types that are used:
* - dismissable popups such as menus, which should close up when there is a
@ -296,7 +301,7 @@ private:
CloseMenuMode mCloseMenuMode;
};
class nsXULPopupManager : public nsIDOMKeyListener,
class nsXULPopupManager : public nsIDOMEventListener,
public nsIMenuRollup,
public nsIRollupListener,
public nsITimerCallback,
@ -311,6 +316,7 @@ public:
NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER
NS_DECL_NSITIMERCALLBACK
NS_DECL_NSIDOMEVENTLISTENER
// nsIRollupListener
NS_IMETHOD Rollup(PRUint32 aCount, nsIContent **aContent);
@ -622,11 +628,9 @@ public:
return HandleKeyboardNavigationInPopup(nsnull, aFrame, aDir);
}
NS_IMETHODIMP HandleEvent(nsIDOMEvent* aEvent) { return NS_OK; }
NS_IMETHOD KeyUp(nsIDOMEvent* aKeyEvent);
NS_IMETHOD KeyDown(nsIDOMEvent* aKeyEvent);
NS_IMETHOD KeyPress(nsIDOMEvent* aKeyEvent);
nsresult KeyUp(nsIDOMKeyEvent* aKeyEvent);
nsresult KeyDown(nsIDOMKeyEvent* aKeyEvent);
nsresult KeyPress(nsIDOMKeyEvent* aKeyEvent);
protected:
nsXULPopupManager();

Просмотреть файл

@ -131,8 +131,7 @@ void nsMenuChainItem::Detach(nsMenuChainItem** aRoot)
}
}
NS_IMPL_ISUPPORTS5(nsXULPopupManager,
nsIDOMKeyListener,
NS_IMPL_ISUPPORTS4(nsXULPopupManager,
nsIDOMEventListener,
nsIMenuRollup,
nsITimerCallback,
@ -2073,7 +2072,30 @@ nsXULPopupManager::IsValidMenuItem(nsPresContext* aPresContext,
}
nsresult
nsXULPopupManager::KeyUp(nsIDOMEvent* aKeyEvent)
nsXULPopupManager::HandleEvent(nsIDOMEvent* aEvent)
{
nsCOMPtr<nsIDOMKeyEvent> keyEvent = do_QueryInterface(aKeyEvent);
NS_ENSURE_TRUE(keyEvent, NS_ERROR_UNEXPECTED);
nsAutoString eventType;
keyEvent->GetType(eventType);
if (eventType.EqualsLiteral("keyup")) {
return KeyUp(keyEvent);
}
if (eventType.EqualsLiteral("keydown")) {
return KeyDown(keyEvent);
}
if (eventType.EqualsLiteral("keypress")) {
return KeyPress(keyEvent);
}
NS_ABORT();
return NS_OK;
}
nsresult
nsXULPopupManager::KeyUp(nsIDOMKeyEvent* aKeyEvent)
{
// don't do anything if a menu isn't open or a menubar isn't active
if (!mActiveMenuBar) {
@ -2089,7 +2111,7 @@ nsXULPopupManager::KeyUp(nsIDOMEvent* aKeyEvent)
}
nsresult
nsXULPopupManager::KeyDown(nsIDOMEvent* aKeyEvent)
nsXULPopupManager::KeyDown(nsIDOMKeyEvent* aKeyEvent)
{
nsMenuChainItem* item = GetTopVisibleMenu();
if (item && item->Frame()->IsMenuLocked())
@ -2107,8 +2129,7 @@ nsXULPopupManager::KeyDown(nsIDOMEvent* aKeyEvent)
nsMenuBarListener::GetMenuAccessKey(&menuAccessKey);
if (menuAccessKey) {
PRUint32 theChar;
nsCOMPtr<nsIDOMKeyEvent> keyEvent = do_QueryInterface(aKeyEvent);
keyEvent->GetKeyCode(&theChar);
aKeyEvent->GetKeyCode(&theChar);
if (theChar == (PRUint32)menuAccessKey) {
PRBool ctrl = PR_FALSE;
@ -2142,7 +2163,7 @@ nsXULPopupManager::KeyDown(nsIDOMEvent* aKeyEvent)
}
nsresult
nsXULPopupManager::KeyPress(nsIDOMEvent* aKeyEvent)
nsXULPopupManager::KeyPress(nsIDOMKeyEvent* aKeyEvent)
{
// Don't check prevent default flag -- menus always get first shot at key events.
// When a menu is open, the prevent default flag on a keypress is always set, so
@ -2164,6 +2185,7 @@ nsXULPopupManager::KeyPress(nsIDOMEvent* aKeyEvent)
return NS_OK;
nsCOMPtr<nsIDOMKeyEvent> keyEvent = do_QueryInterface(aKeyEvent);
NS_ENSURE_TRUE(keyEvent, NS_ERROR_UNEXPECTED);
PRUint32 theChar;
keyEvent->GetKeyCode(&theChar);