зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1566783 - Make sure to clear mLastAnchorScrolledTo after calling PresShell::ScrollToAnchor(). r=dholbert
Seems we can leave this node alive for too long if the user scrolls between domcontentloaded (where GoToAnchor is called) and onload (where ScrollToAnchor() is called). Though it seems we can leave it for too long if we don't end up calling ScrollToAnchor(), the documentation of the method claims that it's cleared unconditionally. Differential Revision: https://phabricator.services.mozilla.com/D38398 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
937b1f9834
Коммит
dcd7223f09
|
@ -3184,22 +3184,20 @@ nsresult PresShell::GoToAnchor(const nsAString& aAnchorName, bool aScroll,
|
|||
}
|
||||
|
||||
nsresult PresShell::ScrollToAnchor() {
|
||||
if (!mLastAnchorScrolledTo) {
|
||||
nsCOMPtr<nsIContent> lastAnchor = mLastAnchorScrolledTo.forget();
|
||||
if (!lastAnchor) {
|
||||
return NS_OK;
|
||||
}
|
||||
NS_ASSERTION(mDidInitialize, "should have done initial reflow by now");
|
||||
|
||||
NS_ASSERTION(mDidInitialize, "should have done initial reflow by now");
|
||||
nsIScrollableFrame* rootScroll = GetRootScrollFrameAsScrollable();
|
||||
if (!rootScroll ||
|
||||
mLastAnchorScrollPositionY != rootScroll->GetScrollPosition().y) {
|
||||
return NS_OK;
|
||||
}
|
||||
nsCOMPtr<nsIContent> lastAnchorScrollTo = mLastAnchorScrolledTo;
|
||||
nsresult rv = ScrollContentIntoView(
|
||||
lastAnchorScrollTo, ScrollAxis(kScrollToTop, WhenToScroll::Always),
|
||||
return ScrollContentIntoView(lastAnchor,
|
||||
ScrollAxis(kScrollToTop, WhenToScroll::Always),
|
||||
ScrollAxis(), ScrollFlags::AnchorScrollFlags);
|
||||
mLastAnchorScrolledTo = nullptr;
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Загрузка…
Ссылка в новой задаче