Bug 1389138 - Add helper to track the topmost scroll id on the WR stack. r=mstange draft
authorKartikaya Gupta <kgupta@mozilla.com>
Thu, 17 Aug 2017 11:06:51 -0400
changeset 648484 677a92f918481a73877f551b9ac32975e0110be9
parent 648483 f2f80e89a400d5b9982d138b29e534701b247072
child 648485 623b116c293e86d063e5acfa4a01f5104719f560
push id74768
push userkgupta@mozilla.com
push dateThu, 17 Aug 2017 20:14:33 +0000
reviewersmstange
bugs1389138
milestone57.0a1
Bug 1389138 - Add helper to track the topmost scroll id on the WR stack. r=mstange Note that when PushClipAndScrollInfo is called, we are pushing an already-defined scrolling clip onto the stack, and anything that gets pushed inside it is going to be defined as being inside that scrolling clip. So we need to make sure to update the scroll id stack for those calls as well. This was an oversight previously but it never mattered. MozReview-Commit-ID: D40Gk00HYrq
gfx/webrender_bindings/WebRenderAPI.cpp
gfx/webrender_bindings/WebRenderAPI.h
--- a/gfx/webrender_bindings/WebRenderAPI.cpp
+++ b/gfx/webrender_bindings/WebRenderAPI.cpp
@@ -739,22 +739,24 @@ DisplayListBuilder::PopScrollLayer()
 void
 DisplayListBuilder::PushClipAndScrollInfo(const layers::FrameMetrics::ViewID& aScrollId,
                                           const wr::WrClipId* aClipId)
 {
   WRDL_LOG("PushClipAndScroll s=%" PRIu64 " c=%s\n", aScrollId,
       aClipId ? Stringify(aClipId->id).c_str() : "none");
   wr_dp_push_clip_and_scroll_info(mWrState, aScrollId,
       aClipId ? &(aClipId->id) : nullptr);
+  mScrollIdStack.push_back(aScrollId);
 }
 
 void
 DisplayListBuilder::PopClipAndScrollInfo()
 {
   WRDL_LOG("PopClipAndScroll\n");
+  mScrollIdStack.pop_back();
   wr_dp_pop_clip_and_scroll_info(mWrState);
 }
 
 void
 DisplayListBuilder::PushRect(const wr::LayoutRect& aBounds,
                              const wr::LayoutRect& aClip,
                              const wr::ColorF& aColor)
 {
@@ -984,16 +986,25 @@ DisplayListBuilder::TopmostClipId()
 {
   if (mClipIdStack.empty()) {
     return Nothing();
   }
   return Some(mClipIdStack.back());
 }
 
 Maybe<layers::FrameMetrics::ViewID>
+DisplayListBuilder::TopmostScrollId()
+{
+  if (mScrollIdStack.empty()) {
+    return Nothing();
+  }
+  return Some(mScrollIdStack.back());
+}
+
+Maybe<layers::FrameMetrics::ViewID>
 DisplayListBuilder::ParentScrollIdFor(layers::FrameMetrics::ViewID aScrollId)
 {
   auto it = mScrollParents.find(aScrollId);
   return (it == mScrollParents.end() ? Nothing() : Some(it->second));
 }
 
 } // namespace wr
 } // namespace mozilla
--- a/gfx/webrender_bindings/WebRenderAPI.h
+++ b/gfx/webrender_bindings/WebRenderAPI.h
@@ -304,16 +304,18 @@ public:
                      const float& aSpreadRadius,
                      const float& aBorderRadius,
                      const wr::BoxShadowClipMode& aClipMode);
 
   // Returns the clip id that was most recently pushed with PushClip and that
   // has not yet been popped with PopClip. Return Nothing() if the clip stack
   // is empty.
   Maybe<wr::WrClipId> TopmostClipId();
+  // Same as TopmostClipId() but for scroll layers.
+  Maybe<layers::FrameMetrics::ViewID> TopmostScrollId();
   // Returns the scroll id that was pushed just before the given scroll id. This
   // function returns Nothing() if the given scrollid has not been encountered,
   // or if it is the rootmost scroll id (and therefore has no ancestor).
   Maybe<layers::FrameMetrics::ViewID> ParentScrollIdFor(layers::FrameMetrics::ViewID aScrollId);
 
   // Try to avoid using this when possible.
   wr::WrState* Raw() { return mWrState; }
 protected: