зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1606503 - Get the value for prefers-reduced-motion via LookAndFeelInt. r=geckoview-reviewers,snorp
With this change we have the same setup for prefers-reduced-motion so that we can change the value with the same manner in automated tests. Differential Revision: https://phabricator.services.mozilla.com/D59023 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
e538eea4dc
Коммит
21a5133d31
|
@ -1445,9 +1445,6 @@ nsresult PuppetWidget::SetPrefersReducedMotionOverrideForTest(bool aValue) {
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsXPLookAndFeel::GetInstance()->SetPrefersReducedMotionOverrideForTest(
|
||||
aValue);
|
||||
|
||||
mBrowserChild->SendSetPrefersReducedMotionOverrideForTest(aValue);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1457,7 +1454,6 @@ nsresult PuppetWidget::ResetPrefersReducedMotionOverrideForTest() {
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsXPLookAndFeel::GetInstance()->ResetPrefersReducedMotionOverrideForTest();
|
||||
mBrowserChild->SendResetPrefersReducedMotionOverrideForTest();
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -76,10 +76,18 @@ 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) {
|
||||
|
@ -412,11 +420,11 @@ nsresult nsLookAndFeel::GetIntImpl(IntID aID, int32_t& aResult) {
|
|||
break;
|
||||
|
||||
case eIntID_PrefersReducedMotion:
|
||||
if (sIsInPrefersReducedMotionForTest) {
|
||||
aResult = sPrefersReducedMotionForTest ? 1 : 0;
|
||||
break;
|
||||
if (!mPrefersReducedMotionCached && XRE_IsParentProcess()) {
|
||||
mPrefersReducedMotion =
|
||||
java::GeckoSystemStateListener::PrefersReducedMotion() ? 1 : 0;
|
||||
}
|
||||
aResult = java::GeckoSystemStateListener::PrefersReducedMotion() ? 1 : 0;
|
||||
aResult = mPrefersReducedMotion;
|
||||
break;
|
||||
|
||||
case eIntID_PrimaryPointerCapabilities:
|
||||
|
@ -513,3 +521,28 @@ 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,6 +23,9 @@ 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) {
|
||||
nsXPLookAndFeel::GetInstance()->SetPrefersReducedMotionOverrideForTest(
|
||||
aValue);
|
||||
LookAndFeel::SetPrefersReducedMotionOverrideForTest(aValue);
|
||||
|
||||
// Notify as if the corresponding setting changed.
|
||||
java::GeckoSystemStateListener::NotifyPrefersReducedMotionChangedForTest();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsWindow::ResetPrefersReducedMotionOverrideForTest() {
|
||||
nsXPLookAndFeel::GetInstance()->ResetPrefersReducedMotionOverrideForTest();
|
||||
LookAndFeel::ResetPrefersReducedMotionOverrideForTest();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -226,8 +226,6 @@ 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;
|
||||
|
|
|
@ -81,15 +81,6 @@ 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;
|
||||
|
||||
|
@ -121,9 +112,6 @@ class nsXPLookAndFeel : public mozilla::LookAndFeel {
|
|||
static nsXPLookAndFeel* sInstance;
|
||||
static bool sShutdown;
|
||||
|
||||
static bool sIsInPrefersReducedMotionForTest;
|
||||
static bool sPrefersReducedMotionForTest;
|
||||
|
||||
int32_t mPrefersReducedMotion = -1;
|
||||
bool mPrefersReducedMotionCached = false;
|
||||
// True if we shouldn't clear the cache value in RefreshImpl().
|
||||
|
|
Загрузка…
Ссылка в новой задаче