support for backgrounds on table elements in both compatibility modes

This commit is contained in:
karnaze@netscape.com
1999-06-07 21:10:25 +00:00
parent b62acd74ce
commit 0a02140339
12 changed files with 422 additions and 38 deletions
+67 -6
View File
@@ -282,11 +282,6 @@ void nsTableRowFrame::SetMaxChildHeight(nscoord aChildHeight, nscoord aTopMargin
mCellMaxBottomMargin = aBottomMargin;
}
NS_METHOD nsTableRowFrame::Paint(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer)
{
/*
const nsStyleColor* myColor =
(const nsStyleColor*)mStyleContext->GetStyleData(eStyleStruct_Color);
@@ -297,8 +292,74 @@ NS_METHOD nsTableRowFrame::Paint(nsIPresContext& aPresContext,
}
*/
PRBool IsFirstRow(nsTableFrame& aTable,
nsTableRowFrame& aRow)
{
nsIFrame* firstRowGroup = nsnull;
aTable.FirstChild(nsnull, &firstRowGroup);
nsIFrame* rowGroupFrame = nsnull;
nsresult rv = aRow.GetParent(&rowGroupFrame);
if (NS_SUCCEEDED(rv) && (rowGroupFrame == firstRowGroup)) {
nsIFrame* firstRow;
rowGroupFrame->FirstChild(nsnull, &firstRow);
return (&aRow == firstRow);
}
return PR_FALSE;
}
NS_METHOD nsTableRowFrame::Paint(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer)
{
nsresult rv;
if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) {
nsCompatibility mode;
aPresContext.GetCompatibilityMode(&mode);
if (eCompatibility_Standard == mode) {
const nsStyleDisplay* disp =
(const nsStyleDisplay*)mStyleContext->GetStyleData(eStyleStruct_Display);
if (disp->mVisible) {
const nsStyleSpacing* spacing =
(const nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing);
const nsStyleColor* color =
(const nsStyleColor*)mStyleContext->GetStyleData(eStyleStruct_Color);
nsTableFrame* tableFrame = nsnull;
rv = nsTableFrame::GetTableFrame(this, tableFrame);
if (NS_FAILED(rv) || (nsnull == tableFrame)) {
return rv;
}
nscoord cellSpacingX = tableFrame->GetCellSpacingX();
nscoord halfCellSpacingY =
NSToCoordRound(((float)tableFrame->GetCellSpacingY()) / (float)2);
// every row is short by the ending cell spacing X
nsRect rect(0, 0, mRect.width + cellSpacingX, mRect.height);
// first row may have gotten too much cell spacing Y
if (tableFrame->GetRowCount() != 1) {
if (IsFirstRow(*tableFrame, *this)) {
rect.height -= halfCellSpacingY;
}
else {
rect.height += halfCellSpacingY;
rect.y -= halfCellSpacingY;
}
}
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *color, *spacing, 0, 0);
}
}
}
// for debug...
if ((NS_FRAME_PAINT_LAYER_DEBUG == aWhichLayer) && GetShowFrameBorders()) {
aRenderingContext.SetColor(NS_RGB(0,255,0));
aRenderingContext.DrawRect(0, 0, mRect.width, mRect.height);
}
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
return NS_OK;
return nsFrame::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
}
PRIntn