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
This commit is contained in:
Emilio Cobos Álvarez 2021-04-06 13:44:06 +00:00
Родитель ed779cb1e2
Коммит 3ea567c134
1 изменённых файлов: 18 добавлений и 0 удалений

Просмотреть файл

@ -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 <typename Item, typename UInt, typename ID>
Result<const Item*, nsresult> MapLookup(const nsTArray<Item>& aItems,
const nsTArray<UInt>& 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;