Bug 1530253 - Trigger re-snap on reflows and in RecomputePosition. r=botond,emilio
The basic machinery to trigger re-snap is same as what scroll anchoring does, queueing a triggering request and flush the queued requests after reflows finished. Depends on D148862 Differential Revision: https://phabricator.services.mozilla.com/D148863
This commit is contained in:
@@ -201,6 +201,7 @@
|
||||
#include "nsIDocShellTreeOwner.h"
|
||||
#include "nsClassHashtable.h"
|
||||
#include "nsHashKeys.h"
|
||||
#include "ScrollSnap.h"
|
||||
#include "VisualViewport.h"
|
||||
#include "ZoomConstraintsClient.h"
|
||||
|
||||
@@ -1363,6 +1364,7 @@ void PresShell::Destroy() {
|
||||
mFramesToDirty.Clear();
|
||||
mPendingScrollAnchorSelection.Clear();
|
||||
mPendingScrollAnchorAdjustment.Clear();
|
||||
mPendingScrollResnap.Clear();
|
||||
|
||||
if (mViewManager) {
|
||||
// Clear the view manager's weak pointer back to |this| in case it
|
||||
@@ -2248,6 +2250,7 @@ void PresShell::NotifyDestroyingFrame(nsIFrame* aFrame) {
|
||||
if (scrollableFrame) {
|
||||
mPendingScrollAnchorSelection.Remove(scrollableFrame);
|
||||
mPendingScrollAnchorAdjustment.Remove(scrollableFrame);
|
||||
mPendingScrollResnap.Remove(scrollableFrame);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2687,6 +2690,17 @@ void PresShell::FlushPendingScrollAnchorAdjustments() {
|
||||
mPendingScrollAnchorAdjustment.Clear();
|
||||
}
|
||||
|
||||
void PresShell::PostPendingScrollResnap(nsIScrollableFrame* aScrollableFrame) {
|
||||
mPendingScrollResnap.Insert(aScrollableFrame);
|
||||
}
|
||||
|
||||
void PresShell::FlushPendingScrollResnap() {
|
||||
for (nsIScrollableFrame* scrollableFrame : mPendingScrollResnap) {
|
||||
scrollableFrame->TryResnap();
|
||||
}
|
||||
mPendingScrollResnap.Clear();
|
||||
}
|
||||
|
||||
void PresShell::FrameNeedsReflow(nsIFrame* aFrame,
|
||||
IntrinsicDirty aIntrinsicDirty,
|
||||
nsFrameState aBitToAdd,
|
||||
@@ -4367,6 +4381,8 @@ void PresShell::DoFlushPendingNotifications(mozilla::ChangesToFlush aFlush) {
|
||||
}
|
||||
}
|
||||
|
||||
FlushPendingScrollResnap();
|
||||
|
||||
if (flushType >= FlushType::Layout) {
|
||||
if (!mIsDestroying) {
|
||||
viewManager->UpdateWidgetGeometry();
|
||||
|
||||
Reference in New Issue
Block a user