Bug 1443792 - Tighten the equivalence between a layer being scrollable and having an APZC. r?botond draft
authorKartikaya Gupta <kgupta@mozilla.com>
Thu, 08 Mar 2018 13:44:33 -0500
changeset 764983 ae4a773d3b59a123652a6056af93097acf9b2910
parent 764982 05d35ca6637c9100489bcfe0a479b6f4ecfaa254
child 764984 444e002fa7c8d9bf0fd0cd55cdb3a559d3a64fbf
push id101912
push userkgupta@mozilla.com
push dateThu, 08 Mar 2018 18:44:58 +0000
reviewersbotond
bugs1443792
milestone60.0a1
Bug 1443792 - Tighten the equivalence between a layer being scrollable and having an APZC. r?botond If we can assume that a layer being composited has an APZC at index i if and only if the frame metrics at index i is scrollable, then we can do the transformations in the next patch without any change in functionality. MozReview-Commit-ID: 2qjboulDp7P
gfx/layers/Layers.cpp
gfx/layers/Layers.h
--- a/gfx/layers/Layers.cpp
+++ b/gfx/layers/Layers.cpp
@@ -224,16 +224,18 @@ Layer::StartPendingAnimations(const Time
         }
       });
 }
 
 void
 Layer::SetAsyncPanZoomController(uint32_t aIndex, AsyncPanZoomController *controller)
 {
   MOZ_ASSERT(aIndex < GetScrollMetadataCount());
+  // We should never be setting an APZC on a non-scrollable layer
+  MOZ_ASSERT(!controller || GetFrameMetrics(aIndex).IsScrollable());
   mApzcs[aIndex] = controller;
 }
 
 AsyncPanZoomController*
 Layer::GetAsyncPanZoomController(uint32_t aIndex) const
 {
   MOZ_ASSERT(aIndex < GetScrollMetadataCount());
 #ifdef DEBUG
--- a/gfx/layers/Layers.h
+++ b/gfx/layers/Layers.h
@@ -1793,16 +1793,20 @@ public:
    * composited.
    */
   virtual void ClearInvalidRegion() { mInvalidRegion.SetEmpty(); }
 
   // These functions allow attaching an AsyncPanZoomController to this layer,
   // and can be used anytime.
   // A layer has an APZC at index aIndex only-if GetFrameMetrics(aIndex).IsScrollable();
   // attempting to get an APZC for a non-scrollable metrics will return null.
+  // The reverse is also true (that if GetFrameMetrics(aIndex).IsScrollable()
+  // is true, then the layer will have an APZC), although that only holds on
+  // the compositor-side layer tree, and only after the APZ code has had a chance
+  // to rebuild its internal hit-testing tree using the layer tree.
   // The aIndex for these functions must be less than GetScrollMetadataCount().
   void SetAsyncPanZoomController(uint32_t aIndex, AsyncPanZoomController *controller);
   AsyncPanZoomController* GetAsyncPanZoomController(uint32_t aIndex) const;
   // The ScrollMetadataChanged function is used internally to ensure the APZC array length
   // matches the frame metrics array length.
 
   virtual void ClearCachedResources() {}