Bug 1459312 - Scroll layers that are fixed w.r.t. the RCD-RSF by the relative visual transform. r=kats

Differential Revision: https://phabricator.services.mozilla.com/D17726

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Botond Ballo 2019-02-02 23:53:54 +00:00
parent 408de98e10
commit 0ac724fa85

View File

@ -381,6 +381,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<ScrollableLayerGuid::ViewID> 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<ScrollableLayerGuid::ViewID> IsFixedOrSticky(Layer* aLayer) {
@ -1198,6 +1224,21 @@ bool AsyncCompositionManager::ApplyAsyncContentTransformToTree(
// scroll metadata for zoomedScrollId appears in the layer tree.
}
}
if (zoomedMetrics && layer->GetIsFixedPosition() &&
!layer->GetParent()->GetIsFixedPosition() &&
IsFixedToZoomContainer(layer)) {
LayerToParentLayerMatrix4x4 currentTransform;
LayerToParentLayerMatrix4x4 previousTransform =
CSSTransformMatrix() *
CompleteAsyncTransform(
sampler->GetCurrentAsyncViewportRelativeTransform(
*zoomedMetrics));
AdjustFixedOrStickyLayer(zoomContainer, layer,
sampler->GetGuid(*zoomedMetrics).mScrollId,
previousTransform, currentTransform,
fixedLayerMargins, clipPartsCache);
}
}
bool clipChanged = (hasAsyncTransform || clipDeferredFromChildren ||