Bug 1357754 - Replace LayerMetricsWrapper::AsRefLayer with GetReferentId. r=botond draft
authorKartikaya Gupta <kgupta@mozilla.com>
Thu, 20 Apr 2017 10:04:48 -0400
changeset 565808 7b889e9b77589caab41f7c35f83a8f257eaacdd6
parent 565807 b81f935cc45ff6baaf6b7fb05832e49dd37afe10
child 565809 eae70e8480e05ff2746b6796ba4d086a415da0db
push id55024
push userkgupta@mozilla.com
push dateThu, 20 Apr 2017 14:05:27 +0000
reviewersbotond
bugs1357754
milestone55.0a1
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
gfx/layers/LayerMetricsWrapper.h
gfx/layers/apz/src/APZCTreeManager.cpp
--- 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();