Bug 1780701 - Collect mSnapTargets even if ComputeScrollSnapInfo gets called for ScrollMetadata. r=botond

mSnapTargets stores the ids for all candidate snap taget elements in this scroll
container. Before this change, we collect the ids when we snap or re-snap on the
main-thread. It's used to check whether the last snap target ids comming from
APZ are not stale or not. So if we haven't done any snapping or re-snapping on
the main-thread, we mis-consider all incoming last snap target ids are stale,
thus we fail to re-snap to the position where we snapped on APZ. This issue
had been wall-papered, will be revealed by the next change in this commit series
(we had been unnecessary snappings and re-snappings).

Differential Revision: https://phabricator.services.mozilla.com/D152617
This commit is contained in:
Hiroyuki Ikezoe 2022-07-26 06:59:14 +00:00
Родитель 0bb31403fd
Коммит 287d08b58f
2 изменённых файлов: 12 добавлений и 13 удалений

Просмотреть файл

@ -7936,8 +7936,7 @@ nsMargin ScrollFrameHelper::GetScrollPadding() const {
GetScrollPortRect().Size());
}
layers::ScrollSnapInfo ScrollFrameHelper::ComputeScrollSnapInfo(
SnapTargetSet* aSnapTargets) {
layers::ScrollSnapInfo ScrollFrameHelper::ComputeScrollSnapInfo() {
ScrollSnapInfo result;
nsIFrame* scrollSnapFrame = GetFrameForStyle();
@ -7961,7 +7960,7 @@ layers::ScrollSnapInfo ScrollFrameHelper::ComputeScrollSnapInfo(
result.mSnapportSize = snapport.Size();
CollectScrollPositionsForSnap(mScrolledFrame, mScrolledFrame,
GetScrolledRect(), scrollPadding, writingMode,
result, aSnapTargets);
result, &mSnapTargets);
return result;
}
@ -7974,14 +7973,14 @@ Maybe<SnapTarget> ScrollFrameHelper::GetSnapPointForDestination(
ScrollUnit aUnit, ScrollSnapFlags aFlags, const nsPoint& aStartPos,
const nsPoint& aDestination) {
// We can release the strong references for the previous snap target
// elements here since calling this ComputeScrollSnapInfo with
// |aSnapTargets| means we are going to evaluate new snap points, thus
// there's no chance to generating nsIContent instances in between this
// function call and the function call for the (re-)evaluation.
// elements here since calling this ComputeScrollSnapInfo means we are going
// to evaluate new snap points, thus there's no chance to generating
// nsIContent instances in between this function call and the function call
// for the (re-)evaluation.
mSnapTargets.Clear();
return ScrollSnapUtils::GetSnapPointForDestination(
ComputeScrollSnapInfo(&mSnapTargets), aUnit, aFlags,
GetLayoutScrollRange(), aStartPos, aDestination);
ComputeScrollSnapInfo(), aUnit, aFlags, GetLayoutScrollRange(), aStartPos,
aDestination);
}
Maybe<SnapTarget> ScrollFrameHelper::GetSnapPointForResnap() {
@ -7991,8 +7990,8 @@ Maybe<SnapTarget> ScrollFrameHelper::GetSnapPointForResnap() {
nsIContent* focusedContent =
mOuter->GetContent()->GetComposedDoc()->GetUnretargetedFocusedContent();
return ScrollSnapUtils::GetSnapPointForResnap(
ComputeScrollSnapInfo(&mSnapTargets), GetLayoutScrollRange(),
GetScrollPosition(), mLastSnapTargetIds, focusedContent);
ComputeScrollSnapInfo(), GetLayoutScrollRange(), GetScrollPosition(),
mLastSnapTargetIds, focusedContent);
}
bool ScrollFrameHelper::NeedsResnap() {

Просмотреть файл

@ -412,8 +412,8 @@ class ScrollFrameHelper : public nsIReflowCallback {
nsIFrame* GetFrameForStyle() const;
// Compute all scroll snap related information and store eash snap target
// element in |aSnapTargets| if it's provided.
ScrollSnapInfo ComputeScrollSnapInfo(SnapTargetSet* aSnapTargets = nullptr);
// element in |mSnapTargets|.
ScrollSnapInfo ComputeScrollSnapInfo();
bool NeedsScrollSnap() const;