зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1486971 - Query NSWorkspace.accessibilityDisplayShouldReduceMotion only if it's on parent processes or it's the initial query on child processes. r=mstange
In child processes on MacOSX we don't spin native event loop at all. Without native event loops NSWorkspace.accessibilityDisplayShouldReduceMotion doesn't return up-to-date value when the system setting changed for some reasons. To workaround this we use NSWorkspace.accessibilityDisplayShouldReduceMotion only on the parent process which spins native event loop or when it's the initial query on the child process. And we give the up-to-date value to the child process via an IPC call just like other cached values do. Depends on D5002 Differential Revision: https://phabricator.services.mozilla.com/D5003 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
04128e57a7
Коммит
1683335036
|
@ -46,6 +46,9 @@ private:
|
|||
int32_t mAllowOverlayScrollbarsOverlap;
|
||||
bool mAllowOverlayScrollbarsOverlapCached;
|
||||
|
||||
int32_t mPrefersReducedMotion;
|
||||
bool mPrefersReducedMotionCached;
|
||||
|
||||
nscolor mColorTextSelectBackground;
|
||||
nscolor mColorTextSelectBackgroundDisabled;
|
||||
nscolor mColorHighlight;
|
||||
|
|
|
@ -43,6 +43,8 @@ nsLookAndFeel::nsLookAndFeel()
|
|||
, mUseOverlayScrollbarsCached(false)
|
||||
, mAllowOverlayScrollbarsOverlap(-1)
|
||||
, mAllowOverlayScrollbarsOverlapCached(false)
|
||||
, mPrefersReducedMotion(-1)
|
||||
, mPrefersReducedMotionCached(false)
|
||||
, mColorTextSelectBackground(0)
|
||||
, mColorTextSelectBackgroundDisabled(0)
|
||||
, mColorHighlight(0)
|
||||
|
@ -119,6 +121,7 @@ nsLookAndFeel::RefreshImpl()
|
|||
if (XRE_IsParentProcess()) {
|
||||
mUseOverlayScrollbarsCached = false;
|
||||
mAllowOverlayScrollbarsOverlapCached = false;
|
||||
mPrefersReducedMotionCached = false;
|
||||
}
|
||||
|
||||
// Fetch colors next time they are requested.
|
||||
|
@ -550,12 +553,20 @@ nsLookAndFeel::GetIntImpl(IntID aID, int32_t &aResult)
|
|||
aResult = SystemWantsDarkTheme();
|
||||
break;
|
||||
case eIntID_PrefersReducedMotion:
|
||||
aResult = 0;
|
||||
if ([[NSWorkspace sharedWorkspace] respondsToSelector:@selector(
|
||||
accessibilityDisplayShouldReduceMotion)]) {
|
||||
aResult =
|
||||
[[NSWorkspace sharedWorkspace] accessibilityDisplayShouldReduceMotion] ? 1 : 0;
|
||||
// Without native event loops,
|
||||
// NSWorkspace.accessibilityDisplayShouldReduceMotion returns stale
|
||||
// information, so we get the information only on the parent processes
|
||||
// or when it's the initial query on child processes. Otherwise we will
|
||||
// get the info via LookAndFeel::SetIntCache on child processes.
|
||||
if (!mPrefersReducedMotionCached &&
|
||||
[[NSWorkspace sharedWorkspace] respondsToSelector:@selector(
|
||||
accessibilityDisplayShouldReduceMotion)]) {
|
||||
mPrefersReducedMotion =
|
||||
[[NSWorkspace sharedWorkspace]
|
||||
accessibilityDisplayShouldReduceMotion] ? 1 : 0;
|
||||
mPrefersReducedMotionCached = true;
|
||||
}
|
||||
aResult = mPrefersReducedMotion;
|
||||
break;
|
||||
default:
|
||||
aResult = 0;
|
||||
|
@ -661,6 +672,11 @@ nsLookAndFeel::GetIntCacheImpl()
|
|||
allowOverlayScrollbarsOverlap.value = GetInt(eIntID_AllowOverlayScrollbarsOverlap);
|
||||
lookAndFeelIntCache.AppendElement(allowOverlayScrollbarsOverlap);
|
||||
|
||||
LookAndFeelInt prefersReducedMotion;
|
||||
prefersReducedMotion.id = eIntID_PrefersReducedMotion;
|
||||
prefersReducedMotion.value = GetInt(eIntID_PrefersReducedMotion);
|
||||
lookAndFeelIntCache.AppendElement(prefersReducedMotion);
|
||||
|
||||
return lookAndFeelIntCache;
|
||||
}
|
||||
|
||||
|
@ -677,6 +693,10 @@ nsLookAndFeel::SetIntCacheImpl(const nsTArray<LookAndFeelInt>& aLookAndFeelIntCa
|
|||
mAllowOverlayScrollbarsOverlap = entry.value;
|
||||
mAllowOverlayScrollbarsOverlapCached = true;
|
||||
break;
|
||||
case eIntID_PrefersReducedMotion:
|
||||
mPrefersReducedMotion = entry.value;
|
||||
mPrefersReducedMotionCached = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче