a variety of fixes and optimizations
together with a fix troy just checked in, this makes a lot of real-world tables look a whole lot better git-svn-id: svn://10.0.0.236/trunk@2982 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -535,7 +535,7 @@ PRBool BasicTableLayoutStrategy::BalanceProportionalColumns(nsIPresContext* aPre
|
||||
|
||||
if (0==aTableFixedWidth)
|
||||
{
|
||||
if (NS_UNCONSTRAINEDSIZE==aMaxWidth)
|
||||
if (NS_UNCONSTRAINEDSIZE==aMaxWidth || NS_UNCONSTRAINEDSIZE==aMinTableWidth)
|
||||
{ // the max width of the table fits comfortably in the available space
|
||||
if (gsDebug) printf (" * table laying out in NS_UNCONSTRAINEDSIZE, calling BalanceColumnsTableFits\n");
|
||||
result = BalanceColumnsTableFits(aPresContext, aAvailWidth, aMaxWidth, aTableFixedWidth);
|
||||
@@ -559,7 +559,12 @@ PRBool BasicTableLayoutStrategy::BalanceProportionalColumns(nsIPresContext* aPre
|
||||
}
|
||||
else
|
||||
{ // tables with fixed-width have their own rules
|
||||
if (aTableFixedWidth<aMinTableWidth)
|
||||
if (NS_UNCONSTRAINEDSIZE==aMinTableWidth)
|
||||
{ // the table has empty content, and needs to be streched to the specified width
|
||||
if (gsDebug) printf (" * specified width table > maxTableWidth, calling BalanceColumnsTableFits\n");
|
||||
result = BalanceColumnsTableFits(aPresContext, aAvailWidth, aMaxWidth, aTableFixedWidth);
|
||||
}
|
||||
else if (aTableFixedWidth<aMinTableWidth)
|
||||
{ // the table's specified width doesn't fit in the available space
|
||||
if (gsDebug) printf (" * specified width table with width<minTableWidth, calling SetColumnsToMinWidth\n");
|
||||
result = SetColumnsToMinWidth(aPresContext);
|
||||
|
||||
@@ -19,13 +19,14 @@
|
||||
#include "nsTableCellFrame.h"
|
||||
#include "nsHTMLParts.h"
|
||||
#include "nsIStyleContext.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsHTMLIIDs.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
static PRBool gsDebug = PR_TRUE;
|
||||
static PRBool gsDebug = PR_FALSE;
|
||||
static PRBool gsNoisyRefs = PR_FALSE;
|
||||
#else
|
||||
static const PRBool gsDebug = PR_FALSE;
|
||||
@@ -180,7 +181,16 @@ void nsTableCell::SetAttribute(nsIAtom* aAttribute, const nsString& aValue)
|
||||
SetColSpan(val.GetIntValue());
|
||||
return;
|
||||
}
|
||||
|
||||
if (aAttribute == nsHTMLAtoms::width) {
|
||||
ParseValueOrPercent(aValue, val, eHTMLUnit_Pixel);
|
||||
nsHTMLTagContent::SetAttribute(aAttribute, val);
|
||||
return;
|
||||
}
|
||||
if (aAttribute == nsHTMLAtoms::height) {
|
||||
ParseValueOrPercent(aValue, val, eHTMLUnit_Pixel);
|
||||
nsHTMLTagContent::SetAttribute(aAttribute, val);
|
||||
return;
|
||||
}
|
||||
// Use default attribute catching code
|
||||
nsTableContent::SetAttribute(aAttribute, aValue);
|
||||
}
|
||||
@@ -192,17 +202,35 @@ void nsTableCell::MapAttributesInto(nsIStyleContext* aContext,
|
||||
{
|
||||
NS_PRECONDITION(nsnull!=aContext, "bad style context arg");
|
||||
NS_PRECONDITION(nsnull!=aPresContext, "bad presentation context arg");
|
||||
if (nsnull != mAttributes) {
|
||||
nsHTMLValue value;
|
||||
|
||||
nsHTMLValue value;
|
||||
// align: enum
|
||||
GetAttribute(nsHTMLAtoms::align, value);
|
||||
if (value.GetUnit() == eHTMLUnit_Enumerated)
|
||||
{
|
||||
nsStyleText* text = (nsStyleText*)aContext->GetData(eStyleStruct_Text);
|
||||
text->mTextAlign = value.GetIntValue();
|
||||
}
|
||||
MapBackgroundAttributesInto(aContext, aPresContext);
|
||||
|
||||
// align: enum
|
||||
GetAttribute(nsHTMLAtoms::align, value);
|
||||
if (value.GetUnit() == eHTMLUnit_Enumerated)
|
||||
{
|
||||
nsStyleText* text = (nsStyleText*)aContext->GetData(eStyleStruct_Text);
|
||||
text->mTextAlign = value.GetIntValue();
|
||||
// width: pixel
|
||||
float p2t = aPresContext->GetPixelsToTwips();
|
||||
nsStylePosition* pos = (nsStylePosition*)
|
||||
aContext->GetData(eStyleStruct_Position);
|
||||
GetAttribute(nsHTMLAtoms::width, value);
|
||||
if (value.GetUnit() == eHTMLUnit_Pixel) {
|
||||
nscoord twips = nscoord(p2t * value.GetPixelValue());
|
||||
pos->mWidth.SetCoordValue(twips);
|
||||
}
|
||||
|
||||
// height: pixel
|
||||
GetAttribute(nsHTMLAtoms::height, value);
|
||||
if (value.GetUnit() == eHTMLUnit_Pixel) {
|
||||
nscoord twips = nscoord(p2t * value.GetPixelValue());
|
||||
pos->mHeight.SetCoordValue(twips);
|
||||
}
|
||||
}
|
||||
MapBackgroundAttributesInto(aContext, aPresContext);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -243,6 +243,12 @@ NS_METHOD nsTableCellFrame::Reflow(nsIPresContext* aPresContext,
|
||||
//PreReflowCheck();
|
||||
#endif
|
||||
|
||||
// Initialize out parameter
|
||||
if (nsnull != aDesiredSize.maxElementSize) {
|
||||
aDesiredSize.maxElementSize->width = 0;
|
||||
aDesiredSize.maxElementSize->height = 0;
|
||||
}
|
||||
|
||||
aStatus = NS_FRAME_COMPLETE;
|
||||
if (gsDebug==PR_TRUE)
|
||||
printf("nsTableCellFrame::ResizeReflow: maxSize=%d,%d\n",
|
||||
@@ -300,6 +306,7 @@ NS_METHOD nsTableCellFrame::Reflow(nsIPresContext* aPresContext,
|
||||
printf(" nsTableCellFrame::ResizeReflow calling ReflowChild with availSize=%d,%d\n",
|
||||
availSize.width, availSize.height);
|
||||
nsReflowMetrics kidSize(pMaxElementSize);
|
||||
kidSize.width=kidSize.height=kidSize.ascent=kidSize.descent=0;
|
||||
nsReflowState kidReflowState(mFirstChild, aReflowState, availSize);
|
||||
mFirstChild->WillReflow(*aPresContext);
|
||||
aStatus = ReflowChild(mFirstChild, aPresContext, kidSize, kidReflowState);
|
||||
|
||||
@@ -189,9 +189,6 @@ PRBool nsTableColGroup::AppendChild (nsIContent *aContent)
|
||||
result = nsTableContent::AppendChild (aContent);
|
||||
if (result)
|
||||
{
|
||||
/* Set the table pointer */
|
||||
((nsTableContent*)aContent)->SetTable(mTable);
|
||||
|
||||
((nsTableCol *)aContent)->SetColGroup (this);
|
||||
ResetColumns ();
|
||||
}
|
||||
|
||||
@@ -41,6 +41,11 @@ static NS_DEFINE_IID(kITableContentIID, NS_ITABLECONTENT_IID);
|
||||
*/
|
||||
nsTableContent::nsTableContent (nsIAtom* aTag)
|
||||
: nsHTMLContainer(aTag)
|
||||
{
|
||||
mTable = nsnull;
|
||||
}
|
||||
|
||||
nsTableContent::~nsTableContent ()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -54,13 +59,15 @@ nsTableContent::nsTableContent (nsIAtom* aTag, PRBool aImplicit)
|
||||
|
||||
nsrefcnt nsTableContent::AddRef(void)
|
||||
{
|
||||
if (gsNoisyRefs==PR_TRUE) printf("Add Ref: nsTableContent cnt = %d \n",mRefCnt+1);
|
||||
if (gsNoisyRefs==PR_TRUE) printf("Add Ref: nsTableContent %d - %p cnt = %d \n",
|
||||
GetType(), this, mRefCnt+1);
|
||||
return ++mRefCnt;
|
||||
}
|
||||
|
||||
nsrefcnt nsTableContent::Release(void)
|
||||
{
|
||||
if (gsNoisyRefs==PR_TRUE) printf("Release: nsTableContent cnt = %d \n",mRefCnt-1);
|
||||
if (gsNoisyRefs==PR_TRUE) printf("Release: nsTableContent %d - %p cnt = %d \n",
|
||||
GetType(), this, mRefCnt-1);
|
||||
if (--mRefCnt == 0) {
|
||||
if (gsNoisyRefs==PR_TRUE) printf("Delete: nsTableContent \n");
|
||||
delete this;
|
||||
@@ -105,7 +112,11 @@ void nsTableContent::SetTableForChildren(nsTablePart *aTable)
|
||||
{
|
||||
PRInt32 count = ChildCount();
|
||||
for (PRInt32 index = 0; index < count; index++)
|
||||
SetTableForTableContent(ChildAt(index),aTable);
|
||||
{
|
||||
nsIContent* child = ChildAt(index);
|
||||
SetTableForTableContent(child,aTable);
|
||||
NS_RELEASE(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
* within a table.
|
||||
*
|
||||
* @author sclark
|
||||
* @version $Revision: 3.3 $
|
||||
* @version $Revision: 3.4 $
|
||||
* @see
|
||||
*/
|
||||
class nsTableContent : public nsHTMLContainer, public nsITableContent
|
||||
@@ -60,6 +60,8 @@ public:
|
||||
*/
|
||||
nsTableContent (nsIAtom* aTag, PRBool aImplicit);
|
||||
|
||||
virtual ~nsTableContent();
|
||||
|
||||
/** supports implementation */
|
||||
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtrResult);
|
||||
|
||||
|
||||
@@ -522,8 +522,7 @@ NS_METHOD nsTableFrame::Reflow(nsIPresContext* aPresContext,
|
||||
if (PR_FALSE==IsFirstPassValid())
|
||||
{ // we treat the table as if we've never seen the layout data before
|
||||
mPass = kPASS_FIRST;
|
||||
aStatus = ResizeReflowPass1(aPresContext, aDesiredSize, aReflowState,
|
||||
aDesiredSize.maxElementSize);
|
||||
aStatus = ResizeReflowPass1(aPresContext, aDesiredSize, aReflowState);
|
||||
// check result
|
||||
}
|
||||
mPass = kPASS_SECOND;
|
||||
@@ -535,8 +534,7 @@ NS_METHOD nsTableFrame::Reflow(nsIPresContext* aPresContext,
|
||||
// assign table width
|
||||
SetTableWidth(aPresContext);
|
||||
|
||||
aStatus = ResizeReflowPass2(aPresContext, aDesiredSize, aReflowState,
|
||||
aDesiredSize.maxElementSize, 0, 0);
|
||||
aStatus = ResizeReflowPass2(aPresContext, aDesiredSize, aReflowState, 0, 0);
|
||||
|
||||
if (gsTiming) {
|
||||
PRIntervalTime endTime = PR_IntervalNow();
|
||||
@@ -568,8 +566,7 @@ NS_METHOD nsTableFrame::Reflow(nsIPresContext* aPresContext,
|
||||
*/
|
||||
nsReflowStatus nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresContext,
|
||||
nsReflowMetrics& aDesiredSize,
|
||||
const nsReflowState& aReflowState,
|
||||
nsSize* aMaxElementSize)
|
||||
const nsReflowState& aReflowState)
|
||||
{
|
||||
NS_PRECONDITION(aReflowState.frame == this, "bad reflow state");
|
||||
NS_PRECONDITION(aReflowState.parentReflowState->frame == mGeometricParent,
|
||||
@@ -594,8 +591,7 @@ nsReflowStatus nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresContext,
|
||||
nsSize availSize(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE); // availSize is the space available at any given time in the process
|
||||
nsSize maxSize(0, 0); // maxSize is the size of the largest child so far in the process
|
||||
nsSize kidMaxSize(0,0);
|
||||
nsSize* pKidMaxSize = (nsnull != aMaxElementSize) ? &kidMaxSize : nsnull;
|
||||
nsReflowMetrics kidSize(pKidMaxSize);
|
||||
nsReflowMetrics kidSize(&kidMaxSize);
|
||||
nscoord y = 0;
|
||||
nscoord maxAscent = 0;
|
||||
nscoord maxDescent = 0;
|
||||
@@ -657,7 +653,7 @@ nsReflowStatus nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresContext,
|
||||
NS_RELEASE(kidDel);
|
||||
}
|
||||
|
||||
nsSize maxKidElementSize;
|
||||
nsSize maxKidElementSize(0,0);
|
||||
nsReflowState kidReflowState(kidFrame, aReflowState, availSize,
|
||||
eReflowReason_Resize);
|
||||
kidFrame->WillReflow(*aPresContext);
|
||||
@@ -665,12 +661,8 @@ nsReflowStatus nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresContext,
|
||||
|
||||
// Place the child since some of it's content fit in us.
|
||||
if (gsDebug) {
|
||||
if (nsnull != pKidMaxSize) {
|
||||
printf ("reflow of row group returned desired=%d,%d, max-element=%d,%d\n",
|
||||
kidSize.width, kidSize.height, pKidMaxSize->width, pKidMaxSize->height);
|
||||
} else {
|
||||
printf ("reflow of row group returned desired=%d,%d\n", kidSize.width, kidSize.height);
|
||||
}
|
||||
printf ("reflow of row group returned desired=%d,%d, max-element=%d,%d\n",
|
||||
kidSize.width, kidSize.height, kidMaxSize.width, kidMaxSize.height);
|
||||
}
|
||||
PRInt32 yCoord = y;
|
||||
if (NS_UNCONSTRAINEDSIZE!=yCoord)
|
||||
@@ -681,13 +673,11 @@ nsReflowStatus nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresContext,
|
||||
y = NS_UNCONSTRAINEDSIZE;
|
||||
else
|
||||
y += kidSize.height;
|
||||
if (nsnull != pKidMaxSize) {
|
||||
if (pKidMaxSize->width > maxSize.width) {
|
||||
maxSize.width = pKidMaxSize->width;
|
||||
}
|
||||
if (pKidMaxSize->height > maxSize.height) {
|
||||
maxSize.height = pKidMaxSize->height;
|
||||
}
|
||||
if (kidMaxSize.width > maxSize.width) {
|
||||
maxSize.width = kidMaxSize.width;
|
||||
}
|
||||
if (kidMaxSize.height > maxSize.height) {
|
||||
maxSize.height = kidMaxSize.height;
|
||||
}
|
||||
|
||||
// Link child frame into the list of children
|
||||
@@ -739,7 +729,6 @@ nsReflowStatus nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresContext,
|
||||
nsReflowStatus nsTableFrame::ResizeReflowPass2(nsIPresContext* aPresContext,
|
||||
nsReflowMetrics& aDesiredSize,
|
||||
const nsReflowState& aReflowState,
|
||||
nsSize* aMaxElementSize,
|
||||
PRInt32 aMinCaptionWidth,
|
||||
PRInt32 mMaxCaptionWidth)
|
||||
{
|
||||
@@ -767,9 +756,9 @@ nsReflowStatus nsTableFrame::ResizeReflowPass2(nsIPresContext* aPresContext,
|
||||
#endif
|
||||
|
||||
// Initialize out parameter
|
||||
if (nsnull != aMaxElementSize) {
|
||||
aMaxElementSize->width = 0;
|
||||
aMaxElementSize->height = 0;
|
||||
if (nsnull != aDesiredSize.maxElementSize) {
|
||||
aDesiredSize.maxElementSize->width = 0;
|
||||
aDesiredSize.maxElementSize->height = 0;
|
||||
}
|
||||
|
||||
PRBool reflowMappedOK = PR_TRUE;
|
||||
@@ -787,7 +776,7 @@ nsReflowStatus nsTableFrame::ResizeReflowPass2(nsIPresContext* aPresContext,
|
||||
|
||||
// Reflow the existing frames
|
||||
if (nsnull != mFirstChild) {
|
||||
reflowMappedOK = ReflowMappedChildren(aPresContext, state, aMaxElementSize);
|
||||
reflowMappedOK = ReflowMappedChildren(aPresContext, state, aDesiredSize.maxElementSize);
|
||||
if (PR_FALSE == reflowMappedOK) {
|
||||
status = NS_FRAME_NOT_COMPLETE;
|
||||
}
|
||||
@@ -803,10 +792,10 @@ nsReflowStatus nsTableFrame::ResizeReflowPass2(nsIPresContext* aPresContext,
|
||||
}
|
||||
} else if (NextChildOffset() < mContent->ChildCount()) {
|
||||
// Try and pull-up some children from a next-in-flow
|
||||
if (PullUpChildren(aPresContext, state, aMaxElementSize)) {
|
||||
if (PullUpChildren(aPresContext, state, aDesiredSize.maxElementSize)) {
|
||||
// If we still have unmapped children then create some new frames
|
||||
if (NextChildOffset() < mContent->ChildCount()) {
|
||||
status = ReflowUnmappedChildren(aPresContext, state, aMaxElementSize);
|
||||
status = ReflowUnmappedChildren(aPresContext, state, aDesiredSize.maxElementSize);
|
||||
}
|
||||
} else {
|
||||
// We were unable to pull-up all the existing frames from the
|
||||
@@ -834,16 +823,16 @@ nsReflowStatus nsTableFrame::ResizeReflowPass2(nsIPresContext* aPresContext,
|
||||
aDesiredSize.height = state.y;
|
||||
|
||||
// shrink wrap rows to height of tallest cell in that row
|
||||
ShrinkWrapChildren(aPresContext, aDesiredSize, aMaxElementSize);
|
||||
ShrinkWrapChildren(aPresContext, aDesiredSize, aDesiredSize.maxElementSize);
|
||||
|
||||
if (gsDebug==PR_TRUE)
|
||||
{
|
||||
if (nsnull!=aMaxElementSize)
|
||||
printf("Reflow complete, returning aDesiredSize = %d,%d and aMaxElementSize=%d,%d\n",
|
||||
if (nsnull!=aDesiredSize.maxElementSize)
|
||||
printf("Inner table reflow complete, returning aDesiredSize = %d,%d and aMaxElementSize=%d,%d\n",
|
||||
aDesiredSize.width, aDesiredSize.height,
|
||||
aMaxElementSize->width, aMaxElementSize->height);
|
||||
aDesiredSize.maxElementSize->width, aDesiredSize.maxElementSize->height);
|
||||
else
|
||||
printf("Reflow complete, returning aDesiredSize = %d,%d and NSNULL aMaxElementSize\n",
|
||||
printf("Inner table reflow complete, returning aDesiredSize = %d,%d and NSNULL aMaxElementSize\n",
|
||||
aDesiredSize.width, aDesiredSize.height);
|
||||
}
|
||||
|
||||
@@ -1000,13 +989,14 @@ PRBool nsTableFrame::ReflowMappedChildren( nsIPresContext* aPresContext,
|
||||
// PushChildren.
|
||||
PRBool originalLastContentIsComplete = mLastContentIsComplete;
|
||||
|
||||
nsSize kidMaxElementSize;
|
||||
nsSize kidMaxElementSize(0,0);
|
||||
nsSize* pKidMaxElementSize = (nsnull != aMaxElementSize) ? &kidMaxElementSize : nsnull;
|
||||
PRBool result = PR_TRUE;
|
||||
|
||||
for (nsIFrame* kidFrame = mFirstChild; nsnull != kidFrame; ) {
|
||||
nsSize kidAvailSize(aState.availSize);
|
||||
nsReflowMetrics desiredSize(pKidMaxElementSize);
|
||||
desiredSize.width=desiredSize.height=desiredSize.ascent=desiredSize.descent=0;
|
||||
nsReflowStatus status;
|
||||
|
||||
// Get top margin for this kid
|
||||
@@ -1204,7 +1194,7 @@ PRBool nsTableFrame::PullUpChildren(nsIPresContext* aPresContext,
|
||||
#endif
|
||||
#endif
|
||||
nsTableFrame* nextInFlow = (nsTableFrame*)mNextInFlow;
|
||||
nsSize kidMaxElementSize;
|
||||
nsSize kidMaxElementSize(0,0);
|
||||
nsSize* pKidMaxElementSize = (nsnull != aMaxElementSize) ? &kidMaxElementSize : nsnull;
|
||||
#ifdef NS_DEBUG
|
||||
PRInt32 kidIndex = NextChildOffset();
|
||||
@@ -1224,6 +1214,7 @@ PRBool nsTableFrame::PullUpChildren(nsIPresContext* aPresContext,
|
||||
|
||||
while (nsnull != nextInFlow) {
|
||||
nsReflowMetrics kidSize(pKidMaxElementSize);
|
||||
kidSize.width=kidSize.height=kidSize.ascent=kidSize.descent=0;
|
||||
nsReflowStatus status;
|
||||
|
||||
// Get the next child
|
||||
@@ -1247,7 +1238,7 @@ PRBool nsTableFrame::PullUpChildren(nsIPresContext* aPresContext,
|
||||
// See if the child fits in the available space. If it fits or
|
||||
// it's splittable then reflow it. The reason we can't just move
|
||||
// it is that we still need ascent/descent information
|
||||
nsSize kidFrameSize;
|
||||
nsSize kidFrameSize(0,0);
|
||||
nsSplittableType kidIsSplittable;
|
||||
|
||||
kidFrame->GetSize(kidFrameSize);
|
||||
@@ -1432,7 +1423,7 @@ nsTableFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
|
||||
mLastContentIsComplete = PR_TRUE;
|
||||
|
||||
// Place our children, one at a time until we are out of children
|
||||
nsSize kidMaxElementSize;
|
||||
nsSize kidMaxElementSize(0,0);
|
||||
nsSize* pKidMaxElementSize = (nsnull != aMaxElementSize) ? &kidMaxElementSize : nsnull;
|
||||
PRInt32 kidIndex = NextChildOffset();
|
||||
nsIFrame* prevKidFrame;
|
||||
@@ -1474,6 +1465,7 @@ nsTableFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
|
||||
// Try to reflow the child into the available space. It might not
|
||||
// fit or might need continuing.
|
||||
nsReflowMetrics kidSize(pKidMaxElementSize);
|
||||
kidSize.width=kidSize.height=kidSize.ascent=kidSize.descent=0;
|
||||
nsReflowState kidReflowState(kidFrame, aState.reflowState, aState.availSize,
|
||||
eReflowReason_Initial);
|
||||
kidFrame->WillReflow(*aPresContext);
|
||||
@@ -1737,7 +1729,7 @@ void nsTableFrame::ShrinkWrapChildren(nsIPresContext* aPresContext,
|
||||
bottomInnerMargin = maxCellBottomMargin;
|
||||
|
||||
|
||||
nsSize rowFrameSize;
|
||||
nsSize rowFrameSize(0,0);
|
||||
|
||||
rowFrame->GetSize(rowFrameSize);
|
||||
rowFrame->SizeTo(rowFrameSize.width, maxRowHeight);
|
||||
@@ -1756,7 +1748,7 @@ void nsTableFrame::ShrinkWrapChildren(nsIPresContext* aPresContext,
|
||||
{
|
||||
if (gsDebug==PR_TRUE) printf(" setting cell[%d,%d] height to %d\n", rowIndex, cellIndex, rowHeights[rowIndex]);
|
||||
|
||||
nsSize cellFrameSize;
|
||||
nsSize cellFrameSize(0,0);
|
||||
|
||||
cellFrame->GetSize(cellFrameSize);
|
||||
cellFrame->SizeTo(cellFrameSize.width, maxCellHeight);
|
||||
@@ -1813,7 +1805,7 @@ void nsTableFrame::ShrinkWrapChildren(nsIPresContext* aPresContext,
|
||||
heightOfRowsSpanned -= topInnerMargin + bottomInnerMargin;
|
||||
|
||||
/* if the cell height fits in the rows, expand the spanning cell's height and slap it in */
|
||||
nsSize cellFrameSize;
|
||||
nsSize cellFrameSize(0,0);
|
||||
cellFrame->GetSize(cellFrameSize);
|
||||
if (heightOfRowsSpanned>cellFrameSize.height)
|
||||
{
|
||||
@@ -1843,7 +1835,7 @@ void nsTableFrame::ShrinkWrapChildren(nsIPresContext* aPresContext,
|
||||
rowHeights[i] += excessHeightPerRow;
|
||||
if (gsDebug==PR_TRUE) printf(" rowHeight[%d] set to %d\n", i, rowHeights[i]);
|
||||
|
||||
nsSize rowFrameSize;
|
||||
nsSize rowFrameSize(0,0);
|
||||
|
||||
rowFrameToBeResized->GetSize(rowFrameSize);
|
||||
rowFrameToBeResized->SizeTo(rowFrameSize.width, rowHeights[i]);
|
||||
@@ -1862,7 +1854,7 @@ void nsTableFrame::ShrinkWrapChildren(nsIPresContext* aPresContext,
|
||||
rowFrameToBeResized->ChildAt(j, (nsIFrame*&)frame);
|
||||
if (frame->GetRowSpan()==1)
|
||||
{
|
||||
nsSize frameSize;
|
||||
nsSize frameSize(0,0);
|
||||
|
||||
frame->GetSize(frameSize);
|
||||
if (gsDebug==PR_TRUE) printf(" cell[%d, %d] set height to %d\n", i, j, frameSize.height+excessHeightPerRow);
|
||||
@@ -1894,7 +1886,7 @@ void nsTableFrame::ShrinkWrapChildren(nsIPresContext* aPresContext,
|
||||
}
|
||||
if (gsDebug==PR_TRUE) printf("row group height set to %d\n", rowGroupHeight);
|
||||
|
||||
nsSize rowGroupFrameSize;
|
||||
nsSize rowGroupFrameSize(0,0);
|
||||
|
||||
rowGroupFrame->GetSize(rowGroupFrameSize);
|
||||
rowGroupFrame->SizeTo(rowGroupFrameSize.width, rowGroupHeight);
|
||||
|
||||
@@ -180,12 +180,11 @@ protected:
|
||||
* as long as content and style don't change. This is managed in the member variable mFirstPassIsValid.
|
||||
* The layout information for each cell is cached in mColumLayoutData.
|
||||
*
|
||||
* @see ResizeReflow
|
||||
* @see Reflow
|
||||
*/
|
||||
virtual nsReflowStatus ResizeReflowPass1(nsIPresContext* aPresContext,
|
||||
nsReflowMetrics& aDesiredSize,
|
||||
const nsReflowState& aReflowState,
|
||||
nsSize* aMaxElementSize);
|
||||
const nsReflowState& aReflowState);
|
||||
|
||||
/** second pass of ResizeReflow.
|
||||
* lays out all table content with aMaxSize(computed_table_width, given_table_height)
|
||||
@@ -195,13 +194,12 @@ protected:
|
||||
* @param aMinCaptionWidth - the max of all the minimum caption widths. 0 if no captions.
|
||||
* @param aMaxCaptionWidth - the max of all the desired caption widths. 0 if no captions.
|
||||
*
|
||||
* @see ResizeReflow
|
||||
* @see Reflow
|
||||
* @see NeedsReflow
|
||||
*/
|
||||
virtual nsReflowStatus ResizeReflowPass2(nsIPresContext* aPresContext,
|
||||
nsReflowMetrics& aDesiredSize,
|
||||
const nsReflowState& aReflowState,
|
||||
nsSize* aMaxElementSize,
|
||||
PRInt32 aMinCaptionWidth,
|
||||
PRInt32 mMaxCaptionWidth);
|
||||
|
||||
|
||||
@@ -90,6 +90,8 @@ struct OuterTableReflowState {
|
||||
unconstrainedHeight = PRBool(aReflowState.maxSize.height == NS_UNCONSTRAINEDSIZE);
|
||||
firstRowGroup = PR_TRUE;
|
||||
processingCaption = PR_FALSE;
|
||||
innerTableMaxSize.width=0;
|
||||
innerTableMaxSize.height=0;
|
||||
}
|
||||
|
||||
~OuterTableReflowState() {
|
||||
@@ -190,7 +192,6 @@ NS_METHOD nsTableOuterFrame::Reflow(nsIPresContext* aPresContext,
|
||||
PRBool reflowMappedOK = PR_TRUE;
|
||||
|
||||
aStatus = NS_FRAME_COMPLETE;
|
||||
nsSize innerTableMaxElementSize(0,0);
|
||||
|
||||
// Set up our kids. They're already present, on an overflow list,
|
||||
// or there are none so we'll create them now
|
||||
@@ -228,11 +229,7 @@ NS_METHOD nsTableOuterFrame::Reflow(nsIPresContext* aPresContext,
|
||||
mInnerTableFrame->SetReflowPass(nsTableFrame::kPASS_FIRST);
|
||||
nsReflowState innerTableReflowState(mInnerTableFrame, aReflowState, aReflowState.maxSize);
|
||||
aStatus = mInnerTableFrame->ResizeReflowPass1(aPresContext, aDesiredSize,
|
||||
innerTableReflowState,
|
||||
&innerTableMaxElementSize);
|
||||
|
||||
mInnerTableFrame->RecalcLayoutData();
|
||||
|
||||
innerTableReflowState);
|
||||
}
|
||||
mInnerTableFrame->SetReflowPass(nsTableFrame::kPASS_SECOND);
|
||||
// assign table width info only if the inner table frame is a first-in-flow
|
||||
@@ -249,7 +246,7 @@ NS_METHOD nsTableOuterFrame::Reflow(nsIPresContext* aPresContext,
|
||||
mInnerTableFrame->SetTableWidth(aPresContext);
|
||||
}
|
||||
// inner table max is now the computed width and assigned height
|
||||
nsSize innerTableSize;
|
||||
nsSize innerTableSize(0,0);
|
||||
|
||||
mInnerTableFrame->GetSize(innerTableSize);
|
||||
state.innerTableMaxSize.width = innerTableSize.width;
|
||||
@@ -443,12 +440,13 @@ PRBool nsTableOuterFrame::ReflowMappedChildren( nsIPresContext* aPresContex
|
||||
// PushChildren.
|
||||
PRBool originalLastContentIsComplete = mLastContentIsComplete;
|
||||
|
||||
nsSize kidMaxElementSize;
|
||||
nsSize kidMaxElementSize(0,0);
|
||||
nsSize* pKidMaxElementSize = (nsnull != aMaxElementSize) ? &kidMaxElementSize : nsnull;
|
||||
PRBool result = PR_TRUE;
|
||||
aState.availSize.width = aState.innerTableMaxSize.width;
|
||||
for (nsIFrame* kidFrame = mFirstChild; nsnull != kidFrame; ) {
|
||||
nsReflowMetrics kidSize(pKidMaxElementSize);
|
||||
kidSize.width=kidSize.height=kidSize.ascent=kidSize.descent=0;
|
||||
nsReflowStatus status;
|
||||
|
||||
SetReflowState(aState, kidFrame);
|
||||
@@ -653,7 +651,7 @@ PRBool nsTableOuterFrame::PullUpChildren( nsIPresContext* aPresContext,
|
||||
#endif
|
||||
#endif
|
||||
nsTableOuterFrame* nextInFlow = (nsTableOuterFrame*)mNextInFlow;
|
||||
nsSize kidMaxElementSize;
|
||||
nsSize kidMaxElementSize(0,0);
|
||||
nsSize* pKidMaxElementSize = (nsnull != aMaxElementSize) ? &kidMaxElementSize : nsnull;
|
||||
#ifdef NS_DEBUG
|
||||
PRInt32 kidIndex = NextChildOffset();
|
||||
@@ -673,6 +671,7 @@ PRBool nsTableOuterFrame::PullUpChildren( nsIPresContext* aPresContext,
|
||||
|
||||
while (nsnull != nextInFlow) {
|
||||
nsReflowMetrics kidSize(pKidMaxElementSize);
|
||||
kidSize.width=kidSize.height=kidSize.ascent=kidSize.descent=0;
|
||||
nsReflowStatus status;
|
||||
|
||||
// Get the next child
|
||||
@@ -697,7 +696,7 @@ PRBool nsTableOuterFrame::PullUpChildren( nsIPresContext* aPresContext,
|
||||
// See if the child fits in the available space. If it fits or
|
||||
// it's splittable then reflow it. The reason we can't just move
|
||||
// it is that we still need ascent/descent information
|
||||
nsSize kidFrameSize;
|
||||
nsSize kidFrameSize(0,0);
|
||||
nsSplittableType kidIsSplittable;
|
||||
|
||||
kidFrame->GetSize(kidFrameSize);
|
||||
@@ -918,8 +917,7 @@ nsTableOuterFrame::ReflowChild( nsIFrame* aKidFrame,
|
||||
{
|
||||
if (PR_TRUE==gsDebug) printf("reflowChild called with a table body\n");
|
||||
nsReflowState kidReflowState(aKidFrame, aState.reflowState, aState.innerTableMaxSize);
|
||||
status = ((nsTableFrame*)aKidFrame)->ResizeReflowPass2(aPresContext, aDesiredSize,
|
||||
kidReflowState, aMaxElementSize,
|
||||
status = ((nsTableFrame*)aKidFrame)->ResizeReflowPass2(aPresContext, aDesiredSize, kidReflowState,
|
||||
mMinCaptionWidth, mMaxCaptionWidth);
|
||||
}
|
||||
if (PR_TRUE==gsDebug)
|
||||
@@ -1034,16 +1032,17 @@ nsTableOuterFrame::ResizeReflowCaptionsPass1(nsIPresContext* aPresContext,
|
||||
{
|
||||
nsSize maxElementSize(0,0);
|
||||
nsSize maxSize(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
|
||||
nsReflowMetrics desiredSize(&maxElementSize);
|
||||
nsReflowMetrics kidSize(&maxElementSize);
|
||||
kidSize.width=kidSize.height=kidSize.ascent=kidSize.descent=0;
|
||||
nsTableCaptionFrame *captionFrame = (nsTableCaptionFrame *)mCaptionFrames->ElementAt(captionIndex);
|
||||
nsReflowStatus status;
|
||||
nsReflowState reflowState(captionFrame, aState.reflowState, maxSize, eReflowReason_Resize);
|
||||
captionFrame->WillReflow(*aPresContext);
|
||||
captionFrame->Reflow(aPresContext, desiredSize, reflowState, status);
|
||||
captionFrame->Reflow(aPresContext, kidSize, reflowState, status);
|
||||
if (mMinCaptionWidth<maxElementSize.width)
|
||||
mMinCaptionWidth = maxElementSize.width;
|
||||
if (mMaxCaptionWidth<desiredSize.width)
|
||||
mMaxCaptionWidth = desiredSize.width;
|
||||
if (mMaxCaptionWidth<kidSize.width)
|
||||
mMaxCaptionWidth = kidSize.width;
|
||||
captionFrame->VerticallyAlignChild(aPresContext);
|
||||
|
||||
}
|
||||
@@ -1087,6 +1086,7 @@ nsTableOuterFrame::ResizeReflowTopCaptionsPass2(nsIPresContext* aPresCont
|
||||
if (NS_FRAME_IS_COMPLETE(result))
|
||||
{
|
||||
nsReflowMetrics desiredSize(nsnull);
|
||||
desiredSize.width=desiredSize.height=desiredSize.ascent=desiredSize.descent=0;
|
||||
nsReflowState reflowState(captionFrame, aState.reflowState, aMaxSize, eReflowReason_Resize);
|
||||
captionFrame->WillReflow(*aPresContext);
|
||||
result = nsContainerFrame::ReflowChild(captionFrame, aPresContext, desiredSize, reflowState);
|
||||
@@ -1149,6 +1149,7 @@ nsTableOuterFrame::ResizeReflowBottomCaptionsPass2(nsIPresContext* aPresContext
|
||||
*/
|
||||
// reflow the caption
|
||||
nsReflowMetrics desiredSize(nsnull);
|
||||
desiredSize.width=desiredSize.height=desiredSize.ascent=desiredSize.descent=0;
|
||||
nsReflowState reflowState(captionFrame, aState.reflowState, aMaxSize, eReflowReason_Resize);
|
||||
captionFrame->WillReflow(*aPresContext);
|
||||
result = nsContainerFrame::ReflowChild(captionFrame, aPresContext, desiredSize, reflowState);
|
||||
|
||||
@@ -433,10 +433,6 @@ PRBool nsTablePart::AppendChild (nsIContent * aContent)
|
||||
contentHandled = PR_TRUE; // whether we succeeded or not, we've "handled" this request
|
||||
}
|
||||
|
||||
// Remember to set the table variable -- gpk
|
||||
if (tableContentInterface)
|
||||
tableContentInterface->SetTable(this);
|
||||
|
||||
/* if aContent is not a known content type, make a capion out of it */
|
||||
// SEC the logic here is very suspicious!!!!
|
||||
if (PR_FALSE==contentHandled)
|
||||
|
||||
@@ -27,6 +27,9 @@
|
||||
#include "nsTableCell.h"
|
||||
#include "nsCellLayoutData.h"
|
||||
#include "nsIView.h"
|
||||
#include "nsIPtr.h"
|
||||
|
||||
NS_DEF_PTR(nsIStyleContext);
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
static PRBool gsDebug1 = PR_FALSE;
|
||||
@@ -234,6 +237,9 @@ void nsTableRowFrame::PlaceChild(nsIPresContext* aPresContext,
|
||||
// Place and size the child
|
||||
aKidFrame->SetRect(aKidRect);
|
||||
|
||||
// update the running total for the row width
|
||||
aState.x += aKidRect.width;
|
||||
|
||||
// Update the maximum element size
|
||||
PRInt32 rowSpan = ((nsTableCellFrame*)aKidFrame)->GetRowSpan();
|
||||
if (nsnull != aMaxElementSize)
|
||||
@@ -322,6 +328,7 @@ PRBool nsTableRowFrame::ReflowMappedChildren(nsIPresContext* aPresContext,
|
||||
kidAvailSize.height = 1; // XXX: HaCk - we don't handle negative heights yet
|
||||
|
||||
nsReflowMetrics desiredSize(pKidMaxElementSize);
|
||||
desiredSize.width=desiredSize.height=desiredSize.ascent=desiredSize.descent=0;
|
||||
nsReflowStatus status;
|
||||
|
||||
nsMargin kidMargin(0,0,0,0);
|
||||
@@ -370,20 +377,17 @@ PRBool nsTableRowFrame::ReflowMappedChildren(nsIPresContext* aPresContext,
|
||||
kidFrame->WillReflow(*aPresContext);
|
||||
status = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState);
|
||||
}
|
||||
if (nsnull!=pKidMaxElementSize)
|
||||
if (gsDebug1)
|
||||
{
|
||||
if (gsDebug1)
|
||||
{
|
||||
if (nsnull!=pKidMaxElementSize)
|
||||
printf("reflow of cell returned result = %s with desired=%d,%d, min = %d,%d\n",
|
||||
NS_FRAME_IS_COMPLETE(status)?"complete":"NOT complete",
|
||||
desiredSize.width, desiredSize.height,
|
||||
pKidMaxElementSize->width, pKidMaxElementSize->height);
|
||||
else
|
||||
printf("reflow of cell returned result = %s with desired=%d,%d, min = nsnull\n",
|
||||
NS_FRAME_IS_COMPLETE(status)?"complete":"NOT complete",
|
||||
desiredSize.width, desiredSize.height);
|
||||
}
|
||||
if (nsnull!=pKidMaxElementSize)
|
||||
printf("reflow of cell returned result = %s with desired=%d,%d, min = %d,%d\n",
|
||||
NS_FRAME_IS_COMPLETE(status)?"complete":"NOT complete",
|
||||
desiredSize.width, desiredSize.height,
|
||||
pKidMaxElementSize->width, pKidMaxElementSize->height);
|
||||
else
|
||||
printf("reflow of cell returned result = %s with desired=%d,%d, min = nsnull\n",
|
||||
NS_FRAME_IS_COMPLETE(status)?"complete":"NOT complete",
|
||||
desiredSize.width, desiredSize.height);
|
||||
}
|
||||
NS_RELEASE(content); // cell: REFCNT--
|
||||
cell = nsnull;
|
||||
@@ -413,8 +417,29 @@ PRBool nsTableRowFrame::ReflowMappedChildren(nsIPresContext* aPresContext,
|
||||
PRInt32 cellColIndex = ((nsTableCellFrame *)kidFrame)->GetColIndex();
|
||||
for (PRInt32 colIndex=0; colIndex<cellColIndex; colIndex++)
|
||||
aState.x += aState.tableFrame->GetColumnWidth(colIndex);
|
||||
// Place the child after taking into account it's margin
|
||||
nsRect kidRect (aState.x, kidMargin.top, desiredSize.width, desiredSize.height);
|
||||
// Place the child after taking into account it's margin and attributes
|
||||
nscoord specifiedHeight = 0;
|
||||
nscoord cellHeight = desiredSize.height;
|
||||
nsIStyleContextPtr kidSC;
|
||||
kidFrame->GetStyleContext(aPresContext, kidSC.AssignRef());
|
||||
nsStylePosition* kidPosition = (nsStylePosition*)
|
||||
kidSC->GetData(eStyleStruct_Position);
|
||||
switch (kidPosition->mHeight.GetUnit()) {
|
||||
case eStyleUnit_Coord:
|
||||
specifiedHeight = kidPosition->mHeight.GetCoordValue();
|
||||
break;
|
||||
case eStyleUnit_Percent:
|
||||
case eStyleUnit_Proportional:
|
||||
// XXX for now these fall through
|
||||
|
||||
default:
|
||||
case eStyleUnit_Auto:
|
||||
case eStyleUnit_Inherit:
|
||||
break;
|
||||
}
|
||||
if (specifiedHeight>cellHeight)
|
||||
cellHeight = specifiedHeight;
|
||||
nsRect kidRect (aState.x, kidMargin.top, desiredSize.width, cellHeight);
|
||||
PlaceChild(aPresContext, aState, kidFrame, kidRect, aMaxElementSize,
|
||||
kidMaxElementSize);
|
||||
if (kidMargin.bottom < 0)
|
||||
@@ -589,6 +614,7 @@ PRBool nsTableRowFrame::PullUpChildren(nsIPresContext* aPresContext,
|
||||
|
||||
while (nsnull != nextInFlow) {
|
||||
nsReflowMetrics desiredSize(pKidMaxElementSize);
|
||||
desiredSize.width=desiredSize.height=desiredSize.ascent=desiredSize.descent=0;
|
||||
nsReflowStatus status;
|
||||
|
||||
// Get the next child
|
||||
@@ -613,7 +639,7 @@ PRBool nsTableRowFrame::PullUpChildren(nsIPresContext* aPresContext,
|
||||
// See if the child fits in the available space. If it fits or
|
||||
// it's splittable then reflow it. The reason we can't just move
|
||||
// it is that we still need ascent/descent information
|
||||
nsSize kidFrameSize;
|
||||
nsSize kidFrameSize(0,0);
|
||||
nsSplittableType kidIsSplittable;
|
||||
|
||||
kidFrame->GetSize(kidFrameSize);
|
||||
@@ -841,7 +867,7 @@ nsTableRowFrame::ReflowUnmappedChildren( nsIPresContext* aPresContext,
|
||||
mLastContentIsComplete = PR_TRUE;
|
||||
|
||||
// Place our children, one at a time, until we are out of children
|
||||
nsSize kidMaxElementSize;
|
||||
nsSize kidMaxElementSize(0,0);
|
||||
nsSize* pKidMaxElementSize = (nsnull != aMaxElementSize) ? &kidMaxElementSize : nsnull;
|
||||
nsSize kidAvailSize(aState.availSize);
|
||||
PRInt32 kidIndex = NextChildOffset();
|
||||
@@ -901,6 +927,7 @@ nsTableRowFrame::ReflowUnmappedChildren( nsIPresContext* aPresContext,
|
||||
// Try to reflow the child into the available space. It might not
|
||||
// fit or might need continuing.
|
||||
nsReflowMetrics desiredSize(pKidMaxElementSize);
|
||||
desiredSize.width=desiredSize.height=desiredSize.ascent=desiredSize.descent=0;
|
||||
nsReflowStatus status;
|
||||
if (NS_UNCONSTRAINEDSIZE == aState.availSize.width)
|
||||
{
|
||||
@@ -1079,7 +1106,7 @@ nsTableRowFrame::Reflow(nsIPresContext* aPresContext,
|
||||
}
|
||||
|
||||
// Return our desired rect
|
||||
aDesiredSize.width = aReflowState.maxSize.width;
|
||||
aDesiredSize.width = state.x;
|
||||
aDesiredSize.height = state.maxCellVertSpace;
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
|
||||
@@ -273,6 +273,7 @@ PRBool nsTableRowGroupFrame::ReflowMappedChildren( nsIPresContext* aPresCon
|
||||
if (0>=kidAvailSize.height)
|
||||
kidAvailSize.height = 1; // XXX: HaCk - we don't handle negative heights yet
|
||||
nsReflowMetrics desiredSize(pKidMaxElementSize);
|
||||
desiredSize.width=desiredSize.height=desiredSize.ascent=desiredSize.descent=0;
|
||||
nsReflowStatus status;
|
||||
|
||||
// Get top margin for this kid
|
||||
@@ -501,6 +502,7 @@ PRBool nsTableRowGroupFrame::PullUpChildren(nsIPresContext* aPresContext,
|
||||
|
||||
while (nsnull != nextInFlow) {
|
||||
nsReflowMetrics kidSize(pKidMaxElementSize);
|
||||
kidSize.width=kidSize.height=kidSize.ascent=kidSize.descent=0;
|
||||
nsReflowStatus status;
|
||||
|
||||
// Get the next child
|
||||
@@ -766,6 +768,7 @@ nsTableRowGroupFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
|
||||
// Try to reflow the child into the available space. It might not
|
||||
// fit or might need continuing.
|
||||
nsReflowMetrics kidSize(pKidMaxElementSize);
|
||||
kidSize.width=kidSize.height=kidSize.ascent=kidSize.descent=0;
|
||||
nsReflowState kidReflowState(kidFrame, aState.reflowState, aState.availSize,
|
||||
eReflowReason_Initial);
|
||||
kidFrame->WillReflow(*aPresContext);
|
||||
|
||||
@@ -535,7 +535,7 @@ PRBool BasicTableLayoutStrategy::BalanceProportionalColumns(nsIPresContext* aPre
|
||||
|
||||
if (0==aTableFixedWidth)
|
||||
{
|
||||
if (NS_UNCONSTRAINEDSIZE==aMaxWidth)
|
||||
if (NS_UNCONSTRAINEDSIZE==aMaxWidth || NS_UNCONSTRAINEDSIZE==aMinTableWidth)
|
||||
{ // the max width of the table fits comfortably in the available space
|
||||
if (gsDebug) printf (" * table laying out in NS_UNCONSTRAINEDSIZE, calling BalanceColumnsTableFits\n");
|
||||
result = BalanceColumnsTableFits(aPresContext, aAvailWidth, aMaxWidth, aTableFixedWidth);
|
||||
@@ -559,7 +559,12 @@ PRBool BasicTableLayoutStrategy::BalanceProportionalColumns(nsIPresContext* aPre
|
||||
}
|
||||
else
|
||||
{ // tables with fixed-width have their own rules
|
||||
if (aTableFixedWidth<aMinTableWidth)
|
||||
if (NS_UNCONSTRAINEDSIZE==aMinTableWidth)
|
||||
{ // the table has empty content, and needs to be streched to the specified width
|
||||
if (gsDebug) printf (" * specified width table > maxTableWidth, calling BalanceColumnsTableFits\n");
|
||||
result = BalanceColumnsTableFits(aPresContext, aAvailWidth, aMaxWidth, aTableFixedWidth);
|
||||
}
|
||||
else if (aTableFixedWidth<aMinTableWidth)
|
||||
{ // the table's specified width doesn't fit in the available space
|
||||
if (gsDebug) printf (" * specified width table with width<minTableWidth, calling SetColumnsToMinWidth\n");
|
||||
result = SetColumnsToMinWidth(aPresContext);
|
||||
|
||||
@@ -243,6 +243,12 @@ NS_METHOD nsTableCellFrame::Reflow(nsIPresContext* aPresContext,
|
||||
//PreReflowCheck();
|
||||
#endif
|
||||
|
||||
// Initialize out parameter
|
||||
if (nsnull != aDesiredSize.maxElementSize) {
|
||||
aDesiredSize.maxElementSize->width = 0;
|
||||
aDesiredSize.maxElementSize->height = 0;
|
||||
}
|
||||
|
||||
aStatus = NS_FRAME_COMPLETE;
|
||||
if (gsDebug==PR_TRUE)
|
||||
printf("nsTableCellFrame::ResizeReflow: maxSize=%d,%d\n",
|
||||
@@ -300,6 +306,7 @@ NS_METHOD nsTableCellFrame::Reflow(nsIPresContext* aPresContext,
|
||||
printf(" nsTableCellFrame::ResizeReflow calling ReflowChild with availSize=%d,%d\n",
|
||||
availSize.width, availSize.height);
|
||||
nsReflowMetrics kidSize(pMaxElementSize);
|
||||
kidSize.width=kidSize.height=kidSize.ascent=kidSize.descent=0;
|
||||
nsReflowState kidReflowState(mFirstChild, aReflowState, availSize);
|
||||
mFirstChild->WillReflow(*aPresContext);
|
||||
aStatus = ReflowChild(mFirstChild, aPresContext, kidSize, kidReflowState);
|
||||
|
||||
@@ -522,8 +522,7 @@ NS_METHOD nsTableFrame::Reflow(nsIPresContext* aPresContext,
|
||||
if (PR_FALSE==IsFirstPassValid())
|
||||
{ // we treat the table as if we've never seen the layout data before
|
||||
mPass = kPASS_FIRST;
|
||||
aStatus = ResizeReflowPass1(aPresContext, aDesiredSize, aReflowState,
|
||||
aDesiredSize.maxElementSize);
|
||||
aStatus = ResizeReflowPass1(aPresContext, aDesiredSize, aReflowState);
|
||||
// check result
|
||||
}
|
||||
mPass = kPASS_SECOND;
|
||||
@@ -535,8 +534,7 @@ NS_METHOD nsTableFrame::Reflow(nsIPresContext* aPresContext,
|
||||
// assign table width
|
||||
SetTableWidth(aPresContext);
|
||||
|
||||
aStatus = ResizeReflowPass2(aPresContext, aDesiredSize, aReflowState,
|
||||
aDesiredSize.maxElementSize, 0, 0);
|
||||
aStatus = ResizeReflowPass2(aPresContext, aDesiredSize, aReflowState, 0, 0);
|
||||
|
||||
if (gsTiming) {
|
||||
PRIntervalTime endTime = PR_IntervalNow();
|
||||
@@ -568,8 +566,7 @@ NS_METHOD nsTableFrame::Reflow(nsIPresContext* aPresContext,
|
||||
*/
|
||||
nsReflowStatus nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresContext,
|
||||
nsReflowMetrics& aDesiredSize,
|
||||
const nsReflowState& aReflowState,
|
||||
nsSize* aMaxElementSize)
|
||||
const nsReflowState& aReflowState)
|
||||
{
|
||||
NS_PRECONDITION(aReflowState.frame == this, "bad reflow state");
|
||||
NS_PRECONDITION(aReflowState.parentReflowState->frame == mGeometricParent,
|
||||
@@ -594,8 +591,7 @@ nsReflowStatus nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresContext,
|
||||
nsSize availSize(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE); // availSize is the space available at any given time in the process
|
||||
nsSize maxSize(0, 0); // maxSize is the size of the largest child so far in the process
|
||||
nsSize kidMaxSize(0,0);
|
||||
nsSize* pKidMaxSize = (nsnull != aMaxElementSize) ? &kidMaxSize : nsnull;
|
||||
nsReflowMetrics kidSize(pKidMaxSize);
|
||||
nsReflowMetrics kidSize(&kidMaxSize);
|
||||
nscoord y = 0;
|
||||
nscoord maxAscent = 0;
|
||||
nscoord maxDescent = 0;
|
||||
@@ -657,7 +653,7 @@ nsReflowStatus nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresContext,
|
||||
NS_RELEASE(kidDel);
|
||||
}
|
||||
|
||||
nsSize maxKidElementSize;
|
||||
nsSize maxKidElementSize(0,0);
|
||||
nsReflowState kidReflowState(kidFrame, aReflowState, availSize,
|
||||
eReflowReason_Resize);
|
||||
kidFrame->WillReflow(*aPresContext);
|
||||
@@ -665,12 +661,8 @@ nsReflowStatus nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresContext,
|
||||
|
||||
// Place the child since some of it's content fit in us.
|
||||
if (gsDebug) {
|
||||
if (nsnull != pKidMaxSize) {
|
||||
printf ("reflow of row group returned desired=%d,%d, max-element=%d,%d\n",
|
||||
kidSize.width, kidSize.height, pKidMaxSize->width, pKidMaxSize->height);
|
||||
} else {
|
||||
printf ("reflow of row group returned desired=%d,%d\n", kidSize.width, kidSize.height);
|
||||
}
|
||||
printf ("reflow of row group returned desired=%d,%d, max-element=%d,%d\n",
|
||||
kidSize.width, kidSize.height, kidMaxSize.width, kidMaxSize.height);
|
||||
}
|
||||
PRInt32 yCoord = y;
|
||||
if (NS_UNCONSTRAINEDSIZE!=yCoord)
|
||||
@@ -681,13 +673,11 @@ nsReflowStatus nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresContext,
|
||||
y = NS_UNCONSTRAINEDSIZE;
|
||||
else
|
||||
y += kidSize.height;
|
||||
if (nsnull != pKidMaxSize) {
|
||||
if (pKidMaxSize->width > maxSize.width) {
|
||||
maxSize.width = pKidMaxSize->width;
|
||||
}
|
||||
if (pKidMaxSize->height > maxSize.height) {
|
||||
maxSize.height = pKidMaxSize->height;
|
||||
}
|
||||
if (kidMaxSize.width > maxSize.width) {
|
||||
maxSize.width = kidMaxSize.width;
|
||||
}
|
||||
if (kidMaxSize.height > maxSize.height) {
|
||||
maxSize.height = kidMaxSize.height;
|
||||
}
|
||||
|
||||
// Link child frame into the list of children
|
||||
@@ -739,7 +729,6 @@ nsReflowStatus nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresContext,
|
||||
nsReflowStatus nsTableFrame::ResizeReflowPass2(nsIPresContext* aPresContext,
|
||||
nsReflowMetrics& aDesiredSize,
|
||||
const nsReflowState& aReflowState,
|
||||
nsSize* aMaxElementSize,
|
||||
PRInt32 aMinCaptionWidth,
|
||||
PRInt32 mMaxCaptionWidth)
|
||||
{
|
||||
@@ -767,9 +756,9 @@ nsReflowStatus nsTableFrame::ResizeReflowPass2(nsIPresContext* aPresContext,
|
||||
#endif
|
||||
|
||||
// Initialize out parameter
|
||||
if (nsnull != aMaxElementSize) {
|
||||
aMaxElementSize->width = 0;
|
||||
aMaxElementSize->height = 0;
|
||||
if (nsnull != aDesiredSize.maxElementSize) {
|
||||
aDesiredSize.maxElementSize->width = 0;
|
||||
aDesiredSize.maxElementSize->height = 0;
|
||||
}
|
||||
|
||||
PRBool reflowMappedOK = PR_TRUE;
|
||||
@@ -787,7 +776,7 @@ nsReflowStatus nsTableFrame::ResizeReflowPass2(nsIPresContext* aPresContext,
|
||||
|
||||
// Reflow the existing frames
|
||||
if (nsnull != mFirstChild) {
|
||||
reflowMappedOK = ReflowMappedChildren(aPresContext, state, aMaxElementSize);
|
||||
reflowMappedOK = ReflowMappedChildren(aPresContext, state, aDesiredSize.maxElementSize);
|
||||
if (PR_FALSE == reflowMappedOK) {
|
||||
status = NS_FRAME_NOT_COMPLETE;
|
||||
}
|
||||
@@ -803,10 +792,10 @@ nsReflowStatus nsTableFrame::ResizeReflowPass2(nsIPresContext* aPresContext,
|
||||
}
|
||||
} else if (NextChildOffset() < mContent->ChildCount()) {
|
||||
// Try and pull-up some children from a next-in-flow
|
||||
if (PullUpChildren(aPresContext, state, aMaxElementSize)) {
|
||||
if (PullUpChildren(aPresContext, state, aDesiredSize.maxElementSize)) {
|
||||
// If we still have unmapped children then create some new frames
|
||||
if (NextChildOffset() < mContent->ChildCount()) {
|
||||
status = ReflowUnmappedChildren(aPresContext, state, aMaxElementSize);
|
||||
status = ReflowUnmappedChildren(aPresContext, state, aDesiredSize.maxElementSize);
|
||||
}
|
||||
} else {
|
||||
// We were unable to pull-up all the existing frames from the
|
||||
@@ -834,16 +823,16 @@ nsReflowStatus nsTableFrame::ResizeReflowPass2(nsIPresContext* aPresContext,
|
||||
aDesiredSize.height = state.y;
|
||||
|
||||
// shrink wrap rows to height of tallest cell in that row
|
||||
ShrinkWrapChildren(aPresContext, aDesiredSize, aMaxElementSize);
|
||||
ShrinkWrapChildren(aPresContext, aDesiredSize, aDesiredSize.maxElementSize);
|
||||
|
||||
if (gsDebug==PR_TRUE)
|
||||
{
|
||||
if (nsnull!=aMaxElementSize)
|
||||
printf("Reflow complete, returning aDesiredSize = %d,%d and aMaxElementSize=%d,%d\n",
|
||||
if (nsnull!=aDesiredSize.maxElementSize)
|
||||
printf("Inner table reflow complete, returning aDesiredSize = %d,%d and aMaxElementSize=%d,%d\n",
|
||||
aDesiredSize.width, aDesiredSize.height,
|
||||
aMaxElementSize->width, aMaxElementSize->height);
|
||||
aDesiredSize.maxElementSize->width, aDesiredSize.maxElementSize->height);
|
||||
else
|
||||
printf("Reflow complete, returning aDesiredSize = %d,%d and NSNULL aMaxElementSize\n",
|
||||
printf("Inner table reflow complete, returning aDesiredSize = %d,%d and NSNULL aMaxElementSize\n",
|
||||
aDesiredSize.width, aDesiredSize.height);
|
||||
}
|
||||
|
||||
@@ -1000,13 +989,14 @@ PRBool nsTableFrame::ReflowMappedChildren( nsIPresContext* aPresContext,
|
||||
// PushChildren.
|
||||
PRBool originalLastContentIsComplete = mLastContentIsComplete;
|
||||
|
||||
nsSize kidMaxElementSize;
|
||||
nsSize kidMaxElementSize(0,0);
|
||||
nsSize* pKidMaxElementSize = (nsnull != aMaxElementSize) ? &kidMaxElementSize : nsnull;
|
||||
PRBool result = PR_TRUE;
|
||||
|
||||
for (nsIFrame* kidFrame = mFirstChild; nsnull != kidFrame; ) {
|
||||
nsSize kidAvailSize(aState.availSize);
|
||||
nsReflowMetrics desiredSize(pKidMaxElementSize);
|
||||
desiredSize.width=desiredSize.height=desiredSize.ascent=desiredSize.descent=0;
|
||||
nsReflowStatus status;
|
||||
|
||||
// Get top margin for this kid
|
||||
@@ -1204,7 +1194,7 @@ PRBool nsTableFrame::PullUpChildren(nsIPresContext* aPresContext,
|
||||
#endif
|
||||
#endif
|
||||
nsTableFrame* nextInFlow = (nsTableFrame*)mNextInFlow;
|
||||
nsSize kidMaxElementSize;
|
||||
nsSize kidMaxElementSize(0,0);
|
||||
nsSize* pKidMaxElementSize = (nsnull != aMaxElementSize) ? &kidMaxElementSize : nsnull;
|
||||
#ifdef NS_DEBUG
|
||||
PRInt32 kidIndex = NextChildOffset();
|
||||
@@ -1224,6 +1214,7 @@ PRBool nsTableFrame::PullUpChildren(nsIPresContext* aPresContext,
|
||||
|
||||
while (nsnull != nextInFlow) {
|
||||
nsReflowMetrics kidSize(pKidMaxElementSize);
|
||||
kidSize.width=kidSize.height=kidSize.ascent=kidSize.descent=0;
|
||||
nsReflowStatus status;
|
||||
|
||||
// Get the next child
|
||||
@@ -1247,7 +1238,7 @@ PRBool nsTableFrame::PullUpChildren(nsIPresContext* aPresContext,
|
||||
// See if the child fits in the available space. If it fits or
|
||||
// it's splittable then reflow it. The reason we can't just move
|
||||
// it is that we still need ascent/descent information
|
||||
nsSize kidFrameSize;
|
||||
nsSize kidFrameSize(0,0);
|
||||
nsSplittableType kidIsSplittable;
|
||||
|
||||
kidFrame->GetSize(kidFrameSize);
|
||||
@@ -1432,7 +1423,7 @@ nsTableFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
|
||||
mLastContentIsComplete = PR_TRUE;
|
||||
|
||||
// Place our children, one at a time until we are out of children
|
||||
nsSize kidMaxElementSize;
|
||||
nsSize kidMaxElementSize(0,0);
|
||||
nsSize* pKidMaxElementSize = (nsnull != aMaxElementSize) ? &kidMaxElementSize : nsnull;
|
||||
PRInt32 kidIndex = NextChildOffset();
|
||||
nsIFrame* prevKidFrame;
|
||||
@@ -1474,6 +1465,7 @@ nsTableFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
|
||||
// Try to reflow the child into the available space. It might not
|
||||
// fit or might need continuing.
|
||||
nsReflowMetrics kidSize(pKidMaxElementSize);
|
||||
kidSize.width=kidSize.height=kidSize.ascent=kidSize.descent=0;
|
||||
nsReflowState kidReflowState(kidFrame, aState.reflowState, aState.availSize,
|
||||
eReflowReason_Initial);
|
||||
kidFrame->WillReflow(*aPresContext);
|
||||
@@ -1737,7 +1729,7 @@ void nsTableFrame::ShrinkWrapChildren(nsIPresContext* aPresContext,
|
||||
bottomInnerMargin = maxCellBottomMargin;
|
||||
|
||||
|
||||
nsSize rowFrameSize;
|
||||
nsSize rowFrameSize(0,0);
|
||||
|
||||
rowFrame->GetSize(rowFrameSize);
|
||||
rowFrame->SizeTo(rowFrameSize.width, maxRowHeight);
|
||||
@@ -1756,7 +1748,7 @@ void nsTableFrame::ShrinkWrapChildren(nsIPresContext* aPresContext,
|
||||
{
|
||||
if (gsDebug==PR_TRUE) printf(" setting cell[%d,%d] height to %d\n", rowIndex, cellIndex, rowHeights[rowIndex]);
|
||||
|
||||
nsSize cellFrameSize;
|
||||
nsSize cellFrameSize(0,0);
|
||||
|
||||
cellFrame->GetSize(cellFrameSize);
|
||||
cellFrame->SizeTo(cellFrameSize.width, maxCellHeight);
|
||||
@@ -1813,7 +1805,7 @@ void nsTableFrame::ShrinkWrapChildren(nsIPresContext* aPresContext,
|
||||
heightOfRowsSpanned -= topInnerMargin + bottomInnerMargin;
|
||||
|
||||
/* if the cell height fits in the rows, expand the spanning cell's height and slap it in */
|
||||
nsSize cellFrameSize;
|
||||
nsSize cellFrameSize(0,0);
|
||||
cellFrame->GetSize(cellFrameSize);
|
||||
if (heightOfRowsSpanned>cellFrameSize.height)
|
||||
{
|
||||
@@ -1843,7 +1835,7 @@ void nsTableFrame::ShrinkWrapChildren(nsIPresContext* aPresContext,
|
||||
rowHeights[i] += excessHeightPerRow;
|
||||
if (gsDebug==PR_TRUE) printf(" rowHeight[%d] set to %d\n", i, rowHeights[i]);
|
||||
|
||||
nsSize rowFrameSize;
|
||||
nsSize rowFrameSize(0,0);
|
||||
|
||||
rowFrameToBeResized->GetSize(rowFrameSize);
|
||||
rowFrameToBeResized->SizeTo(rowFrameSize.width, rowHeights[i]);
|
||||
@@ -1862,7 +1854,7 @@ void nsTableFrame::ShrinkWrapChildren(nsIPresContext* aPresContext,
|
||||
rowFrameToBeResized->ChildAt(j, (nsIFrame*&)frame);
|
||||
if (frame->GetRowSpan()==1)
|
||||
{
|
||||
nsSize frameSize;
|
||||
nsSize frameSize(0,0);
|
||||
|
||||
frame->GetSize(frameSize);
|
||||
if (gsDebug==PR_TRUE) printf(" cell[%d, %d] set height to %d\n", i, j, frameSize.height+excessHeightPerRow);
|
||||
@@ -1894,7 +1886,7 @@ void nsTableFrame::ShrinkWrapChildren(nsIPresContext* aPresContext,
|
||||
}
|
||||
if (gsDebug==PR_TRUE) printf("row group height set to %d\n", rowGroupHeight);
|
||||
|
||||
nsSize rowGroupFrameSize;
|
||||
nsSize rowGroupFrameSize(0,0);
|
||||
|
||||
rowGroupFrame->GetSize(rowGroupFrameSize);
|
||||
rowGroupFrame->SizeTo(rowGroupFrameSize.width, rowGroupHeight);
|
||||
|
||||
@@ -180,12 +180,11 @@ protected:
|
||||
* as long as content and style don't change. This is managed in the member variable mFirstPassIsValid.
|
||||
* The layout information for each cell is cached in mColumLayoutData.
|
||||
*
|
||||
* @see ResizeReflow
|
||||
* @see Reflow
|
||||
*/
|
||||
virtual nsReflowStatus ResizeReflowPass1(nsIPresContext* aPresContext,
|
||||
nsReflowMetrics& aDesiredSize,
|
||||
const nsReflowState& aReflowState,
|
||||
nsSize* aMaxElementSize);
|
||||
const nsReflowState& aReflowState);
|
||||
|
||||
/** second pass of ResizeReflow.
|
||||
* lays out all table content with aMaxSize(computed_table_width, given_table_height)
|
||||
@@ -195,13 +194,12 @@ protected:
|
||||
* @param aMinCaptionWidth - the max of all the minimum caption widths. 0 if no captions.
|
||||
* @param aMaxCaptionWidth - the max of all the desired caption widths. 0 if no captions.
|
||||
*
|
||||
* @see ResizeReflow
|
||||
* @see Reflow
|
||||
* @see NeedsReflow
|
||||
*/
|
||||
virtual nsReflowStatus ResizeReflowPass2(nsIPresContext* aPresContext,
|
||||
nsReflowMetrics& aDesiredSize,
|
||||
const nsReflowState& aReflowState,
|
||||
nsSize* aMaxElementSize,
|
||||
PRInt32 aMinCaptionWidth,
|
||||
PRInt32 mMaxCaptionWidth);
|
||||
|
||||
|
||||
@@ -90,6 +90,8 @@ struct OuterTableReflowState {
|
||||
unconstrainedHeight = PRBool(aReflowState.maxSize.height == NS_UNCONSTRAINEDSIZE);
|
||||
firstRowGroup = PR_TRUE;
|
||||
processingCaption = PR_FALSE;
|
||||
innerTableMaxSize.width=0;
|
||||
innerTableMaxSize.height=0;
|
||||
}
|
||||
|
||||
~OuterTableReflowState() {
|
||||
@@ -190,7 +192,6 @@ NS_METHOD nsTableOuterFrame::Reflow(nsIPresContext* aPresContext,
|
||||
PRBool reflowMappedOK = PR_TRUE;
|
||||
|
||||
aStatus = NS_FRAME_COMPLETE;
|
||||
nsSize innerTableMaxElementSize(0,0);
|
||||
|
||||
// Set up our kids. They're already present, on an overflow list,
|
||||
// or there are none so we'll create them now
|
||||
@@ -228,11 +229,7 @@ NS_METHOD nsTableOuterFrame::Reflow(nsIPresContext* aPresContext,
|
||||
mInnerTableFrame->SetReflowPass(nsTableFrame::kPASS_FIRST);
|
||||
nsReflowState innerTableReflowState(mInnerTableFrame, aReflowState, aReflowState.maxSize);
|
||||
aStatus = mInnerTableFrame->ResizeReflowPass1(aPresContext, aDesiredSize,
|
||||
innerTableReflowState,
|
||||
&innerTableMaxElementSize);
|
||||
|
||||
mInnerTableFrame->RecalcLayoutData();
|
||||
|
||||
innerTableReflowState);
|
||||
}
|
||||
mInnerTableFrame->SetReflowPass(nsTableFrame::kPASS_SECOND);
|
||||
// assign table width info only if the inner table frame is a first-in-flow
|
||||
@@ -249,7 +246,7 @@ NS_METHOD nsTableOuterFrame::Reflow(nsIPresContext* aPresContext,
|
||||
mInnerTableFrame->SetTableWidth(aPresContext);
|
||||
}
|
||||
// inner table max is now the computed width and assigned height
|
||||
nsSize innerTableSize;
|
||||
nsSize innerTableSize(0,0);
|
||||
|
||||
mInnerTableFrame->GetSize(innerTableSize);
|
||||
state.innerTableMaxSize.width = innerTableSize.width;
|
||||
@@ -443,12 +440,13 @@ PRBool nsTableOuterFrame::ReflowMappedChildren( nsIPresContext* aPresContex
|
||||
// PushChildren.
|
||||
PRBool originalLastContentIsComplete = mLastContentIsComplete;
|
||||
|
||||
nsSize kidMaxElementSize;
|
||||
nsSize kidMaxElementSize(0,0);
|
||||
nsSize* pKidMaxElementSize = (nsnull != aMaxElementSize) ? &kidMaxElementSize : nsnull;
|
||||
PRBool result = PR_TRUE;
|
||||
aState.availSize.width = aState.innerTableMaxSize.width;
|
||||
for (nsIFrame* kidFrame = mFirstChild; nsnull != kidFrame; ) {
|
||||
nsReflowMetrics kidSize(pKidMaxElementSize);
|
||||
kidSize.width=kidSize.height=kidSize.ascent=kidSize.descent=0;
|
||||
nsReflowStatus status;
|
||||
|
||||
SetReflowState(aState, kidFrame);
|
||||
@@ -653,7 +651,7 @@ PRBool nsTableOuterFrame::PullUpChildren( nsIPresContext* aPresContext,
|
||||
#endif
|
||||
#endif
|
||||
nsTableOuterFrame* nextInFlow = (nsTableOuterFrame*)mNextInFlow;
|
||||
nsSize kidMaxElementSize;
|
||||
nsSize kidMaxElementSize(0,0);
|
||||
nsSize* pKidMaxElementSize = (nsnull != aMaxElementSize) ? &kidMaxElementSize : nsnull;
|
||||
#ifdef NS_DEBUG
|
||||
PRInt32 kidIndex = NextChildOffset();
|
||||
@@ -673,6 +671,7 @@ PRBool nsTableOuterFrame::PullUpChildren( nsIPresContext* aPresContext,
|
||||
|
||||
while (nsnull != nextInFlow) {
|
||||
nsReflowMetrics kidSize(pKidMaxElementSize);
|
||||
kidSize.width=kidSize.height=kidSize.ascent=kidSize.descent=0;
|
||||
nsReflowStatus status;
|
||||
|
||||
// Get the next child
|
||||
@@ -697,7 +696,7 @@ PRBool nsTableOuterFrame::PullUpChildren( nsIPresContext* aPresContext,
|
||||
// See if the child fits in the available space. If it fits or
|
||||
// it's splittable then reflow it. The reason we can't just move
|
||||
// it is that we still need ascent/descent information
|
||||
nsSize kidFrameSize;
|
||||
nsSize kidFrameSize(0,0);
|
||||
nsSplittableType kidIsSplittable;
|
||||
|
||||
kidFrame->GetSize(kidFrameSize);
|
||||
@@ -918,8 +917,7 @@ nsTableOuterFrame::ReflowChild( nsIFrame* aKidFrame,
|
||||
{
|
||||
if (PR_TRUE==gsDebug) printf("reflowChild called with a table body\n");
|
||||
nsReflowState kidReflowState(aKidFrame, aState.reflowState, aState.innerTableMaxSize);
|
||||
status = ((nsTableFrame*)aKidFrame)->ResizeReflowPass2(aPresContext, aDesiredSize,
|
||||
kidReflowState, aMaxElementSize,
|
||||
status = ((nsTableFrame*)aKidFrame)->ResizeReflowPass2(aPresContext, aDesiredSize, kidReflowState,
|
||||
mMinCaptionWidth, mMaxCaptionWidth);
|
||||
}
|
||||
if (PR_TRUE==gsDebug)
|
||||
@@ -1034,16 +1032,17 @@ nsTableOuterFrame::ResizeReflowCaptionsPass1(nsIPresContext* aPresContext,
|
||||
{
|
||||
nsSize maxElementSize(0,0);
|
||||
nsSize maxSize(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
|
||||
nsReflowMetrics desiredSize(&maxElementSize);
|
||||
nsReflowMetrics kidSize(&maxElementSize);
|
||||
kidSize.width=kidSize.height=kidSize.ascent=kidSize.descent=0;
|
||||
nsTableCaptionFrame *captionFrame = (nsTableCaptionFrame *)mCaptionFrames->ElementAt(captionIndex);
|
||||
nsReflowStatus status;
|
||||
nsReflowState reflowState(captionFrame, aState.reflowState, maxSize, eReflowReason_Resize);
|
||||
captionFrame->WillReflow(*aPresContext);
|
||||
captionFrame->Reflow(aPresContext, desiredSize, reflowState, status);
|
||||
captionFrame->Reflow(aPresContext, kidSize, reflowState, status);
|
||||
if (mMinCaptionWidth<maxElementSize.width)
|
||||
mMinCaptionWidth = maxElementSize.width;
|
||||
if (mMaxCaptionWidth<desiredSize.width)
|
||||
mMaxCaptionWidth = desiredSize.width;
|
||||
if (mMaxCaptionWidth<kidSize.width)
|
||||
mMaxCaptionWidth = kidSize.width;
|
||||
captionFrame->VerticallyAlignChild(aPresContext);
|
||||
|
||||
}
|
||||
@@ -1087,6 +1086,7 @@ nsTableOuterFrame::ResizeReflowTopCaptionsPass2(nsIPresContext* aPresCont
|
||||
if (NS_FRAME_IS_COMPLETE(result))
|
||||
{
|
||||
nsReflowMetrics desiredSize(nsnull);
|
||||
desiredSize.width=desiredSize.height=desiredSize.ascent=desiredSize.descent=0;
|
||||
nsReflowState reflowState(captionFrame, aState.reflowState, aMaxSize, eReflowReason_Resize);
|
||||
captionFrame->WillReflow(*aPresContext);
|
||||
result = nsContainerFrame::ReflowChild(captionFrame, aPresContext, desiredSize, reflowState);
|
||||
@@ -1149,6 +1149,7 @@ nsTableOuterFrame::ResizeReflowBottomCaptionsPass2(nsIPresContext* aPresContext
|
||||
*/
|
||||
// reflow the caption
|
||||
nsReflowMetrics desiredSize(nsnull);
|
||||
desiredSize.width=desiredSize.height=desiredSize.ascent=desiredSize.descent=0;
|
||||
nsReflowState reflowState(captionFrame, aState.reflowState, aMaxSize, eReflowReason_Resize);
|
||||
captionFrame->WillReflow(*aPresContext);
|
||||
result = nsContainerFrame::ReflowChild(captionFrame, aPresContext, desiredSize, reflowState);
|
||||
|
||||
@@ -27,6 +27,9 @@
|
||||
#include "nsTableCell.h"
|
||||
#include "nsCellLayoutData.h"
|
||||
#include "nsIView.h"
|
||||
#include "nsIPtr.h"
|
||||
|
||||
NS_DEF_PTR(nsIStyleContext);
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
static PRBool gsDebug1 = PR_FALSE;
|
||||
@@ -234,6 +237,9 @@ void nsTableRowFrame::PlaceChild(nsIPresContext* aPresContext,
|
||||
// Place and size the child
|
||||
aKidFrame->SetRect(aKidRect);
|
||||
|
||||
// update the running total for the row width
|
||||
aState.x += aKidRect.width;
|
||||
|
||||
// Update the maximum element size
|
||||
PRInt32 rowSpan = ((nsTableCellFrame*)aKidFrame)->GetRowSpan();
|
||||
if (nsnull != aMaxElementSize)
|
||||
@@ -322,6 +328,7 @@ PRBool nsTableRowFrame::ReflowMappedChildren(nsIPresContext* aPresContext,
|
||||
kidAvailSize.height = 1; // XXX: HaCk - we don't handle negative heights yet
|
||||
|
||||
nsReflowMetrics desiredSize(pKidMaxElementSize);
|
||||
desiredSize.width=desiredSize.height=desiredSize.ascent=desiredSize.descent=0;
|
||||
nsReflowStatus status;
|
||||
|
||||
nsMargin kidMargin(0,0,0,0);
|
||||
@@ -370,20 +377,17 @@ PRBool nsTableRowFrame::ReflowMappedChildren(nsIPresContext* aPresContext,
|
||||
kidFrame->WillReflow(*aPresContext);
|
||||
status = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState);
|
||||
}
|
||||
if (nsnull!=pKidMaxElementSize)
|
||||
if (gsDebug1)
|
||||
{
|
||||
if (gsDebug1)
|
||||
{
|
||||
if (nsnull!=pKidMaxElementSize)
|
||||
printf("reflow of cell returned result = %s with desired=%d,%d, min = %d,%d\n",
|
||||
NS_FRAME_IS_COMPLETE(status)?"complete":"NOT complete",
|
||||
desiredSize.width, desiredSize.height,
|
||||
pKidMaxElementSize->width, pKidMaxElementSize->height);
|
||||
else
|
||||
printf("reflow of cell returned result = %s with desired=%d,%d, min = nsnull\n",
|
||||
NS_FRAME_IS_COMPLETE(status)?"complete":"NOT complete",
|
||||
desiredSize.width, desiredSize.height);
|
||||
}
|
||||
if (nsnull!=pKidMaxElementSize)
|
||||
printf("reflow of cell returned result = %s with desired=%d,%d, min = %d,%d\n",
|
||||
NS_FRAME_IS_COMPLETE(status)?"complete":"NOT complete",
|
||||
desiredSize.width, desiredSize.height,
|
||||
pKidMaxElementSize->width, pKidMaxElementSize->height);
|
||||
else
|
||||
printf("reflow of cell returned result = %s with desired=%d,%d, min = nsnull\n",
|
||||
NS_FRAME_IS_COMPLETE(status)?"complete":"NOT complete",
|
||||
desiredSize.width, desiredSize.height);
|
||||
}
|
||||
NS_RELEASE(content); // cell: REFCNT--
|
||||
cell = nsnull;
|
||||
@@ -413,8 +417,29 @@ PRBool nsTableRowFrame::ReflowMappedChildren(nsIPresContext* aPresContext,
|
||||
PRInt32 cellColIndex = ((nsTableCellFrame *)kidFrame)->GetColIndex();
|
||||
for (PRInt32 colIndex=0; colIndex<cellColIndex; colIndex++)
|
||||
aState.x += aState.tableFrame->GetColumnWidth(colIndex);
|
||||
// Place the child after taking into account it's margin
|
||||
nsRect kidRect (aState.x, kidMargin.top, desiredSize.width, desiredSize.height);
|
||||
// Place the child after taking into account it's margin and attributes
|
||||
nscoord specifiedHeight = 0;
|
||||
nscoord cellHeight = desiredSize.height;
|
||||
nsIStyleContextPtr kidSC;
|
||||
kidFrame->GetStyleContext(aPresContext, kidSC.AssignRef());
|
||||
nsStylePosition* kidPosition = (nsStylePosition*)
|
||||
kidSC->GetData(eStyleStruct_Position);
|
||||
switch (kidPosition->mHeight.GetUnit()) {
|
||||
case eStyleUnit_Coord:
|
||||
specifiedHeight = kidPosition->mHeight.GetCoordValue();
|
||||
break;
|
||||
case eStyleUnit_Percent:
|
||||
case eStyleUnit_Proportional:
|
||||
// XXX for now these fall through
|
||||
|
||||
default:
|
||||
case eStyleUnit_Auto:
|
||||
case eStyleUnit_Inherit:
|
||||
break;
|
||||
}
|
||||
if (specifiedHeight>cellHeight)
|
||||
cellHeight = specifiedHeight;
|
||||
nsRect kidRect (aState.x, kidMargin.top, desiredSize.width, cellHeight);
|
||||
PlaceChild(aPresContext, aState, kidFrame, kidRect, aMaxElementSize,
|
||||
kidMaxElementSize);
|
||||
if (kidMargin.bottom < 0)
|
||||
@@ -589,6 +614,7 @@ PRBool nsTableRowFrame::PullUpChildren(nsIPresContext* aPresContext,
|
||||
|
||||
while (nsnull != nextInFlow) {
|
||||
nsReflowMetrics desiredSize(pKidMaxElementSize);
|
||||
desiredSize.width=desiredSize.height=desiredSize.ascent=desiredSize.descent=0;
|
||||
nsReflowStatus status;
|
||||
|
||||
// Get the next child
|
||||
@@ -613,7 +639,7 @@ PRBool nsTableRowFrame::PullUpChildren(nsIPresContext* aPresContext,
|
||||
// See if the child fits in the available space. If it fits or
|
||||
// it's splittable then reflow it. The reason we can't just move
|
||||
// it is that we still need ascent/descent information
|
||||
nsSize kidFrameSize;
|
||||
nsSize kidFrameSize(0,0);
|
||||
nsSplittableType kidIsSplittable;
|
||||
|
||||
kidFrame->GetSize(kidFrameSize);
|
||||
@@ -841,7 +867,7 @@ nsTableRowFrame::ReflowUnmappedChildren( nsIPresContext* aPresContext,
|
||||
mLastContentIsComplete = PR_TRUE;
|
||||
|
||||
// Place our children, one at a time, until we are out of children
|
||||
nsSize kidMaxElementSize;
|
||||
nsSize kidMaxElementSize(0,0);
|
||||
nsSize* pKidMaxElementSize = (nsnull != aMaxElementSize) ? &kidMaxElementSize : nsnull;
|
||||
nsSize kidAvailSize(aState.availSize);
|
||||
PRInt32 kidIndex = NextChildOffset();
|
||||
@@ -901,6 +927,7 @@ nsTableRowFrame::ReflowUnmappedChildren( nsIPresContext* aPresContext,
|
||||
// Try to reflow the child into the available space. It might not
|
||||
// fit or might need continuing.
|
||||
nsReflowMetrics desiredSize(pKidMaxElementSize);
|
||||
desiredSize.width=desiredSize.height=desiredSize.ascent=desiredSize.descent=0;
|
||||
nsReflowStatus status;
|
||||
if (NS_UNCONSTRAINEDSIZE == aState.availSize.width)
|
||||
{
|
||||
@@ -1079,7 +1106,7 @@ nsTableRowFrame::Reflow(nsIPresContext* aPresContext,
|
||||
}
|
||||
|
||||
// Return our desired rect
|
||||
aDesiredSize.width = aReflowState.maxSize.width;
|
||||
aDesiredSize.width = state.x;
|
||||
aDesiredSize.height = state.maxCellVertSpace;
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
|
||||
@@ -273,6 +273,7 @@ PRBool nsTableRowGroupFrame::ReflowMappedChildren( nsIPresContext* aPresCon
|
||||
if (0>=kidAvailSize.height)
|
||||
kidAvailSize.height = 1; // XXX: HaCk - we don't handle negative heights yet
|
||||
nsReflowMetrics desiredSize(pKidMaxElementSize);
|
||||
desiredSize.width=desiredSize.height=desiredSize.ascent=desiredSize.descent=0;
|
||||
nsReflowStatus status;
|
||||
|
||||
// Get top margin for this kid
|
||||
@@ -501,6 +502,7 @@ PRBool nsTableRowGroupFrame::PullUpChildren(nsIPresContext* aPresContext,
|
||||
|
||||
while (nsnull != nextInFlow) {
|
||||
nsReflowMetrics kidSize(pKidMaxElementSize);
|
||||
kidSize.width=kidSize.height=kidSize.ascent=kidSize.descent=0;
|
||||
nsReflowStatus status;
|
||||
|
||||
// Get the next child
|
||||
@@ -766,6 +768,7 @@ nsTableRowGroupFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
|
||||
// Try to reflow the child into the available space. It might not
|
||||
// fit or might need continuing.
|
||||
nsReflowMetrics kidSize(pKidMaxElementSize);
|
||||
kidSize.width=kidSize.height=kidSize.ascent=kidSize.descent=0;
|
||||
nsReflowState kidReflowState(kidFrame, aState.reflowState, aState.availSize,
|
||||
eReflowReason_Initial);
|
||||
kidFrame->WillReflow(*aPresContext);
|
||||
|
||||
Reference in New Issue
Block a user