Debian Codegraph @

mozglue/misc/PreXULSkeletonUI.h

raw
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/. */
6
7 #ifndef PreXULSkeletonUI_h_
8 #define PreXULSkeletonUI_h_
9
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"
16
17 namespace mozilla {
18
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_OVERLAPPED | WS_CLIPCHILDREN | WS_DLGFRAME | WS_BORDER | WS_THICKFRAME |
25 WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_SYSMENU;
26 static const DWORD kPreXULSkeletonUIWindowStyleEx = WS_EX_WINDOWEDGE;
27
28 struct CSSPixelSpan {
29 double start;
30 double end;
31 };
32
33 struct DevPixelSpan {
34 int start;
35 int end;
36 };
37
38 enum class SkeletonUIDensity { Default, Touch, Compact };
39
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 bool verticalTabs;
54 SkeletonUIDensity uiDensity;
55 };
56
57 enum class ThemeMode : uint32_t { Invalid, Default, Dark, Light };
58
59 enum class SkeletonUIFlag : uint8_t {
60 MenubarShown,
61 BookmarksToolbarShown,
62 RtlEnabled,
63 TouchDensity,
64 CompactDensity,
65 VerticalTabs
66 };
67
68 struct ThemeColors {
69 uint32_t backgroundColor;
70 uint32_t toolbarForegroundColor;
71 uint32_t titlebarColor;
72 uint32_t tabColor;
73 uint32_t tabOutlineColor;
74 uint32_t chromeContentDividerColor;
75 uint32_t urlbarColor;
76 uint32_t urlbarBorderColor;
77 uint32_t animationColor;
78 };
79
80 enum class PreXULSkeletonUIError : uint32_t {
81 None,
82 Disabled,
83 EnabledKeyDoesNotExist,
84 OOM,
85 Cmdline,
86 EnvVars,
87 FailedToOpenRegistryKey,
88 RegistryError,
89 FailedLoadingDynamicProcs,
90 FailedGettingLock,
91 FilesystemFailure,
92 NoStartWithLastProfile,
93 FailedRegisteringWindowClass,
94 CorruptData,
95 BadWindowDimensions,
96 FailedGettingMonitorInfo,
97 CreateWindowFailed,
98 FailedGettingDC,
99 FailedBlitting,
100 FailedFillingBottomRect,
101 CrashedOnce,
102 BadUIDensity,
103 Unknown,
104 };
105
106 enum class PreXULSkeletonUIProgress : uint32_t {
107 Started,
108 Completed,
109 };
110
111 MFBT_API void CreateAndStorePreXULSkeletonUI(HINSTANCE hInstance, int argc,
112 char** argv);
113 MFBT_API void CleanupProcessRuntime();
114 MFBT_API bool GetPreXULSkeletonUIWasShown();
115 MFBT_API HWND ConsumePreXULSkeletonUIHandle();
116 MFBT_API bool WasPreXULSkeletonUIMaximized();
117 MFBT_API Result<Ok, PreXULSkeletonUIError> PersistPreXULSkeletonUIValues(
118 const SkeletonUISettings& settings);
119 MFBT_API bool GetPreXULSkeletonUIEnabled();
120 MFBT_API Result<Ok, PreXULSkeletonUIError> SetPreXULSkeletonUIEnabledIfAllowed(
121 bool value);
122 MFBT_API void PollPreXULSkeletonUIEvents();
123 MFBT_API Result<Ok, PreXULSkeletonUIError> SetPreXULSkeletonUIThemeId(
124 ThemeMode theme);
125 MFBT_API Result<Ok, PreXULSkeletonUIError> NotePreXULSkeletonUIRestarting();
126
127 } // namespace mozilla
128
129 #endif