Bug 1357754 - Replace LayerMetricsWrapper::AsRefLayer with GetReferentId. r=botond
This further abstracts away the direct dependence on particular layer
types. This is needed in particular for the APZCTreeManager call site
since it will need to operate on non-layer-tree data which is hard if it
relies specifically on RefLayer.
MozReview-Commit-ID: zbK3oTNHJc
--- a/gfx/layers/LayerMetricsWrapper.h
+++ b/gfx/layers/LayerMetricsWrapper.h
@@ -349,16 +349,28 @@ public:
MOZ_ASSERT(IsValid());
if (AtBottomLayer()) {
return mLayer->AsRefLayer();
}
return nullptr;
}
+ Maybe<uint64_t> GetReferentId() const
+ {
+ MOZ_ASSERT(IsValid());
+
+ if (AtBottomLayer()) {
+ return mLayer->AsRefLayer()
+ ? Some(mLayer->AsRefLayer()->GetReferentId())
+ : Nothing();
+ }
+ return Nothing();
+ }
+
LayerIntRegion GetVisibleRegion() const
{
MOZ_ASSERT(IsValid());
if (AtBottomLayer()) {
return mLayer->GetVisibleRegion();
}
LayerIntRegion region = mLayer->GetVisibleRegion();
--- a/gfx/layers/apz/src/APZCTreeManager.cpp
+++ b/gfx/layers/apz/src/APZCTreeManager.cpp
@@ -299,17 +299,17 @@ APZCTreeManager::UpdateHitTestingTreeImp
}
ancestorTransforms.push(currentTransform);
// Note that |node| at this point will not have any children, otherwise we
// we would have to set next to node->GetFirstChild().
MOZ_ASSERT(!node->GetFirstChild());
parent = node;
next = nullptr;
- layersId = (aLayerMetrics.AsRefLayer() ? aLayerMetrics.AsRefLayer()->GetReferentId() : layersId);
+ layersId = aLayerMetrics.GetReferentId().valueOr(layersId);
indents.push(gfx::TreeAutoIndent(mApzcTreeLog));
},
[&](ScrollNode aLayerMetrics)
{
next = parent;
parent = parent->GetParent();
layersId = next->GetLayersId();
ancestorTransforms.pop();