mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-11 01:57:00 +00:00
Bug 664058: Remove Add/RemoveEventListenerByIID from nsXULPopupManager. r=smaug
This commit is contained in:
parent
598b8d8e3e
commit
2ed50de013
@ -46,7 +46,7 @@
|
|||||||
#include "nsIContent.h"
|
#include "nsIContent.h"
|
||||||
#include "nsIRollupListener.h"
|
#include "nsIRollupListener.h"
|
||||||
#include "nsIMenuRollup.h"
|
#include "nsIMenuRollup.h"
|
||||||
#include "nsIDOMKeyListener.h"
|
#include "nsIDOMEventListener.h"
|
||||||
#include "nsPoint.h"
|
#include "nsPoint.h"
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
#include "nsTArray.h"
|
#include "nsTArray.h"
|
||||||
@ -55,6 +55,11 @@
|
|||||||
#include "nsThreadUtils.h"
|
#include "nsThreadUtils.h"
|
||||||
#include "nsStyleConsts.h"
|
#include "nsStyleConsts.h"
|
||||||
|
|
||||||
|
// X.h defines KeyPress
|
||||||
|
#ifdef KeyPress
|
||||||
|
#undef KeyPress
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* There are two types that are used:
|
* There are two types that are used:
|
||||||
* - dismissable popups such as menus, which should close up when there is a
|
* - dismissable popups such as menus, which should close up when there is a
|
||||||
@ -296,7 +301,7 @@ private:
|
|||||||
CloseMenuMode mCloseMenuMode;
|
CloseMenuMode mCloseMenuMode;
|
||||||
};
|
};
|
||||||
|
|
||||||
class nsXULPopupManager : public nsIDOMKeyListener,
|
class nsXULPopupManager : public nsIDOMEventListener,
|
||||||
public nsIMenuRollup,
|
public nsIMenuRollup,
|
||||||
public nsIRollupListener,
|
public nsIRollupListener,
|
||||||
public nsITimerCallback,
|
public nsITimerCallback,
|
||||||
@ -311,6 +316,7 @@ public:
|
|||||||
NS_DECL_ISUPPORTS
|
NS_DECL_ISUPPORTS
|
||||||
NS_DECL_NSIOBSERVER
|
NS_DECL_NSIOBSERVER
|
||||||
NS_DECL_NSITIMERCALLBACK
|
NS_DECL_NSITIMERCALLBACK
|
||||||
|
NS_DECL_NSIDOMEVENTLISTENER
|
||||||
|
|
||||||
// nsIRollupListener
|
// nsIRollupListener
|
||||||
NS_IMETHOD Rollup(PRUint32 aCount, nsIContent **aContent);
|
NS_IMETHOD Rollup(PRUint32 aCount, nsIContent **aContent);
|
||||||
@ -622,11 +628,9 @@ public:
|
|||||||
return HandleKeyboardNavigationInPopup(nsnull, aFrame, aDir);
|
return HandleKeyboardNavigationInPopup(nsnull, aFrame, aDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP HandleEvent(nsIDOMEvent* aEvent) { return NS_OK; }
|
nsresult KeyUp(nsIDOMKeyEvent* aKeyEvent);
|
||||||
|
nsresult KeyDown(nsIDOMKeyEvent* aKeyEvent);
|
||||||
NS_IMETHOD KeyUp(nsIDOMEvent* aKeyEvent);
|
nsresult KeyPress(nsIDOMKeyEvent* aKeyEvent);
|
||||||
NS_IMETHOD KeyDown(nsIDOMEvent* aKeyEvent);
|
|
||||||
NS_IMETHOD KeyPress(nsIDOMEvent* aKeyEvent);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
nsXULPopupManager();
|
nsXULPopupManager();
|
||||||
|
@ -131,8 +131,7 @@ void nsMenuChainItem::Detach(nsMenuChainItem** aRoot)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS5(nsXULPopupManager,
|
NS_IMPL_ISUPPORTS4(nsXULPopupManager,
|
||||||
nsIDOMKeyListener,
|
|
||||||
nsIDOMEventListener,
|
nsIDOMEventListener,
|
||||||
nsIMenuRollup,
|
nsIMenuRollup,
|
||||||
nsITimerCallback,
|
nsITimerCallback,
|
||||||
@ -2073,7 +2072,30 @@ nsXULPopupManager::IsValidMenuItem(nsPresContext* aPresContext,
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
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
|
// don't do anything if a menu isn't open or a menubar isn't active
|
||||||
if (!mActiveMenuBar) {
|
if (!mActiveMenuBar) {
|
||||||
@ -2089,7 +2111,7 @@ nsXULPopupManager::KeyUp(nsIDOMEvent* aKeyEvent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsXULPopupManager::KeyDown(nsIDOMEvent* aKeyEvent)
|
nsXULPopupManager::KeyDown(nsIDOMKeyEvent* aKeyEvent)
|
||||||
{
|
{
|
||||||
nsMenuChainItem* item = GetTopVisibleMenu();
|
nsMenuChainItem* item = GetTopVisibleMenu();
|
||||||
if (item && item->Frame()->IsMenuLocked())
|
if (item && item->Frame()->IsMenuLocked())
|
||||||
@ -2107,8 +2129,7 @@ nsXULPopupManager::KeyDown(nsIDOMEvent* aKeyEvent)
|
|||||||
nsMenuBarListener::GetMenuAccessKey(&menuAccessKey);
|
nsMenuBarListener::GetMenuAccessKey(&menuAccessKey);
|
||||||
if (menuAccessKey) {
|
if (menuAccessKey) {
|
||||||
PRUint32 theChar;
|
PRUint32 theChar;
|
||||||
nsCOMPtr<nsIDOMKeyEvent> keyEvent = do_QueryInterface(aKeyEvent);
|
aKeyEvent->GetKeyCode(&theChar);
|
||||||
keyEvent->GetKeyCode(&theChar);
|
|
||||||
|
|
||||||
if (theChar == (PRUint32)menuAccessKey) {
|
if (theChar == (PRUint32)menuAccessKey) {
|
||||||
PRBool ctrl = PR_FALSE;
|
PRBool ctrl = PR_FALSE;
|
||||||
@ -2142,7 +2163,7 @@ nsXULPopupManager::KeyDown(nsIDOMEvent* aKeyEvent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsXULPopupManager::KeyPress(nsIDOMEvent* aKeyEvent)
|
nsXULPopupManager::KeyPress(nsIDOMKeyEvent* aKeyEvent)
|
||||||
{
|
{
|
||||||
// Don't check prevent default flag -- menus always get first shot at key events.
|
// 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
|
// 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;
|
return NS_OK;
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMKeyEvent> keyEvent = do_QueryInterface(aKeyEvent);
|
nsCOMPtr<nsIDOMKeyEvent> keyEvent = do_QueryInterface(aKeyEvent);
|
||||||
|
NS_ENSURE_TRUE(keyEvent, NS_ERROR_UNEXPECTED);
|
||||||
PRUint32 theChar;
|
PRUint32 theChar;
|
||||||
keyEvent->GetKeyCode(&theChar);
|
keyEvent->GetKeyCode(&theChar);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user