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:
shindli 2020-01-14 05:07:14 +02:00
Родитель 0b1488e159
Коммит c03a2cf53a
13 изменённых файлов: 69 добавлений и 85 удалений

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

@ -37,16 +37,10 @@ async function promiseForChange(mediaQuery) {
}
add_task(async () => {
const initiallyMatches =
window.matchMedia('(prefers-reduced-motion: reduce)').matches;
SpecialPowers.DOMWindowUtils.setPrefersReducedMotionOverrideForTest(false);
if (initiallyMatches) {
await promiseForChange('(prefers-reduced-motion: reduce)');
} else {
await waitForFrame();
}
// Need to wait a frame since MediaQuery changes are asynchronously processed.
await waitForFrame();
ok(!window.matchMedia('(prefers-reduced-motion: reduce)').matches,
'Does not matches prefers-reduced-motion: reduced) when the system sets ' +

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

@ -534,10 +534,6 @@ class LookAndFeel {
* or not.
*/
static void SetShouldRetainCacheForTest(bool aValue);
static void SetPrefersReducedMotionOverrideForTest(bool aValue);
static void ResetPrefersReducedMotionOverrideForTest();
};
} // namespace mozilla

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

@ -1445,6 +1445,9 @@ nsresult PuppetWidget::SetPrefersReducedMotionOverrideForTest(bool aValue) {
return NS_ERROR_FAILURE;
}
nsXPLookAndFeel::GetInstance()->SetPrefersReducedMotionOverrideForTest(
aValue);
mBrowserChild->SendSetPrefersReducedMotionOverrideForTest(aValue);
return NS_OK;
}
@ -1454,6 +1457,7 @@ nsresult PuppetWidget::ResetPrefersReducedMotionOverrideForTest() {
return NS_ERROR_FAILURE;
}
nsXPLookAndFeel::GetInstance()->ResetPrefersReducedMotionOverrideForTest();
mBrowserChild->SendResetPrefersReducedMotionOverrideForTest();
return NS_OK;
}

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

@ -76,18 +76,10 @@ void nsLookAndFeel::NativeInit() {
/* virtual */
void nsLookAndFeel::RefreshImpl() {
if (mShouldRetainCacheForTest) {
return;
}
nsXPLookAndFeel::RefreshImpl();
mInitializedSystemColors = false;
mInitializedShowPassword = false;
if (XRE_IsParentProcess()) {
mPrefersReducedMotionCached = false;
}
}
nsresult nsLookAndFeel::NativeGetColor(ColorID aID, nscolor& aColor) {
@ -420,11 +412,11 @@ nsresult nsLookAndFeel::GetIntImpl(IntID aID, int32_t& aResult) {
break;
case eIntID_PrefersReducedMotion:
if (!mPrefersReducedMotionCached && XRE_IsParentProcess()) {
mPrefersReducedMotion =
java::GeckoSystemStateListener::PrefersReducedMotion() ? 1 : 0;
if (sIsInPrefersReducedMotionForTest) {
aResult = sPrefersReducedMotionForTest ? 1 : 0;
break;
}
aResult = mPrefersReducedMotion;
aResult = java::GeckoSystemStateListener::PrefersReducedMotion() ? 1 : 0;
break;
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 uint32_t GetPasswordMaskDelayImpl() override;
virtual char16_t GetPasswordCharacterImpl() override;
virtual nsTArray<LookAndFeelInt> GetIntCacheImpl() override;
virtual void SetIntCacheImpl(
const nsTArray<LookAndFeelInt>& aLookAndFeelIntCache) override;
protected:
static bool mInitializedSystemColors;

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

@ -2336,15 +2336,15 @@ void nsWindow::UpdateDynamicToolbarOffset(ScreenIntCoord aOffset) {
}
nsresult nsWindow::SetPrefersReducedMotionOverrideForTest(bool aValue) {
LookAndFeel::SetPrefersReducedMotionOverrideForTest(aValue);
nsXPLookAndFeel::GetInstance()->SetPrefersReducedMotionOverrideForTest(
aValue);
// Notify as if the corresponding setting changed.
java::GeckoSystemStateListener::NotifyPrefersReducedMotionChangedForTest();
return NS_OK;
}
nsresult nsWindow::ResetPrefersReducedMotionOverrideForTest() {
LookAndFeel::ResetPrefersReducedMotionOverrideForTest();
nsXPLookAndFeel::GetInstance()->ResetPrefersReducedMotionOverrideForTest();
return NS_OK;
}

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

@ -2190,7 +2190,24 @@ void nsChildView::LookUpDictionary(const nsAString& aText,
}
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() &&
NSWorkspaceAccessibilityDisplayOptionsDidChangeNotification) {
@ -2210,7 +2227,7 @@ nsresult nsChildView::SetPrefersReducedMotionOverrideForTest(bool aValue) {
}
nsresult nsChildView::ResetPrefersReducedMotionOverrideForTest() {
LookAndFeel::ResetPrefersReducedMotionOverrideForTest();
LookAndFeel::SetShouldRetainCacheForTest(false);
return NS_OK;
}

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

@ -45,6 +45,9 @@ class nsLookAndFeel final : public nsXPLookAndFeel {
int32_t mAllowOverlayScrollbarsOverlap;
bool mAllowOverlayScrollbarsOverlapCached;
int32_t mPrefersReducedMotion;
bool mPrefersReducedMotionCached;
int32_t mSystemUsesDarkTheme;
bool mSystemUsesDarkThemeCached;

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

@ -40,6 +40,8 @@ nsLookAndFeel::nsLookAndFeel()
mUseOverlayScrollbarsCached(false),
mAllowOverlayScrollbarsOverlap(-1),
mAllowOverlayScrollbarsOverlapCached(false),
mPrefersReducedMotion(-1),
mPrefersReducedMotionCached(false),
mSystemUsesDarkTheme(-1),
mSystemUsesDarkThemeCached(false),
mColorTextSelectBackground(0),

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

@ -92,6 +92,7 @@ class nsLookAndFeel final : public nsXPLookAndFeel {
char16_t mInvisibleCharacter = 0;
float mCaretRatio = 0.0f;
int32_t mCaretBlinkTime = 0;
int32_t mPrefersReducedMotion = -1;
bool mMenuSupportsDrag = false;
bool mCSDAvailable = false;
bool mCSDHideTitlebarByDefault = false;
@ -102,6 +103,7 @@ class nsLookAndFeel final : public nsXPLookAndFeel {
bool mSystemUsesDarkTheme = false;
bool mHighContrast = false;
bool mInitialized = false;
bool mPrefersReducedMotionCached = false;
void EnsureInit();
void ConfigureContentGtkTheme();

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

@ -7722,7 +7722,16 @@ void nsWindow::LockAspectRatio(bool aShouldLock) {
}
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.
g_object_notify(G_OBJECT(gtk_settings_get_default()),
@ -7732,7 +7741,7 @@ nsresult nsWindow::SetPrefersReducedMotionOverrideForTest(bool aValue) {
}
nsresult nsWindow::ResetPrefersReducedMotionOverrideForTest() {
LookAndFeel::ResetPrefersReducedMotionOverrideForTest();
LookAndFeel::SetShouldRetainCacheForTest(false);
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};
bool nsXPLookAndFeel::sInitialized = false;
bool nsXPLookAndFeel::sIsInPrefersReducedMotionForTest = false;
bool nsXPLookAndFeel::sPrefersReducedMotionForTest = false;
nsXPLookAndFeel* nsXPLookAndFeel::sInstance = nullptr;
bool nsXPLookAndFeel::sShutdown = false;
@ -256,6 +258,9 @@ void nsXPLookAndFeel::Shutdown() {
sInstance = nullptr;
}
nsXPLookAndFeel::nsXPLookAndFeel()
: LookAndFeel(), mShouldRetainCacheForTest(false) {}
// static
void nsXPLookAndFeel::IntPrefChanged(nsLookAndFeelIntPref* data) {
if (!data) {
@ -1088,26 +1093,4 @@ void LookAndFeel::SetShouldRetainCacheForTest(bool 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

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

@ -81,8 +81,17 @@ class nsXPLookAndFeel : public mozilla::LookAndFeel {
virtual void NativeInit() = 0;
void SetPrefersReducedMotionOverrideForTest(bool aValue) {
sIsInPrefersReducedMotionForTest = true;
sPrefersReducedMotionForTest = aValue;
}
void ResetPrefersReducedMotionOverrideForTest() {
sIsInPrefersReducedMotionForTest = false;
sPrefersReducedMotionForTest = false;
}
protected:
nsXPLookAndFeel() = default;
nsXPLookAndFeel();
static void IntPrefChanged(nsLookAndFeelIntPref* data);
static void FloatPrefChanged(nsLookAndFeelFloatPref* data);
@ -112,11 +121,12 @@ class nsXPLookAndFeel : public mozilla::LookAndFeel {
static nsXPLookAndFeel* sInstance;
static bool sShutdown;
int32_t mPrefersReducedMotion = -1;
bool mPrefersReducedMotionCached = false;
static bool sIsInPrefersReducedMotionForTest;
static bool sPrefersReducedMotionForTest;
// True if we shouldn't clear the cache value in RefreshImpl().
// NOTE: This should be used only for testing.
bool mShouldRetainCacheForTest = false;
bool mShouldRetainCacheForTest;
};
#endif