Bug 672175 part.12 Move MOZ_WM_*SCROLL handler into MouseScrollHandler r=jimm

This commit is contained in:
Masayuki Nakano 2012-03-06 12:20:29 +09:00
Родитель 8702af344a
Коммит edbb2984e2
4 изменённых файлов: 84 добавлений и 50 удалений

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

@ -146,6 +146,14 @@ MouseScrollHandler::ProcessMessage(nsWindow* aWindow, UINT msg,
aEatMessage = true;
return true;
case MOZ_WM_HSCROLL:
case MOZ_WM_VSCROLL:
GetInstance()->
HandleScrollMessageAsMouseWheelMessage(aWindow, msg, wParam, lParam);
// Doesn't need to call next wndproc for internal scroll message.
aEatMessage = true;
return true;
case WM_KEYDOWN:
case WM_KEYUP:
PR_LOG(gMouseScrollLog, PR_LOG_ALWAYS,
@ -176,13 +184,14 @@ MouseScrollHandler::DispatchEvent(nsWindow* aWindow, nsGUIEvent& aEvent)
/* static */
nsModifierKeyState
MouseScrollHandler::GetModifierKeyState()
MouseScrollHandler::GetModifierKeyState(UINT aMessage)
{
nsModifierKeyState result;
// Assume the Control key is down if the Elantech touchpad has sent the
// mis-ordered WM_KEYDOWN/WM_MOUSEWHEEL messages. (See the comment in
// MouseScrollHandler::Device::Elantech::HandleKeyMessage().)
if (!result.mIsControlDown) {
if ((aMessage == MOZ_WM_MOUSEVWHEEL || aMessage == WM_MOUSEWHEEL) &&
!result.mIsControlDown) {
result.mIsControlDown = Device::Elantech::IsZooming();
}
return result;
@ -308,7 +317,7 @@ MouseScrollHandler::HandleMouseWheelMessage(nsWindow* aWindow,
mLastEventInfo.RecordEvent(eventInfo);
nsModifierKeyState modKeyState = GetModifierKeyState();
nsModifierKeyState modKeyState = GetModifierKeyState(aMessage);
// Before dispatching line scroll event, we should get the current scroll
// event target information for pixel scroll.
@ -365,6 +374,59 @@ MouseScrollHandler::HandleMouseWheelMessage(nsWindow* aWindow,
#endif
}
void
MouseScrollHandler::HandleScrollMessageAsMouseWheelMessage(nsWindow* aWindow,
UINT aMessage,
WPARAM aWParam,
LPARAM aLParam)
{
NS_ABORT_IF_FALSE(
(aMessage == MOZ_WM_VSCROLL || aMessage == MOZ_WM_HSCROLL),
"HandleScrollMessageAsMouseWheelMessage must be called with "
"MOZ_WM_VSCROLL or MOZ_WM_HSCROLL");
nsModifierKeyState modKeyState = GetModifierKeyState(aMessage);
nsMouseScrollEvent scrollEvent(true, NS_MOUSE_SCROLL, aWindow);
scrollEvent.scrollFlags =
(aMessage == MOZ_WM_VSCROLL) ? nsMouseScrollEvent::kIsVertical :
nsMouseScrollEvent::kIsHorizontal;
switch (LOWORD(aWParam)) {
case SB_PAGEDOWN:
scrollEvent.scrollFlags |= nsMouseScrollEvent::kIsFullPage;
case SB_LINEDOWN:
scrollEvent.delta = 1;
break;
case SB_PAGEUP:
scrollEvent.scrollFlags |= nsMouseScrollEvent::kIsFullPage;
case SB_LINEUP:
scrollEvent.delta = -1;
break;
default:
return;
}
modKeyState.InitInputEvent(scrollEvent);
// XXX Current mouse position may not be same as when the original message
// is received. We need to know the actual mouse cursor position when
// the original message was received.
aWindow->InitEvent(scrollEvent);
PR_LOG(gMouseScrollLog, PR_LOG_ALWAYS,
("MouseScroll::HandleScrollMessageAsMouseWheelMessage: aWindow=%p, "
"aMessage=MOZ_WM_%sSCROLL, aWParam=0x%08X, aLParam=0x%08X, "
"scrollEvent { refPoint: { x: %d, y: %d }, delta: %d, "
"scrollFlags: 0x%04X, isShift: %s, isControl: %s, isAlt: %s, isMeta: %s }",
aWindow, (aMessage == MOZ_WM_VSCROLL) ? "V" : "H",
aWParam, aLParam, scrollEvent.refPoint.x, scrollEvent.refPoint.y,
scrollEvent.delta, scrollEvent.scrollFlags,
GetBoolName(scrollEvent.isShift),
GetBoolName(scrollEvent.isControl),
GetBoolName(scrollEvent.isAlt),
GetBoolName(scrollEvent.isMeta)));
DispatchEvent(aWindow, scrollEvent);
}
/******************************************************************************
*
* EventInfo

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

@ -52,8 +52,10 @@ private:
* GetModifierKeyState() returns current modifier key state.
* Note that some devices need some hack for the modifier key state.
* This method does it automatically.
*
* @param aMessage Handling message.
*/
static nsModifierKeyState GetModifierKeyState();
static nsModifierKeyState GetModifierKeyState(UINT aMessage);
/**
* HandleMouseWheelMessage() processes MOZ_WM_MOUSEVWHEEL and
@ -70,6 +72,22 @@ private:
WPARAM aWParam,
LPARAM aLParam);
/**
* HandleScrollMessageAsMouseWheelMessage() processes the MOZ_WM_VSCROLL and
* MOZ_WM_HSCROLL which are posted when one of mouse windows received
* WM_VSCROLL or WM_HSCROLL and user wants them to emulate mouse wheel
* message's behavior.
*
* @param aWindow A window which receives the scroll message.
* @param aMessage MOZ_WM_VSCROLL or MOZ_WM_HSCROLL.
* @param aWParam The wParam value of the original message.
* @param aLParam The lParam value of the original message.
*/
void HandleScrollMessageAsMouseWheelMessage(nsWindow* aWindow,
UINT aMessage,
WPARAM aWParam,
LPARAM aLParam);
class EventInfo;
/**
* GetScrollTargetInfo() returns scroll target information which is

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

@ -5062,13 +5062,6 @@ bool nsWindow::ProcessMessage(UINT msg, WPARAM &wParam, LPARAM &lParam,
result = OnScroll(msg, wParam, lParam);
break;
case MOZ_WM_HSCROLL:
case MOZ_WM_VSCROLL:
*aRetValue = 0;
OnScrollInternal(WinUtils::GetNativeMessage(msg), wParam, lParam);
// Doesn't need to call next wndproc for internal message.
return true;
// The WM_ACTIVATE event is fired when a window is raised or lowered,
// and the loword of wParam specifies which. But we don't want to tell
// the focus system about this until the WM_SETFOCUS or WM_KILLFOCUS
@ -7218,43 +7211,6 @@ nsWindow::OnScroll(UINT aMsg, WPARAM aWParam, LPARAM aLParam)
return true;
}
/**
* OnScrollInternal() is called when ProcessMessage() handles MOZ_WM_VSCROLL or
* MOZ_WM_HSCROLL but aMsg may be WM_VSCROLL or WM_HSCROLL.
* These internal messages used only when OnScroll() tries to emulate mouse
* wheel action for the WM_VSCROLL or WM_HSCROLL message.
*/
void
nsWindow::OnScrollInternal(UINT aMsg, WPARAM aWParam, LPARAM aLParam)
{
nsMouseScrollEvent scrollevent(true, NS_MOUSE_SCROLL, this);
scrollevent.scrollFlags = (aMsg == WM_VSCROLL)
? nsMouseScrollEvent::kIsVertical
: nsMouseScrollEvent::kIsHorizontal;
switch (LOWORD(aWParam)) {
case SB_PAGEDOWN:
scrollevent.scrollFlags |= nsMouseScrollEvent::kIsFullPage;
case SB_LINEDOWN:
scrollevent.delta = 1;
break;
case SB_PAGEUP:
scrollevent.scrollFlags |= nsMouseScrollEvent::kIsFullPage;
case SB_LINEUP:
scrollevent.delta = -1;
break;
default:
return;
}
scrollevent.isShift = IS_VK_DOWN(NS_VK_SHIFT);
scrollevent.isControl = IS_VK_DOWN(NS_VK_CONTROL);
scrollevent.isMeta = false;
scrollevent.isAlt = IS_VK_DOWN(NS_VK_ALT);
InitEvent(scrollevent);
if (mEventCallback) {
DispatchWindowEvent(&scrollevent);
}
}
// Can be overriden. Controls auto-erase of background.
bool nsWindow::AutoErase(HDC dc)
{

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

@ -397,8 +397,6 @@ protected:
const MSG *aMsg = nsnull,
bool *aEventDispatched = nsnull);
bool OnScroll(UINT aMsg, WPARAM aWParam, LPARAM aLParam);
void OnScrollInternal(UINT aMsg, WPARAM aWParam,
LPARAM aLParam);
bool OnGesture(WPARAM wParam, LPARAM lParam);
bool OnTouch(WPARAM wParam, LPARAM lParam);
bool OnHotKey(WPARAM wParam, LPARAM lParam);