Bug 1573710 - make window resizing more robust to races. r=sotaro

Differential Revision: https://phabricator.services.mozilla.com/D49634

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Alexis Beingessner 2019-10-18 02:10:20 +00:00
Родитель 6c24ba64b2
Коммит d244997cc9
1 изменённых файлов: 12 добавлений и 1 удалений

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

@ -334,6 +334,17 @@ void WinCompositorWidget::UpdateCompositorWndSizeIfNecessary() {
return;
}
// This code is racing with the compositor, which needs to reparent
// the compositor surface to the actual window (mWnd). To avoid racing
// mutations, we refuse to proceed until GetParent returns the
// expected result. It's ok to fail to resize here since this function is
// called pretty frequently, and the reparenting race only happens when the
// window is being created for the first time.
HWND realParent = ::GetParent(mCompositorWnds.mCompositorWnd);
if (realParent != mWnd) {
return;
}
LayoutDeviceIntSize size = GetClientSize();
if (mLastCompositorWndSize == size) {
return;
@ -342,7 +353,7 @@ void WinCompositorWidget::UpdateCompositorWndSizeIfNecessary() {
// Force a resize and redraw (but not a move, activate, etc.).
if (!::SetWindowPos(mCompositorWnds.mCompositorWnd, nullptr, 0, 0, size.width,
size.height,
SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOCOPYBITS |
SWP_NOACTIVATE | SWP_NOCOPYBITS |
SWP_NOOWNERZORDER | SWP_NOZORDER)) {
return;
}