Merge mozilla-central to autoland. CLOSED TREE
[gecko.git] / mozglue / misc / PreXULSkeletonUI.h
blobc0549cd4e62e42b593768ec9cab032dee90ebcbd
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_
10 #include <windows.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"
17 namespace mozilla {
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;
28 struct CSSPixelSpan {
29 double start;
30 double end;
33 struct DevPixelSpan {
34 int start;
35 int end;
38 enum class SkeletonUIDensity { Default, Touch, Compact };
40 struct SkeletonUISettings {
41 uint32_t screenX;
42 uint32_t screenY;
43 uint32_t width;
44 uint32_t height;
45 CSSPixelSpan urlbarSpan;
46 CSSPixelSpan searchbarSpan;
47 double cssToDevPixelScaling;
48 Vector<CSSPixelSpan> springs;
49 bool maximized;
50 bool menubarShown;
51 bool bookmarksToolbarShown;
52 bool rtlEnabled;
53 SkeletonUIDensity uiDensity;
56 enum class ThemeMode : uint32_t { Invalid, Default, Dark, Light };
58 enum class SkeletonUIFlag : uint8_t {
59 MenubarShown,
60 BookmarksToolbarShown,
61 RtlEnabled,
62 TouchDensity,
63 CompactDensity,
66 struct ThemeColors {
67 uint32_t backgroundColor;
68 uint32_t toolbarForegroundColor;
69 uint32_t tabBarColor;
70 uint32_t tabColor;
71 uint32_t tabOutlineColor;
72 uint32_t chromeContentDividerColor;
73 uint32_t urlbarColor;
74 uint32_t urlbarBorderColor;
75 uint32_t animationColor;
78 enum class PreXULSkeletonUIError : uint32_t {
79 None,
80 Disabled,
81 EnabledKeyDoesNotExist,
82 OOM,
83 Cmdline,
84 EnvVars,
85 FailedToOpenRegistryKey,
86 RegistryError,
87 FailedLoadingDynamicProcs,
88 FailedGettingLock,
89 FilesystemFailure,
90 NoStartWithLastProfile,
91 FailedRegisteringWindowClass,
92 CorruptData,
93 BadWindowDimensions,
94 FailedGettingMonitorInfo,
95 CreateWindowFailed,
96 FailedGettingDC,
97 FailedBlitting,
98 FailedFillingBottomRect,
99 CrashedOnce,
100 BadUIDensity,
101 Unknown,
104 inline const wchar_t* GetPreXULSkeletonUIErrorString(
105 PreXULSkeletonUIError error) {
106 switch (error) {
107 case PreXULSkeletonUIError::None:
108 return L"None";
109 case PreXULSkeletonUIError::Disabled:
110 return L"Disabled";
111 case PreXULSkeletonUIError::OOM:
112 return L"OOM";
113 case PreXULSkeletonUIError::Cmdline:
114 return L"Cmdline";
115 case PreXULSkeletonUIError::EnvVars:
116 return L"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:
152 return L"Unknown";
155 MOZ_ASSERT_UNREACHABLE();
156 return L"Unknown";
159 enum class PreXULSkeletonUIProgress : uint32_t {
160 Started,
161 Completed,
164 MFBT_API void CreateAndStorePreXULSkeletonUI(HINSTANCE hInstance, int argc,
165 char** argv);
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(
175 bool value);
176 MFBT_API void PollPreXULSkeletonUIEvents();
177 MFBT_API Result<Ok, PreXULSkeletonUIError> SetPreXULSkeletonUIThemeId(
178 ThemeMode theme);
179 MFBT_API Result<Ok, PreXULSkeletonUIError> NotePreXULSkeletonUIRestarting();
181 } // namespace mozilla
183 #endif