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
--- 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: