synch with branch

fixed the following bugs: 312653 312656 312655
the fixes were:

1. cells now inherit their bgcolor from the row, if available.  This is the
Nav4 way of drawing row bgcolor, rather than having the row paint its own bgcolor. (Troy, I intend to make this conditional
based on the compatibility mode)

2. colspans across cols that are all specified width no longer try to proportionately
divide the width of the span between the cols.  see http://www.city.net (now it's really fixed, without breaking nested tables in
constrained situations.)  A happy side effect is nested tables in general behave better when constrained.

3. min table sizes are fixed, so min width changes to content now effect the
table correctly during incremental reflow.  This fixes the table layout portion of the bugs on the http://www.aol.com/corp tree.
Rick will check in the other half of this fix soon.  Until then, don't expect to see much improvement.

4. fixed bug 312799.  Table cell now always reserve at least the maxElementSize
of its content, fixing problems when desiredSize<maxElementSize
This commit is contained in:
buster%netscape.com 1998-08-07 02:11:51 +00:00
parent a9f7a46342
commit 79c1b74a7a
12 changed files with 526 additions and 254 deletions

View File

@ -141,24 +141,31 @@ PRBool BasicTableLayoutStrategy::Initialize(nsSize* aMaxElementSize)
if (nsnull!=aMaxElementSize)
{
aMaxElementSize->height = 0;
nsMargin borderPadding;
const nsStylePosition* tablePosition;
const nsStyleSpacing* tableSpacing;
// begin REMOVE_ME_WHEN_TABLE_STYLE_IS_RESOLVED!
nsIFrame * parent = nsnull;
mTableFrame->GetGeometricParent(parent);
const nsStylePosition* tablePosition;
parent->GetStyleData(eStyleStruct_Position, ((nsStyleStruct *&)tablePosition));
parent->GetStyleData(eStyleStruct_Spacing , ((nsStyleStruct *&)tableSpacing));
// end REMOVE_ME_WHEN_TABLE_STYLE_IS_RESOLVED!
nsMargin borderPadding;
const nsStyleSpacing* spacing;
tableSpacing->CalcBorderPaddingFor(mTableFrame, borderPadding);
if (tablePosition->mWidth.GetUnit()==eStyleUnit_Coord)
{
aMaxElementSize->width = tablePosition->mWidth.GetCoordValue();
aMaxElementSize->width = PR_MAX(aMaxElementSize->width, mMinTableWidth);
//XXX: need to factor in borderpadding here!
}
else
aMaxElementSize->width = mMinTableWidth;
{
aMaxElementSize->width = mMinTableWidth + borderPadding.left + borderPadding.right;
}
if (PR_TRUE==gsDebug)
printf("BTLS::Init setting aMaxElementSize->width = %d\n", aMaxElementSize->width);
printf("%p BTLS::Init setting aMaxElementSize->width = %d\n",
mTableFrame, aMaxElementSize->width);
}
return result;
@ -469,95 +476,113 @@ PRBool BasicTableLayoutStrategy::AssignPreliminaryColumnWidths()
// to determine the proportion each column gets from spanners.
if (nsnull!=spanList)
{
for (PRInt32 colIndex=0; colIndex<mNumCols; colIndex++)
{
if (gsDebug) printf("handling span for %d\n", colIndex);
// we only want to do this if there are auto-cells involved
PRInt32 numAutoColumns=0;
PRInt32 *autoColumns=nsnull;
mTableFrame->GetColumnsByType(eStyleUnit_Auto, numAutoColumns, autoColumns);
if (0==numAutoColumns)
{ //table fully specified, so no need to do any extra work here
PRInt32 spanCount = spanList->Count();
// go through the list backwards so we can delete easily
for (PRInt32 spanIndex=spanCount-1; 0<=spanIndex; spanIndex--)
{
SpanInfo *spanInfo = (SpanInfo *)(spanList->ElementAt(spanIndex));
// if the spanInfo is about a column before the current column, it effects
// the current column (otherwise it would have already been deleted.)
if (spanInfo->initialColIndex <= colIndex)
spanList->RemoveElementAt(spanIndex);
delete spanInfo;
}
}
else
{
for (PRInt32 colIndex=0; colIndex<mNumCols; colIndex++)
{
if (gsDebug) printf("handling span for %d\n", colIndex);
PRInt32 spanCount = spanList->Count();
// go through the list backwards so we can delete easily
for (PRInt32 spanIndex=spanCount-1; 0<=spanIndex; spanIndex--)
{
if (0==spanInfo->effectiveMaxWidthOfSpannedCols)
SpanInfo *spanInfo = (SpanInfo *)(spanList->ElementAt(spanIndex));
// if the spanInfo is about a column before the current column, it effects
// the current column (otherwise it would have already been deleted.)
if (spanInfo->initialColIndex <= colIndex)
{
for (PRInt32 span=0; span<spanInfo->initialColSpan; span++)
if (0==spanInfo->effectiveMaxWidthOfSpannedCols)
{
nsTableColFrame *nextColFrame = mTableFrame->GetColFrame(colIndex+span);
if (nsnull==nextColFrame)
break;
spanInfo->effectiveMaxWidthOfSpannedCols += nextColFrame->GetEffectiveMaxColWidth();
spanInfo->effectiveMinWidthOfSpannedCols += nextColFrame->GetEffectiveMinColWidth();
}
if (gsDebug) printf("effective min total = %d, max total = %d\n",
spanInfo->effectiveMinWidthOfSpannedCols, spanInfo->effectiveMaxWidthOfSpannedCols);
}
nsTableColFrame *colFrame = mTableFrame->GetColFrame(colIndex);
nscoord colMinWidth = colFrame->GetMinColWidth();
// compute the spanning cell's contribution to the column min width
// this is the "adjusted" column width, used in SetTableToMinWidth
nscoord spanCellMinWidth;
if (0!=spanInfo->effectiveMinWidthOfSpannedCols)
{
spanCellMinWidth = (spanInfo->cellMinWidth * colFrame->GetEffectiveMinColWidth()) /
(spanInfo->effectiveMinWidthOfSpannedCols);
if (gsDebug==PR_TRUE)
printf ("spanCellMinWidth portion = %d \n", spanCellMinWidth);
if (colMinWidth < spanCellMinWidth)
colFrame->SetAdjustedMinColWidth(spanCellMinWidth); // set the new min width for the col
}
else
{
if (colMinWidth < spanCellMinWidth)
{
spanCellMinWidth = spanInfo->cellMinWidth/spanInfo->initialColSpan;
colFrame->SetAdjustedMinColWidth(spanCellMinWidth);
}
}
// compute the spanning cell's contribution to the column max width
nscoord colMaxWidth = colFrame->GetMaxColWidth();
nscoord spanCellMaxWidth;
if (0!=spanInfo->effectiveMaxWidthOfSpannedCols)
{
spanCellMaxWidth = (spanInfo->cellDesiredWidth * colFrame->GetEffectiveMaxColWidth()) /
(spanInfo->effectiveMaxWidthOfSpannedCols);
if (gsDebug==PR_TRUE)
printf ("spanCellMaxWidth portion = %d\n", spanCellMaxWidth);
if (colMaxWidth < spanCellMaxWidth)
{
// make sure we're at least as big as our min
spanCellMaxWidth = PR_MAX(spanCellMaxWidth, colMinWidth);
colFrame->SetMaxColWidth(spanCellMaxWidth); // set the new max width for the col
mTableFrame->SetColumnWidth(colIndex, spanCellMaxWidth); // set the column to the new desired max width
if (gsDebug==PR_TRUE)
for (PRInt32 span=0; span<spanInfo->initialColSpan; span++)
{
printf ("for spanning cell into col %d with remaining span=%d, old max = %d, new max = %d\n",
colIndex, spanInfo->span, colMaxWidth, spanCellMaxWidth);
nsTableColFrame *nextColFrame = mTableFrame->GetColFrame(colIndex+span);
if (nsnull==nextColFrame)
break;
spanInfo->effectiveMaxWidthOfSpannedCols += nextColFrame->GetEffectiveMaxColWidth();
spanInfo->effectiveMinWidthOfSpannedCols += nextColFrame->GetEffectiveMinColWidth();
}
if (gsDebug) printf("effective min total = %d, max total = %d\n",
spanInfo->effectiveMinWidthOfSpannedCols, spanInfo->effectiveMaxWidthOfSpannedCols);
}
nsTableColFrame *colFrame = mTableFrame->GetColFrame(colIndex);
nscoord colMinWidth = colFrame->GetMinColWidth();
// compute the spanning cell's contribution to the column min width
// this is the "adjusted" column width, used in SetTableToMinWidth
nscoord spanCellMinWidth;
if (0!=spanInfo->effectiveMinWidthOfSpannedCols)
{
spanCellMinWidth = (spanInfo->cellMinWidth * colFrame->GetEffectiveMinColWidth()) /
(spanInfo->effectiveMinWidthOfSpannedCols);
if (gsDebug==PR_TRUE)
printf ("spanCellMinWidth portion = %d \n", spanCellMinWidth);
if (colMinWidth < spanCellMinWidth)
colFrame->SetAdjustedMinColWidth(spanCellMinWidth); // set the new min width for the col
}
else
{
if (colMinWidth < spanCellMinWidth)
{
spanCellMinWidth = spanInfo->cellMinWidth/spanInfo->initialColSpan;
colFrame->SetAdjustedMinColWidth(spanCellMinWidth);
}
}
}
else
{
spanCellMaxWidth = spanInfo->cellDesiredWidth/spanInfo->initialColSpan;
nscoord minColWidth = colFrame->GetMinColWidth();
spanCellMaxWidth = PR_MAX(spanCellMaxWidth, minColWidth);
colFrame->SetMaxColWidth(spanCellMaxWidth);
mTableFrame->SetColumnWidth(colIndex, spanCellMaxWidth);
if (gsDebug==PR_TRUE)
printf (" for spanning cell into col %d with remaining span=%d, old max = %d, new max = %d\n",
colIndex, spanInfo->span, colMaxWidth, spanCellMaxWidth);
}
spanInfo->span--;
if (0==spanInfo->span)
{
spanList->RemoveElementAt(spanIndex);
delete spanInfo;
// compute the spanning cell's contribution to the column max width
nscoord colMaxWidth = colFrame->GetMaxColWidth();
nscoord spanCellMaxWidth;
if (0!=spanInfo->effectiveMaxWidthOfSpannedCols)
{
spanCellMaxWidth = (spanInfo->cellDesiredWidth * colFrame->GetEffectiveMaxColWidth()) /
(spanInfo->effectiveMaxWidthOfSpannedCols);
if (gsDebug==PR_TRUE)
printf ("spanCellMaxWidth portion = %d\n", spanCellMaxWidth);
if (colMaxWidth < spanCellMaxWidth)
{
// make sure we're at least as big as our min
spanCellMaxWidth = PR_MAX(spanCellMaxWidth, colMinWidth);
colFrame->SetMaxColWidth(spanCellMaxWidth); // set the new max width for the col
mTableFrame->SetColumnWidth(colIndex, spanCellMaxWidth); // set the column to the new desired max width
if (gsDebug==PR_TRUE)
{
printf ("for spanning cell into col %d with remaining span=%d, old max = %d, new max = %d\n",
colIndex, spanInfo->span, colMaxWidth, spanCellMaxWidth);
}
}
}
else
{
spanCellMaxWidth = spanInfo->cellDesiredWidth/spanInfo->initialColSpan;
nscoord minColWidth = colFrame->GetMinColWidth();
spanCellMaxWidth = PR_MAX(spanCellMaxWidth, minColWidth);
colFrame->SetMaxColWidth(spanCellMaxWidth);
mTableFrame->SetColumnWidth(colIndex, spanCellMaxWidth);
if (gsDebug==PR_TRUE)
printf (" for spanning cell into col %d with remaining span=%d, old max = %d, new max = %d\n",
colIndex, spanInfo->span, colMaxWidth, spanCellMaxWidth);
}
spanInfo->span--;
if (0==spanInfo->span)
{
spanList->RemoveElementAt(spanIndex);
delete spanInfo;
}
}
}
}

View File

@ -44,7 +44,7 @@ CPPSRCS = \
MODULE = raptor
REQUIRES = xpcom raptor dom js
REQUIRES = xpcom raptor dom js netlib
INCLUDES += -I../../base/src -I../../style/src -I../../../base/src

View File

@ -48,7 +48,7 @@ CPP_OBJS= .\$(OBJDIR)\nsCellMap.obj \
LINCS=-I$(XPDIST)\public\xpcom -I$(XPDIST)\public\raptor \
-I..\..\base\src -I..\..\style\src \
-I..\..\..\base\src \
-I$(PUBLIC)\dom -I$(PUBLIC)\js
-I$(PUBLIC)\dom -I$(PUBLIC)\js -I$(PUBLIC)\netlib
LCFLAGS = \
$(LCFLAGS) \

View File

@ -21,6 +21,8 @@
#include "nsIStyleContext.h"
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
#include "nsIDocument.h"
#include "nsIURL.h"
#include "nsHTMLIIDs.h"
#include "nsHTMLAtoms.h"
#include "nsIPtr.h"
@ -364,6 +366,152 @@ void nsTableCell::MapAttributesInto(nsIStyleContext* aContext,
}
}
void
nsTableCell::MapBackgroundAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
nsHTMLValue value;
nsStyleColor* color=nsnull;
// background
if (eContentAttr_HasValue == GetAttribute(nsHTMLAtoms::background, value)) {
if (eHTMLUnit_String == value.GetUnit()) {
color = (nsStyleColor*)aContext->GetMutableStyleData(eStyleStruct_Color);
SetBackgroundFromAttribute(color, &value);
}
}
// otherwise check the row for background and inherit it
else
{
if (nsnull!=mRow)
{
// TODO: optimize by putting a flag on the row to say whether background attr is set
mRow->GetAttribute(nsHTMLAtoms::background, value);
if (value.GetUnit() == eHTMLUnit_String)
{
nsString rowBackground;
value.GetStringValue(rowBackground);
if (nsnull==color)
color = (nsStyleColor*)aContext->GetMutableStyleData(eStyleStruct_Color);
SetBackgroundFromAttribute(color, &value);
}
else
{ // we need to check the row group as well
nsTableRowGroup *rowGroup = mRow->GetRowGroup();
if (nsnull!=rowGroup)
{
rowGroup->GetAttribute(nsHTMLAtoms::background, value);
if (value.GetUnit() == eHTMLUnit_String)
{
nsString rowBackground;
value.GetStringValue(rowBackground);
if (nsnull==color)
color = (nsStyleColor*)aContext->GetMutableStyleData(eStyleStruct_Color);
SetBackgroundFromAttribute(color, &value);
}
}
}
}
}
// bgcolor
if (eContentAttr_HasValue == GetAttribute(nsHTMLAtoms::bgcolor, value)) {
if (eHTMLUnit_Color == value.GetUnit()) {
if (nsnull==color)
color = (nsStyleColor*)aContext->GetMutableStyleData(eStyleStruct_Color);
color->mBackgroundColor = value.GetColorValue();
color->mBackgroundFlags &= ~NS_STYLE_BG_COLOR_TRANSPARENT;
}
else if (eHTMLUnit_String == value.GetUnit()) {
nsAutoString buffer;
value.GetStringValue(buffer);
char cbuf[40];
buffer.ToCString(cbuf, sizeof(cbuf));
if (nsnull==color)
color = (nsStyleColor*)aContext->GetMutableStyleData(eStyleStruct_Color);
NS_ColorNameToRGB(cbuf, &(color->mBackgroundColor));
color->mBackgroundFlags &= ~NS_STYLE_BG_COLOR_TRANSPARENT;
}
}
// otherwise check the row for background and inherit it
else
{
if (nsnull!=mRow)
{
// TODO: optimize by putting a flag on the row to say whether bgcolor attr is set
if (eContentAttr_HasValue == mRow->GetAttribute(nsHTMLAtoms::bgcolor, value))
{
if (eHTMLUnit_Color == value.GetUnit()) {
if (nsnull==color)
color = (nsStyleColor*)aContext->GetMutableStyleData(eStyleStruct_Color);
color->mBackgroundColor = value.GetColorValue();
color->mBackgroundFlags &= ~NS_STYLE_BG_COLOR_TRANSPARENT;
}
else if (eHTMLUnit_String == value.GetUnit()) {
nsAutoString buffer;
value.GetStringValue(buffer);
char cbuf[40];
buffer.ToCString(cbuf, sizeof(cbuf));
if (nsnull==color)
color = (nsStyleColor*)aContext->GetMutableStyleData(eStyleStruct_Color);
NS_ColorNameToRGB(cbuf, &(color->mBackgroundColor));
color->mBackgroundFlags &= ~NS_STYLE_BG_COLOR_TRANSPARENT;
}
}
else
{ // we need to check the row group as well
nsTableRowGroup *rowGroup = mRow->GetRowGroup();
if (nsnull!=rowGroup)
{
if (eContentAttr_HasValue == rowGroup->GetAttribute(nsHTMLAtoms::bgcolor, value)) {
if (eHTMLUnit_Color == value.GetUnit()) {
if (nsnull==color)
color = (nsStyleColor*)aContext->GetMutableStyleData(eStyleStruct_Color);
color->mBackgroundColor = value.GetColorValue();
color->mBackgroundFlags &= ~NS_STYLE_BG_COLOR_TRANSPARENT;
}
else if (eHTMLUnit_String == value.GetUnit()) {
nsAutoString buffer;
value.GetStringValue(buffer);
char cbuf[40];
buffer.ToCString(cbuf, sizeof(cbuf));
if (nsnull==color)
color = (nsStyleColor*)aContext->GetMutableStyleData(eStyleStruct_Color);
NS_ColorNameToRGB(cbuf, &(color->mBackgroundColor));
color->mBackgroundFlags &= ~NS_STYLE_BG_COLOR_TRANSPARENT;
}
}
}
}
}
}
}
void nsTableCell::SetBackgroundFromAttribute(nsStyleColor *aColor, nsHTMLValue *aValue)
{
NS_ASSERTION(nsnull!=aColor && nsnull!=aValue, "bad args");
// Resolve url to an absolute url
nsIURL* docURL = nsnull;
nsIDocument* doc = mDocument;
if (nsnull != doc) {
docURL = doc->GetDocumentURL();
}
nsAutoString absURLSpec;
nsAutoString spec;
aValue->GetStringValue(spec);
nsresult rv = NS_MakeAbsoluteURL(docURL, "", spec, absURLSpec);
if (nsnull != docURL) {
NS_RELEASE(docURL);
}
aColor->mBackgroundImage = absURLSpec;
aColor->mBackgroundFlags &= ~NS_STYLE_BG_IMAGE_NONE;
aColor->mBackgroundRepeat = NS_STYLE_BG_REPEAT_XY;
}
nsContentAttr
nsTableCell::AttributeToString(nsIAtom* aAttribute,
nsHTMLValue& aValue,

View File

@ -23,6 +23,9 @@
#include "nsTableContent.h"
#include "nsTableRow.h"
// forward declarations
struct nsStyleColor;
/**
* nsTableCell is the content object that represents table cells
* (HTML tags TD and TH). This class cannot be reused
@ -94,6 +97,11 @@ public:
virtual void MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext);
virtual void MapBackgroundAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext);
void SetBackgroundFromAttribute(nsStyleColor *aColor, nsHTMLValue *aValue);
/** @return the number of rows spanned by this cell. Always >= 1 */

View File

@ -1689,6 +1689,24 @@ void nsTableFrame::PlaceChild(nsIPresContext* aPresContext,
}
}
}
if (nsnull != aMaxElementSize)
{
nsMargin borderPadding;
const nsStyleSpacing* tableSpacing;
// begin REMOVE_ME_WHEN_TABLE_STYLE_IS_RESOLVED!
nsIFrame * parent = nsnull;
GetGeometricParent(parent);
parent->GetStyleData(eStyleStruct_Spacing , ((nsStyleStruct *&)tableSpacing));
// end REMOVE_ME_WHEN_TABLE_STYLE_IS_RESOLVED!
tableSpacing->CalcBorderPaddingFor(this, borderPadding);
nscoord cellSpacing = GetCellSpacing();
nscoord kidWidth = aKidMaxElementSize.width + borderPadding.left + borderPadding.right + cellSpacing*2;
aMaxElementSize->width = PR_MAX(aMaxElementSize->width, kidWidth);
aMaxElementSize->height += aKidMaxElementSize.height;
if (gsDebug)
printf("%p placeChild set MES->width to %d\n",
this, aMaxElementSize->width);
}
}
/**
@ -2354,26 +2372,7 @@ void nsTableFrame::BalanceColumnWidths(nsIPresContext* aPresContext,
break;
}
// if we think we're UNCONSTRAINED, find the max width of an ancestor via reflow state
/*
if (NS_UNCONSTRAINEDSIZE==maxWidth)
{
//maxWidth = GetTableContainerWidth(aReflowState);
const nsReflowState* rs = &aReflowState;
while (nsnull != rs)
{
if (NS_UNCONSTRAINEDSIZE!=rs->maxSize.width)
{
maxWidth = rs->maxSize.width;
break;
}
rs = rs->parentReflowState;
}
NS_ASSERTION(NS_UNCONSTRAINEDSIZE!=maxWidth, "illegal max width");
}
*/
// now we know we're not UNCONSTRAINED, so subtract out table border and padding
maxWidth -= borderPadding.left + borderPadding.right;
if (0>maxWidth) // nonsense style specification
maxWidth = 0;

View File

@ -33,11 +33,11 @@
NS_DEF_PTR(nsIStyleContext);
#ifdef NS_DEBUG
static PRBool gsDebug1 = PR_FALSE;
static PRBool gsDebug = PR_FALSE;
//#define NOISY
//#define NOISY_FLOW
#else
static const PRBool gsDebug1 = PR_FALSE;
static const PRBool gsDebug = PR_FALSE;
#endif
/* ----------- RowReflowState ---------- */
@ -150,6 +150,7 @@ NS_METHOD nsTableRowFrame::Paint(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect)
{
/*
const nsStyleColor* myColor =
(const nsStyleColor*)mStyleContext->GetStyleData(eStyleStruct_Color);
if (nsnull != myColor) {
@ -157,6 +158,7 @@ NS_METHOD nsTableRowFrame::Paint(nsIPresContext& aPresContext,
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *myColor);
}
*/
PaintChildren(aPresContext, aRenderingContext, aDirtyRect);
return NS_OK;
@ -278,7 +280,7 @@ void nsTableRowFrame::PlaceChild(nsIPresContext& aPresContext,
nsSize* aMaxElementSize,
nsSize* aKidMaxElementSize)
{
if (PR_TRUE==gsDebug1)
if (PR_TRUE==gsDebug)
printf ("row: placing cell at %d, %d, %d, %d\n",
aKidRect.x, aKidRect.y, aKidRect.width, aKidRect.height);
@ -337,7 +339,7 @@ nsresult nsTableRowFrame::ResizeReflow(nsIPresContext& aPresContext,
nscoord maxCellTopMargin = 0;
nscoord maxCellBottomMargin = 0;
nscoord cellSpacing = aState.tableFrame->GetCellSpacing();
if (PR_TRUE==gsDebug1) printf("%p: RR\n", this);
if (PR_TRUE==gsDebug) printf("%p: RR\n", this);
// Reflow each of our existing cell frames
for (nsIFrame* kidFrame = mFirstChild; nsnull != kidFrame; )
{
@ -357,13 +359,13 @@ nsresult nsTableRowFrame::ResizeReflow(nsIPresContext& aPresContext,
{
aState.x += aState.tableFrame->GetColumnWidth(colIndex);
aState.x += cellSpacing;
if (PR_TRUE==gsDebug1)
if (PR_TRUE==gsDebug)
printf(" in loop, aState.x set to %d from cellSpacing %d and col width\n",
aState.x, aState.tableFrame->GetColumnWidth(colIndex), cellSpacing);
}
}
aState.x += cellSpacing;
if (PR_TRUE==gsDebug1) printf(" past loop, aState.x set to %d\n", aState.x);
if (PR_TRUE==gsDebug) printf(" past loop, aState.x set to %d\n", aState.x);
// at this point, we know the column widths.
// so we get the avail width from the known column widths
@ -377,11 +379,11 @@ nsresult nsTableRowFrame::ResizeReflow(nsIPresContext& aPresContext,
{
availWidth += cellSpacing;
}
if (PR_TRUE==gsDebug1)
if (PR_TRUE==gsDebug)
printf(" in loop, availWidth set to %d from colIndex %d width %d and cellSpacing\n",
availWidth, cellColIndex, aState.tableFrame->GetColumnWidth(cellColIndex+numColSpan), cellSpacing);
}
if (PR_TRUE==gsDebug1) printf(" availWidth for this cell is %d\n", availWidth);
if (PR_TRUE==gsDebug) printf(" availWidth for this cell is %d\n", availWidth);
prevColIndex = cellColIndex + (cellColSpan-1); // remember the rightmost column this cell spans into
@ -409,13 +411,13 @@ nsresult nsTableRowFrame::ResizeReflow(nsIPresContext& aPresContext,
kidFrame->MoveTo(aState.x, kidMargin.top);
nsReflowState kidReflowState(kidFrame, aState.reflowState, kidAvailSize,
eReflowReason_Resize);
if (gsDebug1) printf ("%p RR: avail=%d\n", this, availWidth);
if (gsDebug) printf ("%p RR: avail=%d\n", this, availWidth);
nsReflowStatus status = ReflowChild(kidFrame, &aPresContext, desiredSize,
kidReflowState);
if (gsDebug1) printf ("%p RR: desired=%d\n", this, desiredSize.width);
if (gsDebug) printf ("%p RR: desired=%d\n", this, desiredSize.width);
NS_ASSERTION(NS_FRAME_IS_COMPLETE(status), "unexpected reflow status");
if (gsDebug1)
if (gsDebug)
{
if (nsnull!=pKidMaxElementSize)
printf("reflow of cell returned result = %s with desired=%d,%d, min = %d,%d\n",
@ -470,7 +472,7 @@ nsresult nsTableRowFrame::ResizeReflow(nsIPresContext& aPresContext,
PlaceChild(aPresContext, aState, kidFrame, kidRect, aDesiredSize.maxElementSize,
pKidMaxElementSize);
if (PR_TRUE==gsDebug1) printf(" past PlaceChild, aState.x set to %d\n", aState.x);
if (PR_TRUE==gsDebug) printf(" past PlaceChild, aState.x set to %d\n", aState.x);
// Get the next child
kidFrame->GetNextSibling(kidFrame);
@ -483,6 +485,10 @@ nsresult nsTableRowFrame::ResizeReflow(nsIPresContext& aPresContext,
aDesiredSize.width = aState.x;
aDesiredSize.height = aState.maxCellVertSpace;
if (gsDebug)
printf("rr -- row %p width = %d from maxSize %d\n",
this, aDesiredSize.width, aState.reflowState.maxSize.width);
return NS_OK;
}
@ -573,16 +579,22 @@ nsTableRowFrame::InitialReflow(nsIPresContext& aPresContext,
nsReflowStatus status;
kidFrame->WillReflow(aPresContext);
if (gsDebug1) printf ("%p InitR: avail=%d\n", this, kidAvailSize.width);
if (gsDebug) printf ("%p InitR: avail=%d\n", this, kidAvailSize.width);
status = ReflowChild(kidFrame, &aPresContext, kidSize, kidReflowState);
if (gsDebug1)
if (gsDebug)
printf ("TR %p for cell %p Initial Reflow: desired=%d, MES=%d\n",
this, kidFrame, kidSize.width, kidMaxElementSize.width);
//XXX: this is a hack, shouldn't it be the case that a min size is
// never larger than a desired size?
if (kidMaxElementSize.width>kidSize.width)
kidSize.width = kidMaxElementSize.width;
if (kidMaxElementSize.height>kidSize.height)
kidSize.height = kidMaxElementSize.height;
((nsTableCellFrame *)kidFrame)->SetPass1DesiredSize(kidSize);
((nsTableCellFrame *)kidFrame)->SetPass1MaxElementSize(kidMaxElementSize);
NS_ASSERTION(NS_FRAME_IS_COMPLETE(status), "unexpected child reflow status");
if (gsDebug1)
if (gsDebug)
{
printf("reflow of cell returned result = %s with desired=%d,%d, min = %d,%d\n",
NS_FRAME_IS_COMPLETE(status)?"complete":"NOT complete",
@ -608,6 +620,11 @@ nsTableRowFrame::InitialReflow(nsIPresContext& aPresContext,
aDesiredSize.width = x;
aDesiredSize.height = aState.maxCellVertSpace;
if (gsDebug)
printf("initial -- row %p width = %d MES=%d from maxSize %d\n",
this, aDesiredSize.width, aDesiredSize.maxElementSize->width,
aState.reflowState.maxSize.width);
// Update the content mapping
if (nsnull != prevKidFrame) {
SetLastContentOffset(kidIndex - 1);
@ -785,10 +802,16 @@ nsresult nsTableRowFrame::IncrementalReflow(nsIPresContext& aPresContext,
kidReflowState.reflowCommand = nsnull;
kidReflowState.maxSize.width = NS_UNCONSTRAINEDSIZE;
status = ReflowChild(kidFrame, &aPresContext, desiredSize, kidReflowState);
if (gsDebug1)
if (gsDebug)
printf ("TR %p for cell %p Incremental Reflow: desired=%d, MES=%d\n",
this, kidFrame, desiredSize.width, kidMaxElementSize.width);
// Update the cell layout data.
//XXX: this is a hack, shouldn't it be the case that a min size is
// never larger than a desired size?
if (kidMaxElementSize.width>desiredSize.width)
desiredSize.width = kidMaxElementSize.width;
if (kidMaxElementSize.height>desiredSize.height)
desiredSize.height = kidMaxElementSize.height;
((nsTableCellFrame *)kidFrame)->SetPass1DesiredSize(desiredSize);
((nsTableCellFrame *)kidFrame)->SetPass1MaxElementSize(kidMaxElementSize);
@ -842,6 +865,11 @@ nsresult nsTableRowFrame::IncrementalReflow(nsIPresContext& aPresContext,
aDesiredSize.width = aState.availSize.width;
aDesiredSize.height = aState.maxCellVertSpace;
if (gsDebug)
printf("incr -- row %p width = %d MES=%d from maxSize %d\n",
this, aDesiredSize.width, aDesiredSize.maxElementSize->width,
aState.reflowState.maxSize.width);
return status;
}
@ -854,7 +882,7 @@ nsTableRowFrame::Reflow(nsIPresContext& aPresContext,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus)
{
if (gsDebug1==PR_TRUE)
if (gsDebug==PR_TRUE)
printf("nsTableRowFrame::Reflow - aMaxSize = %d, %d\n",
aReflowState.maxSize.width, aReflowState.maxSize.height);
#ifdef NS_DEBUG
@ -901,7 +929,7 @@ nsTableRowFrame::Reflow(nsIPresContext& aPresContext,
PostReflowCheck(aStatus);
#endif
if (gsDebug1==PR_TRUE)
if (gsDebug==PR_TRUE)
{
if (nsnull!=aDesiredSize.maxElementSize)
printf("nsTableRowFrame::RR returning: %s with aDesiredSize=%d,%d, aMES=%d,%d\n",

View File

@ -194,8 +194,8 @@ void nsTableRowGroupFrame::PlaceChild( nsIPresContext* aPresContext,
nsSize& aKidMaxElementSize)
{
if (PR_TRUE==gsDebug)
printf ("rowgroup: placing row at %d, %d, %d, %d\n",
aKidRect.x, aKidRect.y, aKidRect.width, aKidRect.height);
printf ("rowgroup %p: placing row at %d, %d, %d, %d\n",
this, aKidRect.x, aKidRect.y, aKidRect.width, aKidRect.height);
// Place and size the child
aKidFrame->SetRect(aKidRect);
@ -218,6 +218,12 @@ void nsTableRowGroupFrame::PlaceChild( nsIPresContext* aPresContext,
aMaxElementSize->height = aKidMaxElementSize.height;
}
}
else if (nsnull != aMaxElementSize) {
aMaxElementSize->width = PR_MAX(aMaxElementSize->width, aKidMaxElementSize.width);
}
if (gsDebug && nsnull != aMaxElementSize)
printf ("rowgroup %p: placing row %p with width = %d and MES= %d\n",
this, aKidFrame, aKidRect.width, aMaxElementSize->width);
}
/**
@ -1156,13 +1162,13 @@ nsTableRowGroupFrame::Reflow(nsIPresContext& aPresContext,
if (gsDebug==PR_TRUE)
{
if (nsnull!=aDesiredSize.maxElementSize)
printf("nsTableRowGroupFrame::RR returning: %s with aDesiredSize=%d,%d, aMES=%d,%d\n",
NS_FRAME_IS_COMPLETE(aStatus)?"Complete":"Not Complete",
printf("nsTableRowGroupFrame %p returning: %s with aDesiredSize=%d,%d, aMES=%d,%d\n",
this, NS_FRAME_IS_COMPLETE(aStatus)?"Complete":"Not Complete",
aDesiredSize.width, aDesiredSize.height,
aDesiredSize.maxElementSize->width, aDesiredSize.maxElementSize->height);
else
printf("nsTableRowGroupFrame::RR returning: %s with aDesiredSize=%d,%d, aMES=NSNULL\n",
NS_FRAME_IS_COMPLETE(aStatus)?"Complete":"Not Complete",
printf("nsTableRowGroupFrame %p returning: %s with aDesiredSize=%d,%d, aMES=NSNULL\n",
this, NS_FRAME_IS_COMPLETE(aStatus)?"Complete":"Not Complete",
aDesiredSize.width, aDesiredSize.height);
}

View File

@ -141,24 +141,31 @@ PRBool BasicTableLayoutStrategy::Initialize(nsSize* aMaxElementSize)
if (nsnull!=aMaxElementSize)
{
aMaxElementSize->height = 0;
nsMargin borderPadding;
const nsStylePosition* tablePosition;
const nsStyleSpacing* tableSpacing;
// begin REMOVE_ME_WHEN_TABLE_STYLE_IS_RESOLVED!
nsIFrame * parent = nsnull;
mTableFrame->GetGeometricParent(parent);
const nsStylePosition* tablePosition;
parent->GetStyleData(eStyleStruct_Position, ((nsStyleStruct *&)tablePosition));
parent->GetStyleData(eStyleStruct_Spacing , ((nsStyleStruct *&)tableSpacing));
// end REMOVE_ME_WHEN_TABLE_STYLE_IS_RESOLVED!
nsMargin borderPadding;
const nsStyleSpacing* spacing;
tableSpacing->CalcBorderPaddingFor(mTableFrame, borderPadding);
if (tablePosition->mWidth.GetUnit()==eStyleUnit_Coord)
{
aMaxElementSize->width = tablePosition->mWidth.GetCoordValue();
aMaxElementSize->width = PR_MAX(aMaxElementSize->width, mMinTableWidth);
//XXX: need to factor in borderpadding here!
}
else
aMaxElementSize->width = mMinTableWidth;
{
aMaxElementSize->width = mMinTableWidth + borderPadding.left + borderPadding.right;
}
if (PR_TRUE==gsDebug)
printf("BTLS::Init setting aMaxElementSize->width = %d\n", aMaxElementSize->width);
printf("%p BTLS::Init setting aMaxElementSize->width = %d\n",
mTableFrame, aMaxElementSize->width);
}
return result;
@ -469,95 +476,113 @@ PRBool BasicTableLayoutStrategy::AssignPreliminaryColumnWidths()
// to determine the proportion each column gets from spanners.
if (nsnull!=spanList)
{
for (PRInt32 colIndex=0; colIndex<mNumCols; colIndex++)
{
if (gsDebug) printf("handling span for %d\n", colIndex);
// we only want to do this if there are auto-cells involved
PRInt32 numAutoColumns=0;
PRInt32 *autoColumns=nsnull;
mTableFrame->GetColumnsByType(eStyleUnit_Auto, numAutoColumns, autoColumns);
if (0==numAutoColumns)
{ //table fully specified, so no need to do any extra work here
PRInt32 spanCount = spanList->Count();
// go through the list backwards so we can delete easily
for (PRInt32 spanIndex=spanCount-1; 0<=spanIndex; spanIndex--)
{
SpanInfo *spanInfo = (SpanInfo *)(spanList->ElementAt(spanIndex));
// if the spanInfo is about a column before the current column, it effects
// the current column (otherwise it would have already been deleted.)
if (spanInfo->initialColIndex <= colIndex)
spanList->RemoveElementAt(spanIndex);
delete spanInfo;
}
}
else
{
for (PRInt32 colIndex=0; colIndex<mNumCols; colIndex++)
{
if (gsDebug) printf("handling span for %d\n", colIndex);
PRInt32 spanCount = spanList->Count();
// go through the list backwards so we can delete easily
for (PRInt32 spanIndex=spanCount-1; 0<=spanIndex; spanIndex--)
{
if (0==spanInfo->effectiveMaxWidthOfSpannedCols)
SpanInfo *spanInfo = (SpanInfo *)(spanList->ElementAt(spanIndex));
// if the spanInfo is about a column before the current column, it effects
// the current column (otherwise it would have already been deleted.)
if (spanInfo->initialColIndex <= colIndex)
{
for (PRInt32 span=0; span<spanInfo->initialColSpan; span++)
if (0==spanInfo->effectiveMaxWidthOfSpannedCols)
{
nsTableColFrame *nextColFrame = mTableFrame->GetColFrame(colIndex+span);
if (nsnull==nextColFrame)
break;
spanInfo->effectiveMaxWidthOfSpannedCols += nextColFrame->GetEffectiveMaxColWidth();
spanInfo->effectiveMinWidthOfSpannedCols += nextColFrame->GetEffectiveMinColWidth();
}
if (gsDebug) printf("effective min total = %d, max total = %d\n",
spanInfo->effectiveMinWidthOfSpannedCols, spanInfo->effectiveMaxWidthOfSpannedCols);
}
nsTableColFrame *colFrame = mTableFrame->GetColFrame(colIndex);
nscoord colMinWidth = colFrame->GetMinColWidth();
// compute the spanning cell's contribution to the column min width
// this is the "adjusted" column width, used in SetTableToMinWidth
nscoord spanCellMinWidth;
if (0!=spanInfo->effectiveMinWidthOfSpannedCols)
{
spanCellMinWidth = (spanInfo->cellMinWidth * colFrame->GetEffectiveMinColWidth()) /
(spanInfo->effectiveMinWidthOfSpannedCols);
if (gsDebug==PR_TRUE)
printf ("spanCellMinWidth portion = %d \n", spanCellMinWidth);
if (colMinWidth < spanCellMinWidth)
colFrame->SetAdjustedMinColWidth(spanCellMinWidth); // set the new min width for the col
}
else
{
if (colMinWidth < spanCellMinWidth)
{
spanCellMinWidth = spanInfo->cellMinWidth/spanInfo->initialColSpan;
colFrame->SetAdjustedMinColWidth(spanCellMinWidth);
}
}
// compute the spanning cell's contribution to the column max width
nscoord colMaxWidth = colFrame->GetMaxColWidth();
nscoord spanCellMaxWidth;
if (0!=spanInfo->effectiveMaxWidthOfSpannedCols)
{
spanCellMaxWidth = (spanInfo->cellDesiredWidth * colFrame->GetEffectiveMaxColWidth()) /
(spanInfo->effectiveMaxWidthOfSpannedCols);
if (gsDebug==PR_TRUE)
printf ("spanCellMaxWidth portion = %d\n", spanCellMaxWidth);
if (colMaxWidth < spanCellMaxWidth)
{
// make sure we're at least as big as our min
spanCellMaxWidth = PR_MAX(spanCellMaxWidth, colMinWidth);
colFrame->SetMaxColWidth(spanCellMaxWidth); // set the new max width for the col
mTableFrame->SetColumnWidth(colIndex, spanCellMaxWidth); // set the column to the new desired max width
if (gsDebug==PR_TRUE)
for (PRInt32 span=0; span<spanInfo->initialColSpan; span++)
{
printf ("for spanning cell into col %d with remaining span=%d, old max = %d, new max = %d\n",
colIndex, spanInfo->span, colMaxWidth, spanCellMaxWidth);
nsTableColFrame *nextColFrame = mTableFrame->GetColFrame(colIndex+span);
if (nsnull==nextColFrame)
break;
spanInfo->effectiveMaxWidthOfSpannedCols += nextColFrame->GetEffectiveMaxColWidth();
spanInfo->effectiveMinWidthOfSpannedCols += nextColFrame->GetEffectiveMinColWidth();
}
if (gsDebug) printf("effective min total = %d, max total = %d\n",
spanInfo->effectiveMinWidthOfSpannedCols, spanInfo->effectiveMaxWidthOfSpannedCols);
}
nsTableColFrame *colFrame = mTableFrame->GetColFrame(colIndex);
nscoord colMinWidth = colFrame->GetMinColWidth();
// compute the spanning cell's contribution to the column min width
// this is the "adjusted" column width, used in SetTableToMinWidth
nscoord spanCellMinWidth;
if (0!=spanInfo->effectiveMinWidthOfSpannedCols)
{
spanCellMinWidth = (spanInfo->cellMinWidth * colFrame->GetEffectiveMinColWidth()) /
(spanInfo->effectiveMinWidthOfSpannedCols);
if (gsDebug==PR_TRUE)
printf ("spanCellMinWidth portion = %d \n", spanCellMinWidth);
if (colMinWidth < spanCellMinWidth)
colFrame->SetAdjustedMinColWidth(spanCellMinWidth); // set the new min width for the col
}
else
{
if (colMinWidth < spanCellMinWidth)
{
spanCellMinWidth = spanInfo->cellMinWidth/spanInfo->initialColSpan;
colFrame->SetAdjustedMinColWidth(spanCellMinWidth);
}
}
}
else
{
spanCellMaxWidth = spanInfo->cellDesiredWidth/spanInfo->initialColSpan;
nscoord minColWidth = colFrame->GetMinColWidth();
spanCellMaxWidth = PR_MAX(spanCellMaxWidth, minColWidth);
colFrame->SetMaxColWidth(spanCellMaxWidth);
mTableFrame->SetColumnWidth(colIndex, spanCellMaxWidth);
if (gsDebug==PR_TRUE)
printf (" for spanning cell into col %d with remaining span=%d, old max = %d, new max = %d\n",
colIndex, spanInfo->span, colMaxWidth, spanCellMaxWidth);
}
spanInfo->span--;
if (0==spanInfo->span)
{
spanList->RemoveElementAt(spanIndex);
delete spanInfo;
// compute the spanning cell's contribution to the column max width
nscoord colMaxWidth = colFrame->GetMaxColWidth();
nscoord spanCellMaxWidth;
if (0!=spanInfo->effectiveMaxWidthOfSpannedCols)
{
spanCellMaxWidth = (spanInfo->cellDesiredWidth * colFrame->GetEffectiveMaxColWidth()) /
(spanInfo->effectiveMaxWidthOfSpannedCols);
if (gsDebug==PR_TRUE)
printf ("spanCellMaxWidth portion = %d\n", spanCellMaxWidth);
if (colMaxWidth < spanCellMaxWidth)
{
// make sure we're at least as big as our min
spanCellMaxWidth = PR_MAX(spanCellMaxWidth, colMinWidth);
colFrame->SetMaxColWidth(spanCellMaxWidth); // set the new max width for the col
mTableFrame->SetColumnWidth(colIndex, spanCellMaxWidth); // set the column to the new desired max width
if (gsDebug==PR_TRUE)
{
printf ("for spanning cell into col %d with remaining span=%d, old max = %d, new max = %d\n",
colIndex, spanInfo->span, colMaxWidth, spanCellMaxWidth);
}
}
}
else
{
spanCellMaxWidth = spanInfo->cellDesiredWidth/spanInfo->initialColSpan;
nscoord minColWidth = colFrame->GetMinColWidth();
spanCellMaxWidth = PR_MAX(spanCellMaxWidth, minColWidth);
colFrame->SetMaxColWidth(spanCellMaxWidth);
mTableFrame->SetColumnWidth(colIndex, spanCellMaxWidth);
if (gsDebug==PR_TRUE)
printf (" for spanning cell into col %d with remaining span=%d, old max = %d, new max = %d\n",
colIndex, spanInfo->span, colMaxWidth, spanCellMaxWidth);
}
spanInfo->span--;
if (0==spanInfo->span)
{
spanList->RemoveElementAt(spanIndex);
delete spanInfo;
}
}
}
}

View File

@ -1689,6 +1689,24 @@ void nsTableFrame::PlaceChild(nsIPresContext* aPresContext,
}
}
}
if (nsnull != aMaxElementSize)
{
nsMargin borderPadding;
const nsStyleSpacing* tableSpacing;
// begin REMOVE_ME_WHEN_TABLE_STYLE_IS_RESOLVED!
nsIFrame * parent = nsnull;
GetGeometricParent(parent);
parent->GetStyleData(eStyleStruct_Spacing , ((nsStyleStruct *&)tableSpacing));
// end REMOVE_ME_WHEN_TABLE_STYLE_IS_RESOLVED!
tableSpacing->CalcBorderPaddingFor(this, borderPadding);
nscoord cellSpacing = GetCellSpacing();
nscoord kidWidth = aKidMaxElementSize.width + borderPadding.left + borderPadding.right + cellSpacing*2;
aMaxElementSize->width = PR_MAX(aMaxElementSize->width, kidWidth);
aMaxElementSize->height += aKidMaxElementSize.height;
if (gsDebug)
printf("%p placeChild set MES->width to %d\n",
this, aMaxElementSize->width);
}
}
/**
@ -2354,26 +2372,7 @@ void nsTableFrame::BalanceColumnWidths(nsIPresContext* aPresContext,
break;
}
// if we think we're UNCONSTRAINED, find the max width of an ancestor via reflow state
/*
if (NS_UNCONSTRAINEDSIZE==maxWidth)
{
//maxWidth = GetTableContainerWidth(aReflowState);
const nsReflowState* rs = &aReflowState;
while (nsnull != rs)
{
if (NS_UNCONSTRAINEDSIZE!=rs->maxSize.width)
{
maxWidth = rs->maxSize.width;
break;
}
rs = rs->parentReflowState;
}
NS_ASSERTION(NS_UNCONSTRAINEDSIZE!=maxWidth, "illegal max width");
}
*/
// now we know we're not UNCONSTRAINED, so subtract out table border and padding
maxWidth -= borderPadding.left + borderPadding.right;
if (0>maxWidth) // nonsense style specification
maxWidth = 0;

View File

@ -33,11 +33,11 @@
NS_DEF_PTR(nsIStyleContext);
#ifdef NS_DEBUG
static PRBool gsDebug1 = PR_FALSE;
static PRBool gsDebug = PR_FALSE;
//#define NOISY
//#define NOISY_FLOW
#else
static const PRBool gsDebug1 = PR_FALSE;
static const PRBool gsDebug = PR_FALSE;
#endif
/* ----------- RowReflowState ---------- */
@ -150,6 +150,7 @@ NS_METHOD nsTableRowFrame::Paint(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect)
{
/*
const nsStyleColor* myColor =
(const nsStyleColor*)mStyleContext->GetStyleData(eStyleStruct_Color);
if (nsnull != myColor) {
@ -157,6 +158,7 @@ NS_METHOD nsTableRowFrame::Paint(nsIPresContext& aPresContext,
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *myColor);
}
*/
PaintChildren(aPresContext, aRenderingContext, aDirtyRect);
return NS_OK;
@ -278,7 +280,7 @@ void nsTableRowFrame::PlaceChild(nsIPresContext& aPresContext,
nsSize* aMaxElementSize,
nsSize* aKidMaxElementSize)
{
if (PR_TRUE==gsDebug1)
if (PR_TRUE==gsDebug)
printf ("row: placing cell at %d, %d, %d, %d\n",
aKidRect.x, aKidRect.y, aKidRect.width, aKidRect.height);
@ -337,7 +339,7 @@ nsresult nsTableRowFrame::ResizeReflow(nsIPresContext& aPresContext,
nscoord maxCellTopMargin = 0;
nscoord maxCellBottomMargin = 0;
nscoord cellSpacing = aState.tableFrame->GetCellSpacing();
if (PR_TRUE==gsDebug1) printf("%p: RR\n", this);
if (PR_TRUE==gsDebug) printf("%p: RR\n", this);
// Reflow each of our existing cell frames
for (nsIFrame* kidFrame = mFirstChild; nsnull != kidFrame; )
{
@ -357,13 +359,13 @@ nsresult nsTableRowFrame::ResizeReflow(nsIPresContext& aPresContext,
{
aState.x += aState.tableFrame->GetColumnWidth(colIndex);
aState.x += cellSpacing;
if (PR_TRUE==gsDebug1)
if (PR_TRUE==gsDebug)
printf(" in loop, aState.x set to %d from cellSpacing %d and col width\n",
aState.x, aState.tableFrame->GetColumnWidth(colIndex), cellSpacing);
}
}
aState.x += cellSpacing;
if (PR_TRUE==gsDebug1) printf(" past loop, aState.x set to %d\n", aState.x);
if (PR_TRUE==gsDebug) printf(" past loop, aState.x set to %d\n", aState.x);
// at this point, we know the column widths.
// so we get the avail width from the known column widths
@ -377,11 +379,11 @@ nsresult nsTableRowFrame::ResizeReflow(nsIPresContext& aPresContext,
{
availWidth += cellSpacing;
}
if (PR_TRUE==gsDebug1)
if (PR_TRUE==gsDebug)
printf(" in loop, availWidth set to %d from colIndex %d width %d and cellSpacing\n",
availWidth, cellColIndex, aState.tableFrame->GetColumnWidth(cellColIndex+numColSpan), cellSpacing);
}
if (PR_TRUE==gsDebug1) printf(" availWidth for this cell is %d\n", availWidth);
if (PR_TRUE==gsDebug) printf(" availWidth for this cell is %d\n", availWidth);
prevColIndex = cellColIndex + (cellColSpan-1); // remember the rightmost column this cell spans into
@ -409,13 +411,13 @@ nsresult nsTableRowFrame::ResizeReflow(nsIPresContext& aPresContext,
kidFrame->MoveTo(aState.x, kidMargin.top);
nsReflowState kidReflowState(kidFrame, aState.reflowState, kidAvailSize,
eReflowReason_Resize);
if (gsDebug1) printf ("%p RR: avail=%d\n", this, availWidth);
if (gsDebug) printf ("%p RR: avail=%d\n", this, availWidth);
nsReflowStatus status = ReflowChild(kidFrame, &aPresContext, desiredSize,
kidReflowState);
if (gsDebug1) printf ("%p RR: desired=%d\n", this, desiredSize.width);
if (gsDebug) printf ("%p RR: desired=%d\n", this, desiredSize.width);
NS_ASSERTION(NS_FRAME_IS_COMPLETE(status), "unexpected reflow status");
if (gsDebug1)
if (gsDebug)
{
if (nsnull!=pKidMaxElementSize)
printf("reflow of cell returned result = %s with desired=%d,%d, min = %d,%d\n",
@ -470,7 +472,7 @@ nsresult nsTableRowFrame::ResizeReflow(nsIPresContext& aPresContext,
PlaceChild(aPresContext, aState, kidFrame, kidRect, aDesiredSize.maxElementSize,
pKidMaxElementSize);
if (PR_TRUE==gsDebug1) printf(" past PlaceChild, aState.x set to %d\n", aState.x);
if (PR_TRUE==gsDebug) printf(" past PlaceChild, aState.x set to %d\n", aState.x);
// Get the next child
kidFrame->GetNextSibling(kidFrame);
@ -483,6 +485,10 @@ nsresult nsTableRowFrame::ResizeReflow(nsIPresContext& aPresContext,
aDesiredSize.width = aState.x;
aDesiredSize.height = aState.maxCellVertSpace;
if (gsDebug)
printf("rr -- row %p width = %d from maxSize %d\n",
this, aDesiredSize.width, aState.reflowState.maxSize.width);
return NS_OK;
}
@ -573,16 +579,22 @@ nsTableRowFrame::InitialReflow(nsIPresContext& aPresContext,
nsReflowStatus status;
kidFrame->WillReflow(aPresContext);
if (gsDebug1) printf ("%p InitR: avail=%d\n", this, kidAvailSize.width);
if (gsDebug) printf ("%p InitR: avail=%d\n", this, kidAvailSize.width);
status = ReflowChild(kidFrame, &aPresContext, kidSize, kidReflowState);
if (gsDebug1)
if (gsDebug)
printf ("TR %p for cell %p Initial Reflow: desired=%d, MES=%d\n",
this, kidFrame, kidSize.width, kidMaxElementSize.width);
//XXX: this is a hack, shouldn't it be the case that a min size is
// never larger than a desired size?
if (kidMaxElementSize.width>kidSize.width)
kidSize.width = kidMaxElementSize.width;
if (kidMaxElementSize.height>kidSize.height)
kidSize.height = kidMaxElementSize.height;
((nsTableCellFrame *)kidFrame)->SetPass1DesiredSize(kidSize);
((nsTableCellFrame *)kidFrame)->SetPass1MaxElementSize(kidMaxElementSize);
NS_ASSERTION(NS_FRAME_IS_COMPLETE(status), "unexpected child reflow status");
if (gsDebug1)
if (gsDebug)
{
printf("reflow of cell returned result = %s with desired=%d,%d, min = %d,%d\n",
NS_FRAME_IS_COMPLETE(status)?"complete":"NOT complete",
@ -608,6 +620,11 @@ nsTableRowFrame::InitialReflow(nsIPresContext& aPresContext,
aDesiredSize.width = x;
aDesiredSize.height = aState.maxCellVertSpace;
if (gsDebug)
printf("initial -- row %p width = %d MES=%d from maxSize %d\n",
this, aDesiredSize.width, aDesiredSize.maxElementSize->width,
aState.reflowState.maxSize.width);
// Update the content mapping
if (nsnull != prevKidFrame) {
SetLastContentOffset(kidIndex - 1);
@ -785,10 +802,16 @@ nsresult nsTableRowFrame::IncrementalReflow(nsIPresContext& aPresContext,
kidReflowState.reflowCommand = nsnull;
kidReflowState.maxSize.width = NS_UNCONSTRAINEDSIZE;
status = ReflowChild(kidFrame, &aPresContext, desiredSize, kidReflowState);
if (gsDebug1)
if (gsDebug)
printf ("TR %p for cell %p Incremental Reflow: desired=%d, MES=%d\n",
this, kidFrame, desiredSize.width, kidMaxElementSize.width);
// Update the cell layout data.
//XXX: this is a hack, shouldn't it be the case that a min size is
// never larger than a desired size?
if (kidMaxElementSize.width>desiredSize.width)
desiredSize.width = kidMaxElementSize.width;
if (kidMaxElementSize.height>desiredSize.height)
desiredSize.height = kidMaxElementSize.height;
((nsTableCellFrame *)kidFrame)->SetPass1DesiredSize(desiredSize);
((nsTableCellFrame *)kidFrame)->SetPass1MaxElementSize(kidMaxElementSize);
@ -842,6 +865,11 @@ nsresult nsTableRowFrame::IncrementalReflow(nsIPresContext& aPresContext,
aDesiredSize.width = aState.availSize.width;
aDesiredSize.height = aState.maxCellVertSpace;
if (gsDebug)
printf("incr -- row %p width = %d MES=%d from maxSize %d\n",
this, aDesiredSize.width, aDesiredSize.maxElementSize->width,
aState.reflowState.maxSize.width);
return status;
}
@ -854,7 +882,7 @@ nsTableRowFrame::Reflow(nsIPresContext& aPresContext,
const nsReflowState& aReflowState,
nsReflowStatus& aStatus)
{
if (gsDebug1==PR_TRUE)
if (gsDebug==PR_TRUE)
printf("nsTableRowFrame::Reflow - aMaxSize = %d, %d\n",
aReflowState.maxSize.width, aReflowState.maxSize.height);
#ifdef NS_DEBUG
@ -901,7 +929,7 @@ nsTableRowFrame::Reflow(nsIPresContext& aPresContext,
PostReflowCheck(aStatus);
#endif
if (gsDebug1==PR_TRUE)
if (gsDebug==PR_TRUE)
{
if (nsnull!=aDesiredSize.maxElementSize)
printf("nsTableRowFrame::RR returning: %s with aDesiredSize=%d,%d, aMES=%d,%d\n",

View File

@ -194,8 +194,8 @@ void nsTableRowGroupFrame::PlaceChild( nsIPresContext* aPresContext,
nsSize& aKidMaxElementSize)
{
if (PR_TRUE==gsDebug)
printf ("rowgroup: placing row at %d, %d, %d, %d\n",
aKidRect.x, aKidRect.y, aKidRect.width, aKidRect.height);
printf ("rowgroup %p: placing row at %d, %d, %d, %d\n",
this, aKidRect.x, aKidRect.y, aKidRect.width, aKidRect.height);
// Place and size the child
aKidFrame->SetRect(aKidRect);
@ -218,6 +218,12 @@ void nsTableRowGroupFrame::PlaceChild( nsIPresContext* aPresContext,
aMaxElementSize->height = aKidMaxElementSize.height;
}
}
else if (nsnull != aMaxElementSize) {
aMaxElementSize->width = PR_MAX(aMaxElementSize->width, aKidMaxElementSize.width);
}
if (gsDebug && nsnull != aMaxElementSize)
printf ("rowgroup %p: placing row %p with width = %d and MES= %d\n",
this, aKidFrame, aKidRect.width, aMaxElementSize->width);
}
/**
@ -1156,13 +1162,13 @@ nsTableRowGroupFrame::Reflow(nsIPresContext& aPresContext,
if (gsDebug==PR_TRUE)
{
if (nsnull!=aDesiredSize.maxElementSize)
printf("nsTableRowGroupFrame::RR returning: %s with aDesiredSize=%d,%d, aMES=%d,%d\n",
NS_FRAME_IS_COMPLETE(aStatus)?"Complete":"Not Complete",
printf("nsTableRowGroupFrame %p returning: %s with aDesiredSize=%d,%d, aMES=%d,%d\n",
this, NS_FRAME_IS_COMPLETE(aStatus)?"Complete":"Not Complete",
aDesiredSize.width, aDesiredSize.height,
aDesiredSize.maxElementSize->width, aDesiredSize.maxElementSize->height);
else
printf("nsTableRowGroupFrame::RR returning: %s with aDesiredSize=%d,%d, aMES=NSNULL\n",
NS_FRAME_IS_COMPLETE(aStatus)?"Complete":"Not Complete",
printf("nsTableRowGroupFrame %p returning: %s with aDesiredSize=%d,%d, aMES=NSNULL\n",
this, NS_FRAME_IS_COMPLETE(aStatus)?"Complete":"Not Complete",
aDesiredSize.width, aDesiredSize.height);
}