From 7689a15bf5ee741a80d578d9295085d0637df2e0 Mon Sep 17 00:00:00 2001 From: Ben Turner Date: Thu, 28 Jan 2010 10:03:37 -0800 Subject: [PATCH] Bug 542617 - 'Deferred message loop mishandles WM_NCCALCSIZE'. r=jimm. --- ipc/glue/WindowsMessageLoop.cpp | 41 ++++++++++++++++++++++++--------- ipc/glue/WindowsMessageLoop.h | 4 ++-- 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/ipc/glue/WindowsMessageLoop.cpp b/ipc/glue/WindowsMessageLoop.cpp index fa01b1b3f3f4..6aef2cf68b24 100644 --- a/ipc/glue/WindowsMessageLoop.cpp +++ b/ipc/glue/WindowsMessageLoop.cpp @@ -241,10 +241,7 @@ ProcessOrDeferMessage(HWND hwnd, break; } case WM_NCCALCSIZE: { - UINT flags = SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOMOVE | - SWP_NOSIZE | SWP_NOOWNERZORDER | SWP_NOZORDER | - SWP_DEFERERASE | SWP_NOSENDCHANGING; - deferred = new DeferredWindowPosMessage(hwnd, lParam, true, flags); + deferred = new DeferredWindowPosMessage(hwnd, lParam, true, wParam); break; } @@ -663,16 +660,38 @@ DeferredSettingChangeMessage::~DeferredSettingChangeMessage() DeferredWindowPosMessage::DeferredWindowPosMessage(HWND aHWnd, LPARAM aLParam, - bool aUseCustomFlags, - UINT aFlags) + bool aForCalcSize, + WPARAM aWParam) { - WINDOWPOS* source = reinterpret_cast(aLParam); - memcpy(&windowPos, source, sizeof(windowPos)); - NS_ASSERTION(aHWnd == source->hwnd, "Mismatched hwnds!"); - if (aUseCustomFlags) { - windowPos.flags = aFlags; + if (aForCalcSize) { + if (aWParam) { + NCCALCSIZE_PARAMS* arg = reinterpret_cast(aLParam); + memcpy(&windowPos, arg->lppos, sizeof(windowPos)); + + NS_ASSERTION(aHWnd == windowPos.hwnd, "Mismatched hwnds!"); + } + else { + RECT* arg = reinterpret_cast(aLParam); + windowPos.hwnd = aHWnd; + windowPos.hwndInsertAfter = NULL; + windowPos.x = arg->left; + windowPos.y = arg->top; + windowPos.cx = arg->right - arg->left; + windowPos.cy = arg->bottom - arg->top; + + NS_ASSERTION(arg->right >= arg->left && arg->bottom >= arg->top, + "Negative width or height!"); + } + windowPos.flags = SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOOWNERZORDER | + SWP_NOZORDER | SWP_DEFERERASE | SWP_NOSENDCHANGING; } else { + // Not for WM_NCCALCSIZE + WINDOWPOS* arg = reinterpret_cast(aLParam); + memcpy(&windowPos, arg, sizeof(windowPos)); + + NS_ASSERTION(aHWnd == windowPos.hwnd, "Mismatched hwnds!"); + // Windows sends in some private flags sometimes that we can't simply copy. // Filter here. UINT mask = SWP_ASYNCWINDOWPOS | SWP_DEFERERASE | SWP_DRAWFRAME | diff --git a/ipc/glue/WindowsMessageLoop.h b/ipc/glue/WindowsMessageLoop.h index 1b029165e6cd..2c2e1c7ffc24 100644 --- a/ipc/glue/WindowsMessageLoop.h +++ b/ipc/glue/WindowsMessageLoop.h @@ -145,8 +145,8 @@ class DeferredWindowPosMessage : public DeferredMessage public: DeferredWindowPosMessage(HWND aHWnd, LPARAM aLParam, - bool aUseCustomFlags = false, - UINT aFlags = 0); + bool aForCalcSize = false, + WPARAM aWParam = 0); virtual void Run();