Bug 1560833 - Remove setters for static VarCache prefs. r=froydnj
authorNicholas Nethercote <nnethercote@mozilla.com>
Mon, 24 Jun 2019 16:43:33 +0000
changeset 542817 11459fc963acca1af7f6fc9da8a5a97b0b700257
parent 542816 7c911a7be80e21eef29b4fe3485abcdfbd1433bf
child 542818 84bba101c4f43a39dad3388c93080fb4d9cca804
push id2131
push userffxbld-merge
push dateMon, 26 Aug 2019 18:30:20 +0000
treeherdermozilla-release@b19ffb3ca153 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1560833
milestone69.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1560833 - Remove setters for static VarCache prefs. r=froydnj Static VarCache prefs have setters. These are dangerous because they can violate the primary invariant of VarCache prefs, which is that the global variable always matches the pref value in the table. Fortunately they are only used in tests, and we can use vanilla pref setters instead, and get rid of the VarCache setters. Differential Revision: https://phabricator.services.mozilla.com/D35632
gfx/layers/apz/test/gtest/APZTestCommon.h
gfx/layers/apz/test/gtest/TestBasic.cpp
gfx/layers/apz/test/gtest/TestGestureDetector.cpp
gfx/layers/apz/test/gtest/TestHitTesting.cpp
gfx/layers/apz/test/gtest/TestPanning.cpp
gfx/layers/apz/test/gtest/TestPinching.cpp
gfx/layers/apz/test/gtest/TestScrollHandoff.cpp
gfx/layers/apz/util/CheckerboardReportService.cpp
gfx/thebes/DeviceManagerDx.cpp
gfx/thebes/gfxWindowsPlatform.cpp
modules/libpref/Preferences.cpp
modules/libpref/StaticPrefs.h
--- a/gfx/layers/apz/test/gtest/APZTestCommon.h
+++ b/gfx/layers/apz/test/gtest/APZTestCommon.h
@@ -70,33 +70,51 @@ inline PinchGestureInput CreatePinchGest
   PinchGestureInput result(aType, 0, timestamp, ExternalPoint(0, 0), aFocus,
                            aCurrentSpan, aPreviousSpan, 0);
   return result;
 }
 
 template <class SetArg, class Storage>
 class ScopedGfxSetting {
  public:
-  ScopedGfxSetting(SetArg (*aGetPrefFunc)(void), void (*aSetPrefFunc)(SetArg),
-                   SetArg aVal)
+  ScopedGfxSetting(const std::function<SetArg(void)>& aGetPrefFunc,
+                   const std::function<void(SetArg)>& aSetPrefFunc, SetArg aVal)
       : mSetPrefFunc(aSetPrefFunc) {
     mOldVal = aGetPrefFunc();
     aSetPrefFunc(aVal);
   }
 
   ~ScopedGfxSetting() { mSetPrefFunc(mOldVal); }
 
  private:
-  void (*mSetPrefFunc)(SetArg);
+  std::function<void(SetArg)> mSetPrefFunc;
   Storage mOldVal;
 };
 
-#define SCOPED_GFX_PREF(prefBase, prefType, prefValue)  \
-  ScopedGfxSetting<prefType, prefType> pref_##prefBase( \
-      &(StaticPrefs::prefBase), &(StaticPrefs::Set##prefBase), prefValue)
+#define FRESH_PREF_VAR_PASTE(id, line) id##line
+#define FRESH_PREF_VAR_EXPAND(id, line) FRESH_PREF_VAR_PASTE(id, line)
+#define FRESH_PREF_VAR FRESH_PREF_VAR_EXPAND(pref, __LINE__)
+
+#define SCOPED_GFX_PREF_BOOL(prefName, prefValue)                           \
+  ScopedGfxSetting<bool, bool> FRESH_PREF_VAR(                              \
+      [=]() { return Preferences::GetBool(prefName); },                     \
+      [=](bool aPrefValue) { Preferences::SetBool(prefName, aPrefValue); }, \
+      prefValue)
+
+#define SCOPED_GFX_PREF_INT(prefName, prefValue)                              \
+  ScopedGfxSetting<int32_t, int32_t> FRESH_PREF_VAR(                          \
+      [=]() { return Preferences::GetInt(prefName); },                        \
+      [=](int32_t aPrefValue) { Preferences::SetInt(prefName, aPrefValue); }, \
+      prefValue)
+
+#define SCOPED_GFX_PREF_FLOAT(prefName, prefValue)                            \
+  ScopedGfxSetting<float, float> FRESH_PREF_VAR(                              \
+      [=]() { return Preferences::GetFloat(prefName); },                      \
+      [=](float aPrefValue) { Preferences::SetFloat(prefName, aPrefValue); }, \
+      prefValue)
 
 #define SCOPED_GFX_VAR(varBase, varType, varValue)         \
   ScopedGfxSetting<const varType&, varType> var_##varBase( \
       &(gfxVars::varBase), &(gfxVars::Set##varBase), varValue)
 
 static TimeStamp GetStartupTime() {
   static TimeStamp sStartupTime = TimeStamp::Now();
   return sStartupTime;
@@ -548,18 +566,18 @@ void APZCTesterBase::Pan(const RefPtr<In
                          const ScreenIntPoint& aTouchEnd, PanOptions aOptions,
                          nsTArray<uint32_t>* aAllowedTouchBehaviors,
                          nsEventStatus (*aOutEventStatuses)[4],
                          uint64_t* aOutInputBlockId) {
   // Reduce the touch start and move tolerance to a tiny value.
   // We can't use a scoped pref because this value might be read at some later
   // time when the events are actually processed, rather than when we deliver
   // them.
-  StaticPrefs::SetAPZTouchStartTolerance(1.0f / 1000.0f);
-  StaticPrefs::SetAPZTouchMoveTolerance(0.0f);
+  Preferences::SetFloat("apz.touch_start_tolerance", 1.0f / 1000.0f);
+  Preferences::SetFloat("apz.touch_move_tolerance", 0.0f);
   int overcomeTouchToleranceX = 0;
   int overcomeTouchToleranceY = 0;
   if (!(aOptions & PanOptions::ExactCoordinates)) {
     // Have the direction of the adjustment to overcome the touch tolerance
     // match the direction of the entire gesture, otherwise we run into
     // trouble such as accidentally activating the axis lock.
     if (aTouchStart.x != aTouchEnd.x) {
       overcomeTouchToleranceX = 1;
--- a/gfx/layers/apz/test/gtest/TestBasic.cpp
+++ b/gfx/layers/apz/test/gtest/TestBasic.cpp
@@ -157,17 +157,17 @@ TEST_F(APZCBasicTester, ComplexTransform
       AsyncTransform(LayerToParentLayerScale(1.5), ParentLayerPoint(-45, 0)),
       viewTransformOut);
   EXPECT_EQ(ParentLayerPoint(135, 90), pointOut);
 
   childApzc->Destroy();
 }
 
 TEST_F(APZCBasicTester, Fling) {
-  SCOPED_GFX_PREF(APZFlingMinVelocityThreshold, float, 0.0f);
+  SCOPED_GFX_PREF_FLOAT("apz.fling_min_velocity_threshold", 0.0f);
   int touchStart = 50;
   int touchEnd = 10;
   ParentLayerPoint pointOut;
   AsyncTransform viewTransformOut;
 
   // Fling down. Each step scroll further down
   Pan(apzc, touchStart, touchEnd);
   ParentLayerPoint lastPoint;
@@ -176,18 +176,18 @@ TEST_F(APZCBasicTester, Fling) {
                                          TimeDuration::FromMilliseconds(1));
     EXPECT_GT(pointOut.y, lastPoint.y);
     lastPoint = pointOut;
   }
 }
 
 TEST_F(APZCBasicTester, FlingIntoOverscroll) {
   // Enable overscrolling.
-  SCOPED_GFX_PREF(APZOverscrollEnabled, bool, true);
-  SCOPED_GFX_PREF(APZFlingMinVelocityThreshold, float, 0.0f);
+  SCOPED_GFX_PREF_BOOL("apz.overscroll.enabled", true);
+  SCOPED_GFX_PREF_FLOAT("apz.fling_min_velocity_threshold", 0.0f);
 
   // Scroll down by 25 px. Don't fling for simplicity.
   Pan(apzc, 50, 25, PanOptions::NoFling);
 
   // Now scroll back up by 20px, this time flinging after.
   // The fling should cover the remaining 5 px of room to scroll, then
   // go into overscroll, and finally snap-back to recover from overscroll.
   Pan(apzc, 25, 45);
@@ -203,17 +203,17 @@ TEST_F(APZCBasicTester, FlingIntoOverscr
     }
     mcc->AdvanceBy(increment);
   }
   EXPECT_TRUE(reachedOverscroll);
   EXPECT_TRUE(recoveredFromOverscroll);
 }
 
 TEST_F(APZCBasicTester, PanningTransformNotifications) {
-  SCOPED_GFX_PREF(APZOverscrollEnabled, bool, true);
+  SCOPED_GFX_PREF_BOOL("apz.overscroll.enabled", true);
 
   // Scroll down by 25 px. Ensure we only get one set of
   // state change notifications.
   //
   // Then, scroll back up by 20px, this time flinging after.
   // The fling should cover the remaining 5 px of room to scroll, then
   // go into overscroll, and finally snap-back to recover from overscroll.
   // Again, ensure we only get one set of state change notifications for
@@ -289,48 +289,47 @@ void APZCBasicTester::TestOverscroll() {
   PanIntoOverscroll();
 
   // Check that we recover from overscroll via an animation.
   ParentLayerPoint expectedScrollOffset(0, GetScrollRange().YMost());
   SampleAnimationUntilRecoveredFromOverscroll(expectedScrollOffset);
 }
 
 TEST_F(APZCBasicTester, OverScrollPanning) {
-  SCOPED_GFX_PREF(APZOverscrollEnabled, bool, true);
+  SCOPED_GFX_PREF_BOOL("apz.overscroll.enabled", true);
 
   TestOverscroll();
 }
 
 // Tests that an overscroll animation doesn't trigger an assertion failure
 // in the case where a sample has a velocity of zero.
 TEST_F(APZCBasicTester, OverScroll_Bug1152051a) {
-  SCOPED_GFX_PREF(APZOverscrollEnabled, bool, true);
+  SCOPED_GFX_PREF_BOOL("apz.overscroll.enabled", true);
 
   // Doctor the prefs to make the velocity zero at the end of the first sample.
 
   // This ensures our incoming velocity to the overscroll animation is
   // a round(ish) number, 4.9 (that being the distance of the pan before
   // overscroll, which is 500 - 10 = 490 pixels, divided by the duration of
   // the pan, which is 100 ms).
-  SCOPED_GFX_PREF(APZFlingFriction, float, 0);
+  SCOPED_GFX_PREF_FLOAT("apz.fling_friction", 0);
 
   // To ensure the velocity after the first sample is 0, set the spring
   // stiffness to the incoming velocity (4.9) divided by the overscroll
   // (400 pixels) times the step duration (1 ms).
-  SCOPED_GFX_PREF(APZOverscrollSpringStiffness, float, 0.01225f);
+  SCOPED_GFX_PREF_FLOAT("apz.overscroll.spring_stiffness", 0.01225f);
 
   TestOverscroll();
 }
 
 // Tests that ending an overscroll animation doesn't leave around state that
 // confuses the next overscroll animation.
 TEST_F(APZCBasicTester, OverScroll_Bug1152051b) {
-  SCOPED_GFX_PREF(APZOverscrollEnabled, bool, true);
-
-  SCOPED_GFX_PREF(APZOverscrollStopDistanceThreshold, float, 0.1f);
+  SCOPED_GFX_PREF_BOOL("apz.overscroll.enabled", true);
+  SCOPED_GFX_PREF_FLOAT("apz.overscroll.stop_distance_threshold", 0.1f);
 
   // Pan sufficiently to hit overscroll behavior
   PanIntoOverscroll();
 
   // Sample animations once, to give the fling animation started on touch-up
   // a chance to realize it's overscrolled, and schedule a call to
   // HandleFlingOverscroll().
   SampleAnimationOnce();
@@ -359,32 +358,32 @@ TEST_F(APZCBasicTester, OverScroll_Bug11
   // properly, this will assert.
   ParentLayerPoint expectedScrollOffset(0, GetScrollRange().YMost());
   SampleAnimationUntilRecoveredFromOverscroll(expectedScrollOffset);
 }
 
 // Tests that the page doesn't get stuck in an
 // overscroll animation after a low-velocity pan.
 TEST_F(APZCBasicTester, OverScrollAfterLowVelocityPan_Bug1343775) {
-  SCOPED_GFX_PREF(APZOverscrollEnabled, bool, true);
+  SCOPED_GFX_PREF_BOOL("apz.overscroll.enabled", true);
 
   // Pan into overscroll with a velocity less than the
   // apz.fling_min_velocity_threshold preference.
   Pan(apzc, 10, 30);
 
   EXPECT_TRUE(apzc->IsOverscrolled());
 
   apzc->AdvanceAnimationsUntilEnd();
 
   // Check that we recovered from overscroll.
   EXPECT_FALSE(apzc->IsOverscrolled());
 }
 
 TEST_F(APZCBasicTester, OverScrollAbort) {
-  SCOPED_GFX_PREF(APZOverscrollEnabled, bool, true);
+  SCOPED_GFX_PREF_BOOL("apz.overscroll.enabled", true);
 
   // Pan sufficiently to hit overscroll behavior
   int touchStart = 500;
   int touchEnd = 10;
   Pan(apzc, touchStart, touchEnd);
   EXPECT_TRUE(apzc->IsOverscrolled());
 
   ParentLayerPoint pointOut;
@@ -399,17 +398,17 @@ TEST_F(APZCBasicTester, OverScrollAbort)
   // At this point, we have an active overscroll animation.
   // Check that cancelling the animation clears the overscroll.
   apzc->CancelAnimation();
   EXPECT_FALSE(apzc->IsOverscrolled());
   apzc->AssertStateIsReset();
 }
 
 TEST_F(APZCBasicTester, OverScrollPanningAbort) {
-  SCOPED_GFX_PREF(APZOverscrollEnabled, bool, true);
+  SCOPED_GFX_PREF_BOOL("apz.overscroll.enabled", true);
 
   // Pan sufficiently to hit overscroll behaviour. Keep the finger down so
   // the pan does not end.
   int touchStart = 500;
   int touchEnd = 10;
   Pan(apzc, touchStart, touchEnd, PanOptions::KeepFingerDown);
   EXPECT_TRUE(apzc->IsOverscrolled());
 
--- a/gfx/layers/apz/test/gtest/TestGestureDetector.cpp
+++ b/gfx/layers/apz/test/gtest/TestGestureDetector.cpp
@@ -22,17 +22,17 @@ class APZCGestureDetectorTester : public
     // APZC only allows zooming on the root scrollable frame.
     fm.SetIsRootContent(true);
     // the visible area of the document in CSS pixels is x=300 y=300 w=50 h=100
     return fm;
   }
 };
 
 TEST_F(APZCGestureDetectorTester, Pan_After_Pinch) {
-  SCOPED_GFX_PREF(layout_css_touch_action_enabled, bool, false);
+  SCOPED_GFX_PREF_BOOL("layout.css.touch_action.enabled", false);
 
   FrameMetrics originalMetrics = GetPinchableFrameMetrics();
   apzc->SetFrameMetrics(originalMetrics);
 
   MakeApzcZoomable();
 
   // Test parameters
   float zoomAmount = 1.25;
@@ -121,17 +121,17 @@ TEST_F(APZCGestureDetectorTester, Pan_Af
   // Clear out any remaining fling animation and pending tasks
   apzc->AdvanceAnimationsUntilEnd();
   while (mcc->RunThroughDelayedTasks())
     ;
   apzc->AssertStateIsReset();
 }
 
 TEST_F(APZCGestureDetectorTester, Pan_With_Tap) {
-  SCOPED_GFX_PREF(layout_css_touch_action_enabled, bool, false);
+  SCOPED_GFX_PREF_BOOL("layout.css.touch_action.enabled", false);
 
   FrameMetrics originalMetrics = GetPinchableFrameMetrics();
   apzc->SetFrameMetrics(originalMetrics);
 
   // Making the APZC zoomable isn't really needed for the correct operation of
   // this test, but it could help catch regressions where we accidentally enter
   // a pinch state.
   MakeApzcZoomable();
@@ -311,32 +311,32 @@ class APZCFlingStopTester : public APZCG
     // clean up
     TouchUp(apzc, ScreenIntPoint(10, 10), mcc->Time());
 
     apzc->AssertStateIsReset();
   }
 };
 
 TEST_F(APZCFlingStopTester, FlingStop) {
-  SCOPED_GFX_PREF(APZFlingMinVelocityThreshold, float, 0.0f);
+  SCOPED_GFX_PREF_FLOAT("apz.fling_min_velocity_threshold", 0.0f);
   DoFlingStopTest(false);
 }
 
 TEST_F(APZCFlingStopTester, FlingStopTap) {
-  SCOPED_GFX_PREF(APZFlingMinVelocityThreshold, float, 0.0f);
+  SCOPED_GFX_PREF_FLOAT("apz.fling_min_velocity_threshold", 0.0f);
   DoFlingStopTest(true);
 }
 
 TEST_F(APZCFlingStopTester, FlingStopSlowListener) {
-  SCOPED_GFX_PREF(APZFlingMinVelocityThreshold, float, 0.0f);
+  SCOPED_GFX_PREF_FLOAT("apz.fling_min_velocity_threshold", 0.0f);
   DoFlingStopWithSlowListener(false);
 }
 
 TEST_F(APZCFlingStopTester, FlingStopPreventDefault) {
-  SCOPED_GFX_PREF(APZFlingMinVelocityThreshold, float, 0.0f);
+  SCOPED_GFX_PREF_FLOAT("apz.fling_min_velocity_threshold", 0.0f);
   DoFlingStopWithSlowListener(true);
 }
 
 TEST_F(APZCGestureDetectorTester, ShortPress) {
   MakeApzcUnzoomable();
 
   MockFunction<void(std::string checkPointName)> check;
   {
@@ -516,34 +516,34 @@ class APZCLongPressTester : public APZCG
     EXPECT_EQ(ParentLayerPoint(), pointOut);
     EXPECT_EQ(AsyncTransform(), viewTransformOut);
 
     apzc->AssertStateIsReset();
   }
 };
 
 TEST_F(APZCLongPressTester, LongPress) {
-  SCOPED_GFX_PREF(layout_css_touch_action_enabled, bool, false);
+  SCOPED_GFX_PREF_BOOL("layout.css.touch_action.enabled", false);
   DoLongPressTest(mozilla::layers::AllowedTouchBehavior::NONE);
 }
 
 TEST_F(APZCLongPressTester, LongPressWithTouchAction) {
-  SCOPED_GFX_PREF(layout_css_touch_action_enabled, bool, true);
+  SCOPED_GFX_PREF_BOOL("layout.css.touch_action.enabled", true);
   DoLongPressTest(mozilla::layers::AllowedTouchBehavior::HORIZONTAL_PAN |
                   mozilla::layers::AllowedTouchBehavior::VERTICAL_PAN |
                   mozilla::layers::AllowedTouchBehavior::PINCH_ZOOM);
 }
 
 TEST_F(APZCLongPressTester, LongPressPreventDefault) {
-  SCOPED_GFX_PREF(layout_css_touch_action_enabled, bool, false);
+  SCOPED_GFX_PREF_BOOL("layout.css.touch_action.enabled", false);
   DoLongPressPreventDefaultTest(mozilla::layers::AllowedTouchBehavior::NONE);
 }
 
 TEST_F(APZCLongPressTester, LongPressPreventDefaultWithTouchAction) {
-  SCOPED_GFX_PREF(layout_css_touch_action_enabled, bool, true);
+  SCOPED_GFX_PREF_BOOL("layout.css.touch_action.enabled", true);
   DoLongPressPreventDefaultTest(
       mozilla::layers::AllowedTouchBehavior::HORIZONTAL_PAN |
       mozilla::layers::AllowedTouchBehavior::VERTICAL_PAN |
       mozilla::layers::AllowedTouchBehavior::PINCH_ZOOM);
 }
 
 TEST_F(APZCGestureDetectorTester, DoubleTap) {
   MakeApzcWaitForMainThread();
--- a/gfx/layers/apz/test/gtest/TestHitTesting.cpp
+++ b/gfx/layers/apz/test/gtest/TestHitTesting.cpp
@@ -207,18 +207,18 @@ TEST_F(APZHitTestingTester, HitTesting1)
   EXPECT_EQ(nullAPZC, hit.get());
   EXPECT_EQ(ScreenToParentLayerMatrix4x4(), transformToApzc);
   EXPECT_EQ(ParentLayerToScreenMatrix4x4(), transformToGecko);
 }
 
 // A more involved hit testing test that involves css and async transforms.
 TEST_F(APZHitTestingTester, HitTesting2) {
   SCOPED_GFX_VAR(UseWebRender, bool, false);
-  SCOPED_GFX_PREF(APZVelocityBias, float,
-                  0.0);  // Velocity bias can cause extra repaint requests
+  // Velocity bias can cause extra repaint requests.
+  SCOPED_GFX_PREF_FLOAT("apz.velocity_bias", 0.0);
 
   CreateHitTesting2LayerTree();
   ScopedLayerTreeRegistration registration(manager, LayersId{0}, root, mcc);
 
   manager->UpdateHitTestingTree(root, false, LayersId{0}, 0);
 
   // At this point, the following holds (all coordinates in screen pixels):
   // layers[0] has content from (0,0)-(200,200), clipped by composition bounds
@@ -450,17 +450,17 @@ TEST_F(APZHitTestingTester, ComplexMulti
   EXPECT_EQ(ApzcOf(layers[1]), hit.get());
   hit = GetTargetAPZC(ScreenPoint(275, 375));
   EXPECT_EQ(ApzcOf(layers[9]), hit.get());
   hit = GetTargetAPZC(ScreenPoint(250, 100));
   EXPECT_EQ(ApzcOf(layers[7]), hit.get());
 }
 
 TEST_F(APZHitTestingTester, TestRepaintFlushOnNewInputBlock) {
-  SCOPED_GFX_PREF(layout_css_touch_action_enabled, bool, false);
+  SCOPED_GFX_PREF_BOOL("layout.css.touch_action.enabled", false);
 
   // The main purpose of this test is to verify that touch-start events (or
   // anything that starts a new input block) don't ever get untransformed. This
   // should always hold because the APZ code should flush repaints when we start
   // a new input block and the transform to gecko space should be empty.
 
   CreateSimpleScrollingLayer();
   ScopedLayerTreeRegistration registration(manager, LayersId{0}, root, mcc);
--- a/gfx/layers/apz/test/gtest/TestPanning.cpp
+++ b/gfx/layers/apz/test/gtest/TestPanning.cpp
@@ -77,62 +77,62 @@ class APZCPanningTester : public APZCBas
     EXPECT_EQ(ParentLayerPoint(), pointOut);
     EXPECT_EQ(AsyncTransform(), viewTransformOut);
 
     apzc->AssertStateIsReset();
   }
 };
 
 TEST_F(APZCPanningTester, Pan) {
-  SCOPED_GFX_PREF(layout_css_touch_action_enabled, bool, false);
-  SCOPED_GFX_PREF(APZVelocityBias, float,
-                  0.0);  // Velocity bias can cause extra repaint requests
+  SCOPED_GFX_PREF_BOOL("layout.css.touch_action.enabled", false);
+  // Velocity bias can cause extra repaint requests.
+  SCOPED_GFX_PREF_FLOAT("apz.velocity_bias", 0.0);
   DoPanTest(true, true, mozilla::layers::AllowedTouchBehavior::NONE);
 }
 
 // In the each of the following 4 pan tests we are performing two pan gestures:
 // vertical pan from top to bottom and back - from bottom to top. According to
 // the pointer-events/touch-action spec AUTO and PAN_Y touch-action values allow
 // vertical scrolling while NONE and PAN_X forbid it. The first parameter of
 // DoPanTest method specifies this behavior. However, the events will be marked
 // as consumed even if the behavior in PAN_X, because the user could move their
 // finger horizontally too - APZ has no way of knowing beforehand and so must
 // consume the events.
 TEST_F(APZCPanningTester, PanWithTouchActionAuto) {
-  SCOPED_GFX_PREF(layout_css_touch_action_enabled, bool, true);
-  SCOPED_GFX_PREF(APZVelocityBias, float,
-                  0.0);  // Velocity bias can cause extra repaint requests
+  SCOPED_GFX_PREF_BOOL("layout.css.touch_action.enabled", true);
+  // Velocity bias can cause extra repaint requests.
+  SCOPED_GFX_PREF_FLOAT("apz.velocity_bias", 0.0);
   DoPanTest(true, true,
             mozilla::layers::AllowedTouchBehavior::HORIZONTAL_PAN |
                 mozilla::layers::AllowedTouchBehavior::VERTICAL_PAN);
 }
 
 TEST_F(APZCPanningTester, PanWithTouchActionNone) {
-  SCOPED_GFX_PREF(layout_css_touch_action_enabled, bool, true);
-  SCOPED_GFX_PREF(APZVelocityBias, float,
-                  0.0);  // Velocity bias can cause extra repaint requests
+  SCOPED_GFX_PREF_BOOL("layout.css.touch_action.enabled", true);
+  // Velocity bias can cause extra repaint requests.
+  SCOPED_GFX_PREF_FLOAT("apz.velocity_bias", 0.0);
   DoPanTest(false, false, 0);
 }
 
 TEST_F(APZCPanningTester, PanWithTouchActionPanX) {
-  SCOPED_GFX_PREF(layout_css_touch_action_enabled, bool, true);
-  SCOPED_GFX_PREF(APZVelocityBias, float,
-                  0.0);  // Velocity bias can cause extra repaint requests
+  SCOPED_GFX_PREF_BOOL("layout.css.touch_action.enabled", true);
+  // Velocity bias can cause extra repaint requests.
+  SCOPED_GFX_PREF_FLOAT("apz.velocity_bias", 0.0);
   DoPanTest(false, false,
             mozilla::layers::AllowedTouchBehavior::HORIZONTAL_PAN);
 }
 
 TEST_F(APZCPanningTester, PanWithTouchActionPanY) {
-  SCOPED_GFX_PREF(layout_css_touch_action_enabled, bool, true);
-  SCOPED_GFX_PREF(APZVelocityBias, float,
-                  0.0);  // Velocity bias can cause extra repaint requests
+  SCOPED_GFX_PREF_BOOL("layout.css.touch_action.enabled", true);
+  // Velocity bias can cause extra repaint requests.
+  SCOPED_GFX_PREF_FLOAT("apz.velocity_bias", 0.0);
   DoPanTest(true, true, mozilla::layers::AllowedTouchBehavior::VERTICAL_PAN);
 }
 
 TEST_F(APZCPanningTester, PanWithPreventDefaultAndTouchAction) {
-  SCOPED_GFX_PREF(layout_css_touch_action_enabled, bool, true);
+  SCOPED_GFX_PREF_BOOL("layout.css.touch_action.enabled", true);
   DoPanWithPreventDefaultTest();
 }
 
 TEST_F(APZCPanningTester, PanWithPreventDefault) {
-  SCOPED_GFX_PREF(layout_css_touch_action_enabled, bool, false);
+  SCOPED_GFX_PREF_BOOL("layout.css.touch_action.enabled", false);
   DoPanWithPreventDefaultTest();
 }
--- a/gfx/layers/apz/test/gtest/TestPinching.cpp
+++ b/gfx/layers/apz/test/gtest/TestPinching.cpp
@@ -205,115 +205,115 @@ class APZCPinchLockingTester : public AP
 
     // Avoid side effects, reset to original frame metrics
     apzc->SetFrameMetrics(originalMetrics);
     return lockActive;
   }
 };
 
 TEST_F(APZCPinchTester, Pinch_DefaultGestures_NoTouchAction) {
-  SCOPED_GFX_PREF(layout_css_touch_action_enabled, bool, false);
+  SCOPED_GFX_PREF_BOOL("layout.css.touch_action.enabled", false);
   DoPinchTest(true);
 }
 
 TEST_F(APZCPinchGestureDetectorTester, Pinch_UseGestureDetector_NoTouchAction) {
-  SCOPED_GFX_PREF(layout_css_touch_action_enabled, bool, false);
+  SCOPED_GFX_PREF_BOOL("layout.css.touch_action.enabled", false);
   DoPinchTest(true);
 }
 
 TEST_F(APZCPinchGestureDetectorTester,
        Pinch_UseGestureDetector_TouchActionNone) {
-  SCOPED_GFX_PREF(layout_css_touch_action_enabled, bool, true);
+  SCOPED_GFX_PREF_BOOL("layout.css.touch_action.enabled", true);
   nsTArray<uint32_t> behaviors = {mozilla::layers::AllowedTouchBehavior::NONE,
                                   mozilla::layers::AllowedTouchBehavior::NONE};
   DoPinchTest(false, &behaviors);
 }
 
 TEST_F(APZCPinchGestureDetectorTester,
        Pinch_UseGestureDetector_TouchActionZoom) {
-  SCOPED_GFX_PREF(layout_css_touch_action_enabled, bool, true);
+  SCOPED_GFX_PREF_BOOL("layout.css.touch_action.enabled", true);
   nsTArray<uint32_t> behaviors;
   behaviors.AppendElement(mozilla::layers::AllowedTouchBehavior::PINCH_ZOOM);
   behaviors.AppendElement(mozilla::layers::AllowedTouchBehavior::PINCH_ZOOM);
   DoPinchTest(true, &behaviors);
 }
 
 TEST_F(APZCPinchGestureDetectorTester,
        Pinch_UseGestureDetector_TouchActionNotAllowZoom) {
-  SCOPED_GFX_PREF(layout_css_touch_action_enabled, bool, true);
+  SCOPED_GFX_PREF_BOOL("layout.css.touch_action.enabled", true);
   nsTArray<uint32_t> behaviors;
   behaviors.AppendElement(mozilla::layers::AllowedTouchBehavior::NONE);
   behaviors.AppendElement(mozilla::layers::AllowedTouchBehavior::PINCH_ZOOM);
   DoPinchTest(false, &behaviors);
 }
 
 TEST_F(APZCPinchGestureDetectorTester,
        Pinch_UseGestureDetector_TouchActionNone_NoAPZZoom) {
-  SCOPED_GFX_PREF(layout_css_touch_action_enabled, bool, true);
-  SCOPED_GFX_PREF(APZAllowZooming, bool, false);
+  SCOPED_GFX_PREF_BOOL("layout.css.touch_action.enabled", true);
+  SCOPED_GFX_PREF_BOOL("apz.allow_zooming", false);
 
   // Since we are preventing the pinch action via touch-action we should not be
   // sending the pinch gesture notifications that would normally be sent when
   // APZAllowZooming is false.
   EXPECT_CALL(*mcc, NotifyPinchGesture(_, _, _, _)).Times(0);
   nsTArray<uint32_t> behaviors = {mozilla::layers::AllowedTouchBehavior::NONE,
                                   mozilla::layers::AllowedTouchBehavior::NONE};
   DoPinchTest(false, &behaviors);
 }
 
 TEST_F(APZCPinchGestureDetectorTester, Pinch_PreventDefault) {
   DoPinchWithPreventDefaultTest();
 }
 
 TEST_F(APZCPinchGestureDetectorTester, Pinch_PreventDefault_NoAPZZoom) {
-  SCOPED_GFX_PREF(APZAllowZooming, bool, false);
+  SCOPED_GFX_PREF_BOOL("apz.allow_zooming", false);
 
   // Since we are preventing the pinch action we should not be sending the pinch
   // gesture notifications that would normally be sent when APZAllowZooming is
   // false.
   EXPECT_CALL(*mcc, NotifyPinchGesture(_, _, _, _)).Times(0);
 
   DoPinchWithPreventDefaultTest();
 }
 
 TEST_F(APZCPinchGestureDetectorTester, Panning_TwoFingerFling_ZoomDisabled) {
-  SCOPED_GFX_PREF(APZFlingMinVelocityThreshold, float, 0.0f);
+  SCOPED_GFX_PREF_FLOAT("apz.fling_min_velocity_threshold", 0.0f);
 
   apzc->SetFrameMetrics(GetPinchableFrameMetrics());
   MakeApzcUnzoomable();
 
   // Perform a two finger pan
   int touchInputId = 0;
   uint64_t blockId = 0;
   PinchWithTouchInput(apzc, ScreenIntPoint(100, 200), ScreenIntPoint(100, 100),
                       1, touchInputId, nullptr, nullptr, &blockId);
 
   // Expect to be in a flinging state
   apzc->AssertStateIsFling();
 }
 
 TEST_F(APZCPinchGestureDetectorTester, Panning_TwoFingerFling_ZoomEnabled) {
-  SCOPED_GFX_PREF(APZFlingMinVelocityThreshold, float, 0.0f);
+  SCOPED_GFX_PREF_FLOAT("apz.fling_min_velocity_threshold", 0.0f);
 
   apzc->SetFrameMetrics(GetPinchableFrameMetrics());
   MakeApzcZoomable();
 
   // Perform a two finger pan
   int touchInputId = 0;
   uint64_t blockId = 0;
   PinchWithTouchInput(apzc, ScreenIntPoint(100, 200), ScreenIntPoint(100, 100),
                       1, touchInputId, nullptr, nullptr, &blockId);
 
   // Expect to NOT be in flinging state
   apzc->AssertStateIsReset();
 }
 
 TEST_F(APZCPinchGestureDetectorTester,
        Panning_TwoThenOneFingerFling_ZoomEnabled) {
-  SCOPED_GFX_PREF(APZFlingMinVelocityThreshold, float, 0.0f);
+  SCOPED_GFX_PREF_FLOAT("apz.fling_min_velocity_threshold", 0.0f);
 
   apzc->SetFrameMetrics(GetPinchableFrameMetrics());
   MakeApzcZoomable();
 
   // Perform a two finger pan lifting only the first finger
   int touchInputId = 0;
   uint64_t blockId = 0;
   PinchWithTouchInput(apzc, ScreenIntPoint(100, 200), ScreenIntPoint(100, 100),
@@ -425,17 +425,17 @@ TEST_F(APZCPinchTester, Panning_Beyond_L
   // boundary of the layout viewport.
   EXPECT_EQ(400, fm.GetScrollOffset().x);
   EXPECT_EQ(150, fm.GetScrollOffset().y);
   EXPECT_EQ(350, fm.GetLayoutViewport().X());
   EXPECT_EQ(150, fm.GetLayoutViewport().Y());
 }
 
 TEST_F(APZCPinchGestureDetectorTester, Pinch_APZZoom_Disabled) {
-  SCOPED_GFX_PREF(APZAllowZooming, bool, false);
+  SCOPED_GFX_PREF_BOOL("apz.allow_zooming", false);
 
   FrameMetrics originalMetrics = GetPinchableFrameMetrics();
   apzc->SetFrameMetrics(originalMetrics);
 
   // When APZAllowZooming is false, the ZoomConstraintsClient produces
   // ZoomConstraints with mAllowZoom set to false.
   MakeApzcUnzoomable();
 
@@ -463,18 +463,18 @@ TEST_F(APZCPinchGestureDetectorTester, P
   EXPECT_EQ(originalMetrics.GetZoom(), fm.GetZoom());
   EXPECT_EQ(originalMetrics.GetScrollOffset().x, fm.GetScrollOffset().x);
   EXPECT_EQ(originalMetrics.GetScrollOffset().y, fm.GetScrollOffset().y);
 
   apzc->AssertStateIsReset();
 }
 
 TEST_F(APZCPinchGestureDetectorTester, Pinch_NoSpan) {
-  SCOPED_GFX_PREF(APZAllowZooming, bool, false);
-  SCOPED_GFX_PREF(layout_css_touch_action_enabled, bool, false);
+  SCOPED_GFX_PREF_BOOL("apz.allow_zooming", false);
+  SCOPED_GFX_PREF_BOOL("layout.css.touch_action.enabled", false);
 
   FrameMetrics originalMetrics = GetPinchableFrameMetrics();
   apzc->SetFrameMetrics(originalMetrics);
 
   // When APZAllowZooming is false, the ZoomConstraintsClient produces
   // ZoomConstraints with mAllowZoom set to false.
   MakeApzcUnzoomable();
 
@@ -538,17 +538,17 @@ TEST_F(APZCPinchGestureDetectorTester, P
   EXPECT_EQ(originalMetrics.GetScrollOffset().x, fm.GetScrollOffset().x);
   EXPECT_EQ(originalMetrics.GetScrollOffset().y + 50, fm.GetScrollOffset().y);
 
   apzc->AssertStateIsReset();
 }
 
 TEST_F(APZCPinchTester, Pinch_TwoFinger_APZZoom_Disabled_Bug1354185) {
   // Set up APZ such that mZoomConstraints.mAllowZoom is false.
-  SCOPED_GFX_PREF(APZAllowZooming, bool, false);
+  SCOPED_GFX_PREF_BOOL("apz.allow_zooming", false);
   apzc->SetFrameMetrics(GetPinchableFrameMetrics());
   MakeApzcUnzoomable();
 
   // We expect a repaint request for scrolling.
   EXPECT_CALL(*mcc, RequestContentRepaint(_)).Times(1);
 
   // Send only the PINCHGESTURE_START and PINCHGESTURE_SCALE events,
   // in order to trigger a call to AsyncPanZoomController::OnScale
@@ -563,52 +563,52 @@ TEST_F(APZCPinchTester, Pinch_TwoFinger_
 
   apzc->ReceiveInputEvent(
       CreatePinchGestureInput(PinchGestureInput::PINCHGESTURE_SCALE,
                               aSecondFocus, 10.0 * aScale, 10.0, mcc->Time()),
       nullptr);
 }
 
 TEST_F(APZCPinchLockingTester, Pinch_Locking_Free) {
-  SCOPED_GFX_PREF(APZPinchLockMode, int32_t, 0);  // PINCH_FREE
+  SCOPED_GFX_PREF_INT("apz.pinch_lock.mode", 0);  // PINCH_FREE
 
   twoFingerPan();
   EXPECT_FALSE(isPinchLockActive());
 }
 
 TEST_F(APZCPinchLockingTester, Pinch_Locking_Normal_Lock) {
-  SCOPED_GFX_PREF(APZPinchLockMode, int32_t, 1);  // PINCH_NORMAL
+  SCOPED_GFX_PREF_INT("apz.pinch_lock.mode", 1);  // PINCH_NORMAL
 
   twoFingerPan();
   EXPECT_TRUE(isPinchLockActive());
 }
 
 TEST_F(APZCPinchLockingTester, Pinch_Locking_Normal_Lock_Break) {
-  SCOPED_GFX_PREF(APZPinchLockMode, int32_t, 1);  // PINCH_NORMAL
+  SCOPED_GFX_PREF_INT("apz.pinch_lock.mode", 1);  // PINCH_NORMAL
 
   twoFingerPan();
   twoFingerZoom();
   EXPECT_TRUE(isPinchLockActive());
 }
 
 TEST_F(APZCPinchLockingTester, Pinch_Locking_Sticky_Lock) {
-  SCOPED_GFX_PREF(APZPinchLockMode, int32_t, 2);  // PINCH_STICKY
+  SCOPED_GFX_PREF_INT("apz.pinch_lock.mode", 2);  // PINCH_STICKY
 
   twoFingerPan();
   EXPECT_TRUE(isPinchLockActive());
 }
 
 TEST_F(APZCPinchLockingTester, Pinch_Locking_Sticky_Lock_Break) {
-  SCOPED_GFX_PREF(APZPinchLockMode, int32_t, 2);  // PINCH_STICKY
+  SCOPED_GFX_PREF_INT("apz.pinch_lock.mode", 2);  // PINCH_STICKY
 
   twoFingerPan();
   twoFingerZoom();
   EXPECT_FALSE(isPinchLockActive());
 }
 
 TEST_F(APZCPinchLockingTester, Pinch_Locking_Sticky_Lock_Break_Lock) {
-  SCOPED_GFX_PREF(APZPinchLockMode, int32_t, 2);  // PINCH_STICKY
+  SCOPED_GFX_PREF_INT("apz.pinch_lock.mode", 2);  // PINCH_STICKY
 
   twoFingerPan();
   twoFingerZoom();
   twoFingerPan();
   EXPECT_TRUE(isPinchLockActive());
 }
--- a/gfx/layers/apz/test/gtest/TestScrollHandoff.cpp
+++ b/gfx/layers/apz/test/gtest/TestScrollHandoff.cpp
@@ -132,18 +132,18 @@ class APZScrollHandoffTester : public AP
     rootApzc = ApzcOf(root);
     rootApzc->GetScrollMetadata().SetHasScrollgrab(true);
   }
 
   void TestFlingAcceleration() {
     // Jack up the fling acceleration multiplier so we can easily determine
     // whether acceleration occured.
     const float kAcceleration = 100.0f;
-    SCOPED_GFX_PREF(APZFlingAccelBaseMultiplier, float, kAcceleration);
-    SCOPED_GFX_PREF(APZFlingAccelMinVelocity, float, 0.0);
+    SCOPED_GFX_PREF_FLOAT("apz.fling_accel_base_mult", kAcceleration);
+    SCOPED_GFX_PREF_FLOAT("apz.fling_accel_min_velocity", 0.0);
 
     RefPtr<TestAsyncPanZoomController> childApzc = ApzcOf(layers[1]);
 
     // Pan once, enough to fully scroll the scrollgrab parent and then scroll
     // and fling the child.
     Pan(manager, 70, 40);
 
     // Give the fling animation a chance to start.
@@ -167,17 +167,17 @@ class APZScrollHandoffTester : public AP
 
     // We should not have accelerated twice.
     // The division by 4 is to account for friction.
     EXPECT_LE(childVelocityAfterFling2,
               childVelocityAfterFling1 * kAcceleration * kAcceleration / 4);
   }
 
   void TestCrossApzcAxisLock() {
-    SCOPED_GFX_PREF(APZAxisLockMode, int32_t, 1);
+    SCOPED_GFX_PREF_INT("apz.axis_lock.mode", 1);
 
     CreateScrollHandoffLayerTree1();
 
     RefPtr<TestAsyncPanZoomController> childApzc = ApzcOf(layers[1]);
     Pan(childApzc, ScreenIntPoint(10, 60), ScreenIntPoint(15, 90),
         PanOptions::KeepFingerDown | PanOptions::ExactCoordinates);
 
     childApzc->AssertAxisLocked(ScrollDirection::eVertical);
@@ -260,18 +260,18 @@ TEST_F(APZScrollHandoffTester, LayerStru
   EXPECT_EQ(10, rootApzc->GetFrameMetrics().GetScrollOffset().y);
   EXPECT_EQ(-10, middleApzc->GetFrameMetrics().GetScrollOffset().y);
 }
 
 // Test that putting a second finger down on an APZC while a down-chain APZC
 // is overscrolled doesn't result in being stuck in overscroll.
 TEST_F(APZScrollHandoffTester, StuckInOverscroll_Bug1073250) {
   // Enable overscrolling.
-  SCOPED_GFX_PREF(APZOverscrollEnabled, bool, true);
-  SCOPED_GFX_PREF(APZFlingMinVelocityThreshold, float, 0.0f);
+  SCOPED_GFX_PREF_BOOL("apz.overscroll.enabled", true);
+  SCOPED_GFX_PREF_FLOAT("apz.fling_min_velocity_threshold", 0.0f);
   SCOPED_GFX_VAR(UseWebRender, bool, false);
 
   CreateScrollHandoffLayerTree1();
 
   TestAsyncPanZoomController* child = ApzcOf(layers[1]);
 
   // Pan, causing the parent APZC to overscroll.
   Pan(manager, 10, 40, PanOptions::KeepFingerDown);
@@ -303,18 +303,18 @@ TEST_F(APZScrollHandoffTester, StuckInOv
   EXPECT_FALSE(rootApzc->IsOverscrolled());
 }
 
 // This is almost exactly like StuckInOverscroll_Bug1073250, except the
 // APZC receiving the input events for the first touch block is the child
 // (and thus not the same APZC that overscrolls, which is the parent).
 TEST_F(APZScrollHandoffTester, StuckInOverscroll_Bug1231228) {
   // Enable overscrolling.
-  SCOPED_GFX_PREF(APZOverscrollEnabled, bool, true);
-  SCOPED_GFX_PREF(APZFlingMinVelocityThreshold, float, 0.0f);
+  SCOPED_GFX_PREF_BOOL("apz.overscroll.enabled", true);
+  SCOPED_GFX_PREF_FLOAT("apz.fling_min_velocity_threshold", 0.0f);
   SCOPED_GFX_VAR(UseWebRender, bool, false);
 
   CreateScrollHandoffLayerTree1();
 
   TestAsyncPanZoomController* child = ApzcOf(layers[1]);
 
   // Pan, causing the parent APZC to overscroll.
   Pan(manager, 60, 90, PanOptions::KeepFingerDown);
@@ -343,17 +343,17 @@ TEST_F(APZScrollHandoffTester, StuckInOv
 
   // Make sure nothing is overscrolled.
   EXPECT_FALSE(child->IsOverscrolled());
   EXPECT_FALSE(rootApzc->IsOverscrolled());
 }
 
 TEST_F(APZScrollHandoffTester, StuckInOverscroll_Bug1240202a) {
   // Enable overscrolling.
-  SCOPED_GFX_PREF(APZOverscrollEnabled, bool, true);
+  SCOPED_GFX_PREF_BOOL("apz.overscroll.enabled", true);
 
   CreateScrollHandoffLayerTree1();
 
   TestAsyncPanZoomController* child = ApzcOf(layers[1]);
 
   // Pan, causing the parent APZC to overscroll.
   Pan(manager, 60, 90, PanOptions::KeepFingerDown);
   EXPECT_FALSE(child->IsOverscrolled());
@@ -376,17 +376,17 @@ TEST_F(APZScrollHandoffTester, StuckInOv
 
   // Make sure nothing is overscrolled.
   EXPECT_FALSE(child->IsOverscrolled());
   EXPECT_FALSE(rootApzc->IsOverscrolled());
 }
 
 TEST_F(APZScrollHandoffTester, StuckInOverscroll_Bug1240202b) {
   // Enable overscrolling.
-  SCOPED_GFX_PREF(APZOverscrollEnabled, bool, true);
+  SCOPED_GFX_PREF_BOOL("apz.overscroll.enabled", true);
   SCOPED_GFX_VAR(UseWebRender, bool, false);
 
   CreateScrollHandoffLayerTree1();
 
   TestAsyncPanZoomController* child = ApzcOf(layers[1]);
 
   // Pan, causing the parent APZC to overscroll.
   Pan(manager, 60, 90, PanOptions::KeepFingerDown);
@@ -426,17 +426,17 @@ TEST_F(APZScrollHandoffTester, StuckInOv
 
   // Make sure nothing is overscrolled.
   EXPECT_FALSE(child->IsOverscrolled());
   EXPECT_FALSE(rootApzc->IsOverscrolled());
 }
 
 TEST_F(APZScrollHandoffTester, OpposingConstrainedAxes_Bug1201098) {
   // Enable overscrolling.
-  SCOPED_GFX_PREF(APZOverscrollEnabled, bool, true);
+  SCOPED_GFX_PREF_BOOL("apz.overscroll.enabled", true);
 
   CreateScrollHandoffLayerTree4();
 
   RefPtr<TestAsyncPanZoomController> childApzc = ApzcOf(layers[1]);
 
   // Pan, causing the child APZC to overscroll.
   Pan(childApzc, 50, 60);
 
@@ -446,17 +446,17 @@ TEST_F(APZScrollHandoffTester, OpposingC
 }
 
 // Test that flinging in a direction where one component of the fling goes into
 // overscroll but the other doesn't, results in just the one component being
 // handed off to the parent, while the original APZC continues flinging in the
 // other direction.
 TEST_F(APZScrollHandoffTester, PartialFlingHandoff) {
   SCOPED_GFX_VAR(UseWebRender, bool, false);
-  SCOPED_GFX_PREF(APZFlingMinVelocityThreshold, float, 0.0f);
+  SCOPED_GFX_PREF_FLOAT("apz.fling_min_velocity_threshold", 0.0f);
 
   CreateScrollHandoffLayerTree1();
 
   // Fling up and to the left. The child APZC has room to scroll up, but not
   // to the left, so the horizontal component of the fling should be handed
   // off to the parent APZC.
   Pan(manager, ScreenIntPoint(90, 90), ScreenIntPoint(55, 55));
 
@@ -471,17 +471,17 @@ TEST_F(APZScrollHandoffTester, PartialFl
   // Assert that partial handoff has occurred.
   child->AssertStateIsFling();
   parent->AssertStateIsFling();
 }
 
 // Here we test that if two flings are happening simultaneously, overscroll
 // is handed off correctly for each.
 TEST_F(APZScrollHandoffTester, SimultaneousFlings) {
-  SCOPED_GFX_PREF(APZFlingMinVelocityThreshold, float, 0.0f);
+  SCOPED_GFX_PREF_FLOAT("apz.fling_min_velocity_threshold", 0.0f);
 
   // Set up an initial APZC tree.
   CreateScrollHandoffLayerTree3();
 
   RefPtr<TestAsyncPanZoomController> parent1 = ApzcOf(layers[1]);
   RefPtr<TestAsyncPanZoomController> child1 = ApzcOf(layers[2]);
   RefPtr<TestAsyncPanZoomController> parent2 = ApzcOf(layers[3]);
   RefPtr<TestAsyncPanZoomController> child2 = ApzcOf(layers[4]);
@@ -518,46 +518,46 @@ TEST_F(APZScrollHandoffTester, Scrollgra
   Pan(childApzc, 80, 45);
 
   // Check that the parent and child have scrolled as much as we expect.
   EXPECT_EQ(20, rootApzc->GetFrameMetrics().GetScrollOffset().y);
   EXPECT_EQ(15, childApzc->GetFrameMetrics().GetScrollOffset().y);
 }
 
 TEST_F(APZScrollHandoffTester, ScrollgrabFling) {
-  SCOPED_GFX_PREF(APZFlingMinVelocityThreshold, float, 0.0f);
+  SCOPED_GFX_PREF_FLOAT("apz.fling_min_velocity_threshold", 0.0f);
   // Set up the layer tree
   CreateScrollgrabLayerTree();
 
   RefPtr<TestAsyncPanZoomController> childApzc = ApzcOf(layers[1]);
 
   // Pan on the child, not enough to fully scroll the scrollgrab parent.
   Pan(childApzc, 80, 70);
 
   // Check that it is the scrollgrab parent that's in a fling, not the child.
   rootApzc->AssertStateIsFling();
   childApzc->AssertStateIsReset();
 }
 
 TEST_F(APZScrollHandoffTester, ScrollgrabFlingAcceleration1) {
-  SCOPED_GFX_PREF(APZFlingMinVelocityThreshold, float, 0.0f);
+  SCOPED_GFX_PREF_FLOAT("apz.fling_min_velocity_threshold", 0.0f);
   SCOPED_GFX_VAR(UseWebRender, bool, false);
   CreateScrollgrabLayerTree(true /* make parent scrollable */);
   TestFlingAcceleration();
 }
 
 TEST_F(APZScrollHandoffTester, ScrollgrabFlingAcceleration2) {
-  SCOPED_GFX_PREF(APZFlingMinVelocityThreshold, float, 0.0f);
+  SCOPED_GFX_PREF_FLOAT("apz.fling_min_velocity_threshold", 0.0f);
   SCOPED_GFX_VAR(UseWebRender, bool, false);
   CreateScrollgrabLayerTree(false /* do not make parent scrollable */);
   TestFlingAcceleration();
 }
 
 TEST_F(APZScrollHandoffTester, ImmediateHandoffDisallowed_Pan) {
-  SCOPED_GFX_PREF(APZAllowImmediateHandoff, bool, false);
+  SCOPED_GFX_PREF_BOOL("apz.allow_immediate_handoff", false);
 
   CreateScrollHandoffLayerTree1();
 
   RefPtr<TestAsyncPanZoomController> parentApzc = ApzcOf(root);
   RefPtr<TestAsyncPanZoomController> childApzc = ApzcOf(layers[1]);
 
   // Pan on the child, enough to scroll it to its end and have scroll
   // left to hand off. Since immediate handoff is disallowed, we expect
@@ -572,18 +572,18 @@ TEST_F(APZScrollHandoffTester, Immediate
   // its end when the gesture began, we expect the scroll to be handed off.
   Pan(childApzc, 60, 50);
 
   // Verify that the parent scrolled.
   EXPECT_EQ(10, parentApzc->GetFrameMetrics().GetScrollOffset().y);
 }
 
 TEST_F(APZScrollHandoffTester, ImmediateHandoffDisallowed_Fling) {
-  SCOPED_GFX_PREF(APZAllowImmediateHandoff, bool, false);
-  SCOPED_GFX_PREF(APZFlingMinVelocityThreshold, float, 0.0f);
+  SCOPED_GFX_PREF_BOOL("apz.allow_immediate_handoff", false);
+  SCOPED_GFX_PREF_FLOAT("apz.fling_min_velocity_threshold", 0.0f);
 
   CreateScrollHandoffLayerTree1();
 
   RefPtr<TestAsyncPanZoomController> parentApzc = ApzcOf(root);
   RefPtr<TestAsyncPanZoomController> childApzc = ApzcOf(layers[1]);
 
   // Pan on the child, enough to get very close to the end, so that the
   // subsequent fling reaches the end and has leftover velocity to hand off.
@@ -609,16 +609,16 @@ TEST_F(APZScrollHandoffTester, Immediate
   childApzc->AdvanceAnimationsUntilEnd();
   parentApzc->AdvanceAnimationsUntilEnd();
 
   // Verify that the parent scrolled from the fling.
   EXPECT_GT(parentApzc->GetFrameMetrics().GetScrollOffset().y, 10);
 }
 
 TEST_F(APZScrollHandoffTester, CrossApzcAxisLock_NoTouchAction) {
-  SCOPED_GFX_PREF(layout_css_touch_action_enabled, bool, false);
+  SCOPED_GFX_PREF_BOOL("layout.css.touch_action.enabled", false);
   TestCrossApzcAxisLock();
 }
 
 TEST_F(APZScrollHandoffTester, CrossApzcAxisLock_TouchAction) {
-  SCOPED_GFX_PREF(layout_css_touch_action_enabled, bool, true);
+  SCOPED_GFX_PREF_BOOL("layout.css.touch_action.enabled", true);
   TestCrossApzcAxisLock();
 }
--- a/gfx/layers/apz/util/CheckerboardReportService.cpp
+++ b/gfx/layers/apz/util/CheckerboardReportService.cpp
@@ -190,17 +190,17 @@ void CheckerboardReportService::GetRepor
   instance->GetReports(aOutReports);
 }
 
 bool CheckerboardReportService::IsRecordingEnabled() const {
   return StaticPrefs::APZRecordCheckerboarding();
 }
 
 void CheckerboardReportService::SetRecordingEnabled(bool aEnabled) {
-  StaticPrefs::SetAPZRecordCheckerboarding(aEnabled);
+  Preferences::SetBool("apz.record_checkerboarding", aEnabled);
 }
 
 void CheckerboardReportService::FlushActiveReports() {
   MOZ_ASSERT(XRE_IsParentProcess());
   gfx::GPUProcessManager* gpu = gfx::GPUProcessManager::Get();
   if (gpu && gpu->NotifyGpuObservers("APZ:FlushActiveCheckerboard")) {
     return;
   }
--- a/gfx/thebes/DeviceManagerDx.cpp
+++ b/gfx/thebes/DeviceManagerDx.cpp
@@ -1031,17 +1031,17 @@ bool DeviceManagerDx::GetAnyDeviceRemove
   if (DidDeviceReset(mCompositorDevice, aOutReason) ||
       DidDeviceReset(mContentDevice, aOutReason) ||
       DidDeviceReset(mCanvasDevice, aOutReason)) {
     return true;
   }
 
   if (XRE_IsParentProcess() && NS_IsMainThread() &&
       StaticPrefs::DeviceResetForTesting()) {
-    StaticPrefs::SetDeviceResetForTesting(0);
+    Preferences::SetInt("gfx.testing.device-reset", 0);
     *aOutReason = DeviceResetReason::FORCED_RESET;
     return true;
   }
 
   return false;
 }
 
 void DeviceManagerDx::ForceDeviceReset(ForcedDeviceResetReason aReason) {
--- a/gfx/thebes/gfxWindowsPlatform.cpp
+++ b/gfx/thebes/gfxWindowsPlatform.cpp
@@ -1349,17 +1349,17 @@ void gfxWindowsPlatform::InitializeD3D11
     // update due to the crashes in Bug 1351349.
     if (adaptorId.EqualsLiteral("0x1912") ||
         adaptorId.EqualsLiteral("0x1916") ||
         adaptorId.EqualsLiteral("0x1902")) {
 #ifdef RELEASE_OR_BETA
       d3d11.Disable(FeatureStatus::Blacklisted, "Blacklisted, see bug 1351349",
                     NS_LITERAL_CSTRING("FEATURE_FAILURE_BUG_1351349"));
 #else
-      StaticPrefs::SetCompositorClearState(true);
+      Preferences::SetBool("gfx.compositor.clearstate", true);
 #endif
     }
   }
 
   nsCString message;
   nsCString failureId;
   if (!gfxPlatform::IsGfxInfoStatusOkay(nsIGfxInfo::FEATURE_DIRECT3D_11_LAYERS,
                                         &message, failureId)) {
--- a/modules/libpref/Preferences.cpp
+++ b/modules/libpref/Preferences.cpp
@@ -5423,41 +5423,20 @@ void StaticPrefs::MaybeInitOncePrefs() {
 //   int32_t StaticPrefs::sVarCache_my_varcache(99);
 //   int32_t StaticPrefs::my_varcache() {
 //     if (UpdatePolicy::Skip != UpdatePolicy::Once) {
 //       return sVarCache_myvarcache;
 //     }
 //     MaybeInitOncePrefs();
 //     return sVarCache_myvarcache;
 //   }
-//   void StaticPrefs::Setmy_varcache(int32_t aValue) {
-//     SetPref(Getmy_varcachePrefName(), aValue);
-//     if (UpdatePolicy::policy == UpdatePolicy::Once) {
-//       sVarCache_my_varcache = PreferencesInternalMethods::GetPref(
-//           Getmy_varcachePrefName(), sVarCache_my_varcache);
-//     }
-//     return;
-//   }
 
 #define PREF(name, cpp_type, value)
-#define VARCACHE_PREF(policy, name, id, cpp_type, default_value)               \
-  cpp_type StaticPrefs::sVarCache_##id(default_value);                         \
-  void StaticPrefs::Set##id(StripAtomic<cpp_type> aValue) {                    \
-    MOZ_DIAGNOSTIC_ASSERT(NS_IsMainThread() && XRE_IsParentProcess(),          \
-                          "pref '" name "' being set outside parent process"); \
-    MOZ_DIAGNOSTIC_ASSERT(UpdatePolicy::policy == UpdatePolicy::Live ||        \
-                          !sOncePrefRead);                                     \
-    SetPref(Get##id##PrefName(), aValue);                                      \
-    if (UpdatePolicy::policy == UpdatePolicy::Once) {                          \
-      sVarCache_##id = PreferencesInternalMethods::GetPref(                    \
-          Get##id##PrefName(), StripAtomic<cpp_type>(sVarCache_##id));         \
-    }                                                                          \
-    /* The StaticPrefs storage will be updated by the registered callback */   \
-    return;                                                                    \
-  }
+#define VARCACHE_PREF(policy, name, id, cpp_type, default_value) \
+  cpp_type StaticPrefs::sVarCache_##id(default_value);
 #include "mozilla/StaticPrefList.h"
 #undef PREF
 #undef VARCACHE_PREF
 
 /* static */
 void StaticPrefs::InitAll(bool aIsStartup) {
   // For prefs like these:
   //
--- a/modules/libpref/StaticPrefs.h
+++ b/modules/libpref/StaticPrefs.h
@@ -79,17 +79,16 @@ class StaticPrefs {
   // For example, if the accessor is Foo() then calling SetFoo(...) will update
   // the preference and also change the return value of subsequent Foo() calls.
   // Changing StaticPrefs is only allowed on the parent process' main thread.
   //
   //   private:
   //     static int32_t sVarCache_my_varcache;
   //   public:
   //     static int32_t my_varcache();
-  //     static void Setmy_varcache(int32_t aValue);
   //     static const char* Getmy_varcachePrefName() { return "my.varcache"; }
   //     static int32_t Getmy_varcachePrefDefault() { return 99; }
   //
 
  public:
   // Enums for the update policy.
   enum class UpdatePolicy {
     Skip,  // Set the value to default, skip any Preferences calls.
@@ -110,17 +109,16 @@ class StaticPrefs {
               IsAtomic<cpp_type>::value || NS_IsMainThread(),   \
           "Non-atomic static pref '" str                        \
           "' being accessed on background thread by getter");   \
       return sVarCache_##id;                                    \
     }                                                           \
     MaybeInitOncePrefs();                                       \
     return sVarCache_##id;                                      \
   }                                                             \
-  static void Set##id(StripAtomic<cpp_type> aValue);            \
   static const char* Get##id##PrefName() { return str; }        \
   static StripAtomic<cpp_type> Get##id##PrefDefault() { return default_value; }
 
 #include "mozilla/StaticPrefList.h"
 #undef PREF
 #undef VARCACHE_PREF
 
  private: