Fixed column's incremental reflow function to properly handle margins

This commit is contained in:
troy 1998-04-21 04:27:34 +00:00
parent d61f7585c3
commit 2e70be499e
2 changed files with 17 additions and 11 deletions

View File

@ -1181,6 +1181,10 @@ PRBool nsContainerFrame::IsChild(const nsIFrame* aChild) const
return PR_FALSE;
}
// XXX Turn back on once all frame code has been changed to always add
// a child frame to the sibling list before reflowing the child. Right now
// that's not true for inline and column when reflowing unmapped children...
#if 0
// Check that aChild is in our sibling list
PRInt32 index;
@ -1188,6 +1192,7 @@ PRBool nsContainerFrame::IsChild(const nsIFrame* aChild) const
if (-1 == index) {
return PR_FALSE;
}
#endif
return PR_TRUE;
}

View File

@ -1048,17 +1048,9 @@ NS_METHOD ColumnFrame::IncrementalReflow(nsIPresContext* aPresContext,
state.prevMaxPosBottomMargin = bottomMargin;
}
} else {
// Get style info
nsIStyleContext* kidSC;
kidFrame->GetStyleContext(aPresContext, kidSC);
nsStyleMolecule* kidMol =
(nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
nscoord topMargin = kidMol->margin.top;
NS_RELEASE(kidSC);
// Initialize y to start after the top margin
state.y = topMargin;
state.prevMaxNegBottomMargin = 0;
state.prevMaxPosBottomMargin = 0;
state.y = 0;
}
aSpaceManager->Translate(0, state.y);
@ -1079,13 +1071,20 @@ NS_METHOD ColumnFrame::IncrementalReflow(nsIPresContext* aPresContext,
kidFrame->GetStyleContext(aPresContext, kidSC);
nsStyleMolecule* kidMol =
(nsStyleMolecule*)kidSC->GetData(kStyleMoleculeSID);
nscoord topMargin = GetTopMarginFor(aPresContext, state, kidFrame, kidMol);
nsRect kidRect;
nsSize kidAvailSize(state.availSize);
if (PR_FALSE == state.unconstrainedHeight) {
kidAvailSize.height -= topMargin;
}
// Reflow the child
state.spaceManager->Translate(0, topMargin);
aStatus = ReflowChild(kidFrame, aPresContext, kidMol, state.spaceManager,
kidAvailSize, kidRect, nsnull);
state.spaceManager->Translate(0, -topMargin);
// Did it fit?
if ((kidFrame != mFirstChild) &&
@ -1100,6 +1099,8 @@ NS_METHOD ColumnFrame::IncrementalReflow(nsIPresContext* aPresContext,
}
// Place the child
state.y += topMargin;
state.spaceManager->Translate(0, topMargin);
nsSize kidMaxElementSize; // XXX unused
kidRect.x += kidMol->margin.left;
kidRect.y += state.y;