diff --git a/widget/windows/nsWindow.cpp b/widget/windows/nsWindow.cpp index 012a4f49b7ca..34287fd142f4 100644 --- a/widget/windows/nsWindow.cpp +++ b/widget/windows/nsWindow.cpp @@ -4422,37 +4422,53 @@ static bool CleartypeSettingChanged() return true; } -// The main windows message processing method. -bool nsWindow::ProcessMessage(UINT msg, WPARAM &wParam, LPARAM &lParam, - LRESULT *aRetValue) +bool +nsWindow::ExternalHandlerProcessMessage(UINT aMessage, + WPARAM& aWParam, + LPARAM& aLParam, + MSGResult& aResult) { - // (Large blocks of code should be broken out into OnEvent handlers.) - if (mWindowHook.Notify(mWnd, msg, wParam, lParam, aRetValue)) + if (mWindowHook.Notify(mWnd, aMessage, aWParam, aLParam, &aResult.mResult)) { return true; + } + if (IMEHandler::ProcessMessage(this, aMessage, aWParam, aLParam, + &aResult.mResult, aResult.mConsumed)) { + return true; + } + + if (MouseScrollHandler::ProcessMessage(this, aMessage, aWParam, aLParam, + &aResult.mResult, aResult.mConsumed)) { + return true; + } + + if (PluginHasFocus()) { + bool callDefaultWndProc; + MSG nativeMsg = WinUtils::InitMSG(aMessage, aWParam, aLParam, mWnd); + if (ProcessMessageForPlugin(nativeMsg, &aResult.mResult, + callDefaultWndProc)) { + aResult.mConsumed = !callDefaultWndProc; + return true; + } + } + + return false; +} + +// The main windows message processing method. +bool +nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam, + LRESULT *aRetValue) +{ #if defined(EVENT_DEBUG_OUTPUT) // First param shows all events, second param indicates whether // to show mouse move events. See nsWindowDbg for details. PrintEvent(msg, SHOW_REPEAT_EVENTS, SHOW_MOUSEMOVE_EVENTS); #endif - bool eatMessage; - if (IMEHandler::ProcessMessage(this, msg, wParam, lParam, aRetValue, - eatMessage)) { - return mWnd ? eatMessage : true; - } - - if (MouseScrollHandler::ProcessMessage(this, msg, wParam, lParam, aRetValue, - eatMessage)) { - return mWnd ? eatMessage : true; - } - - if (PluginHasFocus()) { - bool callDefaultWndProc; - MSG nativeMsg = WinUtils::InitMSG(msg, wParam, lParam, mWnd); - if (ProcessMessageForPlugin(nativeMsg, aRetValue, callDefaultWndProc)) { - return mWnd ? !callDefaultWndProc : true; - } + MSGResult msgResult(aRetValue); + if (ExternalHandlerProcessMessage(msg, wParam, lParam, msgResult)) { + return (msgResult.mConsumed || !mWnd); } bool result = false; // call the default nsWindow proc @@ -4467,6 +4483,7 @@ bool nsWindow::ProcessMessage(UINT msg, WPARAM &wParam, LPARAM &lParam, return true; } + // (Large blocks of code should be broken out into OnEvent handlers.) switch (msg) { // WM_QUERYENDSESSION must be handled by all windows. // Otherwise Windows thinks the window can just be killed at will. diff --git a/widget/windows/nsWindow.h b/widget/windows/nsWindow.h index 74fd7fe701ab..ff3410e81b07 100644 --- a/widget/windows/nsWindow.h +++ b/widget/windows/nsWindow.h @@ -58,6 +58,7 @@ namespace mozilla { namespace widget { class NativeKey; class ModifierKeyState; +struct MSGResult; } // namespace widget } // namespacw mozilla; @@ -72,6 +73,7 @@ class nsWindow : public nsWindowBase typedef mozilla::widget::WindowHook WindowHook; typedef mozilla::widget::TaskbarWindowPreview TaskbarWindowPreview; typedef mozilla::widget::NativeKey NativeKey; + typedef mozilla::widget::MSGResult MSGResult; public: nsWindow(); virtual ~nsWindow(); @@ -328,6 +330,9 @@ protected: void RelayMouseEvent(UINT aMsg, WPARAM wParam, LPARAM lParam); virtual bool ProcessMessage(UINT msg, WPARAM &wParam, LPARAM &lParam, LRESULT *aRetValue); + bool ExternalHandlerProcessMessage( + UINT aMessage, WPARAM& aWParam, + LPARAM& aLParam, MSGResult& aResult); bool ProcessMessageForPlugin(const MSG &aMsg, LRESULT *aRetValue, bool &aCallDefWndProc); LRESULT ProcessCharMessage(const MSG &aMsg, diff --git a/widget/windows/nsWindowDefs.h b/widget/windows/nsWindowDefs.h index 56200d9572a1..e3b7e2659d57 100644 --- a/widget/windows/nsWindowDefs.h +++ b/widget/windows/nsWindowDefs.h @@ -221,6 +221,28 @@ struct TITLEBARINFOEX }; #endif +namespace mozilla { +namespace widget { + +struct MSGResult +{ + // Result for the message. + LRESULT& mResult; + // If mConsumed is true, the caller shouldn't call next wndproc. + bool mConsumed; + + MSGResult(LRESULT* aResult = nullptr) : + mResult(aResult ? *aResult : mDefaultResult), mConsumed(false) + { + } + +private: + LRESULT mDefaultResult; +}; + +} // namespace widget +} // namespace mozilla + /************************************************************** * * SECTION: macros