1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
7 #ifndef PreXULSkeletonUI_h_
8 #define PreXULSkeletonUI_h_
11 #include "mozilla/EnumSet.h"
12 #include "mozilla/Maybe.h"
13 #include "mozilla/Result.h"
14 #include "mozilla/Types.h"
15 #include "mozilla/Vector.h"
19 // These unfortunately need to be kept in sync with the window style and
20 // extended window style computations in nsWindow. Luckily those styles seem
21 // to not vary based off of any user settings for the initial toplevel window,
22 // so we're safe here for now.
23 static const DWORD kPreXULSkeletonUIWindowStyle
=
24 WS_CLIPCHILDREN
| WS_DLGFRAME
| WS_BORDER
| WS_MAXIMIZEBOX
|
25 WS_MINIMIZEBOX
| WS_SIZEBOX
| WS_SYSMENU
;
26 static const DWORD kPreXULSkeletonUIWindowStyleEx
= WS_EX_WINDOWEDGE
;
38 enum class SkeletonUIDensity
{ Default
, Touch
, Compact
};
40 struct SkeletonUISettings
{
45 CSSPixelSpan urlbarSpan
;
46 CSSPixelSpan searchbarSpan
;
47 double cssToDevPixelScaling
;
48 Vector
<CSSPixelSpan
> springs
;
51 bool bookmarksToolbarShown
;
53 SkeletonUIDensity uiDensity
;
56 enum class ThemeMode
: uint32_t { Invalid
, Default
, Dark
, Light
};
58 enum class SkeletonUIFlag
: uint8_t {
60 BookmarksToolbarShown
,
67 uint32_t backgroundColor
;
68 uint32_t toolbarForegroundColor
;
71 uint32_t tabOutlineColor
;
72 uint32_t chromeContentDividerColor
;
74 uint32_t urlbarBorderColor
;
75 uint32_t animationColor
;
78 enum class PreXULSkeletonUIError
: uint32_t {
81 EnabledKeyDoesNotExist
,
85 FailedToOpenRegistryKey
,
87 FailedLoadingDynamicProcs
,
90 NoStartWithLastProfile
,
91 FailedRegisteringWindowClass
,
94 FailedGettingMonitorInfo
,
98 FailedFillingBottomRect
,
104 inline const wchar_t* GetPreXULSkeletonUIErrorString(
105 PreXULSkeletonUIError error
) {
107 case PreXULSkeletonUIError::None
:
109 case PreXULSkeletonUIError::Disabled
:
111 case PreXULSkeletonUIError::OOM
:
113 case PreXULSkeletonUIError::Cmdline
:
115 case PreXULSkeletonUIError::EnvVars
:
117 case PreXULSkeletonUIError::FailedToOpenRegistryKey
:
118 return L
"FailedToOpenRegistryKey";
119 case PreXULSkeletonUIError::RegistryError
:
120 return L
"RegistryError";
121 case PreXULSkeletonUIError::FailedLoadingDynamicProcs
:
122 return L
"FailedLoadingDynamicProcs";
123 case PreXULSkeletonUIError::FailedGettingLock
:
124 return L
"FailedGettingLock";
125 case PreXULSkeletonUIError::FilesystemFailure
:
126 return L
"FilesystemFailure";
127 case PreXULSkeletonUIError::NoStartWithLastProfile
:
128 return L
"NoStartWithLastProfile";
129 case PreXULSkeletonUIError::FailedRegisteringWindowClass
:
130 return L
"FailedRegisteringWindowClass";
131 case PreXULSkeletonUIError::CorruptData
:
132 return L
"CorruptData";
133 case PreXULSkeletonUIError::BadWindowDimensions
:
134 return L
"BadWindowDimensions";
135 case PreXULSkeletonUIError::FailedGettingMonitorInfo
:
136 return L
"FailedGettingMonitorInfo";
137 case PreXULSkeletonUIError::EnabledKeyDoesNotExist
:
138 return L
"EnabledKeyDoesNotExist";
139 case PreXULSkeletonUIError::CreateWindowFailed
:
140 return L
"CreateWindowFailed";
141 case PreXULSkeletonUIError::FailedGettingDC
:
142 return L
"FailedGettingDC";
143 case PreXULSkeletonUIError::FailedBlitting
:
144 return L
"FailedBlitting";
145 case PreXULSkeletonUIError::FailedFillingBottomRect
:
146 return L
"FailedFillingBottomRect";
147 case PreXULSkeletonUIError::CrashedOnce
:
148 return L
"CrashedOnce";
149 case PreXULSkeletonUIError::BadUIDensity
:
150 return L
"BadUIDensity";
151 case PreXULSkeletonUIError::Unknown
:
155 MOZ_ASSERT_UNREACHABLE();
159 enum class PreXULSkeletonUIProgress
: uint32_t {
164 MFBT_API
void CreateAndStorePreXULSkeletonUI(HINSTANCE hInstance
, int argc
,
166 MFBT_API
void CleanupProcessRuntime();
167 MFBT_API
bool GetPreXULSkeletonUIWasShown();
168 MFBT_API HWND
ConsumePreXULSkeletonUIHandle();
169 MFBT_API Maybe
<PreXULSkeletonUIError
> GetPreXULSkeletonUIErrorReason();
170 MFBT_API
bool WasPreXULSkeletonUIMaximized();
171 MFBT_API Result
<Ok
, PreXULSkeletonUIError
> PersistPreXULSkeletonUIValues(
172 const SkeletonUISettings
& settings
);
173 MFBT_API
bool GetPreXULSkeletonUIEnabled();
174 MFBT_API Result
<Ok
, PreXULSkeletonUIError
> SetPreXULSkeletonUIEnabledIfAllowed(
176 MFBT_API
void PollPreXULSkeletonUIEvents();
177 MFBT_API Result
<Ok
, PreXULSkeletonUIError
> SetPreXULSkeletonUIThemeId(
179 MFBT_API Result
<Ok
, PreXULSkeletonUIError
> NotePreXULSkeletonUIRestarting();
181 } // namespace mozilla