Bug 1444904 - Get the root scroll frame id from WebRender r=kats

Instead of hard-cording the root scroll frame id, get the value from
WebRender. This was previously hard-coded to 0, so when WebRender
switched to using 1 for the root scroll frame id, the positioning of
sticky frames were broken in subtle ways. This happened because they
were being parented to a root reference frame (which now uses the 0 id)
instead of the root scroll frame.

MozReview-Commit-ID: 66ArgKHGpWE

--HG--
extra : rebase_source : ff6937bf7fc8d4472eb074d0466c8dcd6fba54a8
This commit is contained in:
Martin Robinson 2018-03-26 18:13:07 +02:00
parent 08516a61ad
commit f55533615b
9 changed files with 80 additions and 4 deletions

View File

@ -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()) {

View File

@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<style>
#box {
position: absolute;
top: 80px;
width: 20px;
height: 20px;
background: green;
}
</style>
</head>
<body style="height: 10000px;">
<div id="box"></div>
</body>
</html>

View File

@ -0,0 +1,36 @@
<!DOCTYPE html>
<html>
<head>
<style>
#container {
float: left;
position: sticky;
top: 0;
margin-top: -20px;
z-index: 100;
}
#target {
margin-top: 80px;
width: 20px;
height: 20px;
background: green;
}
#necessary-fixed-box {
position: fixed;
top: 0;
width: 20px;
height: 20px;
}
</style>
</head>
<body style="height: 10000px;">
<div id="container">
<div id="target"></div>
<div id="necessary-fixed-box"></div>
</div>
</body>
</html>

View File

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

View File

@ -941,7 +941,7 @@ Maybe<wr::WrScrollId>
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<wr::WrScrollId>();
}
}
return wr::WrScrollId { 0 };
return wr::WrScrollId::RootScrollNode();
}
bool

View File

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

View File

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

View File

@ -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."),
}
}

View File

@ -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,