From 88e8d89f570a66163c2f3bbe23c591c04928882d Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Mon, 29 Mar 2010 14:46:59 +1300 Subject: [PATCH] Bug 551463. Don't clamp scroll positions during reflow, do it during a post-reflow callback so that temporary frame size changes don't clamp when they shouldn't. r=mats --- layout/generic/nsGfxScrollFrame.cpp | 13 +++++---- layout/reftests/bugs/551463-1-ref.html | 34 ++++++++++++++++++++++ layout/reftests/bugs/551463-1.html | 39 ++++++++++++++++++++++++++ layout/reftests/bugs/reftest.list | 1 + 4 files changed, 82 insertions(+), 5 deletions(-) create mode 100644 layout/reftests/bugs/551463-1-ref.html create mode 100644 layout/reftests/bugs/551463-1.html diff --git a/layout/generic/nsGfxScrollFrame.cpp b/layout/generic/nsGfxScrollFrame.cpp index 9a2d53d078c..69e1c9f77a5 100644 --- a/layout/generic/nsGfxScrollFrame.cpp +++ b/layout/generic/nsGfxScrollFrame.cpp @@ -800,8 +800,7 @@ nsHTMLScrollFrame::Reflow(nsPresContext* aPresContext, // oldScrollPosition is a multiple of device pixels. This could have been // thrown out by a zoom change. nsIntPoint ptDevPx; - nsPoint oldScrollPosition = - mInner.ClampAndRestrictToDevPixels(mInner.GetScrollPosition(), &ptDevPx); + nsPoint oldScrollPosition = mInner.GetScrollPosition(); state.mComputedBorder = aReflowState.mComputedBorderPadding - aReflowState.mComputedPadding; @@ -809,7 +808,10 @@ nsHTMLScrollFrame::Reflow(nsPresContext* aPresContext, nsresult rv = ReflowContents(&state, aDesiredSize); if (NS_FAILED(rv)) return rv; - + + // Restore the old scroll position, for now, even if that's not valid anymore + // because we changed size. We'll fix it up in a post-reflow callback, because + // our current size may only be temporary (e.g. we're compute XUL desired sizes). PlaceScrollArea(state, oldScrollPosition); if (!mInner.mPostedReflowCallback) { // Make sure we'll try scrolling to restored position @@ -1345,13 +1347,11 @@ nsGfxScrollFrameInner::AsyncScrollCallback(nsITimer *aTimer, void* anInstance) } self->ScrollToImpl(destination); - // 'self' may be a dangling pointer here since ScrollToImpl may have destroyed it } else { delete self->mAsyncScroll; self->mAsyncScroll = nsnull; self->ScrollToImpl(self->mDestination); - // 'self' may be a dangling pointer here since ScrollToImpl may have destroyed it } } @@ -2914,6 +2914,9 @@ nsGfxScrollFrameInner::ReflowFinished() ScrollToRestoredPosition(); + // Clamp scroll position + ScrollToImpl(GetScrollPosition()); + if (NS_SUBTREE_DIRTY(mOuter) || !mUpdateScrollbarAttributes) return PR_FALSE; diff --git a/layout/reftests/bugs/551463-1-ref.html b/layout/reftests/bugs/551463-1-ref.html new file mode 100644 index 00000000000..f67e6b784bf --- /dev/null +++ b/layout/reftests/bugs/551463-1-ref.html @@ -0,0 +1,34 @@ + + + +
+
+ Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. + Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. + Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. + Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. + Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. + Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. + Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. + Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. + Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. + Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. + Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. + Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. + Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. + Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. + Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. + Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. + Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. + Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. + Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. + Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. + Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. +
+
+ + + diff --git a/layout/reftests/bugs/551463-1.html b/layout/reftests/bugs/551463-1.html new file mode 100644 index 00000000000..326f796e1e0 --- /dev/null +++ b/layout/reftests/bugs/551463-1.html @@ -0,0 +1,39 @@ + + + +
+
+ Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. + Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. + Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. + Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. + Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. + Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. + Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. + Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. + Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. + Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. + Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. + Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. + Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. + Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. + Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. + Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. + Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. + Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. + Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. + Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. + Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. Hello Kitty. +
+
+ + + diff --git a/layout/reftests/bugs/reftest.list b/layout/reftests/bugs/reftest.list index 3e5d733a37e..15ecf7395c5 100644 --- a/layout/reftests/bugs/reftest.list +++ b/layout/reftests/bugs/reftest.list @@ -1416,3 +1416,4 @@ random-if(!haveTestPlugin) == 541406-1.html 541406-1-ref.html random-if(!haveTestPlugin) == 546071-1.html 546071-1-ref.html == 549184-1.html 549184-1-ref.html == 550716-1.html 550716-1-ref.html +== 551463-1.html 551463-1-ref.html