зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1380471: Move follow-up initialization for emulated windows into a callback invoked by the emulated window's WM_CREATE handler; r=yzen
--HG-- extra : rebase_source : d8742fc08cea75e994c9ee4f7c5eca50d40aeac1
This commit is contained in:
Родитель
3d61d6d6f0
Коммит
22d6b8c708
|
@ -623,26 +623,31 @@ DocAccessibleParent::MaybeInitWindowEmulation()
|
|||
tab->GetDocShellIsActive(&isActive);
|
||||
}
|
||||
|
||||
IAccessibleHolder hWndAccHolder;
|
||||
HWND parentWnd = reinterpret_cast<HWND>(rootDocument->GetNativeWindow());
|
||||
HWND hWnd = nsWinUtils::CreateNativeWindow(kClassNameTabContent,
|
||||
parentWnd, rect.x, rect.y,
|
||||
rect.width, rect.height,
|
||||
isActive);
|
||||
if (hWnd) {
|
||||
// Attach accessible document to the emulated native window
|
||||
::SetPropW(hWnd, kPropNameDocAccParent, (HANDLE)this);
|
||||
SetEmulatedWindowHandle(hWnd);
|
||||
nsWinUtils::NativeWindowCreateProc onCreate([this](HWND aHwnd) -> void {
|
||||
IAccessibleHolder hWndAccHolder;
|
||||
|
||||
::SetPropW(aHwnd, kPropNameDocAccParent, reinterpret_cast<HANDLE>(this));
|
||||
|
||||
SetEmulatedWindowHandle(aHwnd);
|
||||
|
||||
IAccessible* rawHWNDAcc = nullptr;
|
||||
if (SUCCEEDED(::AccessibleObjectFromWindow(hWnd, OBJID_WINDOW,
|
||||
if (SUCCEEDED(::AccessibleObjectFromWindow(aHwnd, OBJID_WINDOW,
|
||||
IID_IAccessible,
|
||||
(void**)&rawHWNDAcc))) {
|
||||
hWndAccHolder.Set(IAccessibleHolder::COMPtrType(rawHWNDAcc));
|
||||
}
|
||||
}
|
||||
|
||||
Unused << SendEmulatedWindow(reinterpret_cast<uintptr_t>(mEmulatedWindowHandle),
|
||||
hWndAccHolder);
|
||||
Unused << SendEmulatedWindow(reinterpret_cast<uintptr_t>(mEmulatedWindowHandle),
|
||||
hWndAccHolder);
|
||||
});
|
||||
|
||||
HWND parentWnd = reinterpret_cast<HWND>(rootDocument->GetNativeWindow());
|
||||
DebugOnly<HWND> hWnd = nsWinUtils::CreateNativeWindow(kClassNameTabContent,
|
||||
parentWnd,
|
||||
rect.x, rect.y,
|
||||
rect.width, rect.height,
|
||||
isActive, &onCreate);
|
||||
MOZ_ASSERT(hWnd);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -163,13 +163,16 @@ DocAccessibleWrap::DoInitialUpdate()
|
|||
docShell->GetIsActive(&isActive);
|
||||
}
|
||||
|
||||
RefPtr<DocAccessibleWrap> self(this);
|
||||
nsWinUtils::NativeWindowCreateProc onCreate([self](HWND aHwnd) -> void {
|
||||
::SetPropW(aHwnd, kPropNameDocAcc, reinterpret_cast<HANDLE>(self.get()));
|
||||
});
|
||||
|
||||
HWND parentWnd = reinterpret_cast<HWND>(rootDocument->GetNativeWindow());
|
||||
mHWND = nsWinUtils::CreateNativeWindow(kClassNameTabContent, parentWnd,
|
||||
rect.x, rect.y,
|
||||
rect.width, rect.height, isActive);
|
||||
|
||||
::SetPropW(static_cast<HWND>(mHWND), kPropNameDocAcc, (HANDLE)this);
|
||||
|
||||
rect.width, rect.height, isActive,
|
||||
&onCreate);
|
||||
} else {
|
||||
DocAccessible* parentDocument = ParentDocument();
|
||||
if (parentDocument)
|
||||
|
|
|
@ -110,21 +110,17 @@ nsWinUtils::RegisterNativeWindow(LPCWSTR aWindowClass)
|
|||
HWND
|
||||
nsWinUtils::CreateNativeWindow(LPCWSTR aWindowClass, HWND aParentWnd,
|
||||
int aX, int aY, int aWidth, int aHeight,
|
||||
bool aIsActive)
|
||||
bool aIsActive,
|
||||
NativeWindowCreateProc* aOnCreateProc)
|
||||
{
|
||||
HWND hwnd = ::CreateWindowExW(WS_EX_TRANSPARENT, aWindowClass,
|
||||
L"NetscapeDispatchWnd",
|
||||
WS_CHILD | (aIsActive ? WS_VISIBLE : 0),
|
||||
aX, aY, aWidth, aHeight,
|
||||
aParentWnd,
|
||||
nullptr,
|
||||
GetModuleHandle(nullptr),
|
||||
nullptr);
|
||||
if (hwnd) {
|
||||
// Mark this window so that ipc related code can identify it.
|
||||
::SetPropW(hwnd, kPropNameTabContent, (HANDLE)1);
|
||||
}
|
||||
return hwnd;
|
||||
return ::CreateWindowExW(WS_EX_TRANSPARENT, aWindowClass,
|
||||
L"NetscapeDispatchWnd",
|
||||
WS_CHILD | (aIsActive ? WS_VISIBLE : 0),
|
||||
aX, aY, aWidth, aHeight,
|
||||
aParentWnd,
|
||||
nullptr,
|
||||
GetModuleHandle(nullptr),
|
||||
aOnCreateProc);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -149,6 +145,21 @@ WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|||
// message semantics.
|
||||
|
||||
switch (msg) {
|
||||
case WM_CREATE:
|
||||
{
|
||||
// Mark this window so that ipc related code can identify it.
|
||||
::SetPropW(hWnd, kPropNameTabContent, reinterpret_cast<HANDLE>(1));
|
||||
|
||||
auto createStruct = reinterpret_cast<CREATESTRUCT*>(lParam);
|
||||
auto createProc = reinterpret_cast<nsWinUtils::NativeWindowCreateProc*>(
|
||||
createStruct->lpCreateParams);
|
||||
|
||||
if (createProc && *createProc) {
|
||||
(*createProc)(hWnd);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
case WM_GETOBJECT:
|
||||
{
|
||||
// Do explicit casting to make it working on 64bit systems (see bug 649236
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#ifndef nsWinUtils_h_
|
||||
#define nsWinUtils_h_
|
||||
|
||||
#include <functional>
|
||||
#include <windows.h>
|
||||
|
||||
#include "nsIDOMCSSStyleDeclaration.h"
|
||||
|
@ -57,12 +58,30 @@ public:
|
|||
*/
|
||||
static void RegisterNativeWindow(LPCWSTR aWindowClass);
|
||||
|
||||
typedef std::function<void(HWND)> NativeWindowCreateProc;
|
||||
|
||||
/**
|
||||
* Helper to create a window.
|
||||
*
|
||||
* NB: If additional setup needs to be done once the window has been created,
|
||||
* you should do so via aOnCreateProc. Hooks will fire during the
|
||||
* CreateNativeWindow call, thus triggering events in the AT.
|
||||
* Using aOnCreateProc guarantees that your additional initialization will
|
||||
* have completed prior to the AT receiving window creation events.
|
||||
*
|
||||
* For example:
|
||||
*
|
||||
* nsWinUtils::NativeWindowCreateProc onCreate([](HWND aHwnd) -> void {
|
||||
* DoSomeAwesomeInitializationStuff(aHwnd);
|
||||
* DoMoreAwesomeInitializationStuff(aHwnd);
|
||||
* });
|
||||
* HWND hwnd = nsWinUtils::CreateNativeWindow(..., &onCreate);
|
||||
* // Doing further initialization work to hwnd on this line is too late!
|
||||
*/
|
||||
static HWND CreateNativeWindow(LPCWSTR aWindowClass, HWND aParentWnd,
|
||||
int aX, int aY, int aWidth, int aHeight,
|
||||
bool aIsActive);
|
||||
bool aIsActive,
|
||||
NativeWindowCreateProc* aOnCreateProc = nullptr);
|
||||
|
||||
/**
|
||||
* Helper to show window.
|
||||
|
|
Загрузка…
Ссылка в новой задаче