From 9507877a936902cee41879b1c8094d8fac42f172 Mon Sep 17 00:00:00 2001 From: "dbaron%dbaron.org" Date: Mon, 16 Jul 2007 05:55:04 +0000 Subject: [PATCH] Don't drop empty rectangles on the floor. b=388019 r=sharparrow1@yahoo.com sr=roc@ocallahan.org git-svn-id: svn://10.0.0.236/trunk@230019 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/base/nsPresShell.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/mozilla/layout/base/nsPresShell.cpp b/mozilla/layout/base/nsPresShell.cpp index 8ea3e1f3115..1645e0360f2 100644 --- a/mozilla/layout/base/nsPresShell.cpp +++ b/mozilla/layout/base/nsPresShell.cpp @@ -3614,6 +3614,7 @@ PresShell::GoToAnchor(const nsAString& aAnchorName, PRBool aScroll) * @param aFrame [in] Frame whose bounds should be unioned * @param aVPercent [in] same as for ScrollContentIntoView * @param aRect [inout] rect into which its bounds should be unioned + * @param aHaveRect [inout] whether aRect contains data yet * @param aClosestScrolledView [inout] the view to which aRect is relative. * If null, should be filled in appropriately. If non-null, the function * will no-op if the closest scrolling view doesn't match. @@ -3622,6 +3623,7 @@ static void UnionRectForClosestScrolledView(nsIFrame* aFrame, PRIntn aVPercent, nsRect& aRect, + PRBool& aHaveRect, nsIView*& aClosestScrolledView) { nsRect frameBounds = aFrame->GetRect(); @@ -3697,7 +3699,19 @@ UnionRectForClosestScrolledView(nsIFrame* aFrame, aClosestScrolledView = closestView; if (aClosestScrolledView == closestView) { - aRect.UnionRect(aRect, frameBounds); + if (aHaveRect) { + // We can't use nsRect::UnionRect since it drops empty rects on + // the floor, and we need to include them. (Thus we need + // aHaveRect to know when to drop the initial value on the floor.) + nscoord x = PR_MIN(aRect.x, frameBounds.x), + y = PR_MIN(aRect.y, frameBounds.y), + xmost = PR_MAX(aRect.XMost(), frameBounds.XMost()), + ymost = PR_MAX(aRect.YMost(), frameBounds.YMost()); + aRect.SetRect(x, y, xmost - x, ymost - y); + } else { + aHaveRect = PR_TRUE; + aRect = frameBounds; + } } } @@ -3849,8 +3863,10 @@ PresShell::ScrollContentIntoView(nsIContent* aContent, nsIView *closestView = nsnull; nsRect frameBounds; + PRBool haveRect = PR_FALSE; do { - UnionRectForClosestScrolledView(frame, aVPercent, frameBounds, closestView); + UnionRectForClosestScrolledView(frame, aVPercent, frameBounds, haveRect, + closestView); } while ((frame = frame->GetNextContinuation())); // Walk up the view hierarchy. Make sure to add the view's position