зеркало из https://github.com/mozilla/gecko-dev.git
bug 753274. Make `nsWindow::SubclassWindow` only fail if `mWnd` is an invalid window AND we're trying to apply a subclass (rather than remove a subclass). r=jimm
This commit is contained in:
Родитель
ed9a551900
Коммит
930ee483df
|
@ -850,32 +850,41 @@ DWORD nsWindow::WindowExStyle()
|
|||
// Subclass (or remove the subclass from) this component's nsWindow
|
||||
void nsWindow::SubclassWindow(BOOL bState)
|
||||
{
|
||||
if (NULL != mWnd) {
|
||||
//NS_PRECONDITION(::IsWindow(mWnd), "Invalid window handle");
|
||||
if (!::IsWindow(mWnd)) {
|
||||
if (bState) {
|
||||
if (!mWnd || !IsWindow(mWnd)) {
|
||||
NS_ERROR("Invalid window handle");
|
||||
}
|
||||
|
||||
if (bState) {
|
||||
// change the nsWindow proc
|
||||
if (mUnicodeWidget)
|
||||
mPrevWndProc = (WNDPROC)::SetWindowLongPtrW(mWnd, GWLP_WNDPROC,
|
||||
(LONG_PTR)nsWindow::WindowProc);
|
||||
else
|
||||
mPrevWndProc = (WNDPROC)::SetWindowLongPtrA(mWnd, GWLP_WNDPROC,
|
||||
(LONG_PTR)nsWindow::WindowProc);
|
||||
NS_ASSERTION(mPrevWndProc, "Null standard window procedure");
|
||||
// connect the this pointer to the nsWindow handle
|
||||
WinUtils::SetNSWindowPtr(mWnd, this);
|
||||
if (mUnicodeWidget) {
|
||||
mPrevWndProc =
|
||||
reinterpret_cast<WNDPROC>(
|
||||
SetWindowLongPtrW(mWnd,
|
||||
GWLP_WNDPROC,
|
||||
reinterpret_cast<LONG_PTR>(nsWindow::WindowProc)));
|
||||
} else {
|
||||
mPrevWndProc =
|
||||
reinterpret_cast<WNDPROC>(
|
||||
SetWindowLongPtrA(mWnd,
|
||||
GWLP_WNDPROC,
|
||||
reinterpret_cast<LONG_PTR>(nsWindow::WindowProc)));
|
||||
}
|
||||
else {
|
||||
if (mUnicodeWidget)
|
||||
::SetWindowLongPtrW(mWnd, GWLP_WNDPROC, (LONG_PTR)mPrevWndProc);
|
||||
else
|
||||
::SetWindowLongPtrA(mWnd, GWLP_WNDPROC, (LONG_PTR)mPrevWndProc);
|
||||
WinUtils::SetNSWindowPtr(mWnd, NULL);
|
||||
mPrevWndProc = NULL;
|
||||
NS_ASSERTION(mPrevWndProc, "Null standard window procedure");
|
||||
// connect the this pointer to the nsWindow handle
|
||||
WinUtils::SetNSWindowPtr(mWnd, this);
|
||||
} else {
|
||||
if (IsWindow(mWnd)) {
|
||||
if (mUnicodeWidget) {
|
||||
SetWindowLongPtrW(mWnd,
|
||||
GWLP_WNDPROC,
|
||||
reinterpret_cast<LONG_PTR>(mPrevWndProc));
|
||||
} else {
|
||||
SetWindowLongPtrA(mWnd,
|
||||
GWLP_WNDPROC,
|
||||
reinterpret_cast<LONG_PTR>(mPrevWndProc));
|
||||
}
|
||||
}
|
||||
WinUtils::SetNSWindowPtr(mWnd, NULL);
|
||||
mPrevWndProc = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче