Bug 552163 [OOPP]Can not start scroll page by mouse wheel when mouse cursor is over a flash video. r=jim

This commit is contained in:
Masayuki Nakano 2010-04-12 16:40:37 +09:00
parent 00a641e433
commit 34a3748454

View File

@ -5606,8 +5606,18 @@ PRBool nsWindow::OnMouseWheel(UINT msg, WPARAM wParam, LPARAM lParam, PRBool& ge
}
}
if (!scrollEvent.delta)
if (!scrollEvent.delta) {
// We store the wheel delta, and it will be used next wheel message, so,
// we consume this message actually. We shouldn't call next wndproc.
result = PR_TRUE;
return PR_FALSE; // break
}
#ifdef MOZ_IPC
// The event may go to a plug-in which already dispatched this message.
// Then, the event can cause deadlock. We should unlock the sender here.
::ReplyMessage(isVertical ? 0 : TRUE);
#endif
scrollEvent.isShift = IS_VK_DOWN(NS_VK_SHIFT);
scrollEvent.isControl = IS_VK_DOWN(NS_VK_CONTROL);
@ -6310,6 +6320,23 @@ void nsWindow::OnSettingsChange(WPARAM wParam, LPARAM lParam)
nsWindowGfx::OnSettingsChangeGfx(wParam);
}
static PRBool IsOurProcessWindow(HWND aHWND)
{
DWORD processId = 0;
::GetWindowThreadProcessId(aHWND, &processId);
return processId == ::GetCurrentProcessId();
}
static HWND FindOurProcessWindow(HWND aHWND)
{
for (HWND wnd = ::GetParent(aHWND); wnd; wnd = ::GetParent(wnd)) {
if (IsOurProcessWindow(wnd)) {
return wnd;
}
}
return nsnull;
}
// Scrolling helper function for handling plugins.
// Return value indicates whether the calling function should handle this
// aHandled indicates whether this was handled at all
@ -6368,15 +6395,32 @@ PRBool nsWindow::HandleScrollingPlugins(UINT aMsg, WPARAM aWParam,
// No window is under the pointer
return PR_FALSE; // break, but continue processing
}
// We don't care about windows belonging to other processes.
DWORD processId = 0;
GetWindowThreadProcessId(destWnd, &processId);
if (processId != GetCurrentProcessId())
{
// Somebody elses window
return PR_FALSE; // break, but continue processing
nsWindow* destWindow;
// We don't handle the message if the found window belongs to another
// process's top window. If it belongs window, that is a plug-in's window.
// Then, we need to send the message to the plug-in window.
if (!IsOurProcessWindow(destWnd)) {
HWND ourPluginWnd = FindOurProcessWindow(destWnd);
if (!ourPluginWnd) {
// Somebody elses window
return PR_FALSE; // break, but continue processing
}
destWindow = GetNSWindowPtr(ourPluginWnd);
} else {
destWindow = GetNSWindowPtr(destWnd);
}
nsWindow* destWindow = GetNSWindowPtr(destWnd);
if (destWindow == this && mWindowType == eWindowType_plugin) {
// If this is plug-in window, the message came from the plug-in window.
// Then, the message should be processed on the parent window.
destWindow = static_cast<nsWindow*>(GetParent());
NS_ENSURE_TRUE(destWindow, PR_FALSE); // break, but continue processing
destWnd = destWindow->mWnd;
NS_ENSURE_TRUE(destWnd, PR_FALSE); // break, but continue processing
}
if (!destWindow || destWindow->mWindowType == eWindowType_plugin) {
// Some other app, or a plugin window.
// Windows directs scrolling messages to the focused window.
@ -6397,15 +6441,24 @@ PRBool nsWindow::HandleScrollingPlugins(UINT aMsg, WPARAM aWParam,
// others will call DefWndProc, which itself still forwards back to us.
// So if we have sent it once, we need to handle it ourself.
#ifdef MOZ_IPC
// XXX The message shouldn't come from the plugin window at here.
// But the message might come from it due to some bugs. If it happens,
// SendMessage causes deadlock. For safety, we should unlock the
// sender here.
::ReplyMessage(aMsg == WM_MOUSEHWHEEL ? TRUE : 0);
#endif
// First time we have seen this message.
// Call the child - either it will consume it, or
// it will wind it's way back to us,triggering the destWnd case above
// either way,when the call returns,we are all done with the message,
sIsProcessing = PR_TRUE;
if (0 == ::SendMessageW(destWnd, aMsg, aWParam, aLParam))
aHandled = PR_TRUE;
::SendMessageW(destWnd, aMsg, aWParam, aLParam);
sIsProcessing = PR_FALSE;
return PR_FALSE; // break, but continue processing
aHandled = PR_TRUE;
aQuitProcessing = PR_TRUE;
return PR_FALSE; // break, and stop processing
}
parentWnd = ::GetParent(parentWnd);
} // while parentWnd
@ -6472,6 +6525,11 @@ PRBool nsWindow::OnScroll(UINT aMsg, WPARAM aWParam, LPARAM aLParam)
default:
return PR_FALSE;
}
#ifdef MOZ_IPC
// The event may go to a plug-in which already dispatched this message.
// Then, the event can cause deadlock. We should unlock the sender here.
::ReplyMessage(0);
#endif
scrollevent.isShift = IS_VK_DOWN(NS_VK_SHIFT);
scrollevent.isControl = IS_VK_DOWN(NS_VK_CONTROL);
scrollevent.isMeta = PR_FALSE;