diff --git a/widget/PuppetWidget.cpp b/widget/PuppetWidget.cpp index fe84925483f7..8a6b19757c82 100644 --- a/widget/PuppetWidget.cpp +++ b/widget/PuppetWidget.cpp @@ -28,6 +28,7 @@ #include "nsIWidgetListener.h" #include "imgIContainer.h" #include "nsView.h" +#include "nsXPLookAndFeel.h" #include "nsPrintfCString.h" using namespace mozilla; @@ -903,10 +904,8 @@ struct CursorSurface { IntSize mSize; }; -void PuppetWidget::SetCursor(nsCursor aCursor, - imgIContainer* aCursorImage, - uint32_t aHotspotX, - uint32_t aHotspotY) { +void PuppetWidget::SetCursor(nsCursor aCursor, imgIContainer* aCursorImage, + uint32_t aHotspotX, uint32_t aHotspotY) { if (!mTabChild) { return; } @@ -945,7 +944,8 @@ void PuppetWidget::SetCursor(nsCursor aCursor, mCustomCursor = nullptr; - nsDependentCString cursorData(customCursorData ? customCursorData.get() : "", length); + nsDependentCString cursorData(customCursorData ? customCursorData.get() : "", + length); if (!mTabChild->SendSetCursor(aCursor, hasCustomCursor, cursorData, customCursorSize.width, customCursorSize.height, stride, format, aHotspotX, aHotspotY, force)) { @@ -1409,6 +1409,9 @@ nsresult PuppetWidget::SetPrefersReducedMotionOverrideForTest(bool aValue) { return NS_ERROR_FAILURE; } + nsXPLookAndFeel::GetInstance()->SetPrefersReducedMotionOverrideForTest( + aValue); + mTabChild->SendSetPrefersReducedMotionOverrideForTest(aValue); return NS_OK; } @@ -1418,6 +1421,7 @@ nsresult PuppetWidget::ResetPrefersReducedMotionOverrideForTest() { return NS_ERROR_FAILURE; } + nsXPLookAndFeel::GetInstance()->ResetPrefersReducedMotionOverrideForTest(); mTabChild->SendResetPrefersReducedMotionOverrideForTest(); return NS_OK; } diff --git a/widget/android/nsLookAndFeel.cpp b/widget/android/nsLookAndFeel.cpp index 6db3d4a2e62a..7631a3f36aec 100644 --- a/widget/android/nsLookAndFeel.cpp +++ b/widget/android/nsLookAndFeel.cpp @@ -21,9 +21,6 @@ AndroidSystemColors nsLookAndFeel::mSystemColors; bool nsLookAndFeel::mInitializedShowPassword = false; bool nsLookAndFeel::mShowPassword = true; -bool nsLookAndFeel::mIsInPrefersReducedMotionForTest = false; -bool nsLookAndFeel::mPrefersReducedMotionForTest = false; - static const char16_t UNICODE_BULLET = 0x2022; nsLookAndFeel::nsLookAndFeel() : nsXPLookAndFeel() {} @@ -389,8 +386,8 @@ nsresult nsLookAndFeel::GetIntImpl(IntID aID, int32_t& aResult) { break; case eIntID_PrefersReducedMotion: - if (mIsInPrefersReducedMotionForTest) { - aResult = mPrefersReducedMotionForTest ? 1 : 0; + if (sIsInPrefersReducedMotionForTest) { + aResult = sPrefersReducedMotionForTest ? 1 : 0; break; } aResult = java::GeckoSystemStateListener::PrefersReducedMotion() ? 1 : 0; diff --git a/widget/android/nsLookAndFeel.h b/widget/android/nsLookAndFeel.h index b381728c4447..df849f14ecb6 100644 --- a/widget/android/nsLookAndFeel.h +++ b/widget/android/nsLookAndFeel.h @@ -27,22 +27,11 @@ class nsLookAndFeel final : public nsXPLookAndFeel { virtual void SetIntCacheImpl( const nsTArray& aLookAndFeelIntCache) override; - void SetPrefersReducedMotionOverrideForTest(bool aValue) { - mIsInPrefersReducedMotionForTest = true; - mPrefersReducedMotionForTest = aValue; - } - void ResetPrefersReducedMotionOverrideForTest() { - mIsInPrefersReducedMotionForTest = false; - mPrefersReducedMotionForTest = false; - } - protected: static bool mInitializedSystemColors; static mozilla::AndroidSystemColors mSystemColors; static bool mInitializedShowPassword; static bool mShowPassword; - static bool mIsInPrefersReducedMotionForTest; - static bool mPrefersReducedMotionForTest; nsresult GetSystemColors(); diff --git a/widget/android/nsWindow.cpp b/widget/android/nsWindow.cpp index c5cb25fab6c6..456cb5340a48 100644 --- a/widget/android/nsWindow.cpp +++ b/widget/android/nsWindow.cpp @@ -2186,20 +2186,15 @@ void nsWindow::RecvScreenPixels(Shmem&& aMem, const ScreenIntSize& aSize) { } nsresult nsWindow::SetPrefersReducedMotionOverrideForTest(bool aValue) { - nsXPLookAndFeel* xpLookAndFeel = nsLookAndFeel::GetInstance(); - - static_cast(xpLookAndFeel) - ->SetPrefersReducedMotionOverrideForTest(aValue); + nsXPLookAndFeel::GetInstance()->SetPrefersReducedMotionOverrideForTest( + aValue); java::GeckoSystemStateListener::NotifyPrefersReducedMotionChangedForTest(); return NS_OK; } nsresult nsWindow::ResetPrefersReducedMotionOverrideForTest() { - nsXPLookAndFeel* xpLookAndFeel = nsLookAndFeel::GetInstance(); - - static_cast(xpLookAndFeel) - ->ResetPrefersReducedMotionOverrideForTest(); + nsXPLookAndFeel::GetInstance()->ResetPrefersReducedMotionOverrideForTest(); return NS_OK; } diff --git a/widget/nsXPLookAndFeel.cpp b/widget/nsXPLookAndFeel.cpp index 1bf242f307c0..f91cfc351762 100644 --- a/widget/nsXPLookAndFeel.cpp +++ b/widget/nsXPLookAndFeel.cpp @@ -216,6 +216,8 @@ bool nsXPLookAndFeel::sInitialized = false; bool nsXPLookAndFeel::sUseNativeColors = true; bool nsXPLookAndFeel::sUseStandinsForNativeColors = false; bool nsXPLookAndFeel::sFindbarModalHighlight = false; +bool nsXPLookAndFeel::sIsInPrefersReducedMotionForTest = false; +bool nsXPLookAndFeel::sPrefersReducedMotionForTest = false; nsXPLookAndFeel* nsXPLookAndFeel::sInstance = nullptr; bool nsXPLookAndFeel::sShutdown = false; diff --git a/widget/nsXPLookAndFeel.h b/widget/nsXPLookAndFeel.h index 2dcb4fd45ca2..0e1f96ef2b0e 100644 --- a/widget/nsXPLookAndFeel.h +++ b/widget/nsXPLookAndFeel.h @@ -80,6 +80,15 @@ 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(); @@ -112,6 +121,9 @@ class nsXPLookAndFeel : public mozilla::LookAndFeel { static nsXPLookAndFeel* sInstance; static bool sShutdown; + 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;