support for CSS2 style property "empty-cells"

This commit is contained in:
buster%netscape.com 1998-12-10 19:57:42 +00:00
parent fd07a08d5e
commit b7ab7be458
4 changed files with 70 additions and 14 deletions

View File

@ -71,14 +71,19 @@ NS_METHOD nsTableCellFrame::Paint(nsIPresContext& aPresContext,
//XXX: this could be calculated once and remembered
// get border padding values
//XXX: also check style for rule on rendering empty cells
nsMargin borderPadding;
const nsStyleSpacing* cellSpacingStyle;
GetStyleData(eStyleStruct_Spacing , ((const nsStyleStruct *&)cellSpacingStyle));
cellSpacingStyle->CalcBorderPaddingFor(this, borderPadding);
nscoord contentWidth = mPass1DesiredSize.width - (borderPadding.left+borderPadding.right);
nscoord contentHeight = mPass1DesiredSize.height - (borderPadding.top+borderPadding.bottom);
/*
*/
// empty cells do not render their border
if (0<contentWidth || 0<contentHeight)
PRBool renderBorder = PR_TRUE;
if (PR_TRUE==GetContentEmpty())
{
const nsStyleTable* cellTableStyle;
GetStyleData(eStyleStruct_Table, ((const nsStyleStruct *&)cellTableStyle));
if (NS_STYLE_TABLE_EMPTY_CELLS_HIDE==cellTableStyle->mEmptyCells)
renderBorder=PR_FALSE;
}
if (PR_TRUE==renderBorder)
{
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *mySpacing, 0);
@ -304,6 +309,13 @@ NS_METHOD nsTableCellFrame::Reflow(nsIPresContext& aPresContext,
// Nav4 hack for 0 dimensioned cells.
// Empty cells are assigned a width and height of 4px
// see testcase "cellHeights.html"
if (eReflowReason_Initial == aReflowState.reason)
{
if ((0==kidSize.width) && (0==kidSize.height))
SetContentEmpty(PR_TRUE);
else
SetContentEmpty(PR_FALSE);
}
if (0==kidSize.width)
{
float p2t;

View File

@ -125,6 +125,9 @@ public:
NS_IMETHOD GetMargin(nsMargin& aMargin);
PRBool GetContentEmpty();
void SetContentEmpty(PRBool aContentEmpty);
protected:
/** implement abstract method on nsHTMLContainerFrame */
virtual PRIntn GetSkipSides() const;
@ -212,6 +215,9 @@ protected:
nsresult mCalculated;
nsMargin mMargin;
nsIFrame* mBorderFrame[4]; // the frame whose border is used
PRBool mIsContentEmpty; // PR_TRUE if the cell's contents take up no space
//XXX: mIsContentEmpty should get yanked in favor of using free a bit on the frame base class
// the FrameState slot (mState; GetFrameState/SetFrameState)
};
@ -291,6 +297,16 @@ inline NS_METHOD nsTableCellFrame::GetMargin(nsMargin& aMargin)
return NS_ERROR_NOT_INITIALIZED;
}
inline PRBool nsTableCellFrame::GetContentEmpty()
{
return mIsContentEmpty;
}
inline void nsTableCellFrame::SetContentEmpty(PRBool aContentEmpty)
{
mIsContentEmpty = aContentEmpty;
}
#endif

View File

@ -71,14 +71,19 @@ NS_METHOD nsTableCellFrame::Paint(nsIPresContext& aPresContext,
//XXX: this could be calculated once and remembered
// get border padding values
//XXX: also check style for rule on rendering empty cells
nsMargin borderPadding;
const nsStyleSpacing* cellSpacingStyle;
GetStyleData(eStyleStruct_Spacing , ((const nsStyleStruct *&)cellSpacingStyle));
cellSpacingStyle->CalcBorderPaddingFor(this, borderPadding);
nscoord contentWidth = mPass1DesiredSize.width - (borderPadding.left+borderPadding.right);
nscoord contentHeight = mPass1DesiredSize.height - (borderPadding.top+borderPadding.bottom);
/*
*/
// empty cells do not render their border
if (0<contentWidth || 0<contentHeight)
PRBool renderBorder = PR_TRUE;
if (PR_TRUE==GetContentEmpty())
{
const nsStyleTable* cellTableStyle;
GetStyleData(eStyleStruct_Table, ((const nsStyleStruct *&)cellTableStyle));
if (NS_STYLE_TABLE_EMPTY_CELLS_HIDE==cellTableStyle->mEmptyCells)
renderBorder=PR_FALSE;
}
if (PR_TRUE==renderBorder)
{
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *mySpacing, 0);
@ -304,6 +309,13 @@ NS_METHOD nsTableCellFrame::Reflow(nsIPresContext& aPresContext,
// Nav4 hack for 0 dimensioned cells.
// Empty cells are assigned a width and height of 4px
// see testcase "cellHeights.html"
if (eReflowReason_Initial == aReflowState.reason)
{
if ((0==kidSize.width) && (0==kidSize.height))
SetContentEmpty(PR_TRUE);
else
SetContentEmpty(PR_FALSE);
}
if (0==kidSize.width)
{
float p2t;

View File

@ -125,6 +125,9 @@ public:
NS_IMETHOD GetMargin(nsMargin& aMargin);
PRBool GetContentEmpty();
void SetContentEmpty(PRBool aContentEmpty);
protected:
/** implement abstract method on nsHTMLContainerFrame */
virtual PRIntn GetSkipSides() const;
@ -212,6 +215,9 @@ protected:
nsresult mCalculated;
nsMargin mMargin;
nsIFrame* mBorderFrame[4]; // the frame whose border is used
PRBool mIsContentEmpty; // PR_TRUE if the cell's contents take up no space
//XXX: mIsContentEmpty should get yanked in favor of using free a bit on the frame base class
// the FrameState slot (mState; GetFrameState/SetFrameState)
};
@ -291,6 +297,16 @@ inline NS_METHOD nsTableCellFrame::GetMargin(nsMargin& aMargin)
return NS_ERROR_NOT_INITIALIZED;
}
inline PRBool nsTableCellFrame::GetContentEmpty()
{
return mIsContentEmpty;
}
inline void nsTableCellFrame::SetContentEmpty(PRBool aContentEmpty)
{
mIsContentEmpty = aContentEmpty;
}
#endif