Skip to content

Commit

Permalink
Bug 1665459 - Control pre-xul skele UI registry value via prefs r=mho…
Browse files Browse the repository at this point in the history
…well

This patch uses the prefs relevant to the pre-xul skeleton UI to control the
registry value. There are three prefs:

- A new pref intended to be the global toggle once all themes can be handled.
- browser.startup.blankWindow - we currently depend on the code in BrowserGlue.jsm,
  gated on this pref, which immediately specifies the width and height of the
  window and ultimately causes XUL to consume and take ownership of our pre-xul
  window. Without this, we resize to fit a small content area, and then resize
  again back to the correct size.
- extensions.activeThemeID - Given that we have hardcoded layout and colors, we
  need to ensure that we're only presenting the skeleton UI for the default theme.

We're hoping to not need to gate on any prefs other than the new pref that we're
adding, but this allows us to provide a simple direction for users who may want
to dogfood our changes in the mean time: use the default theme, ensure the
browser.startup.blankWindow pref is set, and turn our new pref on.

Differential Revision: https://phabricator.services.mozilla.com/D90884
  • Loading branch information
squarewave committed Sep 21, 2020
1 parent 00727cc commit 7aced27
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
20 changes: 20 additions & 0 deletions mozglue/misc/EarlyBlankWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -514,4 +514,24 @@ void PersistEarlyBlankWindowValues(int screenX, int screenY, int width,
}
}

MFBT_API bool GetEarlyBlankWindowEnabled() { return sEarlyBlankWindowEnabled; }

MFBT_API void SetEarlyBlankWindowEnabled(bool value) {
HKEY regKey;
if (!OpenEarlyBlankWindowRegKey(regKey)) {
return;
}
AutoCloseRegKey closeKey(regKey);
DWORD enabled = value;
LSTATUS result =
::RegSetValueExW(regKey, L"enabled", 0, REG_DWORD,
reinterpret_cast<PBYTE>(&enabled), sizeof(enabled));
if (result != ERROR_SUCCESS) {
printf_stderr("Failed persisting enabled to Windows registry\n");
return;
}

sEarlyBlankWindowEnabled = true;
}

} // namespace mozilla
2 changes: 2 additions & 0 deletions mozglue/misc/EarlyBlankWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ MFBT_API HWND ConsumeEarlyBlankWindowHandle();
MFBT_API void PersistEarlyBlankWindowValues(int screenX, int screenY, int width,
int height,
double cssToDevPixelScaling);
MFBT_API bool GetEarlyBlankWindowEnabled();
MFBT_API void SetEarlyBlankWindowEnabled(bool value);

} // namespace mozilla

Expand Down
36 changes: 36 additions & 0 deletions toolkit/xre/nsAppRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
# include <intrin.h>
# include <math.h>
# include "cairo/cairo-features.h"
# include "mozilla/EarlyBlankWindow.h"
# include "mozilla/DllPrefetchExperimentRegistryInfo.h"
# include "mozilla/WindowsDllBlocklist.h"
# include "mozilla/WindowsProcessMitigations.h"
Expand Down Expand Up @@ -268,6 +269,13 @@ static const char kPrefSecurityContentSignatureRootHash[] =
"security.content.signature.root_hash";
#endif // defined(MOZ_DEFAULT_BROWSER_AGENT)

#if defined(XP_WIN)
static const char kPrefThemeId[] = "extensions.activeThemeID";
static const char kPrefBrowserStartupBlankWindow[] =
"browser.startup.blankWindow";
static const char kPrefPreXulSkeletonUI[] = "browser.startup.preXulSkeletonUI";
#endif // defined(XP_WIN)

int gArgc;
char** gArgv;

Expand Down Expand Up @@ -1591,6 +1599,33 @@ static void SetupAlteredPrefetchPref() {
PREF_WIN_ALTERED_DLL_PREFETCH);
}

static void ReflectSkeletonUIPrefToRegistry(const char* aPref, void* aData) {
Unused << aPref;
Unused << aData;

bool shouldBeEnabled =
Preferences::GetBool(kPrefPreXulSkeletonUI, false) &&
Preferences::GetBool(kPrefBrowserStartupBlankWindow, false);
if (shouldBeEnabled && Preferences::HasUserValue(kPrefThemeId)) {
nsCString themeId;
Preferences::GetCString(kPrefThemeId, themeId);
shouldBeEnabled = themeId.EqualsLiteral("[email protected]");
}

if (GetEarlyBlankWindowEnabled() != shouldBeEnabled) {
SetEarlyBlankWindowEnabled(shouldBeEnabled);
}
}

static void SetupSkeletonUIPrefs() {
ReflectSkeletonUIPrefToRegistry(nullptr, nullptr);
Preferences::RegisterCallback(&ReflectSkeletonUIPrefToRegistry,
kPrefPreXulSkeletonUI);
Preferences::RegisterCallback(&ReflectSkeletonUIPrefToRegistry,
kPrefBrowserStartupBlankWindow);
Preferences::RegisterCallback(&ReflectSkeletonUIPrefToRegistry, kPrefThemeId);
}

# if defined(MOZ_LAUNCHER_PROCESS)

static void OnLauncherPrefChanged(const char* aPref, void* aData) {
Expand Down Expand Up @@ -4625,6 +4660,7 @@ nsresult XREMain::XRE_mainRun() {
Preferences::RegisterCallbackAndCall(RegisterApplicationRestartChanged,
PREF_WIN_REGISTER_APPLICATION_RESTART);
SetupAlteredPrefetchPref();
SetupSkeletonUIPrefs();
# if defined(MOZ_LAUNCHER_PROCESS)
SetupLauncherProcessPref();
# endif // defined(MOZ_LAUNCHER_PROCESS)
Expand Down

0 comments on commit 7aced27

Please sign in to comment.