From 8e221b7e30bb026d49ffea5485d63fe38e9fda92 Mon Sep 17 00:00:00 2001 From: Botond Ballo Date: Thu, 25 Apr 2019 14:33:17 +0000 Subject: [PATCH] Bug 1546139 - Restore the call to AdjustFixedOrStickyLayer() for layers fixed to the RCD-RSF. r=kats This call served two purposes: (1) scroll the fixed layer by the eVisual transform, and (2) adjust it by the fixed margins. The first purpose is now served by applying the eVisual transform to the async zoom container, but we still need the call for the second purpose. Differential Revision: https://phabricator.services.mozilla.com/D28735 --HG-- extra : moz-landing-system : lando --- .../composite/AsyncCompositionManager.cpp | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/gfx/layers/composite/AsyncCompositionManager.cpp b/gfx/layers/composite/AsyncCompositionManager.cpp index e260bed3f8f8..227b35a17866 100644 --- a/gfx/layers/composite/AsyncCompositionManager.cpp +++ b/gfx/layers/composite/AsyncCompositionManager.cpp @@ -380,6 +380,32 @@ static bool AsyncTransformShouldBeUnapplied( return false; } +/** + * Given a fixed-position layer, check if it's fixed with respect to the + * zoomed APZC. + */ +static bool IsFixedToZoomContainer(Layer* aFixedLayer) { + ScrollableLayerGuid::ViewID targetId = + aFixedLayer->GetFixedPositionScrollContainerId(); + MOZ_ASSERT(targetId != ScrollableLayerGuid::NULL_SCROLL_ID); + LayerMetricsWrapper result(aFixedLayer, LayerMetricsWrapper::StartAt::BOTTOM); + while (result) { + if (Maybe zoomedScrollId = + result.IsAsyncZoomContainer()) { + return *zoomedScrollId == targetId; + } + // Don't ascend into another layer tree. Scroll IDs are not unique + // across layer trees, and in any case position:fixed doesn't reach + // across documents. + if (result.AsRefLayer() != nullptr) { + break; + } + + result = result.GetParent(); + } + return false; +} + // If |aLayer| is fixed or sticky, returns the scroll id of the scroll frame // that it's fixed or sticky to. Otherwise, returns Nothing(). static Maybe IsFixedOrSticky(Layer* aLayer) { @@ -1197,6 +1223,27 @@ bool AsyncCompositionManager::ApplyAsyncContentTransformToTree( // scroll metadata for zoomedScrollId appears in the layer tree. } } + + // Layers fixed to the RCD-RSF no longer need + // AdjustFixedOrStickyLayer() to scroll them by the eVisual transform, + // as that's now applied to the async zoom container itself. However, + // we still need to adjust them by the fixed layer margins to + // account for dynamic toolbar transitions. This is also handled by + // AdjustFixedOrStickyLayer(), so we now call it with empty transforms + // to get it to perform just the fixed margins adjustment. + if (zoomedMetrics && layer->GetIsFixedPosition() && + !layer->GetParent()->GetIsFixedPosition() && + IsFixedToZoomContainer(layer)) { + LayerToParentLayerMatrix4x4 emptyTransform; + ScreenMargin marginsForFixedLayer; +#ifdef MOZ_WIDGET_ANDROID + marginsForFixedLayer = GetFixedLayerMargins(); +#endif + AdjustFixedOrStickyLayer(zoomContainer, layer, + sampler->GetGuid(*zoomedMetrics).mScrollId, + emptyTransform, emptyTransform, + marginsForFixedLayer, clipPartsCache); + } } bool clipChanged = (hasAsyncTransform || clipDeferredFromChildren ||