From 5c3bc95bd27c629e8515ad8fbc4ff82b38c472b8 Mon Sep 17 00:00:00 2001 From: "bzbarsky@mit.edu" Date: Thu, 8 Nov 2007 21:58:47 -0800 Subject: [PATCH] Handle GetPositionAndSize flushing reflow. Bug 399410, r+sr=roc, a=beltzner --- layout/generic/nsFrameFrame.cpp | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/layout/generic/nsFrameFrame.cpp b/layout/generic/nsFrameFrame.cpp index aec39931fc45..955dcbd81881 100644 --- a/layout/generic/nsFrameFrame.cpp +++ b/layout/generic/nsFrameFrame.cpp @@ -437,15 +437,6 @@ nsSubDocumentFrame::Reflow(nsPresContext* aPresContext, PRBool nsSubDocumentFrame::ReflowFinished() { - mPostedReflowCallback = PR_FALSE; - - nsSize innerSize(GetSize()); - if (IsInline()) { - nsMargin usedBorderPadding = GetUsedBorderAndPadding(); - innerSize.width -= usedBorderPadding.LeftRight(); - innerSize.height -= usedBorderPadding.TopBottom(); - } - nsCOMPtr docShell; GetDocShell(getter_AddRefs(docShell)); @@ -456,11 +447,33 @@ nsSubDocumentFrame::ReflowFinished() PRInt32 x = 0; PRInt32 y = 0; + nsWeakFrame weakFrame(this); + nsPresContext* presContext = PresContext(); baseWindow->GetPositionAndSize(&x, &y, nsnull, nsnull); + + if (!weakFrame.IsAlive()) { + // GetPositionAndSize() killed us + return; + } + + // GetPositionAndSize might have resized us. So now is the time to + // get our size. + mPostedReflowCallback = PR_FALSE; + + nsSize innerSize(GetSize()); + if (IsInline()) { + nsMargin usedBorderPadding = GetUsedBorderAndPadding(); + innerSize.width -= usedBorderPadding.LeftRight(); + innerSize.height -= usedBorderPadding.TopBottom(); + } + PRInt32 cx = presContext->AppUnitsToDevPixels(innerSize.width); PRInt32 cy = presContext->AppUnitsToDevPixels(innerSize.height); baseWindow->SetPositionAndSize(x, y, cx, cy, PR_FALSE); + } else { + // Make sure that we can post a reflow callback in the future. + mPostedReflowCallback = PR_FALSE; } return PR_FALSE;