Bug 1553045 - Place the fallback scroll metadata onto the async zoom container layer if there is one. r=kats

This preserves the APZ invariant that if there is an async zoom container,
then the RCD-RSF scroll metadata is on the same layer or descendant layers.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Botond Ballo 2019-06-08 17:49:38 +00:00
parent ac9bcfca03
commit 1eb526e657
2 changed files with 18 additions and 1 deletions

View File

@ -248,6 +248,7 @@ EXPORTS.mozilla.layers += [
'TextureSourceProvider.h',
'TextureWrapperImage.h',
'TransactionIdAllocator.h',
'TreeTraversal.h',
'UpdateImageHelper.h',
'wr/AsyncImagePipelineManager.h',
'wr/ClipManager.h',

View File

@ -99,6 +99,7 @@
#include "ClientLayerManager.h"
#include "mozilla/layers/RenderRootStateManager.h"
#include "mozilla/layers/StackingContextHelper.h"
#include "mozilla/layers/TreeTraversal.h"
#include "mozilla/layers/WebRenderBridgeChild.h"
#include "mozilla/layers/WebRenderLayerManager.h"
#include "mozilla/layers/WebRenderMessages.h"
@ -2735,6 +2736,20 @@ LayerManager* nsDisplayListBuilder::GetWidgetLayerManager(nsView** aView) {
return nullptr;
}
// Find the layer which should house the root scroll metadata for a given
// layer tree. This is the async zoom container layer if there is one,
// otherwise it's the root layer.
Layer* GetLayerForRootMetadata(Layer* aRootLayer, ViewID aRootScrollId) {
Layer* asyncZoomContainer = DepthFirstSearch<ForwardIterator>(
aRootLayer, [aRootScrollId](Layer* aLayer) {
if (auto id = aLayer->IsAsyncZoomContainer()) {
return *id == aRootScrollId;
}
return false;
});
return asyncZoomContainer ? asyncZoomContainer : aRootLayer;
}
FrameLayerBuilder* nsDisplayList::BuildLayers(nsDisplayListBuilder* aBuilder,
LayerManager* aLayerManager,
uint32_t aFlags,
@ -2810,7 +2825,8 @@ FrameLayerBuilder* nsDisplayList::BuildLayers(nsDisplayListBuilder* aBuilder,
};
if (Maybe<ScrollMetadata> rootMetadata = nsLayoutUtils::GetRootMetadata(
aBuilder, root->Manager(), containerParameters, callback)) {
root->SetScrollMetadata(rootMetadata.value());
GetLayerForRootMetadata(root, rootMetadata->GetMetrics().GetScrollId())
->SetScrollMetadata(rootMetadata.value());
}
// NS_WARNING is debug-only, so don't even bother checking the conditions