From fce2e8b2023a4d1b815fa25ca5ef747105be41f5 Mon Sep 17 00:00:00 2001 From: Jim Mathies Date: Tue, 11 Oct 2011 11:11:35 -0500 Subject: [PATCH] Bug 677883 - Bypass deferred message processing for accessible tab windows. Fixes occasional wm_getobject query failures, which must be responded to. r=davidb --- accessible/src/msaa/nsAccessNodeWrap.cpp | 4 ++++ accessible/src/msaa/nsWinUtils.cpp | 25 ++++++++++++++++-------- ipc/glue/WindowsMessageLoop.cpp | 8 ++++++++ 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/accessible/src/msaa/nsAccessNodeWrap.cpp b/accessible/src/msaa/nsAccessNodeWrap.cpp index 0b39c974105..e17244d64fc 100644 --- a/accessible/src/msaa/nsAccessNodeWrap.cpp +++ b/accessible/src/msaa/nsAccessNodeWrap.cpp @@ -743,6 +743,10 @@ nsRefPtrHashtable nsAccessNodeWrap::sHWNDCach LRESULT CALLBACK nsAccessNodeWrap::WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { + // Note, this window's message handling should not invoke any call that + // may result in a cross-process ipc call. Doing so may violate RPC + // message semantics. + switch (msg) { case WM_GETOBJECT: { diff --git a/accessible/src/msaa/nsWinUtils.cpp b/accessible/src/msaa/nsWinUtils.cpp index 8c25afc35bb..7c422b68b5f 100644 --- a/accessible/src/msaa/nsWinUtils.cpp +++ b/accessible/src/msaa/nsWinUtils.cpp @@ -46,6 +46,10 @@ #include "nsArrayUtils.h" #include "nsIDocShellTreeItem.h" +// Window property used by ipc related code in identifying accessible +// tab windows. +const PRUnichar* kPropNameTabContent = L"AccessibleTabWindow"; + HRESULT nsWinUtils::ConvertToIA2Array(nsIArray *aGeckoArray, IUnknown ***aIA2Array, long *aIA2ArrayLen) @@ -149,14 +153,19 @@ nsWinUtils::CreateNativeWindow(LPCWSTR aWindowClass, HWND aParentWnd, int aX, int aY, int aWidth, int aHeight, bool aIsActive) { - return ::CreateWindowExW(WS_EX_TRANSPARENT, aWindowClass, - L"NetscapeDispatchWnd", - WS_CHILD | (aIsActive ? WS_VISIBLE : 0), - aX, aY, aWidth, aHeight, - aParentWnd, - NULL, - GetModuleHandle(NULL), - NULL); + HWND hwnd = ::CreateWindowExW(WS_EX_TRANSPARENT, aWindowClass, + L"NetscapeDispatchWnd", + WS_CHILD | (aIsActive ? WS_VISIBLE : 0), + aX, aY, aWidth, aHeight, + aParentWnd, + NULL, + GetModuleHandle(NULL), + NULL); + if (hwnd) { + // Mark this window so that ipc related code can identify it. + ::SetPropW(hwnd, kPropNameTabContent, (HANDLE)1); + } + return hwnd; } void diff --git a/ipc/glue/WindowsMessageLoop.cpp b/ipc/glue/WindowsMessageLoop.cpp index a7aaca7edae..df9c4dd2355 100644 --- a/ipc/glue/WindowsMessageLoop.cpp +++ b/ipc/glue/WindowsMessageLoop.cpp @@ -101,6 +101,8 @@ using namespace mozilla::ipc::windows; // pulled from widget's nsAppShell extern const PRUnichar* kAppShellEventId; +// pulled from accessibility's win utils +extern const PRUnichar* kPropNameTabContent; namespace { @@ -379,6 +381,12 @@ WindowIsDeferredWindow(HWND hWnd) return false; } + // Tab content creates a window that responds to accessible WM_GETOBJECT + // calls. This window can safely be ignored. + if (::GetPropW(hWnd, kPropNameTabContent)) { + return false; + } + // Common mozilla windows we must defer messages to. nsDependentString className(buffer, length); if (StringBeginsWith(className, NS_LITERAL_STRING("Mozilla")) ||