From 3ea567c134357bfa4224605897249d47703120f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Tue, 6 Apr 2021 13:44:06 +0000 Subject: [PATCH] Bug 1703205 - Don't query AlertNotificationOrigin from RemoteLookAndFeel. r=cmartin Since it's not read by child processes and it seems it might be expensive to get on windows. Differential Revision: https://phabricator.services.mozilla.com/D110908 --- widget/RemoteLookAndFeel.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/widget/RemoteLookAndFeel.cpp b/widget/RemoteLookAndFeel.cpp index 822829902dc8..f0eca1b97308 100644 --- a/widget/RemoteLookAndFeel.cpp +++ b/widget/RemoteLookAndFeel.cpp @@ -64,6 +64,17 @@ void RemoteLookAndFeel::SetDataImpl(FullLookAndFeel&& aData) { namespace { +// Some lnf values are somewhat expensive to get, and are not needed in child +// processes, so we can avoid querying them. +bool IsNeededInChildProcess(LookAndFeel::IntID aId) { + switch (aId) { + case LookAndFeel::IntID::AlertNotificationOrigin: + return false; // see bug 1703205 + default: + return true; + } +} + template Result MapLookup(const nsTArray& aItems, const nsTArray& aMap, ID aID) { @@ -119,6 +130,10 @@ nsresult RemoteLookAndFeel::NativeGetColor(ColorID aID, ColorScheme aScheme, } nsresult RemoteLookAndFeel::NativeGetInt(IntID aID, int32_t& aResult) { + MOZ_DIAGNOSTIC_ASSERT( + IsNeededInChildProcess(aID), + "Querying value that we didn't bother getting from the parent process!"); + const int32_t* result; MOZ_TRY_VAR(result, MapLookup(mTables.ints(), mTables.intMap(), aID)); aResult = *result; @@ -158,6 +173,9 @@ static bool AddIDsToMap(nsXPLookAndFeel* aImpl, FullLookAndFeel* aLf, bool anyFromOtherTheme = false; for (auto id : MakeEnumeratedRange(IntID::End)) { + if (!IsNeededInChildProcess(id)) { + continue; + } if (aDifferentTheme && aImpl->FromParentTheme(id) != aFromParentTheme) { anyFromOtherTheme = true; continue;