Bug 388280, command event needs to know user input state, otherwise a popup could be blocked, r=jst,sr=bz

This commit is contained in:
enndeakin@sympatico.ca 2007-07-23 17:55:52 -07:00
Родитель daf67977a4
Коммит 6193855ecc
4 изменённых файлов: 19 добавлений и 3 удалений

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

@ -1131,6 +1131,10 @@ nsDOMEvent::GetEventPopupControlState(nsEvent *aEvent)
} }
} }
break; break;
case NS_XUL_COMMAND_EVENT :
if (nsEventStateManager::IsHandlingUserInput()) {
abuse = openControlled;
}
} }
return abuse; return abuse;

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

@ -266,13 +266,15 @@ public:
PRBool aShift, PRBool aShift,
PRBool aControl, PRBool aControl,
PRBool aAlt, PRBool aAlt,
PRBool aMeta) PRBool aMeta,
PRBool aUserInput)
: mMenu(aMenu), : mMenu(aMenu),
mIsTrusted(aIsTrusted), mIsTrusted(aIsTrusted),
mShift(aShift), mShift(aShift),
mControl(aControl), mControl(aControl),
mAlt(aAlt), mAlt(aAlt),
mMeta(aMeta) mMeta(aMeta),
mUserInput(aUserInput)
{ {
NS_ASSERTION(aMenu, "null menu supplied to nsXULMenuCommandEvent constructor"); NS_ASSERTION(aMenu, "null menu supplied to nsXULMenuCommandEvent constructor");
} }
@ -286,6 +288,7 @@ private:
PRBool mControl; PRBool mControl;
PRBool mAlt; PRBool mAlt;
PRBool mMeta; PRBool mMeta;
PRBool mUserInput;
}; };
class nsXULPopupManager : public nsIDOMKeyListener, class nsXULPopupManager : public nsIDOMKeyListener,

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

@ -140,6 +140,7 @@ include $(topsrcdir)/config/rules.mk
LOCAL_INCLUDES = \ LOCAL_INCLUDES = \
-I$(srcdir) \ -I$(srcdir) \
-I$(srcdir)/../../../base \ -I$(srcdir)/../../../base \
-I$(srcdir)/../../../../content/events/src \
-I$(srcdir)/../../../generic \ -I$(srcdir)/../../../generic \
-I$(srcdir)/../../../style \ -I$(srcdir)/../../../style \
$(NULL) $(NULL)

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

@ -47,6 +47,7 @@
#include "nsIDOMNSUIEvent.h" #include "nsIDOMNSUIEvent.h"
#include "nsIPrivateDOMEvent.h" #include "nsIPrivateDOMEvent.h"
#include "nsEventDispatcher.h" #include "nsEventDispatcher.h"
#include "nsEventStateManager.h"
#include "nsCSSFrameConstructor.h" #include "nsCSSFrameConstructor.h"
#include "nsLayoutUtils.h" #include "nsLayoutUtils.h"
#include "nsIViewManager.h" #include "nsIViewManager.h"
@ -681,8 +682,13 @@ nsXULPopupManager::ExecuteMenu(nsIContent* aMenu, nsEvent* aEvent)
meta = static_cast<nsInputEvent *>(aEvent)->isMeta; meta = static_cast<nsInputEvent *>(aEvent)->isMeta;
} }
// Because the command event is firing asynchronously, a flag is needed to
// indicate whether user input is being handled. This ensures that a popup
// window won't get blocked.
PRBool userinput = nsEventStateManager::IsHandlingUserInput();
nsCOMPtr<nsIRunnable> event = nsCOMPtr<nsIRunnable> event =
new nsXULMenuCommandEvent(aMenu, isTrusted, shift, control, alt, meta); new nsXULMenuCommandEvent(aMenu, isTrusted, shift, control, alt, meta, userinput);
NS_DispatchToCurrentThread(event); NS_DispatchToCurrentThread(event);
} }
@ -1612,6 +1618,8 @@ nsXULMenuCommandEvent::Run()
// Deselect ourselves. // Deselect ourselves.
menuFrame->SelectMenu(PR_FALSE); menuFrame->SelectMenu(PR_FALSE);
nsAutoHandlingUserInputStatePusher userInpStatePusher(mUserInput);
nsEventStatus status = nsEventStatus_eIgnore; nsEventStatus status = nsEventStatus_eIgnore;
nsXULCommandEvent commandEvent(mIsTrusted, NS_XUL_COMMAND, nsnull); nsXULCommandEvent commandEvent(mIsTrusted, NS_XUL_COMMAND, nsnull);
commandEvent.isShift = mShift; commandEvent.isShift = mShift;