switch GetOverflowAreaProperty callers to GetOverflowRect b=417116 r+sr=roc a=roc

This commit is contained in:
fantasai.cvs@inkedblade.net 2008-02-19 23:08:55 -08:00
parent 55af2d9050
commit 2f230818c7
12 changed files with 67 additions and 88 deletions

View File

@ -382,10 +382,10 @@ nsBlockFrame::List(FILE* out, PRInt32 aIndent) const
fprintf(out, " [state=%08x]", mState);
}
nsBlockFrame* f = const_cast<nsBlockFrame*>(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;

View File

@ -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();

View File

@ -1515,10 +1515,10 @@ nsContainerFrame::List(FILE* out, PRInt32 aIndent) const
}
fprintf(out, " [content=%p]", static_cast<void*>(mContent));
nsContainerFrame* f = const_cast<nsContainerFrame*>(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<void*>(mStyleContext));
nsIAtom* pseudoTag = mStyleContext->GetPseudoType();

View File

@ -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<nsIFrame*>(this)
->GetOverflowAreaProperty(PR_FALSE);
if (storedOA) {
return *storedOA;
} else {
return nsRect(nsPoint(0, 0), GetSize());
}
if (GetStateBits() & NS_FRAME_OUTSIDE_CHILDREN)
return *const_cast<nsIFrame*>(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<void*>(mContent));
nsFrame* f = const_cast<nsFrame*>(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<nsRect*>(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) {

View File

@ -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);
};
//----------------------------------------------------------------------

View File

@ -5993,10 +5993,10 @@ nsTextFrame::List(FILE* out, PRInt32 aIndent) const
}
}
fprintf(out, " [content=%p]", static_cast<void*>(mContent));
nsRect* overflowArea = const_cast<nsTextFrame*>(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<void*>(mStyleContext));
nsIAtom* pseudoTag = mStyleContext->GetPseudoType();

View File

@ -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) {

View File

@ -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);

View File

@ -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);

View File

@ -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();

View File

@ -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
{

View File

@ -329,10 +329,10 @@ nsPopupSetFrame::List(FILE* out, PRInt32 aIndent) const
}
fprintf(out, " [content=%p]", static_cast<void*>(mContent));
nsPopupSetFrame* f = const_cast<nsPopupSetFrame*>(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<void*>(mStyleContext));
nsIAtom* pseudoTag = mStyleContext->GetPseudoType();