Bug 1460022: Part 11 - Update Win32 nsWindow to work with revised DLL interceptor interface; r=mhowell

--HG--
extra : rebase_source : 273ea15e8379a8ff51ab6d37d210c86a9d72b78c
This commit is contained in:
Aaron Klotz 2018-06-27 11:52:01 -06:00
Родитель 991d4389a0
Коммит 2a9cc69e85
1 изменённых файлов: 22 добавлений и 24 удалений

Просмотреть файл

@ -352,9 +352,6 @@ static NS_DEFINE_CID(kCClipboardCID, NS_CLIPBOARD_CID);
// General purpose user32.dll hook object
static WindowsDllInterceptor sUser32Intercept;
// AddHook success checks
static mozilla::Maybe<bool> sHookedGetWindowInfo;
// 2 pixel offset for eTransparencyBorderlessGlass which equals the size of
// the default window border Windows paints. Glass will be extended inward
// this distance to remove the border.
@ -461,17 +458,17 @@ private:
if (!IsWin10OrLater() && GetModuleHandle(L"tiptsf.dll") &&
!sProcessCaretEventsStub) {
sTipTsfInterceptor.Init("tiptsf.dll");
DebugOnly<bool> ok = sTipTsfInterceptor.AddHook("ProcessCaretEvents",
reinterpret_cast<intptr_t>(&ProcessCaretEventsHook),
(void**) &sProcessCaretEventsStub);
DebugOnly<bool> ok = sProcessCaretEventsStub.Set(sTipTsfInterceptor,
"ProcessCaretEvents",
&ProcessCaretEventsHook);
MOZ_ASSERT(ok);
}
if (!sSendMessageTimeoutWStub) {
sUser32Intercept.Init("user32.dll");
DebugOnly<bool> hooked = sUser32Intercept.AddHook("SendMessageTimeoutW",
reinterpret_cast<intptr_t>(&SendMessageTimeoutWHook),
(void**) &sSendMessageTimeoutWStub);
DebugOnly<bool> hooked = sSendMessageTimeoutWStub.Set(sUser32Intercept,
"SendMessageTimeoutW",
&SendMessageTimeoutWHook);
MOZ_ASSERT(hooked);
}
}
@ -556,8 +553,10 @@ private:
}
static WindowsDllInterceptor sTipTsfInterceptor;
static WINEVENTPROC sProcessCaretEventsStub;
static decltype(&SendMessageTimeoutW) sSendMessageTimeoutWStub;
static WindowsDllInterceptor::FuncHookType<WINEVENTPROC>
sProcessCaretEventsStub;
static WindowsDllInterceptor::FuncHookType<decltype(&SendMessageTimeoutW)>
sSendMessageTimeoutWStub;
static StaticAutoPtr<TIPMessageHandler> sInstance;
HHOOK mHook;
@ -566,8 +565,10 @@ private:
};
WindowsDllInterceptor TIPMessageHandler::sTipTsfInterceptor;
WINEVENTPROC TIPMessageHandler::sProcessCaretEventsStub;
decltype(&SendMessageTimeoutW) TIPMessageHandler::sSendMessageTimeoutWStub;
WindowsDllInterceptor::FuncHookType<WINEVENTPROC>
TIPMessageHandler::sProcessCaretEventsStub;
WindowsDllInterceptor::FuncHookType<decltype(&SendMessageTimeoutW)>
TIPMessageHandler::sSendMessageTimeoutWStub;
StaticAutoPtr<TIPMessageHandler> TIPMessageHandler::sInstance;
} // namespace mozilla
@ -2472,7 +2473,7 @@ nsWindow::ResetLayout()
// margins are set.
static const wchar_t kManageWindowInfoProperty[] = L"ManageWindowInfoProperty";
typedef BOOL (WINAPI *GetWindowInfoPtr)(HWND hwnd, PWINDOWINFO pwi);
static GetWindowInfoPtr sGetWindowInfoPtrStub = nullptr;
static WindowsDllInterceptor::FuncHookType<GetWindowInfoPtr> sGetWindowInfoPtrStub;
BOOL WINAPI
GetWindowInfoHook(HWND hWnd, PWINDOWINFO pwi)
@ -2500,16 +2501,13 @@ nsWindow::UpdateGetWindowInfoCaptionStatus(bool aActiveCaption)
if (!mWnd)
return;
if (sHookedGetWindowInfo.isNothing()) {
sUser32Intercept.Init("user32.dll");
sHookedGetWindowInfo =
Some(sUser32Intercept.AddHook("GetWindowInfo",
reinterpret_cast<intptr_t>(GetWindowInfoHook),
(void**) &sGetWindowInfoPtrStub));
if (!sHookedGetWindowInfo.value()) {
sGetWindowInfoPtrStub.Set(sUser32Intercept, "GetWindowInfo",
&GetWindowInfoHook);
if (!sGetWindowInfoPtrStub) {
return;
}
}
// Update our internally tracked caption status
SetPropW(mWnd, kManageWindowInfoProperty,
reinterpret_cast<HANDLE>(static_cast<INT_PTR>(aActiveCaption) + 1));