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;
case NS_XUL_COMMAND_EVENT :
if (nsEventStateManager::IsHandlingUserInput()) {
abuse = openControlled;
}
}
return abuse;

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

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

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

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

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

@ -47,6 +47,7 @@
#include "nsIDOMNSUIEvent.h"
#include "nsIPrivateDOMEvent.h"
#include "nsEventDispatcher.h"
#include "nsEventStateManager.h"
#include "nsCSSFrameConstructor.h"
#include "nsLayoutUtils.h"
#include "nsIViewManager.h"
@ -681,8 +682,13 @@ nsXULPopupManager::ExecuteMenu(nsIContent* aMenu, nsEvent* aEvent)
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 =
new nsXULMenuCommandEvent(aMenu, isTrusted, shift, control, alt, meta);
new nsXULMenuCommandEvent(aMenu, isTrusted, shift, control, alt, meta, userinput);
NS_DispatchToCurrentThread(event);
}
@ -1612,6 +1618,8 @@ nsXULMenuCommandEvent::Run()
// Deselect ourselves.
menuFrame->SelectMenu(PR_FALSE);
nsAutoHandlingUserInputStatePusher userInpStatePusher(mUserInput);
nsEventStatus status = nsEventStatus_eIgnore;
nsXULCommandEvent commandEvent(mIsTrusted, NS_XUL_COMMAND, nsnull);
commandEvent.isShift = mShift;