bug 12590 - vertical-align:middle working on cell

This commit is contained in:
karnaze@netscape.com
1999-08-27 04:29:05 +00:00
parent 567263f42e
commit 00f459927b
8 changed files with 56 additions and 42 deletions

View File

@@ -396,23 +396,24 @@ void nsTableCellFrame::VerticallyAlignChild()
switch (verticalAlignFlags) switch (verticalAlignFlags)
{ {
case NS_STYLE_VERTICAL_ALIGN_BASELINE: case NS_STYLE_VERTICAL_ALIGN_BASELINE:
// Align the child's baseline at the max baseline // Align the baselines of the child frame with the baselines of
//kidYTop = aMaxAscent - kidAscent; // other children in the same row which have align = baseline
break; // XXX Not yet implemented, so fall through to top
case NS_STYLE_VERTICAL_ALIGN_TOP: case NS_STYLE_VERTICAL_ALIGN_TOP:
// Align the top of the child frame with the top of the box, // Align the top of the child frame with the top of the content area,
// minus the top padding
kidYTop = topInset; kidYTop = topInset;
break; break;
case NS_STYLE_VERTICAL_ALIGN_BOTTOM: case NS_STYLE_VERTICAL_ALIGN_BOTTOM:
// Align the bottom of the child frame with the bottom of the content area,
kidYTop = height - childHeight - bottomInset; kidYTop = height - childHeight - bottomInset;
break; break;
default: default:
case NS_STYLE_VERTICAL_ALIGN_MIDDLE: case NS_STYLE_VERTICAL_ALIGN_MIDDLE:
kidYTop = height/2 - childHeight/2; // Align the middle of the child frame with the middle of the content area,
kidYTop = (height - childHeight - bottomInset + topInset) / 2;
} }
firstKid->MoveTo(kidRect.x, kidYTop); firstKid->MoveTo(kidRect.x, kidYTop);
} }

View File

@@ -60,17 +60,19 @@ static NS_DEFINE_IID(kITableRowGroupFrameIID, NS_ITABLEROWGROUPFRAME_IID);
static const PRInt32 kColumnWidthIncrement=100; static const PRInt32 kColumnWidthIncrement=100;
#if 1 #if 1
PRBool nsDebugTable::gRflTable = PR_FALSE; PRBool nsDebugTable::gRflTableOuter = PR_FALSE;
PRBool nsDebugTable::gRflRowGrp = PR_FALSE; PRBool nsDebugTable::gRflTable = PR_FALSE;
PRBool nsDebugTable::gRflRow = PR_FALSE; PRBool nsDebugTable::gRflRowGrp = PR_FALSE;
PRBool nsDebugTable::gRflCell = PR_FALSE; PRBool nsDebugTable::gRflRow = PR_FALSE;
PRBool nsDebugTable::gRflArea = PR_FALSE; PRBool nsDebugTable::gRflCell = PR_FALSE;
PRBool nsDebugTable::gRflArea = PR_FALSE;
#else #else
PRBool nsDebugTable::gRflTable = PR_TRUE; PRBool nsDebugTable::gRflTableOuter = PR_TRUE;
PRBool nsDebugTable::gRflRowGrp = PR_TRUE; PRBool nsDebugTable::gRflTable = PR_TRUE;
PRBool nsDebugTable::gRflRow = PR_TRUE; PRBool nsDebugTable::gRflRowGrp = PR_TRUE;
PRBool nsDebugTable::gRflCell = PR_TRUE; PRBool nsDebugTable::gRflRow = PR_TRUE;
PRBool nsDebugTable::gRflArea = PR_TRUE; PRBool nsDebugTable::gRflCell = PR_TRUE;
PRBool nsDebugTable::gRflArea = PR_TRUE;
#endif #endif
/* ----------- InnerTableReflowState ---------- */ /* ----------- InnerTableReflowState ---------- */
@@ -5353,11 +5355,12 @@ void nsTableFrame::DebugGetIndent(const nsIFrame* aFrame,
while (parent) { while (parent) {
nsIAtom* frameType = nsnull; nsIAtom* frameType = nsnull;
parent->GetFrameType(&frameType); parent->GetFrameType(&frameType);
if ((nsDebugTable::gRflTable && (nsLayoutAtoms::tableFrame == frameType)) || if ((nsDebugTable::gRflTableOuter && (nsLayoutAtoms::tableOuterFrame == frameType)) ||
(nsDebugTable::gRflRowGrp && (nsLayoutAtoms::tableRowGroupFrame == frameType)) || (nsDebugTable::gRflTable && (nsLayoutAtoms::tableFrame == frameType)) ||
(nsDebugTable::gRflRow && (nsLayoutAtoms::tableRowFrame == frameType)) || (nsDebugTable::gRflRowGrp && (nsLayoutAtoms::tableRowGroupFrame == frameType)) ||
(nsDebugTable::gRflCell && (nsLayoutAtoms::tableCellFrame == frameType)) || (nsDebugTable::gRflRow && (nsLayoutAtoms::tableRowFrame == frameType)) ||
(nsDebugTable::gRflArea && (nsLayoutAtoms::areaFrame == frameType))) { (nsDebugTable::gRflCell && (nsLayoutAtoms::tableCellFrame == frameType)) ||
(nsDebugTable::gRflArea && (nsLayoutAtoms::areaFrame == frameType))) {
numLevels++; numLevels++;
} }
NS_IF_RELEASE(frameType); NS_IF_RELEASE(frameType);

View File

@@ -49,6 +49,7 @@ struct nsStyleSpacing;
struct nsDebugTable struct nsDebugTable
{ {
static PRBool gRflTableOuter;
static PRBool gRflTable; static PRBool gRflTable;
static PRBool gRflRowGrp; static PRBool gRflRowGrp;
static PRBool gRflRow; static PRBool gRflRow;

View File

@@ -860,6 +860,7 @@ NS_METHOD nsTableOuterFrame::Reflow(nsIPresContext& aPresContext,
const nsHTMLReflowState& aReflowState, const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus) nsReflowStatus& aStatus)
{ {
if (nsDebugTable::gRflTableOuter) nsTableFrame::DebugReflow("TO::Rfl en", this, &aReflowState, nsnull);
nsresult rv = NS_OK; nsresult rv = NS_OK;
// Initialize out parameters // Initialize out parameters
@@ -1004,6 +1005,7 @@ NS_METHOD nsTableOuterFrame::Reflow(nsIPresContext& aPresContext,
aDesiredSize.ascent = aDesiredSize.height; aDesiredSize.ascent = aDesiredSize.height;
aDesiredSize.descent = 0; aDesiredSize.descent = 0;
if (nsDebugTable::gRflTableOuter) nsTableFrame::DebugReflow("TO::Rfl ex", this, nsnull, &aDesiredSize);
return rv; return rv;
} }

View File

@@ -396,23 +396,24 @@ void nsTableCellFrame::VerticallyAlignChild()
switch (verticalAlignFlags) switch (verticalAlignFlags)
{ {
case NS_STYLE_VERTICAL_ALIGN_BASELINE: case NS_STYLE_VERTICAL_ALIGN_BASELINE:
// Align the child's baseline at the max baseline // Align the baselines of the child frame with the baselines of
//kidYTop = aMaxAscent - kidAscent; // other children in the same row which have align = baseline
break; // XXX Not yet implemented, so fall through to top
case NS_STYLE_VERTICAL_ALIGN_TOP: case NS_STYLE_VERTICAL_ALIGN_TOP:
// Align the top of the child frame with the top of the box, // Align the top of the child frame with the top of the content area,
// minus the top padding
kidYTop = topInset; kidYTop = topInset;
break; break;
case NS_STYLE_VERTICAL_ALIGN_BOTTOM: case NS_STYLE_VERTICAL_ALIGN_BOTTOM:
// Align the bottom of the child frame with the bottom of the content area,
kidYTop = height - childHeight - bottomInset; kidYTop = height - childHeight - bottomInset;
break; break;
default: default:
case NS_STYLE_VERTICAL_ALIGN_MIDDLE: case NS_STYLE_VERTICAL_ALIGN_MIDDLE:
kidYTop = height/2 - childHeight/2; // Align the middle of the child frame with the middle of the content area,
kidYTop = (height - childHeight - bottomInset + topInset) / 2;
} }
firstKid->MoveTo(kidRect.x, kidYTop); firstKid->MoveTo(kidRect.x, kidYTop);
} }

View File

@@ -60,17 +60,19 @@ static NS_DEFINE_IID(kITableRowGroupFrameIID, NS_ITABLEROWGROUPFRAME_IID);
static const PRInt32 kColumnWidthIncrement=100; static const PRInt32 kColumnWidthIncrement=100;
#if 1 #if 1
PRBool nsDebugTable::gRflTable = PR_FALSE; PRBool nsDebugTable::gRflTableOuter = PR_FALSE;
PRBool nsDebugTable::gRflRowGrp = PR_FALSE; PRBool nsDebugTable::gRflTable = PR_FALSE;
PRBool nsDebugTable::gRflRow = PR_FALSE; PRBool nsDebugTable::gRflRowGrp = PR_FALSE;
PRBool nsDebugTable::gRflCell = PR_FALSE; PRBool nsDebugTable::gRflRow = PR_FALSE;
PRBool nsDebugTable::gRflArea = PR_FALSE; PRBool nsDebugTable::gRflCell = PR_FALSE;
PRBool nsDebugTable::gRflArea = PR_FALSE;
#else #else
PRBool nsDebugTable::gRflTable = PR_TRUE; PRBool nsDebugTable::gRflTableOuter = PR_TRUE;
PRBool nsDebugTable::gRflRowGrp = PR_TRUE; PRBool nsDebugTable::gRflTable = PR_TRUE;
PRBool nsDebugTable::gRflRow = PR_TRUE; PRBool nsDebugTable::gRflRowGrp = PR_TRUE;
PRBool nsDebugTable::gRflCell = PR_TRUE; PRBool nsDebugTable::gRflRow = PR_TRUE;
PRBool nsDebugTable::gRflArea = PR_TRUE; PRBool nsDebugTable::gRflCell = PR_TRUE;
PRBool nsDebugTable::gRflArea = PR_TRUE;
#endif #endif
/* ----------- InnerTableReflowState ---------- */ /* ----------- InnerTableReflowState ---------- */
@@ -5353,11 +5355,12 @@ void nsTableFrame::DebugGetIndent(const nsIFrame* aFrame,
while (parent) { while (parent) {
nsIAtom* frameType = nsnull; nsIAtom* frameType = nsnull;
parent->GetFrameType(&frameType); parent->GetFrameType(&frameType);
if ((nsDebugTable::gRflTable && (nsLayoutAtoms::tableFrame == frameType)) || if ((nsDebugTable::gRflTableOuter && (nsLayoutAtoms::tableOuterFrame == frameType)) ||
(nsDebugTable::gRflRowGrp && (nsLayoutAtoms::tableRowGroupFrame == frameType)) || (nsDebugTable::gRflTable && (nsLayoutAtoms::tableFrame == frameType)) ||
(nsDebugTable::gRflRow && (nsLayoutAtoms::tableRowFrame == frameType)) || (nsDebugTable::gRflRowGrp && (nsLayoutAtoms::tableRowGroupFrame == frameType)) ||
(nsDebugTable::gRflCell && (nsLayoutAtoms::tableCellFrame == frameType)) || (nsDebugTable::gRflRow && (nsLayoutAtoms::tableRowFrame == frameType)) ||
(nsDebugTable::gRflArea && (nsLayoutAtoms::areaFrame == frameType))) { (nsDebugTable::gRflCell && (nsLayoutAtoms::tableCellFrame == frameType)) ||
(nsDebugTable::gRflArea && (nsLayoutAtoms::areaFrame == frameType))) {
numLevels++; numLevels++;
} }
NS_IF_RELEASE(frameType); NS_IF_RELEASE(frameType);

View File

@@ -49,6 +49,7 @@ struct nsStyleSpacing;
struct nsDebugTable struct nsDebugTable
{ {
static PRBool gRflTableOuter;
static PRBool gRflTable; static PRBool gRflTable;
static PRBool gRflRowGrp; static PRBool gRflRowGrp;
static PRBool gRflRow; static PRBool gRflRow;

View File

@@ -860,6 +860,7 @@ NS_METHOD nsTableOuterFrame::Reflow(nsIPresContext& aPresContext,
const nsHTMLReflowState& aReflowState, const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus) nsReflowStatus& aStatus)
{ {
if (nsDebugTable::gRflTableOuter) nsTableFrame::DebugReflow("TO::Rfl en", this, &aReflowState, nsnull);
nsresult rv = NS_OK; nsresult rv = NS_OK;
// Initialize out parameters // Initialize out parameters
@@ -1004,6 +1005,7 @@ NS_METHOD nsTableOuterFrame::Reflow(nsIPresContext& aPresContext,
aDesiredSize.ascent = aDesiredSize.height; aDesiredSize.ascent = aDesiredSize.height;
aDesiredSize.descent = 0; aDesiredSize.descent = 0;
if (nsDebugTable::gRflTableOuter) nsTableFrame::DebugReflow("TO::Rfl ex", this, nsnull, &aDesiredSize);
return rv; return rv;
} }