Bug 1368496 - Propagate the layer's "scrolled clip" to WebRender. r=jrmuizel

If the layer has a "scrolled clip", that clip scrolls with the content
of the layers (it moves if any of the scrollable frames defined by that
layer are scrolled).

MozReview-Commit-ID: 37hvXWO930f

--HG--
extra : rebase_source : 4150c3bb061d027b483e44418bec7f3b810a9ccc
This commit is contained in:
Kartikaya Gupta 2017-06-08 11:34:00 -04:00
Родитель 8e9f1257f8
Коммит c8d5fd6ffd
1 изменённых файлов: 22 добавлений и 0 удалений

Просмотреть файл

@ -51,6 +51,25 @@ ScrollingLayersHelper::ScrollingLayersHelper(WebRenderLayer* aLayer,
aStackingContext.ToRelativeWrRect(contentRect),
aStackingContext.ToRelativeWrRect(clipBounds));
}
// The scrolled clip on the layer is "inside" all of the scrollable metadatas
// on that layer. That is, the clip scrolls along with the content in
// child layers. So we need to apply this after pushing all the scroll layers,
// which we do above.
if (Maybe<LayerClip> scrolledClip = layer->GetScrolledClip()) {
LayerRect clipRect = IntRectToRect(ViewAs<LayerPixel>(
scrolledClip->GetClipRect(),
PixelCastJustification::MovingDownToChildren));
Maybe<WrImageMask> mask;
if (Maybe<size_t> maskLayerIndex = scrolledClip->GetMaskLayerIndex()) {
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));
}
}
ScrollingLayersHelper::~ScrollingLayersHelper()
@ -60,6 +79,9 @@ ScrollingLayersHelper::~ScrollingLayersHelper()
}
Layer* layer = mLayer->GetLayer();
if (layer->GetScrolledClip()) {
mBuilder->PopClip();
}
for (int32_t i = layer->GetScrollMetadataCount(); i > 0; i--) {
const FrameMetrics& fm = layer->GetFrameMetrics(i - 1);
if (!fm.IsScrollable()) {