From 2f230818c7f259d436bac2ef5a8229645deff9d6 Mon Sep 17 00:00:00 2001 From: "fantasai.cvs@inkedblade.net" Date: Tue, 19 Feb 2008 23:08:55 -0800 Subject: [PATCH] switch GetOverflowAreaProperty callers to GetOverflowRect b=417116 r+sr=roc a=roc --- layout/generic/nsBlockFrame.cpp | 8 +-- layout/generic/nsColumnSetFrame.cpp | 3 +- layout/generic/nsContainerFrame.cpp | 8 +-- layout/generic/nsFrame.cpp | 66 ++++++++++++------------- layout/generic/nsIFrame.h | 17 ++++--- layout/generic/nsTextFrameThebes.cpp | 8 +-- layout/tables/nsTableFrame.cpp | 6 +-- layout/tables/nsTableOuterFrame.cpp | 5 +- layout/tables/nsTableRowFrame.cpp | 6 +-- layout/xul/base/src/nsBox.cpp | 12 ++--- layout/xul/base/src/nsLeafBoxFrame.cpp | 8 +-- layout/xul/base/src/nsPopupSetFrame.cpp | 8 +-- 12 files changed, 67 insertions(+), 88 deletions(-) diff --git a/layout/generic/nsBlockFrame.cpp b/layout/generic/nsBlockFrame.cpp index 4c3b0d7c8eb5..d7b28e3c8cce 100644 --- a/layout/generic/nsBlockFrame.cpp +++ b/layout/generic/nsBlockFrame.cpp @@ -382,10 +382,10 @@ nsBlockFrame::List(FILE* out, PRInt32 aIndent) const fprintf(out, " [state=%08x]", mState); } nsBlockFrame* f = const_cast(this); - nsRect* overflowArea = f->GetOverflowAreaProperty(PR_FALSE); - if (overflowArea) { - fprintf(out, " [overflow=%d,%d,%d,%d]", overflowArea->x, overflowArea->y, - overflowArea->width, overflowArea->height); + if (f->GetStateBits() & NS_FRAME_OUTSIDE_CHILDREN) { + nsRect overflowArea = f->GetOverflowRect(); + fprintf(out, " [overflow=%d,%d,%d,%d]", overflowArea.x, overflowArea.y, + overflowArea.width, overflowArea.height); } PRInt32 numInlineLines = 0; PRInt32 numBlockLines = 0; diff --git a/layout/generic/nsColumnSetFrame.cpp b/layout/generic/nsColumnSetFrame.cpp index ecc05c80d3be..5fd373374e07 100644 --- a/layout/generic/nsColumnSetFrame.cpp +++ b/layout/generic/nsColumnSetFrame.cpp @@ -334,8 +334,7 @@ static void MoveChildTo(nsIFrame* aParent, nsIFrame* aChild, nsPoint aOrigin) { return; } - nsRect* overflowArea = aChild->GetOverflowAreaProperty(PR_FALSE); - nsRect r = overflowArea ? *overflowArea : nsRect(nsPoint(0, 0), aChild->GetSize()); + nsRect r = aChild->GetOverflowRect(); r += aChild->GetPosition(); aParent->Invalidate(r); r -= aChild->GetPosition(); diff --git a/layout/generic/nsContainerFrame.cpp b/layout/generic/nsContainerFrame.cpp index 13b9fd0e3088..91db6b46c924 100644 --- a/layout/generic/nsContainerFrame.cpp +++ b/layout/generic/nsContainerFrame.cpp @@ -1515,10 +1515,10 @@ nsContainerFrame::List(FILE* out, PRInt32 aIndent) const } fprintf(out, " [content=%p]", static_cast(mContent)); nsContainerFrame* f = const_cast(this); - nsRect* overflowArea = f->GetOverflowAreaProperty(PR_FALSE); - if (overflowArea) { - fprintf(out, " [overflow=%d,%d,%d,%d]", overflowArea->x, overflowArea->y, - overflowArea->width, overflowArea->height); + if (f->GetStateBits() & NS_FRAME_OUTSIDE_CHILDREN) { + nsRect overflowArea = f->GetOverflowRect(); + fprintf(out, " [overflow=%d,%d,%d,%d]", overflowArea.x, overflowArea.y, + overflowArea.width, overflowArea.height); } fprintf(out, " [sc=%p]", static_cast(mStyleContext)); nsIAtom* pseudoTag = mStyleContext->GetPseudoType(); diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index 0e448782f2f5..f17a42012566 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -3657,13 +3657,12 @@ nsIFrame::GetOverflowRect() const // of child frames. That's OK because any reflow that updates these // areas will invalidate the appropriate area, so any (mis)uses of // this method will be fixed up. - nsRect* storedOA = const_cast(this) - ->GetOverflowAreaProperty(PR_FALSE); - if (storedOA) { - return *storedOA; - } else { - return nsRect(nsPoint(0, 0), GetSize()); - } + + if (GetStateBits() & NS_FRAME_OUTSIDE_CHILDREN) + return *const_cast(this)->GetOverflowAreaProperty(PR_FALSE); + // NOTE this won't return accurate info if the overflow rect was updated + // but the mRect hasn't been set yet! + return nsRect(nsPoint(0, 0), GetSize()); } void @@ -3806,10 +3805,10 @@ nsFrame::List(FILE* out, PRInt32 aIndent) const } fprintf(out, " [content=%p]", static_cast(mContent)); nsFrame* f = const_cast(this); - nsRect* overflowArea = f->GetOverflowAreaProperty(PR_FALSE); - if (overflowArea) { - fprintf(out, " [overflow=%d,%d,%d,%d]", overflowArea->x, overflowArea->y, - overflowArea->width, overflowArea->height); + if (f->GetStateBits() & NS_FRAME_OUTSIDE_CHILDREN) { + nsRect overflowArea = f->GetOverflowRect(); + fprintf(out, " [overflow=%d,%d,%d,%d]", overflowArea.x, overflowArea.y, + overflowArea.width, overflowArea.height); } fputs("\n", out); return NS_OK; @@ -5235,6 +5234,11 @@ DestroyRectFunc(void* aFrame, delete static_cast(aPropertyValue); } +/** Create or retrieve the previously stored overflow area, if the frame does + * not overflow and no creation is required return nsnull. + * @param aCreateIfNecessary create a new nsRect for the overflow area + * @return pointer to the overflow area rectangle + */ nsRect* nsIFrame::GetOverflowAreaProperty(PRBool aCreateIfNecessary) { @@ -5331,15 +5335,9 @@ nsFrame::ConsiderChildOverflow(nsRect& aOverflowArea, // check here also for hidden as table frames (table, tr and td) currently // don't wrap their content into a scrollable frame if overflow is specified if (!disp->IsTableClip()) { - nsRect* overflowArea = aChildFrame->GetOverflowAreaProperty(); - if (overflowArea) { - nsRect childOverflow(*overflowArea); - childOverflow.MoveBy(aChildFrame->GetPosition()); - aOverflowArea.UnionRect(aOverflowArea, childOverflow); - } - else { - aOverflowArea.UnionRect(aOverflowArea, aChildFrame->GetRect()); - } + nsRect childOverflow = aChildFrame->GetOverflowRect(); + childOverflow.MoveBy(aChildFrame->GetPosition()); + aOverflowArea.UnionRect(aOverflowArea, childOverflow); } } @@ -7294,21 +7292,19 @@ void nsFrame::DisplayReflowExit(nsPresContext* aPresContext, printf("status=0x%x", aStatus); } if (aFrame->GetStateBits() & NS_FRAME_OUTSIDE_CHILDREN) { - DR_state->PrettyUC(aMetrics.mOverflowArea.x, x); - DR_state->PrettyUC(aMetrics.mOverflowArea.y, y); - DR_state->PrettyUC(aMetrics.mOverflowArea.width, width); - DR_state->PrettyUC(aMetrics.mOverflowArea.height, height); - printf("o=(%s,%s) %s x %s", x, y, width, height); - nsRect* storedOverflow = aFrame->GetOverflowAreaProperty(); - if (storedOverflow) { - if (aMetrics.mOverflowArea != *storedOverflow) { - DR_state->PrettyUC(storedOverflow->x, x); - DR_state->PrettyUC(storedOverflow->y, y); - DR_state->PrettyUC(storedOverflow->width, width); - DR_state->PrettyUC(storedOverflow->height, height); - printf("sto=(%s,%s) %s x %s", x, y, width, height); - } - } + DR_state->PrettyUC(aMetrics.mOverflowArea.x, x); + DR_state->PrettyUC(aMetrics.mOverflowArea.y, y); + DR_state->PrettyUC(aMetrics.mOverflowArea.width, width); + DR_state->PrettyUC(aMetrics.mOverflowArea.height, height); + printf("o=(%s,%s) %s x %s", x, y, width, height); + if (aFrame->GetStateBits() & NS_FRAME_OUTSIDE_CHILDREN) { + nsRect storedOverflow = aFrame->GetOverflowRect(); + DR_state->PrettyUC(storedOverflow.x, x); + DR_state->PrettyUC(storedOverflow.y, y); + DR_state->PrettyUC(storedOverflow.width, width); + DR_state->PrettyUC(storedOverflow.height, height); + printf("sto=(%s,%s) %s x %s", x, y, width, height); + } } printf("\n"); if (DR_state->mDisplayPixelErrors) { diff --git a/layout/generic/nsIFrame.h b/layout/generic/nsIFrame.h index 842562561106..bd8e559bfe16 100644 --- a/layout/generic/nsIFrame.h +++ b/layout/generic/nsIFrame.h @@ -1676,6 +1676,13 @@ public: * frame's outline, and descentant frames' outline, but does not include * areas clipped out by the CSS "overflow" and "clip" properties. * + * The NS_FRAME_OUTSIDE_CHILDREN state bit is set when this overflow rect + * is different from nsRect(0, 0, GetRect().width, GetRect().height). + * XXX Note: because of a space optimization using the formula above, + * during reflow this function does not give accurate data if + * FinishAndStoreOverflow has been called but mRect hasn't yet been + * updated yet. + * * @return the rect relative to this frame's origin */ nsRect GetOverflowRect() const; @@ -1932,14 +1939,6 @@ NS_PTR_TO_INT32(frame->GetProperty(nsGkAtoms::baseLevel)) #define NS_GET_EMBEDDING_LEVEL(frame) \ NS_PTR_TO_INT32(frame->GetProperty(nsGkAtoms::embeddingLevel)) - /** Create or retrieve the previously stored overflow area, if the frame does - * not overflow and no creation is required return nsnull. - * @param aPresContext PresContext - * @param aCreateIfNecessary create a new nsRect for the overflow area - * @return pointer to the overflow area rectangle - */ - nsRect* GetOverflowAreaProperty(PRBool aCreateIfNecessary = PR_FALSE); - /** * Return PR_TRUE if and only if this frame obeys visibility:hidden. * if it does not, then nsContainerFrame will hide its view even though @@ -2209,6 +2208,8 @@ protected: private: NS_IMETHOD_(nsrefcnt) AddRef(void) = 0; NS_IMETHOD_(nsrefcnt) Release(void) = 0; + + nsRect* GetOverflowAreaProperty(PRBool aCreateIfNecessary = PR_FALSE); }; //---------------------------------------------------------------------- diff --git a/layout/generic/nsTextFrameThebes.cpp b/layout/generic/nsTextFrameThebes.cpp index 336b869606d5..4029bc6c7ccf 100644 --- a/layout/generic/nsTextFrameThebes.cpp +++ b/layout/generic/nsTextFrameThebes.cpp @@ -5993,10 +5993,10 @@ nsTextFrame::List(FILE* out, PRInt32 aIndent) const } } fprintf(out, " [content=%p]", static_cast(mContent)); - nsRect* overflowArea = const_cast(this)->GetOverflowAreaProperty(PR_FALSE); - if (overflowArea) { - fprintf(out, " [overflow=%d,%d,%d,%d]", overflowArea->x, overflowArea->y, - overflowArea->width, overflowArea->height); + if (GetStateBits() & NS_FRAME_OUTSIDE_CHILDREN) { + nsRect overflowArea = GetOverflowRect(); + fprintf(out, " [overflow=%d,%d,%d,%d]", overflowArea.x, overflowArea.y, + overflowArea.width, overflowArea.height); } fprintf(out, " sc=%p", static_cast(mStyleContext)); nsIAtom* pseudoTag = mStyleContext->GetPseudoType(); diff --git a/layout/tables/nsTableFrame.cpp b/layout/tables/nsTableFrame.cpp index e944c6ba8ce2..454e10a7d026 100644 --- a/layout/tables/nsTableFrame.cpp +++ b/layout/tables/nsTableFrame.cpp @@ -1951,10 +1951,8 @@ NS_METHOD nsTableFrame::Reflow(nsPresContext* aPresContext, if (!reflowedChildren) { // use the old overflow area - nsRect* oldOverflowArea = GetOverflowAreaProperty(); - if (oldOverflowArea) { - aDesiredSize.mOverflowArea.UnionRect(aDesiredSize.mOverflowArea, *oldOverflowArea); - } + aDesiredSize.mOverflowArea.UnionRect(aDesiredSize.mOverflowArea, + GetOverflowRect()); } if (GetStateBits() & NS_FRAME_FIRST_REFLOW) { diff --git a/layout/tables/nsTableOuterFrame.cpp b/layout/tables/nsTableOuterFrame.cpp index dc0499a1236e..a6bc831efad5 100644 --- a/layout/tables/nsTableOuterFrame.cpp +++ b/layout/tables/nsTableOuterFrame.cpp @@ -540,10 +540,7 @@ nsTableOuterFrame::InvalidateDamage(PRUint8 aCaptionSide, if (aOldOverflowArea) { damage.UnionRect(damage, *aOldOverflowArea); } - nsRect* overflowArea = GetOverflowAreaProperty(); - if (overflowArea) { - damage.UnionRect(damage, *overflowArea); - } + damage.UnionRect(damage, GetOverflowRect()); } else { nsRect captionRect(0,0,0,0); diff --git a/layout/tables/nsTableRowFrame.cpp b/layout/tables/nsTableRowFrame.cpp index ecdecb9fe11d..a9be8979899f 100644 --- a/layout/tables/nsTableRowFrame.cpp +++ b/layout/tables/nsTableRowFrame.cpp @@ -916,10 +916,8 @@ nsTableRowFrame::ReflowChildren(nsPresContext* aPresContext, desiredSize.width = cellDesiredSize.width; desiredSize.height = cellDesiredSize.height; - nsRect *overflowArea = - cellFrame->GetOverflowAreaProperty(); - if (overflowArea) - desiredSize.mOverflowArea = *overflowArea; + if (cellFrame->GetStateBits() & NS_FRAME_OUTSIDE_CHILDREN) + desiredSize.mOverflowArea = cellFrame->GetOverflowRect(); else desiredSize.mOverflowArea.SetRect(0, 0, cellDesiredSize.width, cellDesiredSize.height); diff --git a/layout/xul/base/src/nsBox.cpp b/layout/xul/base/src/nsBox.cpp index 4270396ff1eb..b8fda1edbf36 100644 --- a/layout/xul/base/src/nsBox.cpp +++ b/layout/xul/base/src/nsBox.cpp @@ -606,11 +606,9 @@ nsBox::SyncLayout(nsBoxLayoutState& aState) nsRect rect(nsPoint(0, 0), GetSize()); if (ComputesOwnOverflowArea()) { - nsRect* overflow = GetOverflowAreaProperty(); - if (overflow) - rect = *overflow; - - } else { + rect = GetOverflowRect(); + } + else { if (!DoesClipChildren()) { // See if our child frames caused us to overflow after being laid // out. If so, store the overflow area. This normally can't happen @@ -619,9 +617,7 @@ nsBox::SyncLayout(nsBoxLayoutState& aState) // frames in HTML inside XUL). nsIFrame* box = GetChildBox(); while (box) { - nsRect* overflowArea = box->GetOverflowAreaProperty(); - nsRect bounds = overflowArea ? *overflowArea + box->GetPosition() - : box->GetRect(); + nsRect bounds = box->GetOverflowRect() + box->GetPosition(); rect.UnionRect(rect, bounds); box = box->GetNextBox(); diff --git a/layout/xul/base/src/nsLeafBoxFrame.cpp b/layout/xul/base/src/nsLeafBoxFrame.cpp index 3b7a6f20c63d..99e788376f86 100644 --- a/layout/xul/base/src/nsLeafBoxFrame.cpp +++ b/layout/xul/base/src/nsLeafBoxFrame.cpp @@ -352,13 +352,7 @@ nsLeafBoxFrame::Reflow(nsPresContext* aPresContext, aDesiredSize.ascent = GetBoxAscent(state); // NS_FRAME_OUTSIDE_CHILDREN is set in SetBounds() above - if (mState & NS_FRAME_OUTSIDE_CHILDREN) { - nsRect* overflowArea = GetOverflowAreaProperty(); - NS_ASSERTION(overflowArea, "Failed to set overflow area property"); - aDesiredSize.mOverflowArea = *overflowArea; - } else { - aDesiredSize.mOverflowArea = nsRect(nsPoint(0, 0), GetSize()); - } + aDesiredSize.mOverflowArea = GetOverflowRect(); #ifdef DO_NOISY_REFLOW { diff --git a/layout/xul/base/src/nsPopupSetFrame.cpp b/layout/xul/base/src/nsPopupSetFrame.cpp index a6975e497367..5b62ca840e78 100644 --- a/layout/xul/base/src/nsPopupSetFrame.cpp +++ b/layout/xul/base/src/nsPopupSetFrame.cpp @@ -329,10 +329,10 @@ nsPopupSetFrame::List(FILE* out, PRInt32 aIndent) const } fprintf(out, " [content=%p]", static_cast(mContent)); nsPopupSetFrame* f = const_cast(this); - nsRect* overflowArea = f->GetOverflowAreaProperty(PR_FALSE); - if (overflowArea) { - fprintf(out, " [overflow=%d,%d,%d,%d]", overflowArea->x, overflowArea->y, - overflowArea->width, overflowArea->height); + if (f->GetStateBits() & NS_FRAME_OUTSIDE_CHILDREN) { + nsRect overflowArea = f->GetOverflowRect(); + fprintf(out, " [overflow=%d,%d,%d,%d]", overflowArea.x, overflowArea.y, + overflowArea.width, overflowArea.height); } fprintf(out, " [sc=%p]", static_cast(mStyleContext)); nsIAtom* pseudoTag = mStyleContext->GetPseudoType();