PreXULSkeletonUI.h (3417B)
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/Result.h" 12 #include "mozilla/Types.h" 13 #include "mozilla/Vector.h" 14 15 namespace mozilla { 16 17 // These unfortunately need to be kept in sync with the window style and 18 // extended window style computations in nsWindow. Luckily those styles seem 19 // to not vary based off of any user settings for the initial toplevel window, 20 // so we're safe here for now. 21 static const DWORD kPreXULSkeletonUIWindowStyle = 22 WS_CLIPCHILDREN | WS_DLGFRAME | WS_BORDER | WS_MAXIMIZEBOX | 23 WS_MINIMIZEBOX | WS_SIZEBOX | WS_SYSMENU; 24 static const DWORD kPreXULSkeletonUIWindowStyleEx = WS_EX_WINDOWEDGE; 25 26 struct CSSPixelSpan { 27 double start; 28 double end; 29 }; 30 31 struct DevPixelSpan { 32 int start; 33 int end; 34 }; 35 36 enum class SkeletonUIDensity { Default, Touch, Compact }; 37 38 struct SkeletonUISettings { 39 uint32_t screenX; 40 uint32_t screenY; 41 uint32_t width; 42 uint32_t height; 43 CSSPixelSpan urlbarSpan; 44 CSSPixelSpan searchbarSpan; 45 double cssToDevPixelScaling; 46 Vector<CSSPixelSpan> springs; 47 bool maximized; 48 bool menubarShown; 49 bool bookmarksToolbarShown; 50 bool rtlEnabled; 51 bool verticalTabs; 52 SkeletonUIDensity uiDensity; 53 }; 54 55 enum class ThemeMode : uint32_t { Invalid, Default, Dark, Light }; 56 57 enum class SkeletonUIFlag : uint8_t { 58 MenubarShown, 59 BookmarksToolbarShown, 60 RtlEnabled, 61 TouchDensity, 62 CompactDensity, 63 VerticalTabs 64 }; 65 66 struct ThemeColors { 67 uint32_t backgroundColor; 68 uint32_t toolbarForegroundColor; 69 uint32_t titlebarColor; 70 uint32_t tabColor; 71 uint32_t tabOutlineColor; 72 uint32_t chromeContentDividerColor; 73 uint32_t urlbarColor; 74 uint32_t urlbarBorderColor; 75 uint32_t animationColor; 76 }; 77 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, 102 }; 103 104 enum class PreXULSkeletonUIProgress : uint32_t { 105 Started, 106 Completed, 107 }; 108 109 MFBT_API void CreateAndStorePreXULSkeletonUI(HINSTANCE hInstance, int argc, 110 char** argv); 111 MFBT_API void CleanupProcessRuntime(); 112 MFBT_API bool GetPreXULSkeletonUIWasShown(); 113 MFBT_API HWND ConsumePreXULSkeletonUIHandle(); 114 MFBT_API bool WasPreXULSkeletonUIMaximized(); 115 MFBT_API Result<Ok, PreXULSkeletonUIError> PersistPreXULSkeletonUIValues( 116 const SkeletonUISettings& settings); 117 MFBT_API bool GetPreXULSkeletonUIEnabled(); 118 MFBT_API Result<Ok, PreXULSkeletonUIError> SetPreXULSkeletonUIEnabledIfAllowed( 119 bool value); 120 MFBT_API void PollPreXULSkeletonUIEvents(); 121 MFBT_API Result<Ok, PreXULSkeletonUIError> SetPreXULSkeletonUIThemeId( 122 ThemeMode theme); 123 MFBT_API Result<Ok, PreXULSkeletonUIError> NotePreXULSkeletonUIRestarting(); 124 125 } // namespace mozilla 126 127 #endif