Bug 1157784. Avoid compositing at the same time as WM_SETTEXT. f=jimm

The innards of Windows don't always recheck that the window is
visible and it will forget to redraw if we Present at the same
time that the window is invisible.
This commit is contained in:
Jeff Muizelaar 2015-05-13 16:05:35 -04:00
parent ff387c13a1
commit 99385c4734
2 changed files with 29 additions and 1 deletions

View File

@ -404,6 +404,8 @@ nsWindow::nsWindow() : nsWindowBase()
mIdleService = nullptr;
::InitializeCriticalSection(&mPresentLock);
sInstanceCount++;
}
@ -4701,12 +4703,19 @@ nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam,
{
// From msdn, the way around this is to disable the visible state
// temporarily. We need the text to be set but we don't want the
// redraw to occur.
// redraw to occur. However, we need to make sure that we don't
// do this at the same time that a Present is happening.
//
// To do this we take mPresentLock in nsWindow::PreRender and
// if that lock is taken we wait before doing WM_SETTEXT
EnterCriticalSection(&mPresentLock);
DWORD style = GetWindowLong(mWnd, GWL_STYLE);
SetWindowLong(mWnd, GWL_STYLE, style & ~WS_VISIBLE);
*aRetValue = CallWindowProcW(GetPrevWindowProc(), mWnd,
msg, wParam, lParam);
SetWindowLong(mWnd, GWL_STYLE, style);
LeaveCriticalSection(&mPresentLock);
return true;
}
@ -7556,6 +7565,21 @@ void nsWindow::PickerClosed()
}
}
bool nsWindow::PreRender(LayerManagerComposite*)
{
// This can block waiting for WM_SETTEXT to finish
// Using PreRender is unnecessarily pessimistic because
// we technically only need to block during the present call
// not all of compositor rendering
EnterCriticalSection(&mPresentLock);
return true;
}
void nsWindow::PostRender(LayerManagerComposite*)
{
LeaveCriticalSection(&mPresentLock);
}
/**************************************************************
**************************************************************
**

View File

@ -451,6 +451,8 @@ protected:
void ClearCachedResources();
nsIWidgetListener* GetPaintListener();
static bool IsRenderMode(gfxWindowsPlatform::RenderMode aMode);
virtual bool PreRender(LayerManagerComposite*) override;
virtual void PostRender(LayerManagerComposite*) override;
protected:
nsCOMPtr<nsIWidget> mParent;
@ -587,6 +589,8 @@ protected:
static bool sNeedsToInitMouseWheelSettings;
static void InitMouseWheelScrollData();
CRITICAL_SECTION mPresentLock;
};
/**