Bug 811301. Part 1: Save and restore state of root scroll frame when reframing the root element, and treat root scroll frame state like any other frame. r=mats

This commit is contained in:
Robert O'Callahan 2012-11-14 22:39:58 -08:00
parent eef569aa0e
commit d38f22466b
6 changed files with 26 additions and 10 deletions

View File

@ -6925,6 +6925,14 @@ nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aContainer,
#endif
}
if (aFrameState) {
// Restore frame state for the root scroll frame if there is one
nsIFrame* rootScrollFrame = mPresShell->GetRootScrollFrame();
if (rootScrollFrame) {
RestoreFrameStateFor(rootScrollFrame, aFrameState);
}
}
#ifdef ACCESSIBILITY
nsAccessibilityService* accService = nsIPresShell::AccService();
if (accService) {

View File

@ -2443,8 +2443,6 @@ PresShell::RestoreRootScrollPosition()
if (scrollFrame) {
nsIScrollableFrame* scrollableFrame = do_QueryFrame(scrollFrame);
if (scrollableFrame) {
mFrameConstructor->RestoreFrameStateFor(scrollFrame, historyState,
nsIStatefulFrame::eDocumentScrollState);
scrollableFrame->ScrollToRestoredPosition();
}
}
@ -3587,8 +3585,6 @@ PresShell::CaptureHistoryState(nsILayoutHistoryState** aState, bool aLeavingPage
if (aLeavingPage) {
nsIFrame* scrollFrame = GetRootScrollFrame();
if (scrollFrame) {
mFrameConstructor->CaptureFrameStateFor(scrollFrame, historyState,
nsIStatefulFrame::eDocumentScrollState);
}
}

View File

@ -3864,12 +3864,6 @@ nsGfxScrollFrameInner::GetCoordAttribute(nsIFrame* aBox, nsIAtom* aAtom,
nsPresState*
nsGfxScrollFrameInner::SaveState(nsIStatefulFrame::SpecialStateID aStateID)
{
// Don't save "normal" state for the root scrollframe; that's
// handled via the eDocumentScrollState state id
if (mIsRoot && aStateID == nsIStatefulFrame::eNoID) {
return nullptr;
}
nsIScrollbarMediator* mediator = do_QueryFrame(GetScrolledFrame());
if (mediator) {
// child handles its own scroll state, so don't bother saving state here

View File

@ -0,0 +1,6 @@
<!DOCTYPE HTML>
<html>
<body style="overflow-y:hidden">
<div style="height:10000px; width:100px; background:yellow; position:relative; top:-200px"></div>
</body>
</html>

View File

@ -0,0 +1,11 @@
<!DOCTYPE HTML>
<html>
<body>
<p>Hello
<div style="height:10000px; width:100px; background:yellow"></div>
<script>
window.scrollTo(0,200);
document.documentElement.setAttribute("style", "overflow-y:hidden");
</script>
</body>
</html>

View File

@ -1727,3 +1727,4 @@ fuzzy(40,800) == 797797-1.html 797797-1-ref.html # 'opacity:N' and rgba(,,,N) te
fuzzy(40,800) == 797797-2.html 797797-2-ref.html # 'opacity:N' and rgba(,,,N) text don't match precisely
== 801994-1.html 801994-1-ref.html
== 804323-1.html 804323-1-ref.html
== 811301-1.html 811301-1-ref.html