From cc1fa1abde50e2a1004428cd6c9791dbb0a5e49f Mon Sep 17 00:00:00 2001 From: Mats Palmgren Date: Fri, 15 Mar 2013 23:32:35 +0100 Subject: [PATCH] Bug 851485 - Restoring scroll position from history should only suppress one scroll-to-anchor. r=bzbarsky --- layout/base/nsPresShell.cpp | 1 + layout/generic/nsGfxScrollFrame.h | 6 ++++++ layout/generic/nsIScrollableFrame.h | 6 ++++++ 3 files changed, 13 insertions(+) diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 5540caf3290..902bd0ce87a 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -2890,6 +2890,7 @@ PresShell::GoToAnchor(const nsAString& aAnchorName, bool aScroll) if (rootScroll && rootScroll->DidHistoryRestore()) { // Scroll position restored from history trumps scrolling to anchor. aScroll = false; + rootScroll->ClearDidHistoryRestore(); } if (content) { diff --git a/layout/generic/nsGfxScrollFrame.h b/layout/generic/nsGfxScrollFrame.h index 174812652fb..283ad3033bb 100644 --- a/layout/generic/nsGfxScrollFrame.h +++ b/layout/generic/nsGfxScrollFrame.h @@ -537,6 +537,9 @@ public: virtual bool DidHistoryRestore() MOZ_OVERRIDE { return mInner.mDidHistoryRestore; } + virtual void ClearDidHistoryRestore() MOZ_OVERRIDE { + mInner.mDidHistoryRestore = false; + } // nsIStatefulFrame NS_IMETHOD SaveState(nsPresState** aState) MOZ_OVERRIDE { @@ -790,6 +793,9 @@ public: virtual bool DidHistoryRestore() MOZ_OVERRIDE { return mInner.mDidHistoryRestore; } + virtual void ClearDidHistoryRestore() MOZ_OVERRIDE { + mInner.mDidHistoryRestore = false; + } // nsIStatefulFrame NS_IMETHOD SaveState(nsPresState** aState) MOZ_OVERRIDE { diff --git a/layout/generic/nsIScrollableFrame.h b/layout/generic/nsIScrollableFrame.h index a6caced5be9..28dd88c3e00 100644 --- a/layout/generic/nsIScrollableFrame.h +++ b/layout/generic/nsIScrollableFrame.h @@ -237,6 +237,12 @@ public: * Was the current presentation state for this frame restored from history? */ virtual bool DidHistoryRestore() = 0; + /** + * Clear the flag so that DidHistoryRestore() returns false until the next + * RestoreState call. + * @see nsIStatefulFrame::RestoreState + */ + virtual void ClearDidHistoryRestore() = 0; }; #endif