Skip to content

Commit 38680c0

Browse files
committed
Revert "Bug 1824053 - [4/4] cloak and clear new window before showing it r=win-reviewers,handyman"
This reverts commit 799ee37.
1 parent d17c1f9 commit 38680c0

File tree

1 file changed

+10
-61
lines changed

1 file changed

+10
-61
lines changed

mozglue/misc/PreXULSkeletonUI.cpp

Lines changed: 10 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#include "PreXULSkeletonUI.h"
88

99
#include <algorithm>
10-
#include <dwmapi.h>
1110
#include <math.h>
1211
#include <limits.h>
1312
#include <cmath>
@@ -148,8 +147,6 @@ MOZ_DECL_IMPORTED_WIN32_FN(GetMonitorInfoW);
148147
MOZ_DECL_IMPORTED_WIN32_FN(SetWindowLongPtrW);
149148
MOZ_DECL_IMPORTED_WIN32_FN(StretchDIBits);
150149
MOZ_DECL_IMPORTED_WIN32_FN(CreateSolidBrush);
151-
MOZ_DECL_IMPORTED_WIN32_FN(DwmGetWindowAttribute);
152-
MOZ_DECL_IMPORTED_WIN32_FN(DwmSetWindowAttribute);
153150
#undef MOZ_DECL_IMPORTED_WIN32_FN
154151

155152
static int sWindowWidth;
@@ -657,17 +654,6 @@ bool RasterizeAnimatedRect(const ColorRect& colorRect,
657654
return true;
658655
}
659656

660-
bool FillRectWithColor(HDC hdc, LPCRECT rect, uint32_t mozColor) {
661-
HBRUSH brush = sCreateSolidBrush(RGB((mozColor & 0xff0000) >> 16,
662-
(mozColor & 0x00ff00) >> 8,
663-
(mozColor & 0x0000ff) >> 0));
664-
int fillRectResult = sFillRect(hdc, rect, brush);
665-
666-
sDeleteObject(brush);
667-
668-
return !!fillRectResult;
669-
}
670-
671657
Result<Ok, PreXULSkeletonUIError> DrawSkeletonUI(
672658
HWND hWnd, CSSPixelSpan urlbarCSSSpan, CSSPixelSpan searchbarCSSSpan,
673659
Vector<CSSPixelSpan>& springs, const ThemeColors& currentTheme,
@@ -1078,10 +1064,15 @@ Result<Ok, PreXULSkeletonUIError> DrawSkeletonUI(
10781064

10791065
// Then, we just fill the rest with FillRect
10801066
RECT rect = {0, sTotalChromeHeight, sWindowWidth, sWindowHeight};
1081-
bool const fillRectOk =
1082-
FillRectWithColor(hdc, &rect, currentTheme.backgroundColor);
1067+
HBRUSH brush =
1068+
sCreateSolidBrush(RGB((currentTheme.backgroundColor & 0xff0000) >> 16,
1069+
(currentTheme.backgroundColor & 0x00ff00) >> 8,
1070+
(currentTheme.backgroundColor & 0x0000ff) >> 0));
1071+
int fillRectResult = sFillRect(hdc, &rect, brush);
10831072

1084-
if (!fillRectOk) {
1073+
sDeleteObject(brush);
1074+
1075+
if (fillRectResult == 0) {
10851076
return Err(PreXULSkeletonUIError::FailedFillingBottomRect);
10861077
}
10871078

@@ -1381,9 +1372,8 @@ Result<HKEY, PreXULSkeletonUIError> OpenPreXULSkeletonUIRegKey() {
13811372
Result<Ok, PreXULSkeletonUIError> LoadGdi32AndUser32Procedures() {
13821373
HMODULE user32Dll = ::LoadLibraryW(L"user32");
13831374
HMODULE gdi32Dll = ::LoadLibraryW(L"gdi32");
1384-
HMODULE dwmapiDll = ::LoadLibraryW(L"dwmapi.dll");
13851375

1386-
if (!user32Dll || !gdi32Dll || !dwmapiDll) {
1376+
if (!user32Dll || !gdi32Dll) {
13871377
return Err(PreXULSkeletonUIError::FailedLoadingDynamicProcs);
13881378
}
13891379

@@ -1419,8 +1409,6 @@ Result<Ok, PreXULSkeletonUIError> LoadGdi32AndUser32Procedures() {
14191409
MOZ_LOAD_OR_FAIL(user32Dll, ShowWindow);
14201410
MOZ_LOAD_OR_FAIL(user32Dll, SetWindowPos);
14211411
MOZ_LOAD_OR_FAIL(user32Dll, GetWindowDC);
1422-
MOZ_LOAD_OR_FAIL(user32Dll, GetWindowRect);
1423-
MOZ_LOAD_OR_FAIL(user32Dll, MapWindowPoints);
14241412
MOZ_LOAD_OR_FAIL(user32Dll, FillRect);
14251413
MOZ_LOAD_OR_FAIL(user32Dll, ReleaseDC);
14261414
MOZ_LOAD_OR_FAIL(user32Dll, LoadIconW);
@@ -1431,8 +1419,6 @@ Result<Ok, PreXULSkeletonUIError> LoadGdi32AndUser32Procedures() {
14311419
MOZ_LOAD_OR_FAIL(gdi32Dll, StretchDIBits);
14321420
MOZ_LOAD_OR_FAIL(gdi32Dll, CreateSolidBrush);
14331421
MOZ_LOAD_OR_FAIL(gdi32Dll, DeleteObject);
1434-
MOZ_LOAD_OR_FAIL(dwmapiDll, DwmGetWindowAttribute);
1435-
MOZ_LOAD_OR_FAIL(dwmapiDll, DwmSetWindowAttribute);
14361422

14371423
#undef MOZ_LOAD_OR_FAIL
14381424

@@ -1932,44 +1918,7 @@ static Result<Ok, PreXULSkeletonUIError> CreateAndStorePreXULSkeletonUIImpl(
19321918
return Err(PreXULSkeletonUIError::CreateWindowFailed);
19331919
}
19341920

1935-
// DWM displays garbage immediately on Show(), and that garbage is usually
1936-
// mostly #FFFFFF. To avoid a bright flash when the window is first created,
1937-
// cloak the window while showing it, and fill it with the appropriate
1938-
// background color before uncloaking it.
1939-
if (sDwmGetWindowAttribute != nullptr) {
1940-
constexpr static auto const CloakWindow = [](HWND hwnd, BOOL state) {
1941-
sDwmSetWindowAttribute(sPreXULSkeletonUIWindow, DWMWA_CLOAK, &state,
1942-
sizeof(state));
1943-
};
1944-
// Equivalent to ::OffsetRect, with no dynamic-symbol resolution needed.
1945-
constexpr static auto const OffsetRect = [](LPRECT rect, int dx, int dy) {
1946-
rect->left += dx;
1947-
rect->top += dy;
1948-
rect->right += dx;
1949-
rect->bottom += dy;
1950-
};
1951-
1952-
CloakWindow(sPreXULSkeletonUIWindow, TRUE);
1953-
auto const _uncloak =
1954-
MakeScopeExit([&]() { CloakWindow(sPreXULSkeletonUIWindow, FALSE); });
1955-
sShowWindow(sPreXULSkeletonUIWindow, showCmd);
1956-
1957-
HDC hdc = sGetWindowDC(sPreXULSkeletonUIWindow);
1958-
if (!hdc) {
1959-
return Err(PreXULSkeletonUIError::FailedGettingDC);
1960-
}
1961-
auto const _cleanupDC =
1962-
MakeScopeExit([&] { sReleaseDC(sPreXULSkeletonUIWindow, hdc); });
1963-
1964-
// This should match the related code in nsWindow::Show.
1965-
RECT rect;
1966-
sGetWindowRect(sPreXULSkeletonUIWindow, &rect); // includes non-client area
1967-
// screen-to-client (handling RTL if necessary)
1968-
sMapWindowPoints(HWND_DESKTOP, sPreXULSkeletonUIWindow, (LPPOINT)&rect, 2);
1969-
// client-to-window (no RTL handling needed)
1970-
OffsetRect(&rect, -rect.left, -rect.top);
1971-
FillRectWithColor(hdc, &rect, currentTheme.backgroundColor);
1972-
}
1921+
sShowWindow(sPreXULSkeletonUIWindow, showCmd);
19731922

19741923
sDpi = sGetDpiForWindow(sPreXULSkeletonUIWindow);
19751924
sNonClientHorizontalMargins =

0 commit comments

Comments
 (0)