зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 3 changesets (bug 1606503) for causing bustages in nsXPLookAndFeel.cpp CLOSED TREE
Backed out changeset 7e9d421335e0 (bug 1606503) Backed out changeset 371f74475fb9 (bug 1606503) Backed out changeset 8aada655d8bc (bug 1606503)
This commit is contained in:
Родитель
0b1488e159
Коммит
c03a2cf53a
|
@ -37,16 +37,10 @@ async function promiseForChange(mediaQuery) {
|
||||||
}
|
}
|
||||||
|
|
||||||
add_task(async () => {
|
add_task(async () => {
|
||||||
const initiallyMatches =
|
|
||||||
window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
||||||
|
|
||||||
SpecialPowers.DOMWindowUtils.setPrefersReducedMotionOverrideForTest(false);
|
SpecialPowers.DOMWindowUtils.setPrefersReducedMotionOverrideForTest(false);
|
||||||
|
|
||||||
if (initiallyMatches) {
|
// Need to wait a frame since MediaQuery changes are asynchronously processed.
|
||||||
await promiseForChange('(prefers-reduced-motion: reduce)');
|
|
||||||
} else {
|
|
||||||
await waitForFrame();
|
await waitForFrame();
|
||||||
}
|
|
||||||
|
|
||||||
ok(!window.matchMedia('(prefers-reduced-motion: reduce)').matches,
|
ok(!window.matchMedia('(prefers-reduced-motion: reduce)').matches,
|
||||||
'Does not matches prefers-reduced-motion: reduced) when the system sets ' +
|
'Does not matches prefers-reduced-motion: reduced) when the system sets ' +
|
||||||
|
|
|
@ -534,10 +534,6 @@ class LookAndFeel {
|
||||||
* or not.
|
* or not.
|
||||||
*/
|
*/
|
||||||
static void SetShouldRetainCacheForTest(bool aValue);
|
static void SetShouldRetainCacheForTest(bool aValue);
|
||||||
|
|
||||||
static void SetPrefersReducedMotionOverrideForTest(bool aValue);
|
|
||||||
|
|
||||||
static void ResetPrefersReducedMotionOverrideForTest();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
|
@ -1445,6 +1445,9 @@ nsresult PuppetWidget::SetPrefersReducedMotionOverrideForTest(bool aValue) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsXPLookAndFeel::GetInstance()->SetPrefersReducedMotionOverrideForTest(
|
||||||
|
aValue);
|
||||||
|
|
||||||
mBrowserChild->SendSetPrefersReducedMotionOverrideForTest(aValue);
|
mBrowserChild->SendSetPrefersReducedMotionOverrideForTest(aValue);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -1454,6 +1457,7 @@ nsresult PuppetWidget::ResetPrefersReducedMotionOverrideForTest() {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsXPLookAndFeel::GetInstance()->ResetPrefersReducedMotionOverrideForTest();
|
||||||
mBrowserChild->SendResetPrefersReducedMotionOverrideForTest();
|
mBrowserChild->SendResetPrefersReducedMotionOverrideForTest();
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,18 +76,10 @@ void nsLookAndFeel::NativeInit() {
|
||||||
|
|
||||||
/* virtual */
|
/* virtual */
|
||||||
void nsLookAndFeel::RefreshImpl() {
|
void nsLookAndFeel::RefreshImpl() {
|
||||||
if (mShouldRetainCacheForTest) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsXPLookAndFeel::RefreshImpl();
|
nsXPLookAndFeel::RefreshImpl();
|
||||||
|
|
||||||
mInitializedSystemColors = false;
|
mInitializedSystemColors = false;
|
||||||
mInitializedShowPassword = false;
|
mInitializedShowPassword = false;
|
||||||
|
|
||||||
if (XRE_IsParentProcess()) {
|
|
||||||
mPrefersReducedMotionCached = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult nsLookAndFeel::NativeGetColor(ColorID aID, nscolor& aColor) {
|
nsresult nsLookAndFeel::NativeGetColor(ColorID aID, nscolor& aColor) {
|
||||||
|
@ -420,11 +412,11 @@ nsresult nsLookAndFeel::GetIntImpl(IntID aID, int32_t& aResult) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case eIntID_PrefersReducedMotion:
|
case eIntID_PrefersReducedMotion:
|
||||||
if (!mPrefersReducedMotionCached && XRE_IsParentProcess()) {
|
if (sIsInPrefersReducedMotionForTest) {
|
||||||
mPrefersReducedMotion =
|
aResult = sPrefersReducedMotionForTest ? 1 : 0;
|
||||||
java::GeckoSystemStateListener::PrefersReducedMotion() ? 1 : 0;
|
break;
|
||||||
}
|
}
|
||||||
aResult = mPrefersReducedMotion;
|
aResult = java::GeckoSystemStateListener::PrefersReducedMotion() ? 1 : 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case eIntID_PrimaryPointerCapabilities:
|
case eIntID_PrimaryPointerCapabilities:
|
||||||
|
@ -521,28 +513,3 @@ void nsLookAndFeel::EnsureInitShowPassword() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nsTArray<LookAndFeelInt> nsLookAndFeel::GetIntCacheImpl() {
|
|
||||||
nsTArray<LookAndFeelInt> lookAndFeelIntCache =
|
|
||||||
nsXPLookAndFeel::GetIntCacheImpl();
|
|
||||||
|
|
||||||
const IntID kIdsToCache[] = {eIntID_PrefersReducedMotion};
|
|
||||||
|
|
||||||
for (IntID id : kIdsToCache) {
|
|
||||||
lookAndFeelIntCache.AppendElement(
|
|
||||||
LookAndFeelInt{id, {.value = GetInt(id)}});
|
|
||||||
}
|
|
||||||
|
|
||||||
return lookAndFeelIntCache;
|
|
||||||
}
|
|
||||||
|
|
||||||
void nsLookAndFeel::SetIntCacheImpl(
|
|
||||||
const nsTArray<LookAndFeelInt>& aLookAndFeelIntCache) {
|
|
||||||
for (const auto& entry : aLookAndFeelIntCache) {
|
|
||||||
switch (entry.id) {
|
|
||||||
case eIntID_PrefersReducedMotion:
|
|
||||||
mPrefersReducedMotion = entry.value;
|
|
||||||
mPrefersReducedMotionCached = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -23,9 +23,6 @@ class nsLookAndFeel final : public nsXPLookAndFeel {
|
||||||
virtual bool GetEchoPasswordImpl() override;
|
virtual bool GetEchoPasswordImpl() override;
|
||||||
virtual uint32_t GetPasswordMaskDelayImpl() override;
|
virtual uint32_t GetPasswordMaskDelayImpl() override;
|
||||||
virtual char16_t GetPasswordCharacterImpl() override;
|
virtual char16_t GetPasswordCharacterImpl() override;
|
||||||
virtual nsTArray<LookAndFeelInt> GetIntCacheImpl() override;
|
|
||||||
virtual void SetIntCacheImpl(
|
|
||||||
const nsTArray<LookAndFeelInt>& aLookAndFeelIntCache) override;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static bool mInitializedSystemColors;
|
static bool mInitializedSystemColors;
|
||||||
|
|
|
@ -2336,15 +2336,15 @@ void nsWindow::UpdateDynamicToolbarOffset(ScreenIntCoord aOffset) {
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult nsWindow::SetPrefersReducedMotionOverrideForTest(bool aValue) {
|
nsresult nsWindow::SetPrefersReducedMotionOverrideForTest(bool aValue) {
|
||||||
LookAndFeel::SetPrefersReducedMotionOverrideForTest(aValue);
|
nsXPLookAndFeel::GetInstance()->SetPrefersReducedMotionOverrideForTest(
|
||||||
|
aValue);
|
||||||
|
|
||||||
// Notify as if the corresponding setting changed.
|
|
||||||
java::GeckoSystemStateListener::NotifyPrefersReducedMotionChangedForTest();
|
java::GeckoSystemStateListener::NotifyPrefersReducedMotionChangedForTest();
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult nsWindow::ResetPrefersReducedMotionOverrideForTest() {
|
nsresult nsWindow::ResetPrefersReducedMotionOverrideForTest() {
|
||||||
LookAndFeel::ResetPrefersReducedMotionOverrideForTest();
|
nsXPLookAndFeel::GetInstance()->ResetPrefersReducedMotionOverrideForTest();
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2190,7 +2190,24 @@ void nsChildView::LookUpDictionary(const nsAString& aText,
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult nsChildView::SetPrefersReducedMotionOverrideForTest(bool aValue) {
|
nsresult nsChildView::SetPrefersReducedMotionOverrideForTest(bool aValue) {
|
||||||
LookAndFeel::SetPrefersReducedMotionOverrideForTest(aValue);
|
// Tell that the cache value we are going to set isn't cleared via
|
||||||
|
// nsPresContext::ThemeChangedInternal which is called right before
|
||||||
|
// we queue the media feature value change for this prefers-reduced-motion
|
||||||
|
// change.
|
||||||
|
LookAndFeel::SetShouldRetainCacheForTest(true);
|
||||||
|
|
||||||
|
LookAndFeelInt prefersReducedMotion;
|
||||||
|
prefersReducedMotion.id = LookAndFeel::eIntID_PrefersReducedMotion;
|
||||||
|
prefersReducedMotion.value = aValue ? 1 : 0;
|
||||||
|
|
||||||
|
AutoTArray<LookAndFeelInt, 1> lookAndFeelCache;
|
||||||
|
lookAndFeelCache.AppendElement(prefersReducedMotion);
|
||||||
|
|
||||||
|
// If we could have a way to modify
|
||||||
|
// NSWorkspace.accessibilityDisplayShouldReduceMotion, we could use it, but
|
||||||
|
// unfortunately there is no way, so we change the cache value instead as if
|
||||||
|
// it's set in the parent process.
|
||||||
|
LookAndFeel::SetIntCache(lookAndFeelCache);
|
||||||
|
|
||||||
if (nsCocoaFeatures::OnMojaveOrLater() &&
|
if (nsCocoaFeatures::OnMojaveOrLater() &&
|
||||||
NSWorkspaceAccessibilityDisplayOptionsDidChangeNotification) {
|
NSWorkspaceAccessibilityDisplayOptionsDidChangeNotification) {
|
||||||
|
@ -2210,7 +2227,7 @@ nsresult nsChildView::SetPrefersReducedMotionOverrideForTest(bool aValue) {
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult nsChildView::ResetPrefersReducedMotionOverrideForTest() {
|
nsresult nsChildView::ResetPrefersReducedMotionOverrideForTest() {
|
||||||
LookAndFeel::ResetPrefersReducedMotionOverrideForTest();
|
LookAndFeel::SetShouldRetainCacheForTest(false);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,9 @@ class nsLookAndFeel final : public nsXPLookAndFeel {
|
||||||
int32_t mAllowOverlayScrollbarsOverlap;
|
int32_t mAllowOverlayScrollbarsOverlap;
|
||||||
bool mAllowOverlayScrollbarsOverlapCached;
|
bool mAllowOverlayScrollbarsOverlapCached;
|
||||||
|
|
||||||
|
int32_t mPrefersReducedMotion;
|
||||||
|
bool mPrefersReducedMotionCached;
|
||||||
|
|
||||||
int32_t mSystemUsesDarkTheme;
|
int32_t mSystemUsesDarkTheme;
|
||||||
bool mSystemUsesDarkThemeCached;
|
bool mSystemUsesDarkThemeCached;
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,8 @@ nsLookAndFeel::nsLookAndFeel()
|
||||||
mUseOverlayScrollbarsCached(false),
|
mUseOverlayScrollbarsCached(false),
|
||||||
mAllowOverlayScrollbarsOverlap(-1),
|
mAllowOverlayScrollbarsOverlap(-1),
|
||||||
mAllowOverlayScrollbarsOverlapCached(false),
|
mAllowOverlayScrollbarsOverlapCached(false),
|
||||||
|
mPrefersReducedMotion(-1),
|
||||||
|
mPrefersReducedMotionCached(false),
|
||||||
mSystemUsesDarkTheme(-1),
|
mSystemUsesDarkTheme(-1),
|
||||||
mSystemUsesDarkThemeCached(false),
|
mSystemUsesDarkThemeCached(false),
|
||||||
mColorTextSelectBackground(0),
|
mColorTextSelectBackground(0),
|
||||||
|
|
|
@ -92,6 +92,7 @@ class nsLookAndFeel final : public nsXPLookAndFeel {
|
||||||
char16_t mInvisibleCharacter = 0;
|
char16_t mInvisibleCharacter = 0;
|
||||||
float mCaretRatio = 0.0f;
|
float mCaretRatio = 0.0f;
|
||||||
int32_t mCaretBlinkTime = 0;
|
int32_t mCaretBlinkTime = 0;
|
||||||
|
int32_t mPrefersReducedMotion = -1;
|
||||||
bool mMenuSupportsDrag = false;
|
bool mMenuSupportsDrag = false;
|
||||||
bool mCSDAvailable = false;
|
bool mCSDAvailable = false;
|
||||||
bool mCSDHideTitlebarByDefault = false;
|
bool mCSDHideTitlebarByDefault = false;
|
||||||
|
@ -102,6 +103,7 @@ class nsLookAndFeel final : public nsXPLookAndFeel {
|
||||||
bool mSystemUsesDarkTheme = false;
|
bool mSystemUsesDarkTheme = false;
|
||||||
bool mHighContrast = false;
|
bool mHighContrast = false;
|
||||||
bool mInitialized = false;
|
bool mInitialized = false;
|
||||||
|
bool mPrefersReducedMotionCached = false;
|
||||||
|
|
||||||
void EnsureInit();
|
void EnsureInit();
|
||||||
void ConfigureContentGtkTheme();
|
void ConfigureContentGtkTheme();
|
||||||
|
|
|
@ -7722,7 +7722,16 @@ void nsWindow::LockAspectRatio(bool aShouldLock) {
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult nsWindow::SetPrefersReducedMotionOverrideForTest(bool aValue) {
|
nsresult nsWindow::SetPrefersReducedMotionOverrideForTest(bool aValue) {
|
||||||
LookAndFeel::SetPrefersReducedMotionOverrideForTest(aValue);
|
LookAndFeel::SetShouldRetainCacheForTest(true);
|
||||||
|
|
||||||
|
LookAndFeelInt prefersReducedMotion;
|
||||||
|
prefersReducedMotion.id = LookAndFeel::eIntID_PrefersReducedMotion;
|
||||||
|
prefersReducedMotion.value = aValue ? 1 : 0;
|
||||||
|
|
||||||
|
AutoTArray<LookAndFeelInt, 1> lookAndFeelCache;
|
||||||
|
lookAndFeelCache.AppendElement(prefersReducedMotion);
|
||||||
|
|
||||||
|
LookAndFeel::SetIntCache(lookAndFeelCache);
|
||||||
|
|
||||||
// Notify as if the corresponding setting changed.
|
// Notify as if the corresponding setting changed.
|
||||||
g_object_notify(G_OBJECT(gtk_settings_get_default()),
|
g_object_notify(G_OBJECT(gtk_settings_get_default()),
|
||||||
|
@ -7732,7 +7741,7 @@ nsresult nsWindow::SetPrefersReducedMotionOverrideForTest(bool aValue) {
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult nsWindow::ResetPrefersReducedMotionOverrideForTest() {
|
nsresult nsWindow::ResetPrefersReducedMotionOverrideForTest() {
|
||||||
LookAndFeel::ResetPrefersReducedMotionOverrideForTest();
|
LookAndFeel::SetShouldRetainCacheForTest(false);
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -226,6 +226,8 @@ int32_t nsXPLookAndFeel::sCachedColors[size_t(LookAndFeel::ColorID::End)] = {0};
|
||||||
int32_t nsXPLookAndFeel::sCachedColorBits[COLOR_CACHE_SIZE] = {0};
|
int32_t nsXPLookAndFeel::sCachedColorBits[COLOR_CACHE_SIZE] = {0};
|
||||||
|
|
||||||
bool nsXPLookAndFeel::sInitialized = false;
|
bool nsXPLookAndFeel::sInitialized = false;
|
||||||
|
bool nsXPLookAndFeel::sIsInPrefersReducedMotionForTest = false;
|
||||||
|
bool nsXPLookAndFeel::sPrefersReducedMotionForTest = false;
|
||||||
|
|
||||||
nsXPLookAndFeel* nsXPLookAndFeel::sInstance = nullptr;
|
nsXPLookAndFeel* nsXPLookAndFeel::sInstance = nullptr;
|
||||||
bool nsXPLookAndFeel::sShutdown = false;
|
bool nsXPLookAndFeel::sShutdown = false;
|
||||||
|
@ -256,6 +258,9 @@ void nsXPLookAndFeel::Shutdown() {
|
||||||
sInstance = nullptr;
|
sInstance = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsXPLookAndFeel::nsXPLookAndFeel()
|
||||||
|
: LookAndFeel(), mShouldRetainCacheForTest(false) {}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void nsXPLookAndFeel::IntPrefChanged(nsLookAndFeelIntPref* data) {
|
void nsXPLookAndFeel::IntPrefChanged(nsLookAndFeelIntPref* data) {
|
||||||
if (!data) {
|
if (!data) {
|
||||||
|
@ -1088,26 +1093,4 @@ void LookAndFeel::SetShouldRetainCacheForTest(bool aValue) {
|
||||||
nsLookAndFeel::GetInstance()->SetShouldRetainCacheImplForTest(aValue);
|
nsLookAndFeel::GetInstance()->SetShouldRetainCacheImplForTest(aValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
|
||||||
void LookAndFeel::SetPrefersReducedMotionOverrideForTest(bool aValue) {
|
|
||||||
// Tell that the cache value we are going to set isn't cleared via
|
|
||||||
// nsPresContext::ThemeChangedInternal which is called right before
|
|
||||||
// we queue the media feature value change for this prefers-reduced-motion
|
|
||||||
// change.
|
|
||||||
SetShouldRetainCacheForTest(true);
|
|
||||||
|
|
||||||
int32_t value = aValue ? 1 : 0;
|
|
||||||
|
|
||||||
AutoTArray<LookAndFeelInt, 1> lookAndFeelCache;
|
|
||||||
lookAndFeelCache.AppendElement(
|
|
||||||
LookAndFeelInt{eIntID_PrefersReducedMotion, .value = value});
|
|
||||||
|
|
||||||
SetIntCache(lookAndFeelCache);
|
|
||||||
}
|
|
||||||
|
|
||||||
// static
|
|
||||||
void LookAndFeel::ResetPrefersReducedMotionOverrideForTest() {
|
|
||||||
SetShouldRetainCacheForTest(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
|
@ -81,8 +81,17 @@ class nsXPLookAndFeel : public mozilla::LookAndFeel {
|
||||||
|
|
||||||
virtual void NativeInit() = 0;
|
virtual void NativeInit() = 0;
|
||||||
|
|
||||||
|
void SetPrefersReducedMotionOverrideForTest(bool aValue) {
|
||||||
|
sIsInPrefersReducedMotionForTest = true;
|
||||||
|
sPrefersReducedMotionForTest = aValue;
|
||||||
|
}
|
||||||
|
void ResetPrefersReducedMotionOverrideForTest() {
|
||||||
|
sIsInPrefersReducedMotionForTest = false;
|
||||||
|
sPrefersReducedMotionForTest = false;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
nsXPLookAndFeel() = default;
|
nsXPLookAndFeel();
|
||||||
|
|
||||||
static void IntPrefChanged(nsLookAndFeelIntPref* data);
|
static void IntPrefChanged(nsLookAndFeelIntPref* data);
|
||||||
static void FloatPrefChanged(nsLookAndFeelFloatPref* data);
|
static void FloatPrefChanged(nsLookAndFeelFloatPref* data);
|
||||||
|
@ -112,11 +121,12 @@ class nsXPLookAndFeel : public mozilla::LookAndFeel {
|
||||||
static nsXPLookAndFeel* sInstance;
|
static nsXPLookAndFeel* sInstance;
|
||||||
static bool sShutdown;
|
static bool sShutdown;
|
||||||
|
|
||||||
int32_t mPrefersReducedMotion = -1;
|
static bool sIsInPrefersReducedMotionForTest;
|
||||||
bool mPrefersReducedMotionCached = false;
|
static bool sPrefersReducedMotionForTest;
|
||||||
|
|
||||||
// True if we shouldn't clear the cache value in RefreshImpl().
|
// True if we shouldn't clear the cache value in RefreshImpl().
|
||||||
// NOTE: This should be used only for testing.
|
// NOTE: This should be used only for testing.
|
||||||
bool mShouldRetainCacheForTest = false;
|
bool mShouldRetainCacheForTest;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Загрузка…
Ссылка в новой задаче