Bug 602787 part.4 Don't implement nsAutoHandlingUserInputStatePusher class in nsEventStateManager.h r=smaug

This commit is contained in:
Masayuki Nakano 2013-10-22 22:27:35 +09:00
Родитель 7811d5c344
Коммит 9c5cb0a5c0
6 изменённых файлов: 67 добавлений и 49 удалений

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

@ -14,6 +14,7 @@
#include "nsCOMPtr.h"
#include "nsEventStateManager.h"
#include "nsFocusManager.h"
#include "nsIMEStateManager.h"
#include "nsContentEventHandler.h"
#include "nsIContent.h"
@ -1955,7 +1956,7 @@ nsEventStateManager::FireContextClick()
}
nsIDocument* doc = mGestureDownContent->GetCurrentDoc();
nsAutoHandlingUserInputStatePusher userInpStatePusher(true, &event, doc);
AutoHandlingUserInputStatePusher userInpStatePusher(true, &event, doc);
// dispatch to DOM
nsEventDispatcher::Dispatch(mGestureDownContent, mPresContext, &event,
@ -5848,4 +5849,51 @@ nsEventStateManager::Prefs::GetAccessModifierMask(int32_t aItemType)
}
}
/******************************************************************/
/* mozilla::AutoHandlingUserInputStatePusher */
/******************************************************************/
AutoHandlingUserInputStatePusher::AutoHandlingUserInputStatePusher(
bool aIsHandlingUserInput,
WidgetEvent* aEvent,
nsIDocument* aDocument) :
mIsHandlingUserInput(aIsHandlingUserInput),
mIsMouseDown(aEvent && aEvent->message == NS_MOUSE_BUTTON_DOWN),
mResetFMMouseDownState(false)
{
if (!aIsHandlingUserInput) {
return;
}
nsEventStateManager::StartHandlingUserInput();
if (!mIsMouseDown) {
return;
}
nsIPresShell::SetCapturingContent(nullptr, 0);
nsIPresShell::AllowMouseCapture(true);
if (!aDocument || !aEvent->mFlags.mIsTrusted) {
return;
}
nsFocusManager* fm = nsFocusManager::GetFocusManager();
NS_ENSURE_TRUE_VOID(fm);
fm->SetMouseButtonDownHandlingDocument(aDocument);
mResetFMMouseDownState = true;
}
AutoHandlingUserInputStatePusher::~AutoHandlingUserInputStatePusher()
{
if (!mIsHandlingUserInput) {
return;
}
nsEventStateManager::StopHandlingUserInput();
if (!mIsMouseDown) {
return;
}
nsIPresShell::AllowMouseCapture(false);
if (!mResetFMMouseDownState) {
return;
}
nsFocusManager* fm = nsFocusManager::GetFocusManager();
NS_ENSURE_TRUE_VOID(fm);
fm->SetMouseButtonDownHandlingDocument(nullptr);
}

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

@ -6,7 +6,6 @@
#ifndef nsEventStateManager_h__
#define nsEventStateManager_h__
#include "mozilla/BasicEvents.h"
#include "mozilla/EventForwards.h"
#include "mozilla/TypedEnum.h"
@ -15,11 +14,11 @@
#include "nsCOMPtr.h"
#include "nsCOMArray.h"
#include "nsCycleCollectionParticipant.h"
#include "nsFocusManager.h"
#include "mozilla/TimeStamp.h"
#include "nsIFrame.h"
#include "Units.h"
class nsFrameLoader;
class nsIContent;
class nsIDocument;
class nsIDocShell;
@ -847,51 +846,19 @@ public:
static void sClickHoldCallback ( nsITimer* aTimer, void* aESM ) ;
};
namespace mozilla {
/**
* This class is used while processing real user input. During this time, popups
* are allowed. For mousedown events, mouse capturing is also permitted.
*/
class nsAutoHandlingUserInputStatePusher
class AutoHandlingUserInputStatePusher
{
public:
nsAutoHandlingUserInputStatePusher(bool aIsHandlingUserInput,
mozilla::WidgetEvent* aEvent,
nsIDocument* aDocument)
: mIsHandlingUserInput(aIsHandlingUserInput),
mIsMouseDown(aEvent && aEvent->message == NS_MOUSE_BUTTON_DOWN),
mResetFMMouseDownState(false)
{
if (aIsHandlingUserInput) {
nsEventStateManager::StartHandlingUserInput();
if (mIsMouseDown) {
nsIPresShell::SetCapturingContent(nullptr, 0);
nsIPresShell::AllowMouseCapture(true);
if (aDocument && aEvent->mFlags.mIsTrusted) {
nsFocusManager* fm = nsFocusManager::GetFocusManager();
if (fm) {
fm->SetMouseButtonDownHandlingDocument(aDocument);
mResetFMMouseDownState = true;
}
}
}
}
}
~nsAutoHandlingUserInputStatePusher()
{
if (mIsHandlingUserInput) {
nsEventStateManager::StopHandlingUserInput();
if (mIsMouseDown) {
nsIPresShell::AllowMouseCapture(false);
if (mResetFMMouseDownState) {
nsFocusManager* fm = nsFocusManager::GetFocusManager();
if (fm) {
fm->SetMouseButtonDownHandlingDocument(nullptr);
}
}
}
}
}
AutoHandlingUserInputStatePusher(bool aIsHandlingUserInput,
WidgetEvent* aEvent,
nsIDocument* aDocument);
~AutoHandlingUserInputStatePusher();
protected:
bool mIsHandlingUserInput;
@ -904,6 +871,8 @@ private:
static void operator delete(void* /*memory*/) {}
};
} // namespace mozilla
// Click and double-click events need to be handled even for content that
// has no frame. This is required for Web compatibility.
#define NS_EVENT_NEEDS_FRAME(event) \

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

@ -807,9 +807,9 @@ HTMLFormElement::SubmitSubmission(nsFormSubmission* aFormSubmission)
{
nsAutoPopupStatePusher popupStatePusher(mSubmitPopupState);
nsAutoHandlingUserInputStatePusher userInpStatePusher(
mSubmitInitiatedFromUserInput,
nullptr, doc);
AutoHandlingUserInputStatePusher userInpStatePusher(
mSubmitInitiatedFromUserInput,
nullptr, doc);
nsCOMPtr<nsIInputStream> postDataStream;
rv = aFormSubmission->GetEncodedSubmission(actionURI,

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

@ -6845,8 +6845,8 @@ PresShell::HandleEventInternal(WidgetEvent* aEvent, nsEventStatus* aStatus)
}
}
nsAutoHandlingUserInputStatePusher userInpStatePusher(isHandlingUserInput,
aEvent, mDocument);
AutoHandlingUserInputStatePusher userInpStatePusher(isHandlingUserInput,
aEvent, mDocument);
if (aEvent->mFlags.mIsTrusted && aEvent->message == NS_MOUSE_MOVE) {
nsIPresShell::AllowMouseCapture(

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

@ -2354,8 +2354,8 @@ nsXULMenuCommandEvent::Run()
if (mCloseMenuMode != CloseMenuMode_None)
menuFrame->SelectMenu(false);
nsAutoHandlingUserInputStatePusher userInpStatePusher(mUserInput, nullptr,
shell->GetDocument());
AutoHandlingUserInputStatePusher userInpStatePusher(mUserInput, nullptr,
shell->GetDocument());
nsContentUtils::DispatchXULCommand(mMenu, mIsTrusted, nullptr, shell,
mControl, mAlt, mShift, mMeta);
}

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

@ -27,6 +27,7 @@
#include "nsLayoutUtils.h"
#include "Layers.h"
#include "gfxPlatform.h"
#include "nsIDocument.h"
/**
XXX TODO XXX