diff --git a/gfx/layers/wr/ScrollingLayersHelper.cpp b/gfx/layers/wr/ScrollingLayersHelper.cpp index 6b75c34104b8..95ede56c48d5 100644 --- a/gfx/layers/wr/ScrollingLayersHelper.cpp +++ b/gfx/layers/wr/ScrollingLayersHelper.cpp @@ -124,7 +124,7 @@ ScrollingLayersHelper::BeginItem(nsDisplayItem* aItem, // nested ScrollingLayersHelper may rely on things like TopmostScrollId and // TopmostClipId, so now we need to push at most two things onto the stack. - wr::WrScrollId rootId = wr::WrScrollId { 0 }; + wr::WrScrollId rootId = wr::WrScrollId::RootScrollNode(); wr::WrScrollId leafmostId = ids.first.valueOr(rootId); FrameMetrics::ViewID viewId = aItem->GetActiveScrolledRoot() @@ -301,7 +301,7 @@ ScrollingLayersHelper::RecurseAndDefineClip(nsDisplayItem* aItem, MOZ_ASSERT(!ancestorIds.second); FrameMetrics::ViewID viewId = aChain->mASR ? aChain->mASR->GetViewId() : FrameMetrics::NULL_SCROLL_ID; - wr::WrScrollId rootId = wr::WrScrollId { 0 }; + wr::WrScrollId rootId = wr::WrScrollId::RootScrollNode(); auto scrollId = mBuilder->GetScrollIdForDefinedScrollLayer(viewId).valueOr(rootId); if (mBuilder->TopmostScrollId() == scrollId) { if (mBuilder->TopmostIsClip()) { diff --git a/gfx/tests/reftest/1444904-ref.html b/gfx/tests/reftest/1444904-ref.html new file mode 100644 index 000000000000..6a3e5673203a --- /dev/null +++ b/gfx/tests/reftest/1444904-ref.html @@ -0,0 +1,19 @@ + + + + + + + +
+ + + diff --git a/gfx/tests/reftest/1444904.html b/gfx/tests/reftest/1444904.html new file mode 100644 index 000000000000..c9fe387e740b --- /dev/null +++ b/gfx/tests/reftest/1444904.html @@ -0,0 +1,36 @@ + + + + + + + +
+
+
+
+ + diff --git a/gfx/tests/reftest/reftest.list b/gfx/tests/reftest/reftest.list index 9f0e5eb0c19c..d8420ef266d0 100644 --- a/gfx/tests/reftest/reftest.list +++ b/gfx/tests/reftest/reftest.list @@ -11,3 +11,4 @@ fuzzy(100,30) == 1149923.html 1149923-ref.html # use fuzzy due to few distorted == 1424673.html 1424673-ref.html == 1429411.html 1429411-ref.html == 1435143.html 1435143-ref.html +== 1444904.html 1444904-ref.html diff --git a/gfx/webrender_bindings/WebRenderAPI.cpp b/gfx/webrender_bindings/WebRenderAPI.cpp index 70ae71754377..38bdc11c0639 100644 --- a/gfx/webrender_bindings/WebRenderAPI.cpp +++ b/gfx/webrender_bindings/WebRenderAPI.cpp @@ -941,7 +941,7 @@ Maybe DisplayListBuilder::GetScrollIdForDefinedScrollLayer(layers::FrameMetrics::ViewID aViewId) const { if (aViewId == layers::FrameMetrics::NULL_SCROLL_ID) { - return Some(wr::WrScrollId { 0 }); + return Some(wr::WrScrollId::RootScrollNode()); } auto it = mScrollIds.find(aViewId); @@ -1320,7 +1320,7 @@ DisplayListBuilder::TopmostScrollId() return it->as(); } } - return wr::WrScrollId { 0 }; + return wr::WrScrollId::RootScrollNode(); } bool diff --git a/gfx/webrender_bindings/WebRenderTypes.cpp b/gfx/webrender_bindings/WebRenderTypes.cpp index d7d129bcdbf4..3a41e7b71d8b 100644 --- a/gfx/webrender_bindings/WebRenderTypes.cpp +++ b/gfx/webrender_bindings/WebRenderTypes.cpp @@ -22,5 +22,9 @@ Assign_WrVecU8(wr::WrVecU8& aVec, mozilla::ipc::ByteBuf&& aOther) aOther.mCapacity = 0; } +WrScrollId WrScrollId::RootScrollNode() { + return WrScrollId { wr_root_scroll_node_id() }; +} + } // namespace wr } // namespace mozilla diff --git a/gfx/webrender_bindings/WebRenderTypes.h b/gfx/webrender_bindings/WebRenderTypes.h index 11bd47da4e7e..542184dff59b 100644 --- a/gfx/webrender_bindings/WebRenderTypes.h +++ b/gfx/webrender_bindings/WebRenderTypes.h @@ -783,6 +783,8 @@ struct WrScrollId { bool operator!=(const WrScrollId& other) const { return id != other.id; } + + static WrScrollId RootScrollNode(); }; // Corresponds to a clip id for a position:sticky clip in webrender. Similar diff --git a/gfx/webrender_bindings/src/bindings.rs b/gfx/webrender_bindings/src/bindings.rs index 609e3ec83077..a8cdd3238205 100644 --- a/gfx/webrender_bindings/src/bindings.rs +++ b/gfx/webrender_bindings/src/bindings.rs @@ -2243,3 +2243,13 @@ pub extern "C" fn wr_init_external_log_handler(log_filter: WrLogLevelFilter) { #[no_mangle] pub extern "C" fn wr_shutdown_external_log_handler() { } + +#[no_mangle] +pub extern "C" fn wr_root_scroll_node_id() -> usize { + // The PipelineId doesn't matter here, since we just want the numeric part of the id + // produced for any given root reference frame. + match ClipId::root_scroll_node(PipelineId(0, 0)) { + ClipId::Clip(id, _) => id, + _ => unreachable!("Got a non Clip ClipId for root reference frame."), + } +} diff --git a/gfx/webrender_bindings/webrender_ffi_generated.h b/gfx/webrender_bindings/webrender_ffi_generated.h index 0e79013aa881..4e2a782e8352 100644 --- a/gfx/webrender_bindings/webrender_ffi_generated.h +++ b/gfx/webrender_bindings/webrender_ffi_generated.h @@ -1528,6 +1528,10 @@ void wr_resource_updates_update_image(ResourceUpdates *aResources, WrVecU8 *aBytes) WR_FUNC; +WR_INLINE +uintptr_t wr_root_scroll_node_id() +WR_FUNC; + WR_INLINE void wr_set_item_tag(WrState *aState, uint64_t aScrollId,