From 70276dcf16986119d675b667facb8364a2f5abc6 Mon Sep 17 00:00:00 2001 From: "troy%netscape.com" Date: Sat, 2 Jan 1999 21:03:51 +0000 Subject: [PATCH] Added logic to make sure that internal table elements have reasonable values for the computed width/height --- layout/html/base/src/nsFrameReflowState.cpp | 41 +++++++++++++++++++-- layout/html/base/src/nsIHTMLReflow.h | 5 ++- 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/layout/html/base/src/nsFrameReflowState.cpp b/layout/html/base/src/nsFrameReflowState.cpp index 1ff9c326c12..72e8c0fc937 100644 --- a/layout/html/base/src/nsFrameReflowState.cpp +++ b/layout/html/base/src/nsFrameReflowState.cpp @@ -48,6 +48,8 @@ nsHTMLReflowState::GetContainingBlockReflowState(const nsReflowState* aParentRS) while (nsnull != aParentRS) { if (nsnull != aParentRS->frame) { PRBool isContainingBlock; + // XXX This needs to go and we need to start using the info in the + // reflow state... nsresult rv = aParentRS->frame->IsPercentageBase(isContainingBlock); if (NS_SUCCEEDED(rv) && isContainingBlock) { return (const nsHTMLReflowState*) aParentRS; @@ -127,8 +129,6 @@ nsHTMLReflowState::DetermineFrameType(nsIPresContext& aPresContext) case NS_STYLE_DISPLAY_BLOCK: case NS_STYLE_DISPLAY_LIST_ITEM: case NS_STYLE_DISPLAY_TABLE: - case NS_STYLE_DISPLAY_TABLE_CELL: - case NS_STYLE_DISPLAY_TABLE_CAPTION: frameType = eCSSFrameType_Block; break; @@ -149,14 +149,15 @@ nsHTMLReflowState::DetermineFrameType(nsIPresContext& aPresContext) frameType = eCSSFrameType_Block; break; + case NS_STYLE_DISPLAY_TABLE_CELL: + case NS_STYLE_DISPLAY_TABLE_CAPTION: case NS_STYLE_DISPLAY_TABLE_ROW_GROUP: case NS_STYLE_DISPLAY_TABLE_COLUMN: case NS_STYLE_DISPLAY_TABLE_COLUMN_GROUP: case NS_STYLE_DISPLAY_TABLE_HEADER_GROUP: case NS_STYLE_DISPLAY_TABLE_FOOTER_GROUP: case NS_STYLE_DISPLAY_TABLE_ROW: - // XXX I don't know what to do about these yet...later - frameType = eCSSFrameType_Inline; + frameType = eCSSFrameType_InternalTable; break; case NS_STYLE_DISPLAY_NONE: @@ -270,6 +271,7 @@ nsHTMLReflowState::InitConstraints(nsIPresContext& aPresContext) // by the content edge nscoord containingBlockWidth = cbrs->computedWidth; nscoord containingBlockHeight = cbrs->computedHeight; + NS_ASSERTION(0 != containingBlockWidth, "containing block width of 0"); nsStyleUnit widthUnit = pos->mWidth.GetUnit(); nsStyleUnit heightUnit = pos->mHeight.GetUnit(); @@ -326,6 +328,37 @@ nsHTMLReflowState::InitConstraints(nsIPresContext& aPresContext) computedHeight); } + } else if (eCSSFrameType_InternalTable == frameType) { + // Internal table elements. The rules vary depending on the type + const nsStyleDisplay* display; + frame->GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&)display); + + // Calculate the computed width + if ((NS_STYLE_DISPLAY_TABLE_ROW == display->mDisplay) || + (NS_STYLE_DISPLAY_TABLE_ROW_GROUP == display->mDisplay)) { + // 'width' property doesn't apply to table rows and row groups + widthUnit = eStyleUnit_Auto; + } + if (eStyleUnit_Auto == widthUnit) { + computedWidth = maxSize.width; + } else { + ComputeHorizontalValue(containingBlockWidth, widthUnit, pos->mWidth, + computedWidth); + } + + // Calculate the computed height + if ((NS_STYLE_DISPLAY_TABLE_COLUMN == display->mDisplay) || + (NS_STYLE_DISPLAY_TABLE_COLUMN_GROUP == display->mDisplay)) { + // 'width' property doesn't apply to table columns and column groups + heightUnit = eStyleUnit_Auto; + } + if (eStyleUnit_Auto == heightUnit) { + computedHeight = NS_AUTOHEIGHT; + } else { + ComputeVerticalValue(containingBlockHeight, heightUnit, pos->mHeight, + computedHeight); + } + } else { // Block-level elements and absolutely positioned elements const nsStyleSpacing* spacing; diff --git a/layout/html/base/src/nsIHTMLReflow.h b/layout/html/base/src/nsIHTMLReflow.h index 4e0c506b361..f562d96388c 100644 --- a/layout/html/base/src/nsIHTMLReflow.h +++ b/layout/html/base/src/nsIHTMLReflow.h @@ -108,7 +108,10 @@ enum nsCSSFrameType { eCSSFrameType_Absolute, // absolutely positioned, replaced elements - eCSSFrameType_AbsoluteReplaced + eCSSFrameType_AbsoluteReplaced, + + // internal table element (row group frame, row frame, table cell, ...) + eCSSFrameType_InternalTable }; // XXX Get rid of the enum