From e2a3abd319e811ac01d67e044c88b3dcfbdea681 Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Thu, 28 Jan 2010 17:39:51 +0900 Subject: [PATCH] Bug 531341 Stack overflow crash related to scrolling with trackpad and plugins [@ nsWindow::HandleScrollingPlugins] [@ _SEH_prolog4 ] r=VYV03354 --- widget/src/windows/nsWindow.cpp | 31 ++++++++++++++++--------------- widget/src/windows/nsWindow.h | 1 - 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/widget/src/windows/nsWindow.cpp b/widget/src/windows/nsWindow.cpp index dff0e479134..8994f1b372c 100644 --- a/widget/src/windows/nsWindow.cpp +++ b/widget/src/windows/nsWindow.cpp @@ -381,7 +381,6 @@ nsWindow::nsWindow() : nsBaseWidget() mHas3DBorder = PR_FALSE; mIsInMouseCapture = PR_FALSE; mIsTopWidgetWindow = PR_FALSE; - mInScrollProcessing = PR_FALSE; mUnicodeWidget = PR_TRUE; mWindowType = eWindowType_child; mBorderStyle = eBorderStyle_default; @@ -6051,6 +6050,11 @@ PRBool nsWindow::HandleScrollingPlugins(UINT aMsg, WPARAM aWParam, point.x = GET_X_LPARAM(dwPoints); point.y = GET_Y_LPARAM(dwPoints); + static PRBool sIsProcessing = PR_FALSE; + if (sIsProcessing) { + return PR_TRUE; // the caller should handle this. + } + static PRBool sMayBeUsingLogitechMouse = PR_FALSE; if (aMsg == WM_MOUSEHWHEEL) { // Logitech (Logicool) mouse driver (confirmed with 4.82.11 and MX-1100) @@ -6115,20 +6119,15 @@ PRBool nsWindow::HandleScrollingPlugins(UINT aMsg, WPARAM aWParam, // message themselves, some will forward directly back to us, while // others will call DefWndProc, which itself still forwards back to us. // So if we have sent it once, we need to handle it ourself. - if (mInScrollProcessing) { - destWnd = parentWnd; - destWindow = parentWindow; - } else { - // 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, - mInScrollProcessing = PR_TRUE; - if (0 == ::SendMessageW(destWnd, aMsg, aWParam, aLParam)) - aHandled = PR_TRUE; - destWnd = nsnull; - mInScrollProcessing = PR_FALSE; - } + + // 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; + sIsProcessing = PR_FALSE; return PR_FALSE; // break, but continue processing } parentWnd = ::GetParent(parentWnd); @@ -6138,7 +6137,9 @@ PRBool nsWindow::HandleScrollingPlugins(UINT aMsg, WPARAM aWParam, return PR_FALSE; if (destWnd != mWnd) { if (destWindow) { + sIsProcessing = PR_TRUE; aHandled = destWindow->ProcessMessage(aMsg, aWParam, aLParam, aRetValue); + sIsProcessing = PR_FALSE; aQuitProcessing = PR_TRUE; return PR_FALSE; // break, and stop processing } diff --git a/widget/src/windows/nsWindow.h b/widget/src/windows/nsWindow.h index ea33eb0669c..ba70275260c 100644 --- a/widget/src/windows/nsWindow.h +++ b/widget/src/windows/nsWindow.h @@ -416,7 +416,6 @@ protected: PRPackedBool mInDtor; PRPackedBool mIsVisible; PRPackedBool mIsInMouseCapture; - PRPackedBool mInScrollProcessing; PRPackedBool mUnicodeWidget; PRPackedBool mPainting; char mLeadByte;