7
7
#include " PreXULSkeletonUI.h"
8
8
9
9
#include < algorithm>
10
- #include < dwmapi.h>
11
10
#include < math.h>
12
11
#include < limits.h>
13
12
#include < cmath>
@@ -148,8 +147,6 @@ MOZ_DECL_IMPORTED_WIN32_FN(GetMonitorInfoW);
148
147
MOZ_DECL_IMPORTED_WIN32_FN (SetWindowLongPtrW);
149
148
MOZ_DECL_IMPORTED_WIN32_FN (StretchDIBits);
150
149
MOZ_DECL_IMPORTED_WIN32_FN (CreateSolidBrush);
151
- MOZ_DECL_IMPORTED_WIN32_FN (DwmGetWindowAttribute);
152
- MOZ_DECL_IMPORTED_WIN32_FN (DwmSetWindowAttribute);
153
150
#undef MOZ_DECL_IMPORTED_WIN32_FN
154
151
155
152
static int sWindowWidth ;
@@ -657,17 +654,6 @@ bool RasterizeAnimatedRect(const ColorRect& colorRect,
657
654
return true ;
658
655
}
659
656
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
-
671
657
Result<Ok, PreXULSkeletonUIError> DrawSkeletonUI (
672
658
HWND hWnd, CSSPixelSpan urlbarCSSSpan, CSSPixelSpan searchbarCSSSpan,
673
659
Vector<CSSPixelSpan>& springs, const ThemeColors& currentTheme,
@@ -1078,10 +1064,15 @@ Result<Ok, PreXULSkeletonUIError> DrawSkeletonUI(
1078
1064
1079
1065
// Then, we just fill the rest with FillRect
1080
1066
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);
1083
1072
1084
- if (!fillRectOk) {
1073
+ sDeleteObject (brush);
1074
+
1075
+ if (fillRectResult == 0 ) {
1085
1076
return Err (PreXULSkeletonUIError::FailedFillingBottomRect);
1086
1077
}
1087
1078
@@ -1381,9 +1372,8 @@ Result<HKEY, PreXULSkeletonUIError> OpenPreXULSkeletonUIRegKey() {
1381
1372
Result<Ok, PreXULSkeletonUIError> LoadGdi32AndUser32Procedures () {
1382
1373
HMODULE user32Dll = ::LoadLibraryW (L" user32" );
1383
1374
HMODULE gdi32Dll = ::LoadLibraryW (L" gdi32" );
1384
- HMODULE dwmapiDll = ::LoadLibraryW (L" dwmapi.dll" );
1385
1375
1386
- if (!user32Dll || !gdi32Dll || !dwmapiDll ) {
1376
+ if (!user32Dll || !gdi32Dll) {
1387
1377
return Err (PreXULSkeletonUIError::FailedLoadingDynamicProcs);
1388
1378
}
1389
1379
@@ -1419,8 +1409,6 @@ Result<Ok, PreXULSkeletonUIError> LoadGdi32AndUser32Procedures() {
1419
1409
MOZ_LOAD_OR_FAIL (user32Dll, ShowWindow);
1420
1410
MOZ_LOAD_OR_FAIL (user32Dll, SetWindowPos);
1421
1411
MOZ_LOAD_OR_FAIL (user32Dll, GetWindowDC);
1422
- MOZ_LOAD_OR_FAIL (user32Dll, GetWindowRect);
1423
- MOZ_LOAD_OR_FAIL (user32Dll, MapWindowPoints);
1424
1412
MOZ_LOAD_OR_FAIL (user32Dll, FillRect);
1425
1413
MOZ_LOAD_OR_FAIL (user32Dll, ReleaseDC);
1426
1414
MOZ_LOAD_OR_FAIL (user32Dll, LoadIconW);
@@ -1431,8 +1419,6 @@ Result<Ok, PreXULSkeletonUIError> LoadGdi32AndUser32Procedures() {
1431
1419
MOZ_LOAD_OR_FAIL (gdi32Dll, StretchDIBits);
1432
1420
MOZ_LOAD_OR_FAIL (gdi32Dll, CreateSolidBrush);
1433
1421
MOZ_LOAD_OR_FAIL (gdi32Dll, DeleteObject);
1434
- MOZ_LOAD_OR_FAIL (dwmapiDll, DwmGetWindowAttribute);
1435
- MOZ_LOAD_OR_FAIL (dwmapiDll, DwmSetWindowAttribute);
1436
1422
1437
1423
#undef MOZ_LOAD_OR_FAIL
1438
1424
@@ -1932,44 +1918,7 @@ static Result<Ok, PreXULSkeletonUIError> CreateAndStorePreXULSkeletonUIImpl(
1932
1918
return Err (PreXULSkeletonUIError::CreateWindowFailed);
1933
1919
}
1934
1920
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);
1973
1922
1974
1923
sDpi = sGetDpiForWindow (sPreXULSkeletonUIWindow );
1975
1924
sNonClientHorizontalMargins =
0 commit comments