Bug 1546139 - Add support for setting fixed layer margins in a reftest. r=kats
authorBotond Ballo <botond@mozilla.com>
Thu, 25 Apr 2019 14:25:04 +0000
changeset 530339 d441eb4ab6012d75af70ff90f3d40fe205c862a3
parent 530338 b0f3d584835c25ce778177d8f9395a974d431185
child 530340 11a838d3eab47ea19397d714d22aaf21bdc56d3c
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs1546139
milestone68.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 1546139 - Add support for setting fixed layer margins in a reftest. r=kats This is accomplished via prefs rather than using a reftest attribute because it's easier to get the right persistence (that is, how long the fixed margins stick around) this way. The downside is that someone reading the reftest page needs to look at the test- or ref-specific prefs in reftest.list to get a full picture of what the test is doing. Differential Revision: https://phabricator.services.mozilla.com/D28728
gfx/layers/composite/AsyncCompositionManager.cpp
gfx/layers/composite/AsyncCompositionManager.h
gfx/thebes/gfxPrefs.h
modules/libpref/init/all.js
--- a/gfx/layers/composite/AsyncCompositionManager.cpp
+++ b/gfx/layers/composite/AsyncCompositionManager.cpp
@@ -1079,17 +1079,17 @@ bool AsyncCompositionManager::ApplyAsync
                   // AsyncPanZoomController::NotifyLayersUpdated because the
                   // root content document is not scrollable. So update it here
                   // so it knows if the root composition size has changed.
                   if (animator && !metrics.IsRootContent()) {
                     animator->MaybeUpdateCompositionSizeAndRootFrameMetrics(
                         metrics);
                   }
                 }
-                fixedLayerMargins = mFixedLayerMargins;
+                fixedLayerMargins = GetFixedLayerMargins();
               }
             }
 #else
             *aOutFoundRoot = false;
             // Non-Android platforms still care about this flag being cleared
             // after the first call to TransformShadowTree().
             mIsFirstPaint = false;
 #endif
@@ -1402,19 +1402,19 @@ bool AsyncCompositionManager::TransformS
 
   if (!(aSkip & CompositorBridgeParentBase::TransformsToSkip::APZ)) {
     // Apply an async content transform to any layer that has
     // an async pan zoom controller.
     bool foundRoot = false;
     if (ApplyAsyncContentTransformToTree(root, &foundRoot)) {
 #if defined(MOZ_WIDGET_ANDROID)
       MOZ_ASSERT(foundRoot);
-      if (foundRoot && mFixedLayerMargins != ScreenMargin()) {
+      if (foundRoot && GetFixedLayerMargins() != ScreenMargin()) {
         MoveScrollbarForLayerMargin(root, mRootScrollableId,
-                                    mFixedLayerMargins);
+                                    GetFixedLayerMargins());
       }
 #endif
     }
 
     bool apzAnimating = false;
     if (RefPtr<APZSampler> apz = mCompositorBridge->GetAPZSampler()) {
       apzAnimating =
           apz->SampleAnimations(LayerMetricsWrapper(root), nextFrame);
@@ -1436,12 +1436,20 @@ bool AsyncCompositionManager::TransformS
 }
 
 #if defined(MOZ_WIDGET_ANDROID)
 void AsyncCompositionManager::SetFixedLayerMargins(ScreenIntCoord aTop,
                                                    ScreenIntCoord aBottom) {
   mFixedLayerMargins.top = aTop;
   mFixedLayerMargins.bottom = aBottom;
 }
+ScreenMargin AsyncCompositionManager::GetFixedLayerMargins() const {
+  ScreenMargin result = mFixedLayerMargins;
+  if (gfxPrefs::APZFixedMarginOverrideEnabled()) {
+    result.top = gfxPrefs::APZFixedMarginOverrideTop();
+    result.bottom = gfxPrefs::APZFixedMarginOverrideBottom();
+  }
+  return result;
+}
 #endif  // defined(MOZ_WIDGET_ANDROID)
 
 }  // namespace layers
 }  // namespace mozilla
--- a/gfx/layers/composite/AsyncCompositionManager.h
+++ b/gfx/layers/composite/AsyncCompositionManager.h
@@ -232,16 +232,17 @@ class AsyncCompositionManager final {
 
   TimeStamp mPreviousFrameTimeStamp;
 
   MOZ_NON_OWNING_REF CompositorBridgeParent* mCompositorBridge;
 
 #ifdef MOZ_WIDGET_ANDROID
  public:
   void SetFixedLayerMargins(ScreenIntCoord aTop, ScreenIntCoord aBottom);
+  ScreenMargin GetFixedLayerMargins() const;
 
  private:
   // This calculates whether frame metrics should be sent to Java.
   bool FrameMetricsHaveUpdated(const FrameMetrics& aMetrics);
   // This holds the most recent scroll/zoom metrics sent to Java, and is used
   // to send new updates when it changes.
   FrameMetrics mLastMetrics;
   // The following two fields are only needed on Fennec with C++ APZ, because
--- a/gfx/thebes/gfxPrefs.h
+++ b/gfx/thebes/gfxPrefs.h
@@ -312,16 +312,19 @@ class gfxPrefs final {
   DECL_GFX_PREF(Live, "apz.danger_zone_x",                     APZDangerZoneX, int32_t, 50);
   DECL_GFX_PREF(Live, "apz.danger_zone_y",                     APZDangerZoneY, int32_t, 100);
   DECL_GFX_PREF(Live, "apz.disable_for_scroll_linked_effects", APZDisableForScrollLinkedEffects, bool, false);
   DECL_GFX_PREF(Live, "apz.displayport_expiry_ms",             APZDisplayPortExpiryTime, uint32_t, 15000);
   DECL_GFX_PREF(Live, "apz.drag.enabled",                      APZDragEnabled, bool, false);
   DECL_GFX_PREF(Live, "apz.drag.initial.enabled",              APZDragInitiationEnabled, bool, false);
   DECL_GFX_PREF(Live, "apz.drag.touch.enabled",                APZTouchDragEnabled, bool, false);
   DECL_GFX_PREF(Live, "apz.enlarge_displayport_when_clipped",  APZEnlargeDisplayPortWhenClipped, bool, false);
+  DECL_GFX_PREF(Live, "apz.fixed-margin-override.enabled",     APZFixedMarginOverrideEnabled, bool, false);
+  DECL_GFX_PREF(Live, "apz.fixed-margin-override.bottom",      APZFixedMarginOverrideBottom, int32_t, 0);
+  DECL_GFX_PREF(Live, "apz.fixed-margin-override.top",         APZFixedMarginOverrideTop, int32_t, 0);
   DECL_GFX_PREF(Live, "apz.fling_accel_base_mult",             APZFlingAccelBaseMultiplier, float, 1.0f);
   DECL_GFX_PREF(Live, "apz.fling_accel_interval_ms",           APZFlingAccelInterval, int32_t, 500);
   DECL_GFX_PREF(Live, "apz.fling_accel_supplemental_mult",     APZFlingAccelSupplementalMultiplier, float, 1.0f);
   DECL_GFX_PREF(Live, "apz.fling_accel_min_velocity",          APZFlingAccelMinVelocity, float, 1.5f);
   DECL_GFX_PREF(Once, "apz.fling_curve_function_x1",           APZCurveFunctionX1, float, 0.0f);
   DECL_GFX_PREF(Once, "apz.fling_curve_function_x2",           APZCurveFunctionX2, float, 1.0f);
   DECL_GFX_PREF(Once, "apz.fling_curve_function_y1",           APZCurveFunctionY1, float, 0.0f);
   DECL_GFX_PREF(Once, "apz.fling_curve_function_y2",           APZCurveFunctionY2, float, 1.0f);
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -724,16 +724,19 @@ pref("apz.content_response_timeout", 400
 pref("apz.drag.enabled", true);
 pref("apz.drag.initial.enabled", true);
 pref("apz.drag.touch.enabled", true);
 pref("apz.danger_zone_x", 50);
 pref("apz.danger_zone_y", 100);
 pref("apz.disable_for_scroll_linked_effects", false);
 pref("apz.displayport_expiry_ms", 15000);
 pref("apz.enlarge_displayport_when_clipped", false);
+pref("apz.fixed-margin-override.enabled", false);  // test only
+pref("apz.fixed-margin-override.bottom", 0);       // test only
+pref("apz.fixed-margin-override.top", 0);          // test only
 pref("apz.fling_accel_base_mult", "1.0");
 pref("apz.fling_accel_interval_ms", 500);
 pref("apz.fling_accel_min_velocity", "1.5");
 pref("apz.fling_accel_supplemental_mult", "1.0");
 pref("apz.fling_curve_function_x1", "0.0");
 pref("apz.fling_curve_function_y1", "0.0");
 pref("apz.fling_curve_function_x2", "1.0");
 pref("apz.fling_curve_function_y2", "1.0");