From e29d6cd39586008ac84a7801bf046a8cc64bafa8 Mon Sep 17 00:00:00 2001 From: Kristen Wright Date: Wed, 18 Mar 2020 20:46:07 +0000 Subject: [PATCH] Bug 1622111 - Convert dom.animations.offscreen-throttling to static pref. r=njn Converts dom.animations.offscreen-throttling to a static pref and removes the static function used to create the varcache pref. Differential Revision: https://phabricator.services.mozilla.com/D67182 --HG-- extra : moz-landing-system : lando --- dom/animation/AnimationUtils.cpp | 15 --------------- dom/animation/AnimationUtils.h | 5 ----- dom/animation/KeyframeEffect.cpp | 2 +- modules/libpref/init/StaticPrefList.yaml | 6 ++++++ modules/libpref/init/all.js | 3 --- 5 files changed, 7 insertions(+), 24 deletions(-) diff --git a/dom/animation/AnimationUtils.cpp b/dom/animation/AnimationUtils.cpp index bb6ac71dcc95..80e984ce4307 100644 --- a/dom/animation/AnimationUtils.cpp +++ b/dom/animation/AnimationUtils.cpp @@ -9,7 +9,6 @@ #include "mozilla/dom/Document.h" #include "mozilla/dom/KeyframeEffect.h" #include "mozilla/EffectSet.h" -#include "mozilla/Preferences.h" #include "nsDebug.h" #include "nsAtom.h" #include "nsIContent.h" @@ -58,20 +57,6 @@ Document* AnimationUtils::GetDocumentFromGlobal(JSObject* aGlobalObject) { return win->GetDoc(); } -/* static */ -bool AnimationUtils::IsOffscreenThrottlingEnabled() { - static bool sOffscreenThrottlingEnabled; - static bool sPrefCached = false; - - if (!sPrefCached) { - sPrefCached = true; - Preferences::AddBoolVarCache(&sOffscreenThrottlingEnabled, - "dom.animations.offscreen-throttling"); - } - - return sOffscreenThrottlingEnabled; -} - /* static */ bool AnimationUtils::FrameHasAnimatedScale(const nsIFrame* aFrame) { EffectSet* effectSet = EffectSet::GetEffectSetForFrame( diff --git a/dom/animation/AnimationUtils.h b/dom/animation/AnimationUtils.h index 7af19aedca96..f2d84e794df9 100644 --- a/dom/animation/AnimationUtils.h +++ b/dom/animation/AnimationUtils.h @@ -73,11 +73,6 @@ class AnimationUtils { */ static Document* GetDocumentFromGlobal(JSObject* aGlobalObject); - /** - * Checks if offscreen animation throttling is enabled. - */ - static bool IsOffscreenThrottlingEnabled(); - /** * Returns true if the given frame has an animated scale. */ diff --git a/dom/animation/KeyframeEffect.cpp b/dom/animation/KeyframeEffect.cpp index 31c6c1c034a9..11e61aae3c63 100644 --- a/dom/animation/KeyframeEffect.cpp +++ b/dom/animation/KeyframeEffect.cpp @@ -1838,7 +1838,7 @@ void KeyframeEffect::SetAnimation(Animation* aAnimation) { } bool KeyframeEffect::CanIgnoreIfNotVisible() const { - if (!AnimationUtils::IsOffscreenThrottlingEnabled()) { + if (StaticPrefs::dom_animations_offscreen_throttling()) { return false; } diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml index ea7dcd916a05..ec5a2673f3e3 100644 --- a/modules/libpref/init/StaticPrefList.yaml +++ b/modules/libpref/init/StaticPrefList.yaml @@ -1329,6 +1329,12 @@ value: false mirror: always +# Checks if offscreen animation throttling is enabled. +- name: dom.animations.offscreen-throttling + type: bool + value: true + mirror: always + # Is support for automatically removing replaced filling animations enabled? - name: dom.animations-api.autoremove.enabled type: bool diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index b911c1200c89..56a93cd5745f 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -2583,9 +2583,6 @@ pref("layout.testing.overlay-scrollbars.always-visible", false); // pref to control whether layout warnings that are hit quite often are enabled pref("layout.spammy_warnings.enabled", false); -// Pref to throttle offsreen animations -pref("dom.animations.offscreen-throttling", true); - // if true, allow plug-ins to override internal imglib decoder mime types in full-page mode pref("plugin.override_internal_types", false);