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
Родитель 124ffff8d5
Коммит 45d73d88de
12 изменённых файлов: 422 добавлений и 38 удалений

Просмотреть файл

@ -23,6 +23,7 @@
#include "nsIPresContext.h"
#include "nsHTMLIIDs.h"
#include "nsHTMLAtoms.h"
#include "nsCSSRendering.h"
#ifdef NS_DEBUG
static PRBool gsDebug = PR_FALSE;
@ -44,8 +45,25 @@ NS_METHOD nsTableColFrame::Paint(nsIPresContext& aPresContext,
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer)
{
if (gsDebug==PR_TRUE)
printf("nsTableColFrame::Paint\n");
if (gsDebug==PR_TRUE) printf("nsTableColFrame::Paint\n");
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);
nsRect rect(0, 0, mRect.width, mRect.height);
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *color, *spacing, 0, 0);
}
}
}
return NS_OK;
}

Просмотреть файл

@ -29,6 +29,7 @@
#include "nsHTMLAtoms.h"
#include "nsHTMLIIDs.h"
#include "nsCOMPtr.h"
#include "nsCSSRendering.h"
NS_DEF_PTR(nsIContent);
@ -136,12 +137,30 @@ nsTableColGroupFrame::SetInitialChildList(nsIPresContext& aPresContext,
return result;
}
NS_METHOD nsTableColGroupFrame::Paint(nsIPresContext& aPresContext,
NS_METHOD nsTableColGroupFrame::Paint(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer)
nsFramePaintLayer aWhichLayer)
{
if (gsDebug==PR_TRUE) printf("nsTableColGroupFrame::Paint\n");
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);
nsRect rect(0, 0, mRect.width, mRect.height);
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *color, *spacing, 0, 0);
}
}
}
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
return NS_OK;
}

Просмотреть файл

@ -2285,8 +2285,19 @@ NS_METHOD nsTableFrame::Paint(nsIPresContext& aPresContext,
(const nsStyleTable*)mStyleContext->GetStyleData(eStyleStruct_Table);
nsRect rect(0, 0, mRect.width, mRect.height);
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *color, *spacing, 0, 0);
nsCompatibility mode;
aPresContext.GetCompatibilityMode(&mode);
if (eCompatibility_Standard == mode) {
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *color, *spacing, 0, 0);
// paint the column groups and columns
nsIFrame* colGroupFrame = mColGroups.FirstChild();
while (nsnull != colGroupFrame) {
PaintChild(aPresContext, aRenderingContext, aDirtyRect, colGroupFrame, aWhichLayer);
colGroupFrame->GetNextSibling(&colGroupFrame);
}
}
PRIntn skipSides = GetSkipSides();
if (NS_STYLE_BORDER_SEPARATE==tableStyle->mBorderCollapse)
{
@ -2413,6 +2424,47 @@ nsresult nsTableFrame::AdjustSiblingsAfterReflow(nsIPresContext& aPresCon
return NS_OK;
}
void nsTableFrame::SetColumnDimensions(nscoord aHeight)
{
const nsStyleSpacing* spacing =
(const nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing);
nsMargin borderPadding;
spacing->CalcBorderPaddingFor(this, borderPadding);
nscoord colHeight = aHeight -= borderPadding.top + borderPadding.bottom;
nscoord cellSpacingX = GetCellSpacingX();
nscoord halfCellSpacingX = NSToCoordRound(((float)cellSpacingX) / (float)2);
nsIFrame* colGroupFrame = mColGroups.FirstChild();
PRInt32 colX = 0;
nsPoint colGroupOrigin(borderPadding.left, borderPadding.top);
while (nsnull != colGroupFrame) {
nscoord colGroupWidth = 0;
nsIFrame* colFrame = nsnull;
colGroupFrame->FirstChild(nsnull, &colFrame);
nsPoint colOrigin(0, 0);
while (nsnull != colFrame) {
NS_ASSERTION(colX < mColCount, "invalid number of columns");
nscoord colWidth = mColumnWidths[colX] + cellSpacingX;
if (mColCount == 1) {
colWidth += cellSpacingX;
}
else if ((0 == colX) || (mColCount - 1 == colX)) {
colWidth += halfCellSpacingX;
}
colGroupWidth += colWidth;
nsRect colRect(colOrigin.x, colOrigin.y, colWidth, colHeight);
colFrame->SetRect(colRect);
colFrame->GetNextSibling(&colFrame);
colOrigin.x += colWidth;
colX++;
}
nsRect colGroupRect(colGroupOrigin.x, colGroupOrigin.y, colGroupWidth, colHeight);
colGroupFrame->SetRect(colGroupRect);
colGroupFrame->GetNextSibling(&colGroupFrame);
colGroupOrigin.x += colGroupWidth;
}
}
// SEC: TODO need to worry about continuing frames prev/next in flow for splitting across pages.
/* overview:
@ -2556,6 +2608,8 @@ NS_METHOD nsTableFrame::Reflow(nsIPresContext& aPresContext,
this, aDesiredSize.width, aDesiredSize.height);
}
SetColumnDimensions(aDesiredSize.height);
if (PR_TRUE==gsDebug) printf("end reflow for table %p\n", this);
return rv;
}

Просмотреть файл

@ -697,6 +697,8 @@ protected:
*/
virtual nsCellMap *GetCellMap() const;
void SetColumnDimensions(nscoord aHeight);
#ifdef NS_DEBUG
/** for debugging only
* prints out information about the cell map

Просмотреть файл

@ -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

Просмотреть файл

@ -34,6 +34,7 @@
#include "nsIStyleSet.h"
#include "nsIPresShell.h"
#include "nsLayoutAtoms.h"
#include "nsCSSRendering.h"
#ifdef NS_DEBUG
static PRBool gsDebug = PR_FALSE;
@ -220,22 +221,59 @@ nsTableRowGroupFrame::InitRepeatedFrame(nsTableRowGroupFrame* aHeaderFooterFrame
return NS_OK;
}
NS_METHOD nsTableRowGroupFrame::Paint(nsIPresContext& aPresContext,
NS_METHOD nsTableRowGroupFrame::Paint(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer)
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 halfCellSpacingY =
NSToCoordRound(((float)tableFrame->GetCellSpacingY()) / (float)2);
// every row group is short by the ending cell spacing X
nsRect rect(0, 0, mRect.width, mRect.height);
nsIFrame* firstRowGroup = nsnull;
tableFrame->FirstChild(nsnull, &firstRowGroup);
// first row group may have gotten too much cell spacing Y
if (tableFrame->GetRowCount() != 1) {
if (this == firstRowGroup) {
rect.height -= halfCellSpacingY;
}
else {
rect.height += halfCellSpacingY;
rect.y -= halfCellSpacingY;
}
}
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *color, *spacing, 0, 0);
}
}
}
// for debug...
/*
if (nsIFrame::GetShowFrameBorders()) {
aRenderingContext.SetColor(NS_RGB(128,0,0));
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

Просмотреть файл

@ -23,6 +23,7 @@
#include "nsIPresContext.h"
#include "nsHTMLIIDs.h"
#include "nsHTMLAtoms.h"
#include "nsCSSRendering.h"
#ifdef NS_DEBUG
static PRBool gsDebug = PR_FALSE;
@ -44,8 +45,25 @@ NS_METHOD nsTableColFrame::Paint(nsIPresContext& aPresContext,
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer)
{
if (gsDebug==PR_TRUE)
printf("nsTableColFrame::Paint\n");
if (gsDebug==PR_TRUE) printf("nsTableColFrame::Paint\n");
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);
nsRect rect(0, 0, mRect.width, mRect.height);
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *color, *spacing, 0, 0);
}
}
}
return NS_OK;
}

Просмотреть файл

@ -29,6 +29,7 @@
#include "nsHTMLAtoms.h"
#include "nsHTMLIIDs.h"
#include "nsCOMPtr.h"
#include "nsCSSRendering.h"
NS_DEF_PTR(nsIContent);
@ -136,12 +137,30 @@ nsTableColGroupFrame::SetInitialChildList(nsIPresContext& aPresContext,
return result;
}
NS_METHOD nsTableColGroupFrame::Paint(nsIPresContext& aPresContext,
NS_METHOD nsTableColGroupFrame::Paint(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer)
nsFramePaintLayer aWhichLayer)
{
if (gsDebug==PR_TRUE) printf("nsTableColGroupFrame::Paint\n");
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);
nsRect rect(0, 0, mRect.width, mRect.height);
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *color, *spacing, 0, 0);
}
}
}
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
return NS_OK;
}

Просмотреть файл

@ -2285,8 +2285,19 @@ NS_METHOD nsTableFrame::Paint(nsIPresContext& aPresContext,
(const nsStyleTable*)mStyleContext->GetStyleData(eStyleStruct_Table);
nsRect rect(0, 0, mRect.width, mRect.height);
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *color, *spacing, 0, 0);
nsCompatibility mode;
aPresContext.GetCompatibilityMode(&mode);
if (eCompatibility_Standard == mode) {
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *color, *spacing, 0, 0);
// paint the column groups and columns
nsIFrame* colGroupFrame = mColGroups.FirstChild();
while (nsnull != colGroupFrame) {
PaintChild(aPresContext, aRenderingContext, aDirtyRect, colGroupFrame, aWhichLayer);
colGroupFrame->GetNextSibling(&colGroupFrame);
}
}
PRIntn skipSides = GetSkipSides();
if (NS_STYLE_BORDER_SEPARATE==tableStyle->mBorderCollapse)
{
@ -2413,6 +2424,47 @@ nsresult nsTableFrame::AdjustSiblingsAfterReflow(nsIPresContext& aPresCon
return NS_OK;
}
void nsTableFrame::SetColumnDimensions(nscoord aHeight)
{
const nsStyleSpacing* spacing =
(const nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing);
nsMargin borderPadding;
spacing->CalcBorderPaddingFor(this, borderPadding);
nscoord colHeight = aHeight -= borderPadding.top + borderPadding.bottom;
nscoord cellSpacingX = GetCellSpacingX();
nscoord halfCellSpacingX = NSToCoordRound(((float)cellSpacingX) / (float)2);
nsIFrame* colGroupFrame = mColGroups.FirstChild();
PRInt32 colX = 0;
nsPoint colGroupOrigin(borderPadding.left, borderPadding.top);
while (nsnull != colGroupFrame) {
nscoord colGroupWidth = 0;
nsIFrame* colFrame = nsnull;
colGroupFrame->FirstChild(nsnull, &colFrame);
nsPoint colOrigin(0, 0);
while (nsnull != colFrame) {
NS_ASSERTION(colX < mColCount, "invalid number of columns");
nscoord colWidth = mColumnWidths[colX] + cellSpacingX;
if (mColCount == 1) {
colWidth += cellSpacingX;
}
else if ((0 == colX) || (mColCount - 1 == colX)) {
colWidth += halfCellSpacingX;
}
colGroupWidth += colWidth;
nsRect colRect(colOrigin.x, colOrigin.y, colWidth, colHeight);
colFrame->SetRect(colRect);
colFrame->GetNextSibling(&colFrame);
colOrigin.x += colWidth;
colX++;
}
nsRect colGroupRect(colGroupOrigin.x, colGroupOrigin.y, colGroupWidth, colHeight);
colGroupFrame->SetRect(colGroupRect);
colGroupFrame->GetNextSibling(&colGroupFrame);
colGroupOrigin.x += colGroupWidth;
}
}
// SEC: TODO need to worry about continuing frames prev/next in flow for splitting across pages.
/* overview:
@ -2556,6 +2608,8 @@ NS_METHOD nsTableFrame::Reflow(nsIPresContext& aPresContext,
this, aDesiredSize.width, aDesiredSize.height);
}
SetColumnDimensions(aDesiredSize.height);
if (PR_TRUE==gsDebug) printf("end reflow for table %p\n", this);
return rv;
}

Просмотреть файл

@ -697,6 +697,8 @@ protected:
*/
virtual nsCellMap *GetCellMap() const;
void SetColumnDimensions(nscoord aHeight);
#ifdef NS_DEBUG
/** for debugging only
* prints out information about the cell map

Просмотреть файл

@ -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

Просмотреть файл

@ -34,6 +34,7 @@
#include "nsIStyleSet.h"
#include "nsIPresShell.h"
#include "nsLayoutAtoms.h"
#include "nsCSSRendering.h"
#ifdef NS_DEBUG
static PRBool gsDebug = PR_FALSE;
@ -220,22 +221,59 @@ nsTableRowGroupFrame::InitRepeatedFrame(nsTableRowGroupFrame* aHeaderFooterFrame
return NS_OK;
}
NS_METHOD nsTableRowGroupFrame::Paint(nsIPresContext& aPresContext,
NS_METHOD nsTableRowGroupFrame::Paint(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer)
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 halfCellSpacingY =
NSToCoordRound(((float)tableFrame->GetCellSpacingY()) / (float)2);
// every row group is short by the ending cell spacing X
nsRect rect(0, 0, mRect.width, mRect.height);
nsIFrame* firstRowGroup = nsnull;
tableFrame->FirstChild(nsnull, &firstRowGroup);
// first row group may have gotten too much cell spacing Y
if (tableFrame->GetRowCount() != 1) {
if (this == firstRowGroup) {
rect.height -= halfCellSpacingY;
}
else {
rect.height += halfCellSpacingY;
rect.y -= halfCellSpacingY;
}
}
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *color, *spacing, 0, 0);
}
}
}
// for debug...
/*
if (nsIFrame::GetShowFrameBorders()) {
aRenderingContext.SetColor(NS_RGB(128,0,0));
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