1998-04-14 00:24:54 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Netscape Public License
|
|
|
|
* Version 1.0 (the "NPL"); you may not use this file except in
|
|
|
|
* compliance with the NPL. You may obtain a copy of the NPL at
|
|
|
|
* http://www.mozilla.org/NPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* NPL.
|
|
|
|
*
|
|
|
|
* The Initial Developer of this code under the NPL is Netscape
|
|
|
|
* Communications Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
|
|
|
* Reserved.
|
|
|
|
*/
|
|
|
|
#include "nsTableCellFrame.h"
|
1999-01-03 22:22:40 +03:00
|
|
|
#include "nsTableColFrame.h"
|
1998-11-11 22:56:02 +03:00
|
|
|
#include "nsTableFrame.h"
|
1998-06-09 08:51:44 +04:00
|
|
|
#include "nsIReflowCommand.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsIStyleContext.h"
|
|
|
|
#include "nsStyleConsts.h"
|
|
|
|
#include "nsIPresContext.h"
|
|
|
|
#include "nsIRenderingContext.h"
|
|
|
|
#include "nsCSSRendering.h"
|
|
|
|
#include "nsIContent.h"
|
1998-09-15 21:58:24 +04:00
|
|
|
#include "nsIHTMLContent.h"
|
|
|
|
#include "nsHTMLIIDs.h"
|
1998-10-06 04:44:35 +04:00
|
|
|
#include "nsHTMLParts.h"
|
1998-06-11 04:13:18 +04:00
|
|
|
#include "nsHTMLValue.h"
|
1998-05-02 00:44:55 +04:00
|
|
|
#include "nsHTMLAtoms.h"
|
1998-06-05 06:36:25 +04:00
|
|
|
#include "nsHTMLIIDs.h"
|
1998-10-06 04:44:35 +04:00
|
|
|
#include "nsVoidArray.h"
|
1998-06-05 06:36:25 +04:00
|
|
|
#include "nsIPtr.h"
|
1998-05-22 03:43:18 +04:00
|
|
|
#include "nsIView.h"
|
1998-07-23 22:05:03 +04:00
|
|
|
#include "nsStyleUtil.h"
|
1999-02-24 08:54:31 +03:00
|
|
|
#include "nsLayoutAtoms.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-06-05 06:36:25 +04:00
|
|
|
NS_DEF_PTR(nsIStyleContext);
|
|
|
|
|
1998-06-24 03:23:21 +04:00
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
#ifdef NS_DEBUG
|
|
|
|
static PRBool gsDebug = PR_FALSE;
|
1998-06-24 03:23:21 +04:00
|
|
|
static PRBool gsDebugNT = PR_FALSE;
|
1998-05-03 07:51:48 +04:00
|
|
|
//#define NOISY_STYLE
|
1998-04-14 00:24:54 +04:00
|
|
|
//#define NOISY_FLOW
|
|
|
|
#else
|
|
|
|
static const PRBool gsDebug = PR_FALSE;
|
1998-06-24 03:23:21 +04:00
|
|
|
static const PRBool gsDebugNT = PR_FALSE;
|
1998-04-14 00:24:54 +04:00
|
|
|
#endif
|
|
|
|
|
1998-12-21 09:38:18 +03:00
|
|
|
|
1999-02-11 04:16:28 +03:00
|
|
|
|
|
|
|
NS_IMPL_ADDREF(nsTableCellFrame)
|
|
|
|
NS_IMPL_RELEASE(nsTableCellFrame)
|
|
|
|
|
|
|
|
|
1998-12-21 09:38:18 +03:00
|
|
|
void nsTableCellFrame::InitCellFrame(PRInt32 aColIndex)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(0<=aColIndex, "bad col index arg");
|
|
|
|
mColIndex = aColIndex;
|
1998-12-23 18:47:43 +03:00
|
|
|
mBorderEdges.mOutsideEdge=PR_FALSE;
|
1998-12-21 09:38:18 +03:00
|
|
|
nsTableFrame* tableFrame=nsnull; // I should be checking my own style context, but border-collapse isn't inheriting correctly
|
|
|
|
nsresult rv = nsTableFrame::GetTableFrame(this, tableFrame);
|
|
|
|
if ((NS_SUCCEEDED(rv)) && (nsnull!=tableFrame))
|
|
|
|
{
|
|
|
|
const nsStyleTable* tableStyle;
|
|
|
|
tableFrame->GetStyleData(eStyleStruct_Table, ((const nsStyleStruct *&)tableStyle));
|
|
|
|
if (NS_STYLE_BORDER_COLLAPSE==tableStyle->mBorderCollapse)
|
|
|
|
{
|
|
|
|
PRInt32 rowspan = GetRowSpan();
|
|
|
|
PRInt32 i;
|
|
|
|
for (i=0; i<rowspan; i++)
|
|
|
|
{
|
|
|
|
nsBorderEdge *borderToAdd = new nsBorderEdge();
|
|
|
|
mBorderEdges.mEdges[NS_SIDE_LEFT].AppendElement(borderToAdd);
|
|
|
|
borderToAdd = new nsBorderEdge();
|
|
|
|
mBorderEdges.mEdges[NS_SIDE_RIGHT].AppendElement(borderToAdd);
|
|
|
|
}
|
|
|
|
PRInt32 colspan = GetColSpan();
|
|
|
|
for (i=0; i<colspan; i++)
|
|
|
|
{
|
|
|
|
nsBorderEdge *borderToAdd = new nsBorderEdge();
|
|
|
|
mBorderEdges.mEdges[NS_SIDE_TOP].AppendElement(borderToAdd);
|
|
|
|
borderToAdd = new nsBorderEdge();
|
|
|
|
mBorderEdges.mEdges[NS_SIDE_BOTTOM].AppendElement(borderToAdd);
|
|
|
|
}
|
|
|
|
}
|
1999-02-11 09:22:33 +03:00
|
|
|
mCollapseOffset = nsPoint(0,0);
|
1998-12-21 09:38:18 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-12-21 21:54:23 +03:00
|
|
|
void nsTableCellFrame::SetBorderEdgeLength(PRUint8 aSide,
|
|
|
|
PRInt32 aIndex,
|
|
|
|
nscoord aLength)
|
1998-12-21 09:38:18 +03:00
|
|
|
{
|
|
|
|
if ((NS_SIDE_LEFT==aSide) || (NS_SIDE_RIGHT==aSide))
|
|
|
|
{
|
1999-02-11 04:16:28 +03:00
|
|
|
PRInt32 baseRowIndex;
|
|
|
|
GetRowIndex(baseRowIndex);
|
|
|
|
PRInt32 rowIndex = aIndex-baseRowIndex;
|
1998-12-21 09:38:18 +03:00
|
|
|
nsBorderEdge *border = (nsBorderEdge *)(mBorderEdges.mEdges[aSide].ElementAt(rowIndex));
|
|
|
|
border->mLength = aLength;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
NS_ASSERTION(PR_FALSE, "bad arg aSide passed to SetBorderEdgeLength");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-04-17 05:41:24 +04:00
|
|
|
NS_METHOD nsTableCellFrame::Paint(nsIPresContext& aPresContext,
|
|
|
|
nsIRenderingContext& aRenderingContext,
|
1998-12-18 18:54:23 +03:00
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsFramePaintLayer aWhichLayer)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-12-18 18:54:23 +03:00
|
|
|
if (eFramePaintLayer_Underlay == aWhichLayer) {
|
|
|
|
const nsStyleDisplay* disp =
|
|
|
|
(const nsStyleDisplay*)mStyleContext->GetStyleData(eStyleStruct_Display);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-12-18 18:54:23 +03:00
|
|
|
if (disp->mVisible) {
|
|
|
|
const nsStyleColor* myColor =
|
|
|
|
(const nsStyleColor*)mStyleContext->GetStyleData(eStyleStruct_Color);
|
|
|
|
const nsStyleSpacing* mySpacing =
|
|
|
|
(const nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing);
|
|
|
|
NS_ASSERTION(nsnull!=myColor, "bad style color");
|
|
|
|
NS_ASSERTION(nsnull!=mySpacing, "bad style spacing");
|
1998-04-30 04:27:59 +04:00
|
|
|
|
1998-12-21 09:38:18 +03:00
|
|
|
const nsStyleTable* cellTableStyle;
|
|
|
|
GetStyleData(eStyleStruct_Table, ((const nsStyleStruct *&)cellTableStyle));
|
1998-12-18 18:54:23 +03:00
|
|
|
nsRect rect(0, 0, mRect.width, mRect.height);
|
1998-05-27 03:17:29 +04:00
|
|
|
|
1998-12-18 18:54:23 +03:00
|
|
|
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
|
1999-01-15 21:25:58 +03:00
|
|
|
aDirtyRect, rect, *myColor, *mySpacing, 0, 0);
|
1998-10-30 10:57:44 +03:00
|
|
|
|
1998-12-18 18:54:23 +03:00
|
|
|
// empty cells do not render their border
|
|
|
|
PRBool renderBorder = PR_TRUE;
|
|
|
|
if (PR_TRUE==GetContentEmpty())
|
|
|
|
{
|
|
|
|
if (NS_STYLE_TABLE_EMPTY_CELLS_HIDE==cellTableStyle->mEmptyCells)
|
|
|
|
renderBorder=PR_FALSE;
|
|
|
|
}
|
|
|
|
if (PR_TRUE==renderBorder)
|
|
|
|
{
|
1998-12-21 09:38:18 +03:00
|
|
|
PRIntn skipSides = GetSkipSides();
|
|
|
|
nsTableFrame* tableFrame=nsnull; // I should be checking my own style context, but border-collapse isn't inheriting correctly
|
|
|
|
nsresult rv = nsTableFrame::GetTableFrame(this, tableFrame);
|
|
|
|
if ((NS_SUCCEEDED(rv)) && (nsnull!=tableFrame))
|
|
|
|
{
|
|
|
|
const nsStyleTable* tableStyle;
|
|
|
|
tableFrame->GetStyleData(eStyleStruct_Table, ((const nsStyleStruct *&)tableStyle));
|
|
|
|
if (NS_STYLE_BORDER_SEPARATE==tableStyle->mBorderCollapse)
|
|
|
|
{
|
|
|
|
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
|
1999-01-23 01:38:34 +03:00
|
|
|
aDirtyRect, rect, *mySpacing, mStyleContext, skipSides);
|
1998-12-21 09:38:18 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nsCSSRendering::PaintBorderEdges(aPresContext, aRenderingContext, this,
|
1999-01-23 01:38:34 +03:00
|
|
|
aDirtyRect, rect, &mBorderEdges, mStyleContext, skipSides);
|
1998-12-21 09:38:18 +03:00
|
|
|
}
|
|
|
|
}
|
1998-12-18 18:54:23 +03:00
|
|
|
}
|
1998-07-27 11:37:57 +04:00
|
|
|
}
|
1998-05-27 03:17:29 +04:00
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
// for debug...
|
1998-12-18 18:54:23 +03:00
|
|
|
if ((eFramePaintLayer_Overlay == aWhichLayer) && GetShowFrameBorders()) {
|
1998-12-23 18:47:43 +03:00
|
|
|
aRenderingContext.SetColor(NS_RGB(0, 0, 128));
|
1998-04-14 00:24:54 +04:00
|
|
|
aRenderingContext.DrawRect(0, 0, mRect.width, mRect.height);
|
|
|
|
}
|
|
|
|
|
1999-02-11 09:22:33 +03:00
|
|
|
|
|
|
|
// if the cell originates in a row and/or col that is collapsed, the bottom and/or
|
|
|
|
// right portion of the cell is painted by translating the rendering context.
|
|
|
|
// XXX What about content that can leak outside the cell?
|
|
|
|
PRBool clipState;
|
|
|
|
aRenderingContext.PushState();
|
|
|
|
nsPoint offset = mCollapseOffset;
|
|
|
|
if ((0 != offset.x) || (0 != offset.y)) {
|
|
|
|
aRenderingContext.Translate(offset.x, offset.y);
|
|
|
|
}
|
|
|
|
aRenderingContext.SetClipRect(nsRect(-offset.x, -offset.y, mRect.width, mRect.height),
|
|
|
|
nsClipCombine_kIntersect, clipState);
|
1998-12-18 18:54:23 +03:00
|
|
|
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
|
1999-02-11 09:22:33 +03:00
|
|
|
aRenderingContext.PopState(clipState);
|
|
|
|
|
1998-04-17 05:41:24 +04:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-10-20 21:45:07 +04:00
|
|
|
PRIntn
|
|
|
|
nsTableCellFrame::GetSkipSides() const
|
|
|
|
{
|
|
|
|
PRIntn skip = 0;
|
|
|
|
if (nsnull != mPrevInFlow) {
|
|
|
|
skip |= 1 << NS_SIDE_TOP;
|
|
|
|
}
|
|
|
|
if (nsnull != mNextInFlow) {
|
|
|
|
skip |= 1 << NS_SIDE_BOTTOM;
|
|
|
|
}
|
|
|
|
return skip;
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-12-21 09:38:18 +03:00
|
|
|
void nsTableCellFrame::SetBorderEdge(PRUint8 aSide,
|
|
|
|
PRInt32 aRowIndex,
|
|
|
|
PRInt32 aColIndex,
|
1998-12-21 21:54:23 +03:00
|
|
|
nsBorderEdge *aBorder,
|
|
|
|
nscoord aOddAmountToAdd)
|
1998-12-21 09:38:18 +03:00
|
|
|
{
|
|
|
|
nsBorderEdge *border = nsnull;
|
|
|
|
switch (aSide)
|
|
|
|
{
|
|
|
|
case NS_SIDE_TOP:
|
|
|
|
{
|
1999-02-11 04:16:28 +03:00
|
|
|
PRInt32 baseColIndex;
|
|
|
|
GetColIndex(baseColIndex);
|
|
|
|
PRInt32 colIndex = aColIndex-baseColIndex;
|
1998-12-21 09:38:18 +03:00
|
|
|
border = (nsBorderEdge *)(mBorderEdges.mEdges[aSide].ElementAt(colIndex));
|
1998-12-31 02:23:45 +03:00
|
|
|
mBorderEdges.mMaxBorderWidth.top = PR_MAX(aBorder->mWidth+aOddAmountToAdd, mBorderEdges.mMaxBorderWidth.top);
|
1998-12-21 09:38:18 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case NS_SIDE_BOTTOM:
|
|
|
|
{
|
1999-02-11 04:16:28 +03:00
|
|
|
PRInt32 baseColIndex;
|
|
|
|
GetColIndex(baseColIndex);
|
|
|
|
PRInt32 colIndex = aColIndex-baseColIndex;
|
1998-12-21 09:38:18 +03:00
|
|
|
border = (nsBorderEdge *)(mBorderEdges.mEdges[aSide].ElementAt(colIndex));
|
1998-12-31 02:23:45 +03:00
|
|
|
mBorderEdges.mMaxBorderWidth.bottom = PR_MAX(aBorder->mWidth+aOddAmountToAdd, mBorderEdges.mMaxBorderWidth.bottom);
|
1998-12-21 09:38:18 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case NS_SIDE_LEFT:
|
|
|
|
{
|
1999-02-11 04:16:28 +03:00
|
|
|
PRInt32 baseRowIndex;
|
|
|
|
GetRowIndex(baseRowIndex);
|
|
|
|
PRInt32 rowIndex = aRowIndex-baseRowIndex;
|
1998-12-21 09:38:18 +03:00
|
|
|
border = (nsBorderEdge *)(mBorderEdges.mEdges[aSide].ElementAt(rowIndex));
|
1998-12-31 02:23:45 +03:00
|
|
|
mBorderEdges.mMaxBorderWidth.left = PR_MAX(aBorder->mWidth+aOddAmountToAdd, mBorderEdges.mMaxBorderWidth.left);
|
1998-12-21 09:38:18 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case NS_SIDE_RIGHT:
|
|
|
|
{
|
1999-02-11 04:16:28 +03:00
|
|
|
PRInt32 baseRowIndex;
|
|
|
|
GetRowIndex(baseRowIndex);
|
|
|
|
PRInt32 rowIndex = aRowIndex-baseRowIndex;
|
1998-12-21 09:38:18 +03:00
|
|
|
border = (nsBorderEdge *)(mBorderEdges.mEdges[aSide].ElementAt(rowIndex));
|
1998-12-31 02:23:45 +03:00
|
|
|
mBorderEdges.mMaxBorderWidth.right = PR_MAX(aBorder->mWidth+aOddAmountToAdd, mBorderEdges.mMaxBorderWidth.right);
|
1998-12-21 09:38:18 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (nsnull!=border) {
|
|
|
|
*border=*aBorder;
|
1998-12-21 21:54:23 +03:00
|
|
|
border->mWidth += aOddAmountToAdd;
|
1998-12-21 09:38:18 +03:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
NS_ASSERTION(PR_FALSE, "bad border edge state");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-10-20 21:45:07 +04:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Align the cell's child frame within the cell
|
|
|
|
*
|
|
|
|
*/
|
1998-11-20 04:01:25 +03:00
|
|
|
void nsTableCellFrame::VerticallyAlignChild()
|
1998-04-25 22:48:48 +04:00
|
|
|
{
|
1998-06-05 10:09:09 +04:00
|
|
|
const nsStyleSpacing* spacing =
|
|
|
|
(const nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing);
|
|
|
|
const nsStyleText* textStyle =
|
|
|
|
(const nsStyleText*)mStyleContext->GetStyleData(eStyleStruct_Text);
|
1998-12-23 18:47:43 +03:00
|
|
|
/* XXX: remove tableFrame when border-collapse inherits */
|
|
|
|
nsTableFrame* tableFrame=nsnull;
|
|
|
|
nsresult rv = nsTableFrame::GetTableFrame(this, tableFrame);
|
1998-05-13 02:28:01 +04:00
|
|
|
nsMargin borderPadding;
|
1998-12-23 18:47:43 +03:00
|
|
|
GetCellBorder (borderPadding, tableFrame);
|
|
|
|
nsMargin padding;
|
|
|
|
spacing->GetPadding(padding);
|
|
|
|
borderPadding += padding;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-05-13 02:28:01 +04:00
|
|
|
nscoord topInset = borderPadding.top;
|
|
|
|
nscoord bottomInset = borderPadding.bottom;
|
1998-04-29 03:57:01 +04:00
|
|
|
PRUint8 verticalAlignFlags = NS_STYLE_VERTICAL_ALIGN_MIDDLE;
|
|
|
|
if (textStyle->mVerticalAlign.GetUnit() == eStyleUnit_Enumerated) {
|
|
|
|
verticalAlignFlags = textStyle->mVerticalAlign.GetIntValue();
|
|
|
|
}
|
1998-11-20 04:01:25 +03:00
|
|
|
nscoord height = mRect.height;
|
|
|
|
nsRect kidRect;
|
1999-01-16 01:52:05 +03:00
|
|
|
nsIFrame* firstKid = mFrames.FirstChild();
|
|
|
|
firstKid->GetRect(kidRect);
|
1998-11-20 04:01:25 +03:00
|
|
|
nscoord childHeight = kidRect.height;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
|
|
|
|
// Vertically align the child
|
|
|
|
nscoord kidYTop = 0;
|
1998-04-28 01:26:48 +04:00
|
|
|
switch (verticalAlignFlags)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
case NS_STYLE_VERTICAL_ALIGN_BASELINE:
|
|
|
|
// Align the child's baseline at the max baseline
|
|
|
|
//kidYTop = aMaxAscent - kidAscent;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_STYLE_VERTICAL_ALIGN_TOP:
|
|
|
|
// Align the top of the child frame with the top of the box,
|
|
|
|
// minus the top padding
|
|
|
|
kidYTop = topInset;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_STYLE_VERTICAL_ALIGN_BOTTOM:
|
|
|
|
kidYTop = height - childHeight - bottomInset;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
case NS_STYLE_VERTICAL_ALIGN_MIDDLE:
|
|
|
|
kidYTop = height/2 - childHeight/2;
|
|
|
|
}
|
1999-01-16 01:52:05 +03:00
|
|
|
firstKid->MoveTo(kidRect.x, kidYTop);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-09-15 21:58:24 +04:00
|
|
|
PRInt32 nsTableCellFrame::GetRowSpan()
|
|
|
|
{
|
|
|
|
PRInt32 rowSpan=1;
|
|
|
|
nsIHTMLContent *hc=nsnull;
|
|
|
|
nsresult rv = mContent->QueryInterface(kIHTMLContentIID, (void**) &hc);
|
|
|
|
if (NS_OK==rv)
|
|
|
|
{
|
|
|
|
nsHTMLValue val;
|
1998-12-20 04:21:23 +03:00
|
|
|
hc->GetHTMLAttribute(nsHTMLAtoms::rowspan, val);
|
1998-09-15 21:58:24 +04:00
|
|
|
if (eHTMLUnit_Integer == val.GetUnit()) {
|
|
|
|
rowSpan=val.GetIntValue();
|
|
|
|
}
|
|
|
|
NS_RELEASE(hc);
|
|
|
|
}
|
|
|
|
return rowSpan;
|
|
|
|
}
|
1998-05-22 03:43:18 +04:00
|
|
|
|
1998-09-15 21:58:24 +04:00
|
|
|
PRInt32 nsTableCellFrame::GetColSpan()
|
|
|
|
{
|
|
|
|
PRInt32 colSpan=1;
|
|
|
|
nsIHTMLContent *hc=nsnull;
|
|
|
|
nsresult rv = mContent->QueryInterface(kIHTMLContentIID, (void**) &hc);
|
|
|
|
if (NS_OK==rv)
|
|
|
|
{
|
|
|
|
nsHTMLValue val;
|
1998-12-20 04:21:23 +03:00
|
|
|
hc->GetHTMLAttribute(nsHTMLAtoms::colspan, val);
|
1998-09-15 21:58:24 +04:00
|
|
|
if (eHTMLUnit_Integer == val.GetUnit()) {
|
|
|
|
colSpan=val.GetIntValue();
|
|
|
|
}
|
|
|
|
NS_RELEASE(hc);
|
|
|
|
}
|
|
|
|
return colSpan;
|
|
|
|
}
|
1998-05-22 03:43:18 +04:00
|
|
|
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
/**
|
|
|
|
*/
|
1998-07-15 06:53:09 +04:00
|
|
|
NS_METHOD nsTableCellFrame::Reflow(nsIPresContext& aPresContext,
|
1998-10-01 08:46:11 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
1998-10-02 08:10:00 +04:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
1998-05-25 21:31:49 +04:00
|
|
|
nsReflowStatus& aStatus)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
#ifdef NS_DEBUG
|
|
|
|
//PreReflowCheck();
|
|
|
|
#endif
|
|
|
|
|
1998-10-30 10:57:44 +03:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
1998-06-03 04:43:53 +04:00
|
|
|
// Initialize out parameter
|
|
|
|
if (nsnull != aDesiredSize.maxElementSize) {
|
|
|
|
aDesiredSize.maxElementSize->width = 0;
|
|
|
|
aDesiredSize.maxElementSize->height = 0;
|
|
|
|
}
|
|
|
|
|
1998-05-12 08:17:56 +04:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
1998-06-24 03:23:21 +04:00
|
|
|
if (PR_TRUE==gsDebug || PR_TRUE==gsDebugNT)
|
|
|
|
printf("%p nsTableCellFrame::Reflow: maxSize=%d,%d\n",
|
1999-01-06 02:31:18 +03:00
|
|
|
this, aReflowState.availableWidth, aReflowState.availableHeight);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-01-06 02:31:18 +03:00
|
|
|
nsSize availSize(aReflowState.availableWidth, aReflowState.availableHeight);
|
1998-04-14 00:24:54 +04:00
|
|
|
nsSize maxElementSize;
|
1998-05-25 21:31:49 +04:00
|
|
|
nsSize *pMaxElementSize = aDesiredSize.maxElementSize;
|
1999-01-06 02:31:18 +03:00
|
|
|
if (NS_UNCONSTRAINEDSIZE==aReflowState.availableWidth)
|
1998-04-14 00:24:54 +04:00
|
|
|
pMaxElementSize = &maxElementSize;
|
|
|
|
nscoord x = 0;
|
|
|
|
// SEC: what about ascent and decent???
|
|
|
|
|
|
|
|
// Compute the insets (sum of border and padding)
|
1998-06-05 10:09:09 +04:00
|
|
|
const nsStyleSpacing* spacing =
|
|
|
|
(const nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing);
|
1998-05-22 03:43:18 +04:00
|
|
|
|
1998-12-23 18:47:43 +03:00
|
|
|
/* XXX: remove tableFrame when border-collapse inherits */
|
|
|
|
nsTableFrame* tableFrame=nsnull;
|
|
|
|
rv = nsTableFrame::GetTableFrame(this, tableFrame);
|
1998-05-13 02:28:01 +04:00
|
|
|
nsMargin borderPadding;
|
1998-12-23 18:47:43 +03:00
|
|
|
GetCellBorder (borderPadding, tableFrame);
|
|
|
|
nsMargin padding;
|
|
|
|
spacing->GetPadding(padding);
|
|
|
|
borderPadding += padding;
|
1998-05-13 02:28:01 +04:00
|
|
|
|
|
|
|
nscoord topInset = borderPadding.top;
|
|
|
|
nscoord rightInset = borderPadding.right;
|
|
|
|
nscoord bottomInset = borderPadding.bottom;
|
|
|
|
nscoord leftInset = borderPadding.left;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-07-07 01:00:11 +04:00
|
|
|
// reduce available space by insets, if we're in a constrained situation
|
1998-06-26 04:48:44 +04:00
|
|
|
if (NS_UNCONSTRAINEDSIZE!=availSize.width)
|
1998-07-07 01:00:11 +04:00
|
|
|
availSize.width -= leftInset+rightInset;
|
1998-06-26 04:48:44 +04:00
|
|
|
if (NS_UNCONSTRAINEDSIZE!=availSize.height)
|
1998-11-22 11:56:19 +03:00
|
|
|
availSize.height -= topInset+bottomInset;
|
1998-06-26 04:48:44 +04:00
|
|
|
|
1998-10-30 10:57:44 +03:00
|
|
|
if (eReflowReason_Incremental == aReflowState.reason)
|
|
|
|
{
|
1998-07-17 02:15:02 +04:00
|
|
|
// XXX We *must* do this otherwise incremental reflow that's
|
|
|
|
// passing through will not work right.
|
|
|
|
nsIFrame* next;
|
|
|
|
aReflowState.reflowCommand->GetNext(next);
|
1998-10-30 10:57:44 +03:00
|
|
|
|
|
|
|
// if it is a StyleChanged reflow targeted at this cell frame,
|
|
|
|
// handle that here
|
|
|
|
// first determine if this frame is the target or not
|
|
|
|
nsIFrame *target=nsnull;
|
|
|
|
rv = aReflowState.reflowCommand->GetTarget(target);
|
|
|
|
if ((PR_TRUE==NS_SUCCEEDED(rv)) && (nsnull!=target))
|
|
|
|
{
|
|
|
|
if (this==target)
|
|
|
|
{
|
|
|
|
nsIReflowCommand::ReflowType type;
|
|
|
|
aReflowState.reflowCommand->GetType(type);
|
|
|
|
if (nsIReflowCommand::StyleChanged==type)
|
|
|
|
{
|
|
|
|
nsresult rv = IR_StyleChanged(aPresContext, aDesiredSize, aReflowState, aStatus);
|
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// if any of these conditions are not true, we just pass the reflow command down
|
1998-07-17 02:15:02 +04:00
|
|
|
}
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
// Try to reflow the child into the available space. It might not
|
|
|
|
// fit or might need continuing.
|
1998-04-23 21:29:07 +04:00
|
|
|
if (availSize.height < 0)
|
|
|
|
availSize.height = 1;
|
1998-09-24 20:37:22 +04:00
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
if (gsDebug==PR_TRUE)
|
1998-09-10 00:00:40 +04:00
|
|
|
printf(" nsTableCellFrame::Reflow calling ReflowChild with availSize=%d,%d\n",
|
1998-04-14 00:24:54 +04:00
|
|
|
availSize.width, availSize.height);
|
1998-10-01 08:46:11 +04:00
|
|
|
nsHTMLReflowMetrics kidSize(pMaxElementSize);
|
1998-06-03 04:43:53 +04:00
|
|
|
kidSize.width=kidSize.height=kidSize.ascent=kidSize.descent=0;
|
1999-01-06 02:31:18 +03:00
|
|
|
SetPriorAvailWidth(aReflowState.availableWidth);
|
1999-01-16 01:52:05 +03:00
|
|
|
nsIFrame* firstKid = mFrames.FirstChild();
|
|
|
|
nsHTMLReflowState kidReflowState(aPresContext, firstKid, aReflowState,
|
1998-10-12 18:48:02 +04:00
|
|
|
availSize);
|
1998-10-01 08:46:11 +04:00
|
|
|
|
1999-01-16 01:52:05 +03:00
|
|
|
ReflowChild(firstKid, aPresContext, kidSize, kidReflowState, aStatus);
|
1998-09-10 00:00:40 +04:00
|
|
|
#ifdef NS_DEBUG
|
1998-10-06 04:27:22 +04:00
|
|
|
if (kidSize.width > availSize.width)
|
|
|
|
{
|
1998-11-10 02:35:05 +03:00
|
|
|
printf("WARNING: cell ");
|
1998-11-19 20:22:29 +03:00
|
|
|
nsAutoString tmp;
|
1999-01-16 01:52:05 +03:00
|
|
|
firstKid->GetFrameName(tmp);
|
1998-11-19 20:22:29 +03:00
|
|
|
fputs(tmp, stdout);
|
1998-11-10 02:35:05 +03:00
|
|
|
printf(" content returned desired width %d given avail width %d\n",
|
1998-10-06 04:27:22 +04:00
|
|
|
kidSize.width, availSize.width);
|
1998-10-01 08:46:11 +04:00
|
|
|
}
|
1998-12-08 22:18:33 +03:00
|
|
|
#endif
|
|
|
|
|
1998-12-05 08:27:21 +03:00
|
|
|
// Nav4 hack for 0 dimensioned cells.
|
|
|
|
// Empty cells are assigned a width and height of 4px
|
1998-11-25 21:43:56 +03:00
|
|
|
// see testcase "cellHeights.html"
|
1998-12-10 22:57:42 +03:00
|
|
|
if (eReflowReason_Initial == aReflowState.reason)
|
|
|
|
{
|
|
|
|
if ((0==kidSize.width) && (0==kidSize.height))
|
|
|
|
SetContentEmpty(PR_TRUE);
|
|
|
|
else
|
|
|
|
SetContentEmpty(PR_FALSE);
|
|
|
|
}
|
1998-11-25 21:43:56 +03:00
|
|
|
if (0==kidSize.width)
|
|
|
|
{
|
1998-12-31 01:41:08 +03:00
|
|
|
if (eReflowReason_Initial == aReflowState.reason)
|
|
|
|
{
|
|
|
|
float p2t;
|
1999-02-12 20:45:58 +03:00
|
|
|
aPresContext.GetScaledPixelsToTwips(&p2t);
|
1998-12-31 01:41:08 +03:00
|
|
|
kidSize.width=NSIntPixelsToTwips(4, p2t);
|
|
|
|
if (nsnull!=aDesiredSize.maxElementSize && 0==pMaxElementSize->width)
|
|
|
|
pMaxElementSize->width=NSIntPixelsToTwips(4, p2t);
|
|
|
|
if (gsDebug) printf ("setting initial child width from 0 to %d for nav4 compatibility\n", NSIntPixelsToTwips(4, p2t));
|
|
|
|
}
|
|
|
|
else // empty content has to be forced to the assigned width for resize or incremental reflow
|
1999-01-06 02:31:18 +03:00
|
|
|
kidSize.width = kidReflowState.availableWidth;
|
1998-11-25 21:43:56 +03:00
|
|
|
}
|
1998-12-05 08:27:21 +03:00
|
|
|
if (0==kidSize.height)
|
|
|
|
{
|
|
|
|
float p2t;
|
1999-02-12 20:45:58 +03:00
|
|
|
aPresContext.GetScaledPixelsToTwips(&p2t);
|
1998-12-05 08:27:21 +03:00
|
|
|
kidSize.height=NSIntPixelsToTwips(4, p2t);
|
|
|
|
if (nsnull!=aDesiredSize.maxElementSize && 0==pMaxElementSize->width)
|
|
|
|
pMaxElementSize->height=NSIntPixelsToTwips(4, p2t);
|
|
|
|
if (gsDebug) printf ("setting child height from 0 to %d for nav4 compatibility\n", NSIntPixelsToTwips(4, p2t));
|
|
|
|
}
|
|
|
|
// end Nav4 hack for 0 dimensioned cells
|
1998-12-08 22:18:33 +03:00
|
|
|
|
1998-06-24 03:23:21 +04:00
|
|
|
if (PR_TRUE==gsDebug || PR_TRUE==gsDebugNT)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
if (nsnull!=pMaxElementSize)
|
1998-08-04 00:27:59 +04:00
|
|
|
printf(" %p cellFrame child returned desiredSize=%d,%d, and maxElementSize=%d,%d\n",
|
1998-06-24 03:23:21 +04:00
|
|
|
this, kidSize.width, kidSize.height,
|
1998-04-14 00:24:54 +04:00
|
|
|
pMaxElementSize->width, pMaxElementSize->height);
|
|
|
|
else
|
1998-08-04 00:27:59 +04:00
|
|
|
printf(" %p cellFrame child returned desiredSize=%d,%d, and maxElementSize=nsnull\n",
|
1998-06-24 03:23:21 +04:00
|
|
|
this, kidSize.width, kidSize.height);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-06-05 06:36:25 +04:00
|
|
|
// Place the child
|
1998-09-10 00:00:40 +04:00
|
|
|
//////////////////////////////// HACK //////////////////////////////
|
|
|
|
kidSize.width = PR_MIN(kidSize.width, availSize.width);
|
|
|
|
///////////////////////////// END HACK /////////////////////////////
|
1999-01-16 01:52:05 +03:00
|
|
|
firstKid->SetRect(nsRect(leftInset, topInset,
|
1998-06-05 06:36:25 +04:00
|
|
|
kidSize.width, kidSize.height));
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
// Return our size and our result
|
1998-06-05 06:36:25 +04:00
|
|
|
|
|
|
|
// first, compute the height
|
|
|
|
// the height can be set w/o being restricted by aMaxSize.height
|
|
|
|
nscoord cellHeight = kidSize.height;
|
1998-07-13 23:22:45 +04:00
|
|
|
// NAV4 compatibility: only add insets if cell content was not 0 height
|
|
|
|
if (0!=kidSize.height)
|
|
|
|
cellHeight += topInset + bottomInset;
|
1998-06-24 03:23:21 +04:00
|
|
|
if (PR_TRUE==gsDebugNT)
|
|
|
|
printf(" %p cellFrame height set to %d from kidSize=%d and insets %d,%d\n",
|
|
|
|
this, cellHeight, kidSize.height, topInset, bottomInset);
|
1998-06-05 06:36:25 +04:00
|
|
|
// next determine the cell's width
|
1998-07-07 01:00:11 +04:00
|
|
|
nscoord cellWidth = kidSize.width; // at this point, we've factored in the cell's style attributes
|
1998-07-02 21:40:56 +04:00
|
|
|
|
1998-12-08 22:18:33 +03:00
|
|
|
// add the insets into the cell width (in both the constrained-width and unconstrained-width cases
|
|
|
|
cellWidth += leftInset + rightInset; // factor in border and padding
|
1998-07-31 04:32:27 +04:00
|
|
|
|
1998-06-05 06:36:25 +04:00
|
|
|
// set the cell's desired size and max element size
|
|
|
|
aDesiredSize.width = cellWidth;
|
|
|
|
aDesiredSize.height = cellHeight;
|
1998-04-14 00:24:54 +04:00
|
|
|
aDesiredSize.ascent = topInset;
|
|
|
|
aDesiredSize.descent = bottomInset;
|
1998-05-25 21:31:49 +04:00
|
|
|
if (nsnull!=aDesiredSize.maxElementSize)
|
1998-04-21 02:49:15 +04:00
|
|
|
{
|
1998-05-25 21:31:49 +04:00
|
|
|
*aDesiredSize.maxElementSize = *pMaxElementSize;
|
1998-07-14 00:41:38 +04:00
|
|
|
if (0!=pMaxElementSize->height)
|
|
|
|
aDesiredSize.maxElementSize->height += topInset + bottomInset;
|
|
|
|
if (0!=pMaxElementSize->width)
|
|
|
|
aDesiredSize.maxElementSize->width += leftInset + rightInset;
|
1998-04-21 02:49:15 +04:00
|
|
|
}
|
1998-10-03 00:36:35 +04:00
|
|
|
// remember my desired size for this reflow
|
1998-07-11 04:00:31 +04:00
|
|
|
SetDesiredSize(aDesiredSize);
|
1998-10-03 00:36:35 +04:00
|
|
|
|
1998-06-24 03:23:21 +04:00
|
|
|
if (PR_TRUE==gsDebug || PR_TRUE==gsDebugNT)
|
|
|
|
printf(" %p cellFrame returning aDesiredSize=%d,%d\n",
|
|
|
|
this, aDesiredSize.width, aDesiredSize.height);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-10-08 19:34:48 +04:00
|
|
|
aDesiredSize.ascent=aDesiredSize.height;
|
|
|
|
aDesiredSize.descent=0;
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
#ifdef NS_DEBUG
|
|
|
|
//PostReflowCheck(result);
|
|
|
|
#endif
|
|
|
|
|
1998-04-17 05:41:24 +04:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-10-30 10:57:44 +03:00
|
|
|
NS_METHOD nsTableCellFrame::IR_StyleChanged(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
|
|
|
if (PR_TRUE==gsDebug) printf("Cell IR: IR_StyleChanged for frame %p\n", this);
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
// we presume that all the easy optimizations were done in the nsHTMLStyleSheet before we were called here
|
|
|
|
// XXX: we can optimize this when we know which style attribute changed
|
|
|
|
nsTableFrame* tableFrame=nsnull;
|
|
|
|
rv = nsTableFrame::GetTableFrame(this, tableFrame);
|
|
|
|
if ((NS_SUCCEEDED(rv)) && (nsnull!=tableFrame))
|
|
|
|
{
|
|
|
|
tableFrame->InvalidateCellMap();
|
|
|
|
tableFrame->InvalidateFirstPassCache();
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1998-05-07 04:08:20 +04:00
|
|
|
NS_METHOD
|
1998-07-15 07:23:23 +04:00
|
|
|
nsTableCellFrame::CreateContinuingFrame(nsIPresContext& aPresContext,
|
1998-05-07 04:08:20 +04:00
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIStyleContext* aStyleContext,
|
|
|
|
nsIFrame*& aContinuingFrame)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-12-03 09:31:43 +03:00
|
|
|
nsTableCellFrame* cf = new nsTableCellFrame;
|
1998-05-07 04:08:20 +04:00
|
|
|
if (nsnull == cf) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
1999-02-25 06:27:57 +03:00
|
|
|
cf->Init(aPresContext, mContent, aParent, aStyleContext, this);
|
1999-02-11 04:16:28 +03:00
|
|
|
PRInt32 baseColIndex;
|
|
|
|
GetColIndex(baseColIndex);
|
|
|
|
cf->InitCellFrame(baseColIndex);
|
1998-04-17 05:41:24 +04:00
|
|
|
aContinuingFrame = cf;
|
1998-12-15 19:39:09 +03:00
|
|
|
|
|
|
|
// Create a continuing body frame
|
|
|
|
nsIFrame* childList;
|
|
|
|
nsIStyleContext* kidSC;
|
|
|
|
|
1999-01-16 01:52:05 +03:00
|
|
|
nsIFrame* firstKid = mFrames.FirstChild();
|
1999-02-10 03:42:56 +03:00
|
|
|
firstKid->GetStyleContext(&kidSC);
|
1999-01-16 01:52:05 +03:00
|
|
|
firstKid->CreateContinuingFrame(aPresContext, cf, kidSC, childList);
|
1998-12-15 19:39:09 +03:00
|
|
|
NS_RELEASE(kidSC);
|
|
|
|
cf->SetInitialChildList(aPresContext, nsnull, childList);
|
1998-04-17 05:41:24 +04:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-05-02 00:44:55 +04:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Update the border style to map to the HTML border style
|
|
|
|
*
|
|
|
|
*/
|
1998-11-11 22:56:02 +03:00
|
|
|
void nsTableCellFrame::MapHTMLBorderStyle(nsIPresContext* aPresContext,
|
|
|
|
nsStyleSpacing& aSpacingStyle,
|
|
|
|
nscoord aBorderWidth,
|
|
|
|
nsTableFrame *aTableFrame)
|
1998-05-02 00:44:55 +04:00
|
|
|
{
|
1998-05-13 02:28:01 +04:00
|
|
|
nsStyleCoord width;
|
|
|
|
width.SetCoordValue(aBorderWidth);
|
|
|
|
aSpacingStyle.mBorder.SetTop(width);
|
|
|
|
aSpacingStyle.mBorder.SetLeft(width);
|
|
|
|
aSpacingStyle.mBorder.SetBottom(width);
|
|
|
|
aSpacingStyle.mBorder.SetRight(width);
|
|
|
|
|
1998-07-21 11:47:46 +04:00
|
|
|
// XXX This should come from the default style sheet (ua.css), and
|
|
|
|
// not be hardcoded. Using solid causes the borders not to show up...
|
1998-10-13 23:17:57 +04:00
|
|
|
#if 1
|
1998-12-07 22:06:55 +03:00
|
|
|
|
1999-01-23 01:38:34 +03:00
|
|
|
aSpacingStyle.SetBorderStyle(NS_SIDE_TOP, NS_STYLE_BORDER_STYLE_BG_INSET);
|
|
|
|
aSpacingStyle.SetBorderStyle(NS_SIDE_LEFT, NS_STYLE_BORDER_STYLE_BG_INSET);
|
|
|
|
aSpacingStyle.SetBorderStyle(NS_SIDE_BOTTOM, NS_STYLE_BORDER_STYLE_BG_INSET);
|
|
|
|
aSpacingStyle.SetBorderStyle(NS_SIDE_RIGHT, NS_STYLE_BORDER_STYLE_BG_INSET);
|
1998-12-07 22:06:55 +03:00
|
|
|
|
1998-07-21 11:47:46 +04:00
|
|
|
#endif
|
1998-05-02 00:44:55 +04:00
|
|
|
|
1998-09-24 20:37:22 +04:00
|
|
|
nsTableFrame* tableFrame;
|
|
|
|
nsTableFrame::GetTableFrame(this, tableFrame);
|
1998-05-27 00:57:24 +04:00
|
|
|
nsIStyleContext* styleContext = nsnull;
|
|
|
|
|
1999-02-10 03:42:56 +03:00
|
|
|
tableFrame->GetStyleContext(&styleContext);
|
1998-05-27 00:57:24 +04:00
|
|
|
|
1998-07-23 22:05:03 +04:00
|
|
|
const nsStyleColor* colorData =
|
|
|
|
nsStyleUtil::FindNonTransparentBackground(styleContext);
|
|
|
|
NS_IF_RELEASE(styleContext);
|
1998-05-27 00:57:24 +04:00
|
|
|
|
|
|
|
// Yaahoo, we found a style context which has a background color
|
|
|
|
nscolor borderColor = 0xFFC0C0C0;
|
|
|
|
|
1998-07-23 22:05:03 +04:00
|
|
|
if (colorData != nsnull)
|
1998-05-27 00:57:24 +04:00
|
|
|
borderColor = colorData->mBackgroundColor;
|
|
|
|
|
|
|
|
// if the border color is white, then shift to grey
|
|
|
|
if (borderColor == 0xFFFFFFFF)
|
|
|
|
borderColor = 0xFFC0C0C0;
|
1998-12-07 22:06:55 +03:00
|
|
|
aSpacingStyle.SetBorderColor(NS_SIDE_TOP, borderColor);
|
|
|
|
aSpacingStyle.SetBorderColor(NS_SIDE_LEFT, borderColor);
|
|
|
|
aSpacingStyle.SetBorderColor(NS_SIDE_BOTTOM, borderColor);
|
|
|
|
aSpacingStyle.SetBorderColor(NS_SIDE_RIGHT, borderColor);
|
|
|
|
|
1998-11-11 22:56:02 +03:00
|
|
|
//adjust the border style based on the table rules attribute
|
|
|
|
const nsStyleTable* tableStyle;
|
|
|
|
tableFrame->GetStyleData(eStyleStruct_Table, (const nsStyleStruct *&)tableStyle);
|
|
|
|
|
|
|
|
switch (tableStyle->mRules)
|
|
|
|
{
|
|
|
|
case NS_STYLE_TABLE_RULES_NONE:
|
1998-12-07 22:06:55 +03:00
|
|
|
aSpacingStyle.SetBorderStyle(NS_SIDE_TOP, NS_STYLE_BORDER_STYLE_NONE);
|
|
|
|
aSpacingStyle.SetBorderStyle(NS_SIDE_LEFT, NS_STYLE_BORDER_STYLE_NONE);
|
|
|
|
aSpacingStyle.SetBorderStyle(NS_SIDE_BOTTOM, NS_STYLE_BORDER_STYLE_NONE);
|
|
|
|
aSpacingStyle.SetBorderStyle(NS_SIDE_RIGHT, NS_STYLE_BORDER_STYLE_NONE);
|
1998-11-11 22:56:02 +03:00
|
|
|
break;
|
|
|
|
case NS_STYLE_TABLE_RULES_GROUPS:
|
1998-12-08 22:18:33 +03:00
|
|
|
#ifdef NS_DEBUG
|
|
|
|
printf("warning: NS_STYLE_TABLE_RULES_GROUPS used but not yet implemented.\n");
|
|
|
|
#endif
|
1998-11-11 22:56:02 +03:00
|
|
|
// XXX: it depends on which cell this is!
|
|
|
|
/*
|
1998-12-08 22:18:33 +03:00
|
|
|
for h-sides, walk up content parent list to row and see what "index in parent" row is.
|
|
|
|
if it is 0 or last, then draw the rule. otherwise, don't. Probably just compare
|
|
|
|
against FirstChild and LastChild.
|
|
|
|
for v-sides, do the same thing only for col and colgroup.
|
|
|
|
*/
|
|
|
|
/*
|
1998-11-11 22:56:02 +03:00
|
|
|
aSpacingStyle.mBorderStyle[NS_SIDE_TOP] = NS_STYLE_BORDER_STYLE_NONE;
|
|
|
|
aSpacingStyle.mBorderStyle[NS_SIDE_RIGHT] = NS_STYLE_BORDER_STYLE_NONE;
|
|
|
|
aSpacingStyle.mBorderStyle[NS_SIDE_BOTTOM] = NS_STYLE_BORDER_STYLE_NONE;
|
|
|
|
aSpacingStyle.mBorderStyle[NS_SIDE_LEFT] = NS_STYLE_BORDER_STYLE_NONE;
|
|
|
|
*/
|
|
|
|
break;
|
|
|
|
case NS_STYLE_TABLE_RULES_COLS:
|
1998-12-07 22:06:55 +03:00
|
|
|
aSpacingStyle.SetBorderStyle(NS_SIDE_TOP, NS_STYLE_BORDER_STYLE_NONE);
|
|
|
|
aSpacingStyle.SetBorderStyle(NS_SIDE_BOTTOM, NS_STYLE_BORDER_STYLE_NONE);
|
1998-11-11 22:56:02 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_STYLE_TABLE_RULES_ROWS:
|
1998-12-07 22:06:55 +03:00
|
|
|
aSpacingStyle.SetBorderStyle(NS_SIDE_LEFT, NS_STYLE_BORDER_STYLE_NONE);
|
|
|
|
aSpacingStyle.SetBorderStyle(NS_SIDE_RIGHT, NS_STYLE_BORDER_STYLE_NONE);
|
1998-11-11 22:56:02 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
// do nothing for "ALL" or for any illegal value
|
|
|
|
}
|
1998-05-02 00:44:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-05-22 03:43:18 +04:00
|
|
|
PRBool nsTableCellFrame::ConvertToPixelValue(nsHTMLValue& aValue, PRInt32 aDefault, PRInt32& aResult)
|
1998-05-02 01:55:36 +04:00
|
|
|
{
|
|
|
|
PRInt32 result = 0;
|
|
|
|
|
1998-05-22 03:43:18 +04:00
|
|
|
if (aValue.GetUnit() == eHTMLUnit_Pixel)
|
1998-05-02 01:55:36 +04:00
|
|
|
aResult = aValue.GetPixelValue();
|
|
|
|
else if (aValue.GetUnit() == eHTMLUnit_Empty)
|
|
|
|
aResult = aDefault;
|
|
|
|
else
|
1998-05-22 03:43:18 +04:00
|
|
|
{
|
|
|
|
NS_ERROR("Unit must be pixel or empty");
|
1998-05-02 01:55:36 +04:00
|
|
|
return PR_FALSE;
|
1998-05-22 03:43:18 +04:00
|
|
|
}
|
1998-05-02 01:55:36 +04:00
|
|
|
return PR_TRUE;
|
|
|
|
}
|
1998-05-02 00:44:55 +04:00
|
|
|
|
|
|
|
void nsTableCellFrame::MapBorderMarginPadding(nsIPresContext* aPresContext)
|
|
|
|
{
|
|
|
|
// Check to see if the table has either cell padding or
|
|
|
|
// Cell spacing defined for the table. If true, then
|
|
|
|
// this setting overrides any specific border, margin or
|
|
|
|
// padding information in the cell. If these attributes
|
|
|
|
// are not defined, the the cells attributes are used
|
|
|
|
|
1998-09-24 20:37:22 +04:00
|
|
|
nsTableFrame* tableFrame;
|
|
|
|
nsTableFrame::GetTableFrame(this, tableFrame);
|
1998-11-20 04:01:25 +03:00
|
|
|
NS_ASSERTION(tableFrame,"Table must not be null");
|
1998-06-11 19:46:37 +04:00
|
|
|
if (!tableFrame)
|
1998-05-02 00:44:55 +04:00
|
|
|
return;
|
|
|
|
|
1998-12-05 08:27:21 +03:00
|
|
|
nscoord padding = tableFrame->GetCellPadding();
|
1998-12-09 09:37:18 +03:00
|
|
|
nscoord spacingX = tableFrame->GetCellSpacingX();
|
|
|
|
nscoord spacingY = tableFrame->GetCellSpacingY();
|
1998-12-05 08:27:21 +03:00
|
|
|
nscoord border = 1;
|
|
|
|
|
|
|
|
|
1998-06-11 19:46:37 +04:00
|
|
|
// get the table frame style context, and from it get cellpadding, cellspacing, and border info
|
1998-11-11 22:56:02 +03:00
|
|
|
const nsStyleTable* tableStyle;
|
|
|
|
tableFrame->GetStyleData(eStyleStruct_Table, (const nsStyleStruct *&)tableStyle);
|
1998-12-02 19:45:20 +03:00
|
|
|
const nsStyleSpacing* tableSpacingStyle;
|
|
|
|
tableFrame->GetStyleData(eStyleStruct_Spacing,(const nsStyleStruct *&)tableSpacingStyle);
|
1998-06-05 10:09:09 +04:00
|
|
|
nsStyleSpacing* spacingData = (nsStyleSpacing*)mStyleContext->GetMutableStyleData(eStyleStruct_Spacing);
|
1998-05-13 02:28:01 +04:00
|
|
|
|
1998-12-09 09:37:18 +03:00
|
|
|
spacingData->mMargin.SetTop(spacingY);
|
|
|
|
spacingData->mMargin.SetLeft(spacingX);
|
|
|
|
spacingData->mMargin.SetBottom(spacingY);
|
|
|
|
spacingData->mMargin.SetRight(spacingX);
|
1998-12-05 08:27:21 +03:00
|
|
|
spacingData->mPadding.SetTop(padding);
|
|
|
|
spacingData->mPadding.SetLeft(padding);
|
|
|
|
spacingData->mPadding.SetBottom(padding);
|
|
|
|
spacingData->mPadding.SetRight(padding);
|
1998-05-02 01:55:36 +04:00
|
|
|
|
1998-06-11 19:46:37 +04:00
|
|
|
// get border information from the table
|
1998-11-11 22:56:02 +03:00
|
|
|
if (tableStyle->mRules!= NS_STYLE_TABLE_RULES_NONE)
|
1998-06-11 19:46:37 +04:00
|
|
|
{
|
1998-11-11 22:56:02 +03:00
|
|
|
// XXX: need to get border width here
|
|
|
|
// in HTML, cell borders are always 1 pixel by default
|
1998-11-14 04:52:27 +03:00
|
|
|
float p2t;
|
1999-02-12 20:45:58 +03:00
|
|
|
aPresContext->GetScaledPixelsToTwips(&p2t);
|
1998-11-14 04:52:27 +03:00
|
|
|
border = NSIntPixelsToTwips(1, p2t);
|
1998-11-11 22:56:02 +03:00
|
|
|
MapHTMLBorderStyle(aPresContext, *spacingData, border, tableFrame);
|
1998-05-02 00:44:55 +04:00
|
|
|
}
|
1998-11-20 04:01:25 +03:00
|
|
|
|
1999-01-03 22:22:40 +03:00
|
|
|
MapVAlignAttribute(aPresContext, tableFrame);
|
|
|
|
MapHAlignAttribute(aPresContext, tableFrame);
|
1998-06-24 03:23:21 +04:00
|
|
|
|
1998-05-02 00:44:55 +04:00
|
|
|
}
|
|
|
|
|
1999-01-03 22:22:40 +03:00
|
|
|
/* XXX: this code will not work properly until the style and layout code has been updated
|
|
|
|
* as outlined in Bugzilla bug report 1802 and 915 */
|
|
|
|
void nsTableCellFrame::MapVAlignAttribute(nsIPresContext* aPresContext, nsTableFrame *aTableFrame)
|
|
|
|
{
|
|
|
|
const nsStyleText* textStyle;
|
|
|
|
GetStyleData(eStyleStruct_Text,(const nsStyleStruct *&)textStyle);
|
|
|
|
// check if valign is set on the cell
|
|
|
|
// this condition will also be true if we inherited valign from the row or rowgroup
|
|
|
|
if (textStyle->mVerticalAlign.GetUnit() == eStyleUnit_Enumerated)
|
|
|
|
{
|
|
|
|
return; // valign is already set on this cell
|
|
|
|
}
|
|
|
|
|
|
|
|
// check if valign is set on the cell's COL (or COLGROUP by inheritance)
|
|
|
|
nsTableColFrame *colFrame;
|
1999-02-11 04:16:28 +03:00
|
|
|
PRInt32 colIndex;
|
|
|
|
GetColIndex(colIndex);
|
|
|
|
aTableFrame->GetColumnFrame(colIndex, colFrame);
|
1999-01-03 22:22:40 +03:00
|
|
|
const nsStyleText* colTextStyle;
|
|
|
|
colFrame->GetStyleData(eStyleStruct_Text,(const nsStyleStruct *&)colTextStyle);
|
|
|
|
if (colTextStyle->mVerticalAlign.GetUnit() == eStyleUnit_Enumerated)
|
|
|
|
{
|
|
|
|
nsStyleText* mutableTextStyle = (nsStyleText*)mStyleContext->GetMutableStyleData(eStyleStruct_Text);
|
|
|
|
mutableTextStyle->mVerticalAlign.SetIntValue(colTextStyle->mVerticalAlign.GetIntValue(), eStyleUnit_Enumerated);
|
|
|
|
return; // valign set from COL info
|
|
|
|
}
|
|
|
|
|
|
|
|
// otherwise, set the vertical align attribute to the HTML default
|
|
|
|
nsStyleText* mutableTextStyle = (nsStyleText*)mStyleContext->GetMutableStyleData(eStyleStruct_Text);
|
|
|
|
mutableTextStyle->mVerticalAlign.SetIntValue(NS_STYLE_VERTICAL_ALIGN_MIDDLE, eStyleUnit_Enumerated);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* XXX: this code will not work properly until the style and layout code has been updated
|
|
|
|
* as outlined in Bugzilla bug report 1802 and 915.
|
|
|
|
* In particular, mTextAlign has to be an nsStyleCoord, not just an int */
|
|
|
|
void nsTableCellFrame::MapHAlignAttribute(nsIPresContext* aPresContext, nsTableFrame *aTableFrame)
|
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
const nsStyleText* textStyle;
|
|
|
|
GetStyleData(eStyleStruct_Text,(const nsStyleStruct *&)textStyle);
|
|
|
|
// check if halign is set on the cell
|
|
|
|
// cells do not inherited halign from the row or rowgroup
|
|
|
|
if (textStyle->mTextAlign.GetUnit() == eStyleUnit_Enumerated)
|
|
|
|
{
|
|
|
|
if (textStyle->mTextAlign.GetIntValue() != NS_STYLE_TEXT_ALIGN_DEFAULT)
|
|
|
|
return; // valign is already set on this cell
|
|
|
|
}
|
|
|
|
|
|
|
|
// check if halign is set on the cell's ROW (or ROWGROUP by inheritance)
|
|
|
|
nsIFrame *rowFrame;
|
|
|
|
aTableFrame->GetContentParent(rowFrame);
|
|
|
|
const nsStyleText* rowTextStyle;
|
|
|
|
rowFrame->GetStyleData(eStyleStruct_Text,(const nsStyleStruct *&)rowTextStyle);
|
|
|
|
if (rowTextStyle->mTextAlign.GetUnit() == eStyleUnit_Enumerated)
|
|
|
|
{
|
|
|
|
nsStyleText* mutableTextStyle = (nsStyleText*)mStyleContext->GetMutableStyleData(eStyleStruct_Text);
|
|
|
|
mutableTextStyle->mTextAlign.SetIntValue(rowTextStyle->mTextAlign.GetIntValue(), eStyleUnit_Enumerated);
|
|
|
|
return; // halign set from ROW info
|
|
|
|
}
|
|
|
|
|
|
|
|
// check if halign is set on the cell's COL (or COLGROUP by inheritance)
|
|
|
|
nsTableColFrame *colFrame;
|
1999-02-11 04:16:28 +03:00
|
|
|
PRInt32 colIndex;
|
|
|
|
GetColIndex(colIndex);
|
|
|
|
aTableFrame->GetColumnFrame(colIndex, colFrame);
|
1999-01-03 22:22:40 +03:00
|
|
|
const nsStyleText* colTextStyle;
|
|
|
|
colFrame->GetStyleData(eStyleStruct_Text,(const nsStyleStruct *&)colTextStyle);
|
|
|
|
if (colTextStyle->mTextAlign.GetUnit() == eStyleUnit_Enumerated)
|
|
|
|
{
|
|
|
|
nsStyleText* mutableTextStyle = (nsStyleText*)mStyleContext->GetMutableStyleData(eStyleStruct_Text);
|
|
|
|
mutableTextStyle->mTextAlign.SetIntValue(colTextStyle->mTextAlign.GetIntValue(), eStyleUnit_Enumerated);
|
|
|
|
return; // halign set from COL info
|
|
|
|
}
|
|
|
|
|
|
|
|
// otherwise, set the vertical align attribute to the HTML default (center for TH, left for TD and all others)
|
|
|
|
nsStyleText* mutableTextStyle = (nsStyleText*)mStyleContext->GetMutableStyleData(eStyleStruct_Text);
|
|
|
|
nsIAtom *tag=nsnull;
|
|
|
|
if (nsnull!=mContent)
|
|
|
|
mContent->GetTag(tag);
|
|
|
|
if (nsHTMLAtoms::th==tag)
|
|
|
|
mutableTextStyle->mVerticalAlign.SetIntValue(NS_STYLE_TEXT_ALIGN_CENTER, eStyleUnit_Enumerated);
|
|
|
|
else
|
|
|
|
mutableTextStyle->mVerticalAlign.SetIntValue(NS_STYLE_TEXT_ALIGN_LEFT, eStyleUnit_Enumerated);
|
|
|
|
#endif
|
|
|
|
}
|
1998-05-02 00:44:55 +04:00
|
|
|
|
|
|
|
// Subclass hook for style post processing
|
|
|
|
NS_METHOD nsTableCellFrame::DidSetStyleContext(nsIPresContext* aPresContext)
|
|
|
|
{
|
|
|
|
#ifdef NOISY_STYLE
|
|
|
|
printf("nsTableCellFrame::DidSetStyleContext \n");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
MapBorderMarginPadding(aPresContext);
|
1998-05-13 02:28:01 +04:00
|
|
|
mStyleContext->RecalcAutomaticData(aPresContext);
|
1998-05-02 00:44:55 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-06-24 03:23:21 +04:00
|
|
|
NS_METHOD
|
|
|
|
nsTableCellFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(0 != aInstancePtr, "null ptr");
|
|
|
|
if (NULL == aInstancePtr) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
1999-02-11 04:16:28 +03:00
|
|
|
if (aIID.Equals(nsITableCellLayout::IID())) {
|
|
|
|
*aInstancePtr = (void*)(nsISupports*)(nsITableCellLayout*)this;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-06-24 03:23:21 +04:00
|
|
|
return nsContainerFrame::QueryInterface(aIID, aInstancePtr);
|
|
|
|
}
|
1998-05-22 03:43:18 +04:00
|
|
|
|
1998-09-15 21:58:24 +04:00
|
|
|
/* ----- global methods ----- */
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-09-15 21:58:24 +04:00
|
|
|
nsresult
|
1998-12-03 09:31:43 +03:00
|
|
|
NS_NewTableCellFrame(nsIFrame*& aResult)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-12-03 09:31:43 +03:00
|
|
|
nsIFrame* it = new nsTableCellFrame;
|
1998-04-14 00:24:54 +04:00
|
|
|
if (nsnull == it) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
1998-09-15 21:58:24 +04:00
|
|
|
aResult = it;
|
1998-04-14 00:24:54 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-05-22 03:43:18 +04:00
|
|
|
|
|
|
|
|
1998-07-11 04:00:31 +04:00
|
|
|
|
|
|
|
/* ----- methods from CellLayoutData ----- */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Given a frame and an edge, find the margin
|
|
|
|
*
|
|
|
|
**/
|
|
|
|
nscoord nsTableCellFrame::GetMargin(nsIFrame* aFrame, PRUint8 aEdge) const
|
|
|
|
{
|
|
|
|
nscoord result = 0;
|
|
|
|
|
|
|
|
if (aFrame)
|
|
|
|
{
|
|
|
|
const nsStyleSpacing* spacing;
|
|
|
|
aFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct*&)spacing);
|
|
|
|
nsMargin margin;
|
|
|
|
spacing->CalcMarginFor(aFrame, margin);
|
|
|
|
switch (aEdge)
|
|
|
|
{
|
|
|
|
case NS_SIDE_TOP:
|
|
|
|
result = margin.top;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_SIDE_RIGHT:
|
|
|
|
result = margin.right;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_SIDE_BOTTOM:
|
|
|
|
result = margin.bottom;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_SIDE_LEFT:
|
|
|
|
result = margin.left;
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Given an Edge, find the opposing edge (top<-->bottom, left<-->right)
|
|
|
|
*
|
|
|
|
**/
|
|
|
|
PRUint8 nsTableCellFrame::GetOpposingEdge(PRUint8 aEdge)
|
|
|
|
{
|
|
|
|
PRUint8 result;
|
|
|
|
|
|
|
|
switch (aEdge)
|
|
|
|
{
|
|
|
|
case NS_SIDE_LEFT:
|
|
|
|
result = NS_SIDE_RIGHT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_SIDE_RIGHT:
|
|
|
|
result = NS_SIDE_LEFT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_SIDE_TOP:
|
|
|
|
result = NS_SIDE_BOTTOM;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_SIDE_BOTTOM:
|
|
|
|
result = NS_SIDE_TOP;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
result = NS_SIDE_TOP;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Given a List of cell layout data, compare the edges to see which has the
|
|
|
|
* border with the highest precidence.
|
|
|
|
*
|
|
|
|
**/
|
|
|
|
nscoord nsTableCellFrame::FindLargestMargin(nsVoidArray* aList,PRUint8 aEdge)
|
|
|
|
{
|
|
|
|
nscoord result = 0;
|
|
|
|
PRInt32 index = 0;
|
|
|
|
PRInt32 count = 0;
|
|
|
|
|
|
|
|
|
|
|
|
NS_ASSERTION(aList,"a List must be valid");
|
|
|
|
count = aList->Count();
|
|
|
|
if (count)
|
|
|
|
{
|
|
|
|
nsIFrame* frame;
|
|
|
|
|
|
|
|
nscoord value = 0;
|
|
|
|
while (index < count)
|
|
|
|
{
|
|
|
|
frame = (nsIFrame*)(aList->ElementAt(index++));
|
|
|
|
value = GetMargin(frame, aEdge);
|
|
|
|
if (value > result)
|
|
|
|
result = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-12-23 18:47:43 +03:00
|
|
|
void nsTableCellFrame::GetCellBorder(nsMargin &aBorder, nsTableFrame *aTableFrame)
|
|
|
|
{
|
|
|
|
aBorder.left = aBorder.right = aBorder.top = aBorder.bottom = 0;
|
|
|
|
if (nsnull==aTableFrame)
|
|
|
|
return;
|
1998-07-11 04:00:31 +04:00
|
|
|
|
1998-12-23 18:47:43 +03:00
|
|
|
if (NS_STYLE_BORDER_COLLAPSE==aTableFrame->GetBorderCollapseStyle())
|
|
|
|
{
|
|
|
|
aBorder = mBorderEdges.mMaxBorderWidth;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const nsStyleSpacing* spacing;
|
|
|
|
aTableFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct*&)spacing);
|
|
|
|
spacing->GetBorder(aBorder);
|
|
|
|
}
|
|
|
|
}
|
1998-07-11 04:00:31 +04:00
|
|
|
|
|
|
|
void nsTableCellFrame::CalculateMargins(nsTableFrame* aTableFrame,
|
|
|
|
nsVoidArray* aBoundaryCells[4])
|
|
|
|
{
|
|
|
|
// By default the margin is just the margin found in the
|
|
|
|
// table cells style
|
|
|
|
const nsStyleSpacing* spacing;
|
|
|
|
GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct*&)spacing);
|
|
|
|
spacing->CalcMarginFor(this, mMargin);
|
|
|
|
|
|
|
|
// Left and Top Margins are collapsed with their neightbors
|
|
|
|
// Right and Bottom Margins are simple left as they are
|
|
|
|
nscoord value;
|
|
|
|
|
|
|
|
// The left and top sides margins are the difference between
|
|
|
|
// their inherint value and the value of the margin of the
|
|
|
|
// object to the left or right of them.
|
|
|
|
|
|
|
|
value = FindLargestMargin(aBoundaryCells[NS_SIDE_LEFT],NS_SIDE_RIGHT);
|
|
|
|
if (value > mMargin.left)
|
|
|
|
mMargin.left = 0;
|
|
|
|
else
|
|
|
|
mMargin.left -= value;
|
|
|
|
|
|
|
|
value = FindLargestMargin(aBoundaryCells[NS_SIDE_TOP],NS_SIDE_BOTTOM);
|
|
|
|
if (value > mMargin.top)
|
|
|
|
mMargin.top = 0;
|
|
|
|
else
|
|
|
|
mMargin.top -= value;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void nsTableCellFrame::RecalcLayoutData(nsTableFrame* aTableFrame,
|
|
|
|
nsVoidArray* aBoundaryCells[4])
|
|
|
|
|
|
|
|
{
|
|
|
|
CalculateBorders(aTableFrame, aBoundaryCells);
|
|
|
|
CalculateMargins(aTableFrame, aBoundaryCells);
|
|
|
|
mCalculated = NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-02-24 08:54:31 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableCellFrame::GetFrameType(nsIAtom** aType) const
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aType, "null OUT parameter pointer");
|
|
|
|
*aType = nsLayoutAtoms::tableCellFrame;
|
|
|
|
NS_ADDREF(*aType);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-11-19 20:22:29 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableCellFrame::GetFrameName(nsString& aResult) const
|
|
|
|
{
|
|
|
|
return MakeFrameName("TableCell", aResult);
|
|
|
|
}
|
1999-02-11 09:22:33 +03:00
|
|
|
|
|
|
|
void nsTableCellFrame::SetCollapseOffsetX(nscoord aXOffset)
|
|
|
|
{
|
|
|
|
mCollapseOffset.x = aXOffset;
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsTableCellFrame::SetCollapseOffsetY(nscoord aYOffset)
|
|
|
|
{
|
|
|
|
mCollapseOffset.y = aYOffset;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsPoint nsTableCellFrame::GetCollapseOffset()
|
|
|
|
{
|
|
|
|
return mCollapseOffset;
|
|
|
|
}
|
|
|
|
|