From f17ce63d0746667e68c247cee0b09a0b4be91d1f Mon Sep 17 00:00:00 2001 From: "bzbarsky@mit.edu" Date: Wed, 19 Sep 2007 20:41:29 -0700 Subject: [PATCH] Backing out bug 396587 to hopefully fix orange. --- docshell/base/nsDocShell.cpp | 6 +-- layout/base/nsPresShell.cpp | 72 +++++++++++++-------------------- layout/generic/nsFrameFrame.cpp | 72 +++++++++------------------------ 3 files changed, 49 insertions(+), 101 deletions(-) diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index aa51d969387f..8dd14bc8092e 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -3624,11 +3624,9 @@ nsDocShell::SetPositionAndSize(PRInt32 x, PRInt32 y, PRInt32 cx, mBounds.width = cx; mBounds.height = cy; - // Hold strong ref, since SetBounds can make us null out mContentViewer - nsCOMPtr viewer = mContentViewer; - if (viewer) { + if (mContentViewer) { //XXX Border figured in here or is that handled elsewhere? - NS_ENSURE_SUCCESS(viewer->SetBounds(mBounds), NS_ERROR_FAILURE); + NS_ENSURE_SUCCESS(mContentViewer->SetBounds(mBounds), NS_ERROR_FAILURE); } return NS_OK; diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index f27d06a8bc4a..e8b37423f61d 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -2480,40 +2480,29 @@ PresShell::ResizeReflow(nscoord aWidth, nscoord aHeight) return NS_OK; NS_ASSERTION(mViewManager, "Must have view manager"); - nsCOMPtr viewManager = mViewManager; - viewManager->BeginUpdateViewBatch(); + mViewManager->BeginUpdateViewBatch(); - // Take this ref after viewManager so it'll make sure to go away first - nsCOMPtr kungFuDeathGrip(this); + // XXX Do a full invalidate at the beginning so that invalidates along + // the way don't have region accumulation issues? - // Make sure style is up to date - mFrameConstructor->ProcessPendingRestyles(); - if (!mIsDestroying) { - // XXX Do a full invalidate at the beginning so that invalidates along - // the way don't have region accumulation issues? + WillCauseReflow(); + WillDoReflow(); - WillCauseReflow(); - WillDoReflow(); + { + // Kick off a top-down reflow + AUTO_LAYOUT_PHASE_ENTRY_POINT(GetPresContext(), Reflow); + mIsReflowing = PR_TRUE; - { - // Kick off a top-down reflow - AUTO_LAYOUT_PHASE_ENTRY_POINT(GetPresContext(), Reflow); - mIsReflowing = PR_TRUE; - - mDirtyRoots.RemoveElement(rootFrame); - DoReflow(rootFrame); - mIsReflowing = PR_FALSE; - } - - DidCauseReflow(); - DidDoReflow(); + mDirtyRoots.RemoveElement(rootFrame); + DoReflow(rootFrame); + mIsReflowing = PR_FALSE; } - viewManager->EndUpdateViewBatch(NS_VMREFRESH_NO_SYNC); + DidCauseReflow(); + DidDoReflow(); + mViewManager->EndUpdateViewBatch(NS_VMREFRESH_NO_SYNC); - if (!mIsDestroying) { - CreateResizeEventTimer(); - } + CreateResizeEventTimer(); return NS_OK; //XXX this needs to be real. MMP } @@ -6234,31 +6223,26 @@ PresShell::ProcessReflowCommands(PRBool aInterruptible) DidDoReflow(); - // DidDoReflow might have killed us - if (!mIsDestroying) { #ifdef DEBUG - if (VERIFY_REFLOW_DUMP_COMMANDS & gVerifyReflowFlags) { - printf("\nPresShell::ProcessReflowCommands() finished: this=%p\n", - (void*)this); - } - DoVerifyReflow(); + if (VERIFY_REFLOW_DUMP_COMMANDS & gVerifyReflowFlags) { + printf("\nPresShell::ProcessReflowCommands() finished: this=%p\n", (void*)this); + } + DoVerifyReflow(); #endif - // If any new reflow commands were enqueued during the reflow, schedule - // another reflow event to process them. Note that we want to do this - // after DidDoReflow(), since that method can change whether there are - // dirty roots around by flushing, and there's no point in posting a - // reflow event just to have the flush revoke it. - if (mDirtyRoots.Count()) - PostReflowEvent(); - } + // If any new reflow commands were enqueued during the reflow, schedule + // another reflow event to process them. Note that we want to do this + // after DidDoReflow(), since that method can change whether there are + // dirty roots around by flushing, and there's no point in posting a reflow + // event just to have the flush revoke it. + if (mDirtyRoots.Count()) + PostReflowEvent(); } MOZ_TIMER_DEBUGLOG(("Stop: Reflow: PresShell::ProcessReflowCommands(), this=%p\n", this)); MOZ_TIMER_STOP(mReflowWatch); - if (!mIsDestroying && mShouldUnsuppressPainting && - mDirtyRoots.Count() == 0) { + if (mShouldUnsuppressPainting && mDirtyRoots.Count() == 0) { // We only unlock if we're out of reflows. It's pointless // to unlock if reflows are still pending, since reflows // are just going to thrash the frames around some more. By diff --git a/layout/generic/nsFrameFrame.cpp b/layout/generic/nsFrameFrame.cpp index c6afff2a0f2d..a654fb0f0226 100644 --- a/layout/generic/nsFrameFrame.cpp +++ b/layout/generic/nsFrameFrame.cpp @@ -89,7 +89,6 @@ #include "nsIDOMNSHTMLDocument.h" #include "nsDisplayList.h" #include "nsUnicharUtils.h" -#include "nsIReflowCallback.h" // For Accessibility #ifdef ACCESSIBILITY @@ -103,8 +102,7 @@ static NS_DEFINE_CID(kCChildCID, NS_CHILD_CID); * nsSubDocumentFrame *****************************************************************************/ class nsSubDocumentFrame : public nsLeafFrame, - public nsIFrameFrame, - public nsIReflowCallback + public nsIFrameFrame { public: nsSubDocumentFrame(nsStyleContext* aContext); @@ -161,9 +159,6 @@ public: NS_IMETHOD VerifyTree() const; - // nsIReflowCallback - virtual PRBool ReflowFinished(); - protected: nsSize GetMargin(); PRBool IsInline() { return mIsInline; } @@ -180,12 +175,11 @@ protected: PRPackedBool mDidCreateDoc; PRPackedBool mOwnsFrameLoader; PRPackedBool mIsInline; - PRPackedBool mPostedReflowCallback; }; nsSubDocumentFrame::nsSubDocumentFrame(nsStyleContext* aContext) : nsLeafFrame(aContext), mDidCreateDoc(PR_FALSE), mOwnsFrameLoader(PR_FALSE), - mIsInline(PR_FALSE), mPostedReflowCallback(PR_FALSE) + mIsInline(PR_FALSE) { } @@ -378,9 +372,6 @@ nsSubDocumentFrame::Reflow(nsPresContext* aPresContext, aStatus = NS_FRAME_COMPLETE; - NS_ASSERTION(aPresContext->GetPresShell()->GetPrimaryFrameFor(mContent) == this, - "Shouldn't happen"); - // "offset" is the offset of our content area from our frame's // top-left corner. nsPoint offset(0, 0); @@ -418,9 +409,22 @@ nsSubDocumentFrame::Reflow(nsPresContext* aPresContext, nsRect rect(nsPoint(0, 0), GetSize()); Invalidate(rect, PR_FALSE); - if (!aPresContext->IsPaginated() && !mPostedReflowCallback) { - PresContext()->PresShell()->PostReflowCallback(this); - mPostedReflowCallback = PR_TRUE; + if (!aPresContext->IsPaginated()) { + nsCOMPtr docShell; + GetDocShell(getter_AddRefs(docShell)); + + nsCOMPtr baseWindow(do_QueryInterface(docShell)); + + // resize the sub document + if (baseWindow) { + PRInt32 x = 0; + PRInt32 y = 0; + + baseWindow->GetPositionAndSize(&x, &y, nsnull, nsnull); + PRInt32 cx = aPresContext->AppUnitsToDevPixels(innerSize.width); + PRInt32 cy = aPresContext->AppUnitsToDevPixels(innerSize.height); + baseWindow->SetPositionAndSize(x, y, cx, cy, PR_FALSE); + } } // printf("OuterFrame::Reflow DONE %X (%d,%d)\n", this, @@ -434,39 +438,6 @@ nsSubDocumentFrame::Reflow(nsPresContext* aPresContext, return NS_OK; } -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)); - - nsCOMPtr baseWindow(do_QueryInterface(docShell)); - - // resize the sub document - if (baseWindow) { - PRInt32 x = 0; - PRInt32 y = 0; - - nsPresContext* presContext = PresContext(); - baseWindow->GetPositionAndSize(&x, &y, nsnull, nsnull); - PRInt32 cx = presContext->AppUnitsToDevPixels(innerSize.width); - PRInt32 cy = presContext->AppUnitsToDevPixels(innerSize.height); - baseWindow->SetPositionAndSize(x, y, cx, cy, PR_FALSE); - } - - return PR_FALSE; -} - - NS_IMETHODIMP nsSubDocumentFrame::VerifyTree() const { @@ -585,11 +556,6 @@ NS_NewSubDocumentFrame(nsIPresShell* aPresShell, nsStyleContext* aContext) void nsSubDocumentFrame::Destroy() { - if (mPostedReflowCallback) { - PresContext()->PresShell()->CancelReflowCallback(this); - mPostedReflowCallback = PR_FALSE; - } - if (mFrameLoader && mDidCreateDoc) { // Get the content viewer through the docshell, but don't call // GetDocShell() since we don't want to create one if we don't @@ -718,7 +684,7 @@ nsSubDocumentFrame::ShowDocShell() if (presShell) { // The docshell is already showing, nothing left to do... - NS_ASSERTION(mInnerView, "What's going on?"); + return NS_OK; }