Bug 1368496 - Add support for fixed-positioning with APZ. r=jrmuizel
authorKartikaya Gupta <kgupta@mozilla.com>
Thu, 08 Jun 2017 11:34:01 -0400
changeset 363030 dcffcfdf03ad254ae04b91fe6b230cd455723f7a
parent 363029 c48397f4c2e2c2b8152abc7370bc615047130de3
child 363031 b30457bfb195fd7abb1cb938cc4ca151112f6c5b
push id31994
push usercbook@mozilla.com
push dateFri, 09 Jun 2017 10:56:24 +0000
treeherdermozilla-central@7c9d96bbc400 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1368496
milestone55.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 1368496 - Add support for fixed-positioning with APZ. r=jrmuizel This implements at least enough fixed-positioning support to make the reftest in layout/reftests/async-scrolling/bg-fixed-child.html pass. That test implements a simple background-attachment:fixed which is implemented in the layer tree with a combination of a scrolled clip and a fixed-position layer. Previous patches in this patchset implemented support for the scrolled clip, and this patch implements the fixed-position layer support. MozReview-Commit-ID: 1Al1YshhUL7
gfx/layers/wr/ScrollingLayersHelper.cpp
--- a/gfx/layers/wr/ScrollingLayersHelper.cpp
+++ b/gfx/layers/wr/ScrollingLayersHelper.cpp
@@ -65,25 +65,44 @@ ScrollingLayersHelper::ScrollingLayersHe
       Layer* maskLayer = layer->GetAncestorMaskLayerAt(maskLayerIndex.value());
       WebRenderLayer* maskWrLayer = WebRenderLayer::ToWebRenderLayer(maskLayer);
       // TODO: check this transform is correct in all cases
       mask = maskWrLayer->RenderMaskLayer(maskLayer->GetTransform());
     }
     mBuilder->PushClip(aStackingContext.ToRelativeWrRect(clipRect),
         mask.ptrOr(nullptr));
   }
+
+  // If the layer is marked as fixed-position, it is fixed relative to something
+  // (the scroll layer referred to by GetFixedPositionScrollContainerId, hereafter
+  // referred to as the "scroll container"). What this really means is that we
+  // don't want this content to scroll with any scroll layer on the stack up to
+  // and including the scroll container, but we do want it to scroll with any
+  // ancestor scroll layers. So we do a PushClipAndScrollInfo that maintains
+  // the current non-scrolling clip stack, but resets the scrolling clip stack
+  // to the ancestor of the scroll container.
+  if (layer->GetIsFixedPosition()) {
+    FrameMetrics::ViewID fixedFor = layer->GetFixedPositionScrollContainerId();
+    Maybe<FrameMetrics::ViewID> scrollsWith = mBuilder->ParentScrollIdFor(fixedFor);
+    Maybe<uint64_t> clipId = mBuilder->TopmostClipId();
+    // Default to 0 if there is no ancestor, because 0 refers to the root scrollframe.
+    mBuilder->PushClipAndScrollInfo(scrollsWith.valueOr(0), clipId.ptrOr(nullptr));
+  }
 }
 
 ScrollingLayersHelper::~ScrollingLayersHelper()
 {
   if (!mLayer->WrManager()->AsyncPanZoomEnabled()) {
     return;
   }
 
   Layer* layer = mLayer->GetLayer();
+  if (layer->GetIsFixedPosition()) {
+    mBuilder->PopClipAndScrollInfo();
+  }
   if (layer->GetScrolledClip()) {
     mBuilder->PopClip();
   }
   for (int32_t i = layer->GetScrollMetadataCount(); i > 0; i--) {
     const FrameMetrics& fm = layer->GetFrameMetrics(i - 1);
     if (!fm.IsScrollable()) {
       continue;
     }