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.
|
|
|
|
*/
|
1999-02-12 20:45:58 +03:00
|
|
|
#include "nsCOMPtr.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsTableFrame.h"
|
|
|
|
#include "nsIRenderingContext.h"
|
|
|
|
#include "nsIStyleContext.h"
|
|
|
|
#include "nsIContent.h"
|
|
|
|
#include "nsCellMap.h"
|
|
|
|
#include "nsTableCellFrame.h"
|
1998-09-15 21:58:24 +04:00
|
|
|
#include "nsHTMLParts.h"
|
1998-06-05 06:36:25 +04:00
|
|
|
#include "nsTableColFrame.h"
|
1998-06-17 20:38:24 +04:00
|
|
|
#include "nsTableColGroupFrame.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsTableRowFrame.h"
|
|
|
|
#include "nsTableRowGroupFrame.h"
|
1998-09-30 03:15:01 +04:00
|
|
|
#include "nsTableOuterFrame.h"
|
1998-09-15 21:58:24 +04:00
|
|
|
#include "nsIHTMLContent.h"
|
1998-04-30 21:57:09 +04:00
|
|
|
|
|
|
|
#include "BasicTableLayoutStrategy.h"
|
1998-09-30 03:15:01 +04:00
|
|
|
#include "FixedTableLayoutStrategy.h"
|
1998-04-30 21:57:09 +04:00
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsIPresContext.h"
|
|
|
|
#include "nsCSSRendering.h"
|
|
|
|
#include "nsStyleConsts.h"
|
|
|
|
#include "nsVoidArray.h"
|
1998-04-22 10:37:57 +04:00
|
|
|
#include "nsIPtr.h"
|
1998-05-22 03:43:18 +04:00
|
|
|
#include "nsIView.h"
|
1998-05-27 00:57:24 +04:00
|
|
|
#include "nsHTMLAtoms.h"
|
1998-06-05 06:36:25 +04:00
|
|
|
#include "nsHTMLIIDs.h"
|
1998-06-23 09:43:27 +04:00
|
|
|
#include "nsIReflowCommand.h"
|
1998-12-09 08:30:17 +03:00
|
|
|
#include "nsLayoutAtoms.h"
|
1999-01-18 02:35:56 +03:00
|
|
|
#include "nsIDeviceContext.h"
|
1999-02-24 07:03:50 +03:00
|
|
|
#include "nsIStyleSet.h"
|
|
|
|
#include "nsIPresShell.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
#ifdef NS_DEBUG
|
1998-06-02 01:07:56 +04:00
|
|
|
static PRBool gsDebug = PR_FALSE;
|
1999-03-05 07:19:09 +03:00
|
|
|
//static PRBool gsDebugCLD = PR_FALSE;
|
1998-06-24 03:23:21 +04:00
|
|
|
static PRBool gsDebugNT = PR_FALSE;
|
1998-10-11 13:18:27 +04:00
|
|
|
static PRBool gsDebugIR = PR_FALSE;
|
1998-04-14 00:24:54 +04:00
|
|
|
#else
|
|
|
|
static const PRBool gsDebug = PR_FALSE;
|
1999-03-05 07:19:09 +03:00
|
|
|
//static const PRBool gsDebugCLD = PR_FALSE;
|
1998-06-24 03:23:21 +04:00
|
|
|
static const PRBool gsDebugNT = PR_FALSE;
|
1998-10-11 13:18:27 +04:00
|
|
|
static const PRBool gsDebugIR = PR_FALSE;
|
1998-04-14 00:24:54 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef max
|
|
|
|
#define max(x, y) ((x) > (y) ? (x) : (y))
|
|
|
|
#endif
|
|
|
|
|
1998-04-22 10:37:57 +04:00
|
|
|
NS_DEF_PTR(nsIStyleContext);
|
|
|
|
NS_DEF_PTR(nsIContent);
|
1998-06-17 20:38:24 +04:00
|
|
|
|
1999-01-30 18:52:19 +03:00
|
|
|
static NS_DEFINE_IID(kITableRowGroupFrameIID, NS_ITABLEROWGROUPFRAME_IID);
|
|
|
|
|
1998-10-10 01:53:07 +04:00
|
|
|
static const PRInt32 kColumnWidthIncrement=100;
|
|
|
|
|
1998-06-17 20:38:24 +04:00
|
|
|
/* ----------- CellData ---------- */
|
|
|
|
|
|
|
|
/* CellData is the info stored in the cell map */
|
|
|
|
CellData::CellData()
|
|
|
|
{
|
1999-07-28 12:09:02 +04:00
|
|
|
mOrigCell = nsnull;
|
|
|
|
mSpanData = nsnull;
|
|
|
|
mSpanData2 = nsnull;
|
1998-06-17 20:38:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
CellData::~CellData()
|
|
|
|
{}
|
1998-04-22 10:37:57 +04:00
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
/* ----------- InnerTableReflowState ---------- */
|
|
|
|
|
|
|
|
struct InnerTableReflowState {
|
|
|
|
|
1998-05-30 00:36:05 +04:00
|
|
|
// Our reflow state
|
1998-10-02 08:10:00 +04:00
|
|
|
const nsHTMLReflowState& reflowState;
|
1998-05-30 00:36:05 +04:00
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
// The body's available size (computed from the body's parent)
|
|
|
|
nsSize availSize;
|
|
|
|
|
|
|
|
// Flags for whether the max size is unconstrained
|
|
|
|
PRBool unconstrainedWidth;
|
|
|
|
PRBool unconstrainedHeight;
|
|
|
|
|
|
|
|
// Running y-offset
|
|
|
|
nscoord y;
|
|
|
|
|
1999-03-05 09:00:40 +03:00
|
|
|
// Pointer to the footer in the table
|
|
|
|
nsIFrame* footerFrame;
|
1998-04-23 21:29:07 +04:00
|
|
|
|
1999-03-05 09:00:40 +03:00
|
|
|
// The first body section row group frame, i.e. not a header or footer
|
|
|
|
nsIFrame* firstBodySection;
|
1998-04-23 21:29:07 +04:00
|
|
|
|
1998-10-11 13:18:27 +04:00
|
|
|
InnerTableReflowState(nsIPresContext& aPresContext,
|
1998-10-02 08:10:00 +04:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
const nsMargin& aBorderPadding)
|
1998-05-30 00:36:05 +04:00
|
|
|
: reflowState(aReflowState)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-01-05 03:41:40 +03:00
|
|
|
y=0; // border/padding???
|
1998-04-25 22:48:48 +04:00
|
|
|
|
1999-01-06 02:31:18 +03:00
|
|
|
unconstrainedWidth = PRBool(aReflowState.availableWidth == NS_UNCONSTRAINEDSIZE);
|
|
|
|
availSize.width = aReflowState.availableWidth;
|
1998-04-25 22:48:48 +04:00
|
|
|
if (!unconstrainedWidth) {
|
1998-05-13 02:28:01 +04:00
|
|
|
availSize.width -= aBorderPadding.left + aBorderPadding.right;
|
1998-04-25 22:48:48 +04:00
|
|
|
}
|
|
|
|
|
1999-01-06 02:31:18 +03:00
|
|
|
unconstrainedHeight = PRBool(aReflowState.availableHeight == NS_UNCONSTRAINEDSIZE);
|
|
|
|
availSize.height = aReflowState.availableHeight;
|
1998-04-25 22:48:48 +04:00
|
|
|
if (!unconstrainedHeight) {
|
1998-05-13 02:28:01 +04:00
|
|
|
availSize.height -= aBorderPadding.top + aBorderPadding.bottom;
|
1998-04-25 22:48:48 +04:00
|
|
|
}
|
|
|
|
|
1999-03-05 09:00:40 +03:00
|
|
|
footerFrame = nsnull;
|
|
|
|
firstBodySection = nsnull;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
1998-06-05 06:36:25 +04:00
|
|
|
/* ----------- ColumnInfoCache ---------- */
|
|
|
|
|
|
|
|
static const PRInt32 NUM_COL_WIDTH_TYPES=4;
|
|
|
|
|
|
|
|
class ColumnInfoCache
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ColumnInfoCache(PRInt32 aNumColumns);
|
|
|
|
~ColumnInfoCache();
|
|
|
|
|
|
|
|
void AddColumnInfo(const nsStyleUnit aType,
|
|
|
|
PRInt32 aColumnIndex);
|
|
|
|
|
|
|
|
void GetColumnsByType(const nsStyleUnit aType,
|
|
|
|
PRInt32& aOutNumColumns,
|
|
|
|
PRInt32 *& aOutColumnIndexes);
|
|
|
|
enum ColWidthType {
|
|
|
|
eColWidthType_Auto = 0, // width based on contents
|
|
|
|
eColWidthType_Percent = 1, // (float) 1.0 == 100%
|
|
|
|
eColWidthType_Coord = 2, // (nscoord) value is twips
|
1998-06-27 06:47:44 +04:00
|
|
|
eColWidthType_Proportional = 3 // (int) value has proportional meaning
|
1998-06-05 06:36:25 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
|
|
|
PRInt32 mColCounts [4];
|
|
|
|
PRInt32 *mColIndexes[4];
|
|
|
|
PRInt32 mNumColumns;
|
|
|
|
};
|
|
|
|
|
|
|
|
ColumnInfoCache::ColumnInfoCache(PRInt32 aNumColumns)
|
|
|
|
{
|
1998-10-23 07:23:29 +04:00
|
|
|
if (PR_TRUE==gsDebug || PR_TRUE==gsDebugIR) printf("CIC constructor: aNumColumns %d\n", aNumColumns);
|
1998-06-05 06:36:25 +04:00
|
|
|
mNumColumns = aNumColumns;
|
|
|
|
for (PRInt32 i=0; i<NUM_COL_WIDTH_TYPES; i++)
|
|
|
|
{
|
|
|
|
mColCounts[i] = 0;
|
|
|
|
mColIndexes[i] = nsnull;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ColumnInfoCache::~ColumnInfoCache()
|
|
|
|
{
|
|
|
|
for (PRInt32 i=0; i<NUM_COL_WIDTH_TYPES; i++)
|
|
|
|
{
|
|
|
|
if (nsnull!=mColIndexes[i])
|
|
|
|
{
|
|
|
|
delete [] mColIndexes[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ColumnInfoCache::AddColumnInfo(const nsStyleUnit aType,
|
|
|
|
PRInt32 aColumnIndex)
|
|
|
|
{
|
1998-10-23 07:23:29 +04:00
|
|
|
if (PR_TRUE==gsDebug || PR_TRUE==gsDebugIR) printf("CIC AddColumnInfo: adding col index %d of type %d\n", aColumnIndex, aType);
|
1998-10-15 02:51:50 +04:00
|
|
|
// a table may have more COLs than actual columns, so we guard against that here
|
|
|
|
if (aColumnIndex<mNumColumns)
|
1998-06-05 06:36:25 +04:00
|
|
|
{
|
1998-10-15 02:51:50 +04:00
|
|
|
switch (aType)
|
|
|
|
{
|
|
|
|
case eStyleUnit_Auto:
|
|
|
|
if (nsnull==mColIndexes[eColWidthType_Auto])
|
|
|
|
mColIndexes[eColWidthType_Auto] = new PRInt32[mNumColumns]; // TODO : be much more efficient
|
|
|
|
mColIndexes[eColWidthType_Auto][mColCounts[eColWidthType_Auto]] = aColumnIndex;
|
|
|
|
mColCounts[eColWidthType_Auto]++;
|
|
|
|
break;
|
1998-06-05 06:36:25 +04:00
|
|
|
|
1998-10-15 02:51:50 +04:00
|
|
|
case eStyleUnit_Percent:
|
|
|
|
if (nsnull==mColIndexes[eColWidthType_Percent])
|
|
|
|
mColIndexes[eColWidthType_Percent] = new PRInt32[mNumColumns]; // TODO : be much more efficient
|
|
|
|
mColIndexes[eColWidthType_Percent][mColCounts[eColWidthType_Percent]] = aColumnIndex;
|
|
|
|
mColCounts[eColWidthType_Percent]++;
|
|
|
|
break;
|
1998-06-05 06:36:25 +04:00
|
|
|
|
1998-10-15 02:51:50 +04:00
|
|
|
case eStyleUnit_Coord:
|
|
|
|
if (nsnull==mColIndexes[eColWidthType_Coord])
|
|
|
|
mColIndexes[eColWidthType_Coord] = new PRInt32[mNumColumns]; // TODO : be much more efficient
|
|
|
|
mColIndexes[eColWidthType_Coord][mColCounts[eColWidthType_Coord]] = aColumnIndex;
|
|
|
|
mColCounts[eColWidthType_Coord]++;
|
|
|
|
break;
|
1998-06-05 06:36:25 +04:00
|
|
|
|
1998-10-15 02:51:50 +04:00
|
|
|
case eStyleUnit_Proportional:
|
|
|
|
if (nsnull==mColIndexes[eColWidthType_Proportional])
|
|
|
|
mColIndexes[eColWidthType_Proportional] = new PRInt32[mNumColumns]; // TODO : be much more efficient
|
|
|
|
mColIndexes[eColWidthType_Proportional][mColCounts[eColWidthType_Proportional]] = aColumnIndex;
|
|
|
|
mColCounts[eColWidthType_Proportional]++;
|
|
|
|
break;
|
1999-02-12 20:45:58 +03:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
1998-10-15 02:51:50 +04:00
|
|
|
}
|
1998-06-05 06:36:25 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ColumnInfoCache::GetColumnsByType(const nsStyleUnit aType,
|
1998-10-20 09:05:17 +04:00
|
|
|
PRInt32& aOutNumColumns,
|
|
|
|
PRInt32 *& aOutColumnIndexes)
|
1998-06-05 06:36:25 +04:00
|
|
|
{
|
1998-06-30 04:37:03 +04:00
|
|
|
// initialize out-params
|
|
|
|
aOutNumColumns=0;
|
|
|
|
aOutColumnIndexes=nsnull;
|
|
|
|
|
|
|
|
// fill out params with column info based on aType
|
1998-06-05 06:36:25 +04:00
|
|
|
switch (aType)
|
|
|
|
{
|
|
|
|
case eStyleUnit_Auto:
|
|
|
|
aOutNumColumns = mColCounts[eColWidthType_Auto];
|
|
|
|
aOutColumnIndexes = mColIndexes[eColWidthType_Auto];
|
|
|
|
break;
|
|
|
|
case eStyleUnit_Percent:
|
|
|
|
aOutNumColumns = mColCounts[eColWidthType_Percent];
|
|
|
|
aOutColumnIndexes = mColIndexes[eColWidthType_Percent];
|
|
|
|
break;
|
|
|
|
case eStyleUnit_Coord:
|
|
|
|
aOutNumColumns = mColCounts[eColWidthType_Coord];
|
|
|
|
aOutColumnIndexes = mColIndexes[eColWidthType_Coord];
|
|
|
|
break;
|
|
|
|
case eStyleUnit_Proportional:
|
|
|
|
aOutNumColumns = mColCounts[eColWidthType_Proportional];
|
|
|
|
aOutColumnIndexes = mColIndexes[eColWidthType_Proportional];
|
|
|
|
break;
|
1999-02-12 20:45:58 +03:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
1998-06-05 06:36:25 +04:00
|
|
|
}
|
1998-10-23 07:23:29 +04:00
|
|
|
if (PR_TRUE==gsDebug || PR_TRUE==gsDebugIR) printf("CIC GetColumnsByType: found %d of type %d\n", aOutNumColumns, aType);
|
1998-06-05 06:36:25 +04:00
|
|
|
}
|
|
|
|
|
1999-02-24 08:54:31 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableFrame::GetFrameType(nsIAtom** aType) const
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aType, "null OUT parameter pointer");
|
|
|
|
*aType = nsLayoutAtoms::tableFrame;
|
|
|
|
NS_ADDREF(*aType);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
|
1998-06-17 20:38:24 +04:00
|
|
|
/* --------------------- nsTableFrame -------------------- */
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-12-03 21:01:35 +03:00
|
|
|
|
1998-12-03 09:31:43 +03:00
|
|
|
nsTableFrame::nsTableFrame()
|
|
|
|
: nsHTMLContainerFrame(),
|
1998-10-16 01:07:37 +04:00
|
|
|
mColumnWidthsValid(PR_FALSE),
|
1999-03-05 07:19:09 +03:00
|
|
|
mFirstPassValid(PR_FALSE),
|
1998-10-15 02:51:50 +04:00
|
|
|
mColumnCacheValid(PR_FALSE),
|
1998-10-14 20:32:45 +04:00
|
|
|
mCellMapValid(PR_TRUE),
|
1999-01-18 02:35:56 +03:00
|
|
|
mIsInvariantWidth(PR_FALSE),
|
1999-03-05 07:19:09 +03:00
|
|
|
mHasScrollableRowGroup(PR_FALSE),
|
|
|
|
mCellMap(nsnull),
|
|
|
|
mColCache(nsnull),
|
|
|
|
mTableLayoutStrategy(nsnull)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-10-11 13:18:27 +04:00
|
|
|
mColumnWidthsSet=PR_FALSE;
|
|
|
|
mColumnWidthsLength = kColumnWidthIncrement;
|
1998-10-10 01:53:07 +04:00
|
|
|
mColumnWidths = new PRInt32[mColumnWidthsLength];
|
|
|
|
nsCRT::memset (mColumnWidths, 0, mColumnWidthsLength*sizeof(PRInt32));
|
1998-09-24 01:48:26 +04:00
|
|
|
mCellMap = new nsCellMap(0, 0);
|
1998-12-23 18:47:43 +03:00
|
|
|
mBorderEdges.mOutsideEdge=PR_TRUE;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 08:27:21 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableFrame::Init(nsIPresContext& aPresContext,
|
|
|
|
nsIContent* aContent,
|
1999-01-14 08:16:23 +03:00
|
|
|
nsIFrame* aParent,
|
1999-02-25 06:27:57 +03:00
|
|
|
nsIStyleContext* aContext,
|
|
|
|
nsIFrame* aPrevInFlow)
|
1998-12-05 08:27:21 +03:00
|
|
|
{
|
1999-02-25 08:31:15 +03:00
|
|
|
nsresult rv;
|
1998-12-05 08:27:21 +03:00
|
|
|
|
1999-02-25 08:31:15 +03:00
|
|
|
// Let the base class do its processing
|
|
|
|
rv = nsHTMLContainerFrame::Init(aPresContext, aContent, aParent, aContext,
|
|
|
|
aPrevInFlow);
|
|
|
|
|
|
|
|
if (aPrevInFlow) {
|
|
|
|
// set my width, because all frames in a table flow are the same width and
|
|
|
|
// code in nsTableOuterFrame depends on this being set
|
|
|
|
nsSize size;
|
|
|
|
aPrevInFlow->GetSize(size);
|
|
|
|
mRect.width = size.width;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
1998-12-05 08:27:21 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
nsTableFrame::~nsTableFrame()
|
|
|
|
{
|
1999-07-01 11:12:46 +04:00
|
|
|
if (nsnull!=mCellMap) {
|
|
|
|
delete mCellMap;
|
|
|
|
mCellMap = nsnull;
|
|
|
|
}
|
1998-06-17 20:38:24 +04:00
|
|
|
|
1999-07-01 11:12:46 +04:00
|
|
|
if (nsnull!=mColumnWidths) {
|
1998-04-14 00:24:54 +04:00
|
|
|
delete [] mColumnWidths;
|
1999-07-01 11:12:46 +04:00
|
|
|
mColumnWidths = nsnull;
|
|
|
|
}
|
1998-06-17 20:38:24 +04:00
|
|
|
|
1999-07-01 11:12:46 +04:00
|
|
|
if (nsnull!=mTableLayoutStrategy) {
|
1998-04-30 21:57:09 +04:00
|
|
|
delete mTableLayoutStrategy;
|
1999-07-01 11:12:46 +04:00
|
|
|
mTableLayoutStrategy = nsnull;
|
|
|
|
}
|
1998-06-17 20:38:24 +04:00
|
|
|
|
1999-07-01 11:12:46 +04:00
|
|
|
if (nsnull!=mColCache) {
|
1998-06-05 06:36:25 +04:00
|
|
|
delete mColCache;
|
1999-07-01 11:12:46 +04:00
|
|
|
mColCache = nsnull;
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-12-04 06:14:28 +03:00
|
|
|
NS_IMETHODIMP
|
1999-07-22 06:24:52 +04:00
|
|
|
nsTableFrame::Destroy(nsIPresContext& aPresContext)
|
1998-12-04 06:14:28 +03:00
|
|
|
{
|
1999-07-22 08:00:57 +04:00
|
|
|
mColGroups.DestroyFrames(aPresContext);
|
1999-07-22 06:24:52 +04:00
|
|
|
return nsHTMLContainerFrame::Destroy(aPresContext);
|
1998-12-04 06:14:28 +03:00
|
|
|
}
|
|
|
|
|
1998-09-16 21:19:20 +04:00
|
|
|
NS_IMETHODIMP
|
1998-11-10 09:05:32 +03:00
|
|
|
nsTableFrame::SetInitialChildList(nsIPresContext& aPresContext,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aChildList)
|
1998-09-16 21:19:20 +04:00
|
|
|
{
|
1998-10-14 20:32:45 +04:00
|
|
|
nsresult rv=NS_OK;
|
1999-01-16 01:52:05 +03:00
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
// I know now that I have all my children, so build the cell map
|
1998-12-03 21:01:35 +03:00
|
|
|
nsIFrame *childFrame = aChildList;
|
|
|
|
nsIFrame *prevMainChild = nsnull;
|
|
|
|
nsIFrame *prevColGroupChild = nsnull;
|
|
|
|
for ( ; nsnull!=childFrame; )
|
1998-10-14 20:32:45 +04:00
|
|
|
{
|
1998-12-03 21:01:35 +03:00
|
|
|
const nsStyleDisplay *childDisplay;
|
1998-12-05 04:47:37 +03:00
|
|
|
childFrame->GetStyleData(eStyleStruct_Display, (const nsStyleStruct *&)childDisplay);
|
1998-12-03 21:01:35 +03:00
|
|
|
if (PR_TRUE==IsRowGroup(childDisplay->mDisplay))
|
|
|
|
{
|
1999-01-16 01:52:05 +03:00
|
|
|
if (mFrames.IsEmpty())
|
|
|
|
mFrames.SetFrames(childFrame);
|
1998-12-03 21:01:35 +03:00
|
|
|
else
|
|
|
|
prevMainChild->SetNextSibling(childFrame);
|
1999-03-03 19:33:57 +03:00
|
|
|
// If we have a prev-in-flow, then we're a table that has been split and
|
|
|
|
// so don't treat this like an append
|
|
|
|
if (!mPrevInFlow) {
|
|
|
|
rv = DidAppendRowGroup(GetRowGroupFrameFor(childFrame, childDisplay));
|
|
|
|
}
|
1998-12-03 21:01:35 +03:00
|
|
|
prevMainChild = childFrame;
|
|
|
|
}
|
|
|
|
else if (NS_STYLE_DISPLAY_TABLE_COLUMN_GROUP == childDisplay->mDisplay)
|
1998-10-14 20:32:45 +04:00
|
|
|
{
|
1999-01-16 01:52:05 +03:00
|
|
|
if (mColGroups.IsEmpty())
|
|
|
|
mColGroups.SetFrames(childFrame);
|
1998-12-03 21:01:35 +03:00
|
|
|
else
|
|
|
|
prevColGroupChild->SetNextSibling(childFrame);
|
|
|
|
prevColGroupChild = childFrame;
|
1998-10-14 20:32:45 +04:00
|
|
|
}
|
1998-12-03 21:01:35 +03:00
|
|
|
else
|
|
|
|
{ // unknown frames go on the main list for now
|
1999-01-16 01:52:05 +03:00
|
|
|
if (mFrames.IsEmpty())
|
|
|
|
mFrames.SetFrames(childFrame);
|
1998-12-03 21:01:35 +03:00
|
|
|
else
|
|
|
|
prevMainChild->SetNextSibling(childFrame);
|
|
|
|
prevMainChild = childFrame;
|
|
|
|
}
|
|
|
|
nsIFrame *prevChild = childFrame;
|
1999-02-10 09:13:38 +03:00
|
|
|
childFrame->GetNextSibling(&childFrame);
|
1998-12-03 21:01:35 +03:00
|
|
|
prevChild->SetNextSibling(nsnull);
|
1998-10-14 20:32:45 +04:00
|
|
|
}
|
1998-12-03 21:01:35 +03:00
|
|
|
if (nsnull!=prevMainChild)
|
|
|
|
prevMainChild->SetNextSibling(nsnull);
|
|
|
|
if (nsnull!=prevColGroupChild)
|
|
|
|
prevColGroupChild->SetNextSibling(nsnull);
|
|
|
|
|
1999-07-28 12:09:02 +04:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
//mCellMap->Dump();
|
1998-10-14 20:32:45 +04:00
|
|
|
EnsureColumns(aPresContext);
|
1999-07-28 12:09:02 +04:00
|
|
|
}
|
1998-12-03 21:01:35 +03:00
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
return rv;
|
1998-09-16 21:19:20 +04:00
|
|
|
}
|
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
NS_IMETHODIMP nsTableFrame::DidAppendRowGroup(nsTableRowGroupFrame *aRowGroupFrame)
|
|
|
|
{
|
|
|
|
nsresult rv=NS_OK;
|
|
|
|
nsIFrame *nextRow=nsnull;
|
1999-02-10 05:25:01 +03:00
|
|
|
aRowGroupFrame->FirstChild(nsnull, &nextRow);
|
1999-02-10 09:13:38 +03:00
|
|
|
for ( ; nsnull!=nextRow; nextRow->GetNextSibling(&nextRow))
|
1998-10-14 20:32:45 +04:00
|
|
|
{
|
|
|
|
const nsStyleDisplay *rowDisplay;
|
1998-12-02 19:45:20 +03:00
|
|
|
nextRow->GetStyleData(eStyleStruct_Display, (const nsStyleStruct *&)rowDisplay);
|
1999-02-11 09:22:33 +03:00
|
|
|
if (NS_STYLE_DISPLAY_TABLE_ROW==rowDisplay->mDisplay) {
|
1998-10-14 20:32:45 +04:00
|
|
|
rv = ((nsTableRowFrame *)nextRow)->InitChildren();
|
1999-02-11 09:22:33 +03:00
|
|
|
if (NS_FAILED(rv)) {
|
1998-10-14 20:32:45 +04:00
|
|
|
return rv;
|
1999-02-11 09:22:33 +03:00
|
|
|
}
|
1998-10-14 20:32:45 +04:00
|
|
|
}
|
1999-06-14 12:01:00 +04:00
|
|
|
else if (NS_STYLE_DISPLAY_TABLE_ROW_GROUP==rowDisplay->mDisplay) {
|
|
|
|
rv = DidAppendRowGroup((nsTableRowGroupFrame*)nextRow);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
}
|
1998-10-14 20:32:45 +04:00
|
|
|
}
|
1999-02-11 09:22:33 +03:00
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-06-17 20:38:24 +04:00
|
|
|
/* ****** CellMap methods ******* */
|
|
|
|
|
|
|
|
/* counts columns in column groups */
|
|
|
|
PRInt32 nsTableFrame::GetSpecifiedColumnCount ()
|
|
|
|
{
|
1999-07-28 12:09:02 +04:00
|
|
|
PRInt32 colCount = 0;
|
1999-01-16 01:52:05 +03:00
|
|
|
nsIFrame * childFrame = mColGroups.FirstChild();
|
1999-07-28 12:09:02 +04:00
|
|
|
while (nsnull!=childFrame) {
|
|
|
|
colCount += ((nsTableColGroupFrame *)childFrame)->GetColumnCount();
|
1999-02-10 09:13:38 +03:00
|
|
|
childFrame->GetNextSibling(&childFrame);
|
1998-06-17 20:38:24 +04:00
|
|
|
}
|
1999-07-28 12:09:02 +04:00
|
|
|
if (PR_TRUE==gsDebug) printf("TIF GetSpecifiedColumnCount: returning %d\n", colCount);
|
|
|
|
return colCount;
|
1998-06-17 20:38:24 +04:00
|
|
|
}
|
|
|
|
|
1998-11-20 04:01:25 +03:00
|
|
|
PRInt32 nsTableFrame::GetRowCount () const
|
1998-06-17 20:38:24 +04:00
|
|
|
{
|
|
|
|
PRInt32 rowCount = 0;
|
1998-08-14 20:16:43 +04:00
|
|
|
nsCellMap *cellMap = GetCellMap();
|
1998-10-14 20:32:45 +04:00
|
|
|
NS_ASSERTION(nsnull!=cellMap, "GetRowCount null cellmap");
|
|
|
|
if (nsnull!=cellMap)
|
|
|
|
rowCount = cellMap->GetRowCount();
|
1998-06-17 20:38:24 +04:00
|
|
|
return rowCount;
|
|
|
|
}
|
1998-07-11 04:00:31 +04:00
|
|
|
|
1998-07-24 20:51:16 +04:00
|
|
|
/* return the effective col count */
|
1998-07-22 07:53:43 +04:00
|
|
|
PRInt32 nsTableFrame::GetColCount ()
|
|
|
|
{
|
1999-07-28 12:09:02 +04:00
|
|
|
PRInt32 colCount = 0;
|
|
|
|
nsCellMap* cellMap = GetCellMap();
|
|
|
|
NS_ASSERTION(nsnull != cellMap, "GetColCount null cellmap");
|
|
|
|
if (nsnull != cellMap)
|
|
|
|
colCount = cellMap->GetColCount();
|
|
|
|
return colCount;
|
1998-07-24 20:51:16 +04:00
|
|
|
}
|
1998-07-22 07:53:43 +04:00
|
|
|
|
|
|
|
|
1998-07-11 04:00:31 +04:00
|
|
|
nsTableColFrame * nsTableFrame::GetColFrame(PRInt32 aColIndex)
|
|
|
|
{
|
|
|
|
nsTableColFrame *result = nsnull;
|
1998-08-14 20:16:43 +04:00
|
|
|
nsCellMap *cellMap = GetCellMap();
|
|
|
|
if (nsnull!=cellMap)
|
1998-07-11 04:00:31 +04:00
|
|
|
{
|
1998-08-14 20:16:43 +04:00
|
|
|
result = cellMap->GetColumnFrame(aColIndex);
|
1998-07-11 04:00:31 +04:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
// can return nsnull
|
1998-09-19 02:37:14 +04:00
|
|
|
nsTableCellFrame * nsTableFrame::GetCellFrameAt(PRInt32 aRowIndex, PRInt32 aColIndex)
|
1998-07-11 04:00:31 +04:00
|
|
|
{
|
|
|
|
nsTableCellFrame *result = nsnull;
|
1998-08-14 20:16:43 +04:00
|
|
|
nsCellMap *cellMap = GetCellMap();
|
|
|
|
if (nsnull!=cellMap)
|
1998-07-11 04:00:31 +04:00
|
|
|
{
|
1998-08-14 20:16:43 +04:00
|
|
|
CellData * cellData = cellMap->GetCellAt(aRowIndex, aColIndex);
|
1998-07-11 04:00:31 +04:00
|
|
|
if (nsnull!=cellData)
|
|
|
|
{
|
1999-07-28 12:09:02 +04:00
|
|
|
result = cellData->mOrigCell;
|
1998-07-11 04:00:31 +04:00
|
|
|
if (nsnull==result)
|
1999-07-28 12:09:02 +04:00
|
|
|
result = cellData->mSpanData->mOrigCell;
|
1998-07-11 04:00:31 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1998-07-17 03:23:31 +04:00
|
|
|
// return the number of rows spanned by aCell starting at aRowIndex
|
1998-06-17 20:38:24 +04:00
|
|
|
// note that this is different from just the rowspan of aCell
|
|
|
|
// (that would be GetEffectiveRowSpan (indexOfRowThatContains_aCell, aCell)
|
1998-07-03 00:35:23 +04:00
|
|
|
//
|
|
|
|
// XXX This code should be in the table row group frame instead, and it
|
|
|
|
// should clip rows spans so they don't extend past a row group rather than
|
|
|
|
// clip to the table itself. Before that can happen the code that builds the
|
|
|
|
// cell map needs to take row groups into account
|
1998-06-17 20:38:24 +04:00
|
|
|
PRInt32 nsTableFrame::GetEffectiveRowSpan (PRInt32 aRowIndex, nsTableCellFrame *aCell)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION (nsnull!=aCell, "bad cell arg");
|
|
|
|
NS_PRECONDITION (0<=aRowIndex && aRowIndex<GetRowCount(), "bad row index arg");
|
|
|
|
|
1998-09-16 00:36:42 +04:00
|
|
|
if (!(0<=aRowIndex && aRowIndex<GetRowCount()))
|
|
|
|
return 1;
|
|
|
|
|
1999-02-21 21:38:41 +03:00
|
|
|
// XXX I don't think this is correct...
|
|
|
|
#if 0
|
1998-07-22 07:53:43 +04:00
|
|
|
PRInt32 rowSpan = aCell->GetRowSpan();
|
|
|
|
PRInt32 rowCount = GetRowCount();
|
1998-06-17 20:38:24 +04:00
|
|
|
if (rowCount < (aRowIndex + rowSpan))
|
|
|
|
return (rowCount - aRowIndex);
|
|
|
|
return rowSpan;
|
1999-02-21 21:38:41 +03:00
|
|
|
#else
|
|
|
|
PRInt32 rowSpan = aCell->GetRowSpan();
|
|
|
|
PRInt32 rowCount = GetRowCount();
|
|
|
|
PRInt32 startRow;
|
|
|
|
aCell->GetRowIndex(startRow);
|
|
|
|
|
|
|
|
// Clip the row span so it doesn't extend past the bottom of the table
|
|
|
|
if ((startRow + rowSpan) > rowCount) {
|
|
|
|
rowSpan = rowCount - startRow;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check that aRowIndex is in the range startRow..startRow+rowSpan-1
|
|
|
|
PRInt32 lastRow = startRow + rowSpan - 1;
|
|
|
|
if ((aRowIndex < startRow) || (aRowIndex > lastRow)) {
|
|
|
|
return 0; // cell doesn't span any rows starting at aRowIndex
|
|
|
|
} else {
|
|
|
|
return lastRow - aRowIndex + 1;
|
|
|
|
}
|
|
|
|
#endif
|
1998-06-17 20:38:24 +04:00
|
|
|
}
|
|
|
|
|
1999-07-28 12:09:02 +04:00
|
|
|
PRInt32 nsTableFrame::GetEffectiveRowSpan(nsTableCellFrame *aCell)
|
|
|
|
{
|
|
|
|
PRInt32 startRow;
|
|
|
|
aCell->GetRowIndex(startRow);
|
|
|
|
return GetEffectiveRowSpan(startRow, aCell);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Return the number of cols spanned by aCell starting at aColIndex
|
|
|
|
// This is different from the colspan of aCell. If the cell spans no
|
|
|
|
// dead cells then the colSpan of the cell would be
|
|
|
|
// GetEffectiveColSpan (indexOfColThatContains_aCell, aCell)
|
1998-07-17 03:23:31 +04:00
|
|
|
//
|
|
|
|
// XXX Should be moved to colgroup, as GetEffectiveRowSpan should be moved to rowgroup?
|
1999-07-28 12:09:02 +04:00
|
|
|
PRInt32 nsTableFrame::GetEffectiveColSpan(PRInt32 aColIndex, nsTableCellFrame* aCell)
|
1998-07-17 03:23:31 +04:00
|
|
|
{
|
1999-07-28 12:09:02 +04:00
|
|
|
NS_PRECONDITION (nsnull != aCell, "bad cell arg");
|
|
|
|
nsCellMap* cellMap = GetCellMap();
|
|
|
|
NS_PRECONDITION (nsnull != cellMap, "bad call, cellMap not yet allocated.");
|
1998-07-17 03:23:31 +04:00
|
|
|
|
1999-07-28 12:09:02 +04:00
|
|
|
return cellMap->GetEffectiveColSpan(aColIndex, aCell);
|
|
|
|
}
|
|
|
|
|
|
|
|
PRInt32 nsTableFrame::GetEffectiveColSpan(nsTableCellFrame* aCell)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION (nsnull != aCell, "bad cell arg");
|
|
|
|
nsCellMap* cellMap = GetCellMap();
|
|
|
|
NS_PRECONDITION (nsnull != cellMap, "bad call, cellMap not yet allocated.");
|
|
|
|
|
|
|
|
PRInt32 initialColIndex;
|
|
|
|
aCell->GetColIndex(initialColIndex);
|
|
|
|
return cellMap->GetEffectiveColSpan(initialColIndex, aCell);
|
1998-07-17 03:23:31 +04:00
|
|
|
}
|
|
|
|
|
1998-07-22 07:53:43 +04:00
|
|
|
PRInt32 nsTableFrame::GetEffectiveCOLSAttribute()
|
|
|
|
{
|
1998-08-14 20:16:43 +04:00
|
|
|
nsCellMap *cellMap = GetCellMap();
|
1998-10-14 20:32:45 +04:00
|
|
|
NS_PRECONDITION (nsnull!=cellMap, "null cellMap.");
|
1998-07-22 07:53:43 +04:00
|
|
|
PRInt32 result;
|
1998-12-02 19:45:20 +03:00
|
|
|
const nsStyleTable *tableStyle=nsnull;
|
|
|
|
GetStyleData(eStyleStruct_Table, (const nsStyleStruct *&)tableStyle);
|
1998-07-22 07:53:43 +04:00
|
|
|
result = tableStyle->mCols;
|
|
|
|
PRInt32 numCols = GetColCount();
|
|
|
|
if (result>numCols)
|
|
|
|
result = numCols;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1998-06-17 20:38:24 +04:00
|
|
|
/** sum the columns represented by all nsTableColGroup objects
|
|
|
|
* if the cell map says there are more columns than this,
|
|
|
|
* add extra implicit columns to the content tree.
|
|
|
|
*/
|
1998-10-11 13:18:27 +04:00
|
|
|
void nsTableFrame::EnsureColumns(nsIPresContext& aPresContext)
|
1998-06-17 20:38:24 +04:00
|
|
|
{
|
1998-10-20 09:05:17 +04:00
|
|
|
if (PR_TRUE==gsDebug) printf("TIF EnsureColumns\n");
|
1998-09-24 01:48:26 +04:00
|
|
|
NS_PRECONDITION(nsnull!=mCellMap, "bad state: null cellmap");
|
1999-07-28 12:09:02 +04:00
|
|
|
if (nsnull == mCellMap)
|
1998-07-07 04:20:21 +04:00
|
|
|
return; // no info yet, so nothing useful to do
|
1998-06-17 20:38:24 +04:00
|
|
|
|
1998-07-26 08:23:01 +04:00
|
|
|
// make sure we've accounted for the COLS attribute
|
|
|
|
AdjustColumnsForCOLSAttribute();
|
|
|
|
|
1998-12-03 21:01:35 +03:00
|
|
|
// count the number of column frames we already have
|
|
|
|
PRInt32 actualColumns = 0;
|
|
|
|
nsTableColGroupFrame *lastColGroupFrame = nsnull;
|
1999-06-15 03:42:16 +04:00
|
|
|
nsIFrame* childFrame = mColGroups.FirstChild();
|
1999-07-28 12:09:02 +04:00
|
|
|
while (nsnull!=childFrame) {
|
1998-12-03 21:01:35 +03:00
|
|
|
((nsTableColGroupFrame*)childFrame)->SetStartColumnIndex(actualColumns);
|
|
|
|
PRInt32 numCols = ((nsTableColGroupFrame*)childFrame)->GetColumnCount();
|
|
|
|
actualColumns += numCols;
|
|
|
|
lastColGroupFrame = (nsTableColGroupFrame *)childFrame;
|
|
|
|
if (PR_TRUE==gsDebug) printf("EC: found a col group %p\n", lastColGroupFrame);
|
1999-02-10 09:13:38 +03:00
|
|
|
childFrame->GetNextSibling(&childFrame);
|
1998-12-03 21:01:35 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// if we have fewer column frames than we need, create some implicit column frames
|
1998-10-20 09:05:17 +04:00
|
|
|
PRInt32 colCount = mCellMap->GetColCount();
|
1998-09-24 01:48:26 +04:00
|
|
|
if (PR_TRUE==gsDebug) printf("EC: actual = %d, colCount=%d\n", actualColumns, colCount);
|
1999-07-28 12:09:02 +04:00
|
|
|
if (actualColumns < colCount) {
|
1998-10-20 09:05:17 +04:00
|
|
|
if (PR_TRUE==gsDebug) printf("TIF EnsureColumns: actual %d < colCount %d\n", actualColumns, colCount);
|
1998-12-03 21:01:35 +03:00
|
|
|
nsIContent *lastColGroupElement = nsnull;
|
1999-07-28 12:09:02 +04:00
|
|
|
if (nsnull==lastColGroupFrame) { // there are no col groups, so create an implicit colgroup frame
|
1998-12-03 21:01:35 +03:00
|
|
|
if (PR_TRUE==gsDebug) printf("EnsureColumns:creating colgroup frame\n");
|
|
|
|
// Resolve style for the colgroup frame
|
|
|
|
// first, need to get the nearest containing content object
|
1999-02-10 03:42:56 +03:00
|
|
|
GetContent(&lastColGroupElement); // ADDREF a: lastColGroupElement++ (either here or in the loop below)
|
1998-12-03 21:01:35 +03:00
|
|
|
nsIFrame *parentFrame;
|
1999-02-10 04:36:30 +03:00
|
|
|
GetParent(&parentFrame);
|
1999-07-28 12:09:02 +04:00
|
|
|
while (nsnull==lastColGroupElement) {
|
1999-02-10 03:42:56 +03:00
|
|
|
parentFrame->GetContent(&lastColGroupElement);
|
1998-12-03 21:01:35 +03:00
|
|
|
if (nsnull==lastColGroupElement)
|
1999-02-10 04:36:30 +03:00
|
|
|
parentFrame->GetParent(&parentFrame);
|
1998-12-03 21:01:35 +03:00
|
|
|
}
|
|
|
|
// now we have a ref-counted "lastColGroupElement" content object
|
1999-02-11 18:56:23 +03:00
|
|
|
nsIStyleContext* colGroupStyleContext;
|
|
|
|
aPresContext.ResolvePseudoStyleContextFor (lastColGroupElement,
|
|
|
|
nsHTMLAtoms::tableColGroupPseudo,
|
|
|
|
mStyleContext,
|
1999-02-12 20:45:58 +03:00
|
|
|
PR_FALSE,
|
1999-02-11 18:56:23 +03:00
|
|
|
&colGroupStyleContext); // colGroupStyleContext: REFCNT++
|
1998-09-23 03:36:06 +04:00
|
|
|
// Create a col group frame
|
|
|
|
nsIFrame* newFrame;
|
1999-05-12 02:03:29 +04:00
|
|
|
NS_NewTableColGroupFrame(&newFrame);
|
1999-02-25 06:27:57 +03:00
|
|
|
newFrame->Init(aPresContext, lastColGroupElement, this, colGroupStyleContext,
|
|
|
|
nsnull);
|
1998-09-23 03:36:06 +04:00
|
|
|
lastColGroupFrame = (nsTableColGroupFrame*)newFrame;
|
1998-06-17 20:38:24 +04:00
|
|
|
NS_RELEASE(colGroupStyleContext); // kidStyleContenxt: REFCNT--
|
|
|
|
|
|
|
|
// hook lastColGroupFrame into child list
|
1999-01-16 01:52:05 +03:00
|
|
|
mColGroups.SetFrames(lastColGroupFrame);
|
1998-06-17 20:38:24 +04:00
|
|
|
}
|
1999-07-28 12:09:02 +04:00
|
|
|
else {
|
1999-02-10 03:42:56 +03:00
|
|
|
lastColGroupFrame->GetContent(&lastColGroupElement); // ADDREF b: lastColGroupElement++
|
1998-06-17 20:38:24 +04:00
|
|
|
}
|
|
|
|
|
1998-09-23 03:36:06 +04:00
|
|
|
// XXX It would be better to do this in the style code while constructing
|
1998-12-03 21:01:35 +03:00
|
|
|
// the table's frames. But we don't know how many columns we have at that point.
|
1998-09-23 03:36:06 +04:00
|
|
|
nsAutoString colTag;
|
|
|
|
nsHTMLAtoms::col->ToString(colTag);
|
1998-10-20 09:05:17 +04:00
|
|
|
PRInt32 excessColumns = colCount - actualColumns;
|
1998-09-23 03:36:06 +04:00
|
|
|
nsIFrame* firstNewColFrame = nsnull;
|
|
|
|
nsIFrame* lastNewColFrame = nsnull;
|
1998-11-03 23:33:43 +03:00
|
|
|
nsIStyleContextPtr lastColGroupStyle;
|
1999-02-10 03:42:56 +03:00
|
|
|
lastColGroupFrame->GetStyleContext(lastColGroupStyle.AssignPtr());
|
1999-07-28 12:09:02 +04:00
|
|
|
for ( ; excessColumns > 0; excessColumns--) {
|
1998-09-23 03:36:06 +04:00
|
|
|
// Create a new col frame
|
|
|
|
nsIFrame* colFrame;
|
1998-12-03 21:01:35 +03:00
|
|
|
// note we pass in PR_TRUE here to force unique style contexts.
|
1999-02-11 18:56:23 +03:00
|
|
|
nsIStyleContext* colStyleContext;
|
|
|
|
aPresContext.ResolvePseudoStyleContextFor (lastColGroupElement,
|
|
|
|
nsHTMLAtoms::tableColPseudo,
|
|
|
|
lastColGroupStyle,
|
1999-02-12 20:45:58 +03:00
|
|
|
PR_TRUE,
|
|
|
|
&colStyleContext); // colStyleContext: REFCNT++
|
1999-05-12 02:03:29 +04:00
|
|
|
NS_NewTableColFrame(&colFrame);
|
1998-12-29 06:38:16 +03:00
|
|
|
colFrame->Init(aPresContext, lastColGroupElement, lastColGroupFrame,
|
1999-02-25 06:27:57 +03:00
|
|
|
colStyleContext, nsnull);
|
1998-12-04 06:39:05 +03:00
|
|
|
NS_RELEASE(colStyleContext);
|
1998-11-10 09:05:32 +03:00
|
|
|
colFrame->SetInitialChildList(aPresContext, nsnull, nsnull);
|
1999-07-28 12:09:02 +04:00
|
|
|
((nsTableColFrame *)colFrame)->SetIsAnonymous(PR_TRUE);
|
1998-09-23 03:36:06 +04:00
|
|
|
|
|
|
|
// Add it to our list
|
|
|
|
if (nsnull == lastNewColFrame) {
|
|
|
|
firstNewColFrame = colFrame;
|
|
|
|
} else {
|
|
|
|
lastNewColFrame->SetNextSibling(colFrame);
|
|
|
|
}
|
|
|
|
lastNewColFrame = colFrame;
|
1998-06-17 20:38:24 +04:00
|
|
|
}
|
1998-11-10 09:05:32 +03:00
|
|
|
lastColGroupFrame->SetInitialChildList(aPresContext, nsnull, firstNewColFrame);
|
1998-12-03 21:01:35 +03:00
|
|
|
NS_RELEASE(lastColGroupElement); // ADDREF: lastColGroupElement--
|
1998-06-17 20:38:24 +04:00
|
|
|
}
|
1999-07-28 12:09:02 +04:00
|
|
|
else if (actualColumns > colCount) { // the cell map needs to grow to accomodate extra cols
|
|
|
|
nsCellMap* cellMap = GetCellMap();
|
|
|
|
if (cellMap) {
|
|
|
|
cellMap->AddColsAtEnd(actualColumns - colCount);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-06-17 20:38:24 +04:00
|
|
|
}
|
|
|
|
|
1998-08-26 21:26:38 +04:00
|
|
|
|
1998-09-01 01:23:28 +04:00
|
|
|
void nsTableFrame::AddColumnFrame (nsTableColFrame *aColFrame)
|
|
|
|
{
|
1998-10-20 09:05:17 +04:00
|
|
|
if (gsDebug==PR_TRUE) printf("TIF: AddColumnFrame %p\n", aColFrame);
|
1998-10-14 20:32:45 +04:00
|
|
|
nsCellMap *cellMap = GetCellMap();
|
|
|
|
NS_PRECONDITION (nsnull!=cellMap, "null cellMap.");
|
|
|
|
if (nsnull!=cellMap)
|
1998-10-22 09:27:11 +04:00
|
|
|
{
|
|
|
|
if (gsDebug) printf("TIF AddColumnFrame: adding column frame %p\n", aColFrame);
|
1998-10-14 20:32:45 +04:00
|
|
|
cellMap->AppendColumnFrame(aColFrame);
|
1998-10-22 09:27:11 +04:00
|
|
|
}
|
1998-09-01 01:23:28 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/** return the index of the next row that is not yet assigned */
|
|
|
|
PRInt32 nsTableFrame::GetNextAvailRowIndex() const
|
|
|
|
{
|
|
|
|
PRInt32 result=0;
|
1998-10-14 20:32:45 +04:00
|
|
|
nsCellMap *cellMap = GetCellMap();
|
|
|
|
NS_PRECONDITION (nsnull!=cellMap, "null cellMap.");
|
1999-07-28 12:09:02 +04:00
|
|
|
if (nsnull!=cellMap) {
|
|
|
|
result = cellMap->GetNextAvailRowIndex();
|
1998-09-01 01:23:28 +04:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1998-08-14 20:16:43 +04:00
|
|
|
/** Get the cell map for this table frame. It is not always mCellMap.
|
|
|
|
* Only the firstInFlow has a legit cell map
|
|
|
|
*/
|
1998-10-14 20:32:45 +04:00
|
|
|
nsCellMap * nsTableFrame::GetCellMap() const
|
1998-08-14 20:16:43 +04:00
|
|
|
{
|
|
|
|
nsTableFrame * firstInFlow = (nsTableFrame *)GetFirstInFlow();
|
|
|
|
if (this!=firstInFlow)
|
|
|
|
{
|
|
|
|
return firstInFlow->GetCellMap();
|
|
|
|
}
|
|
|
|
return mCellMap;
|
|
|
|
}
|
|
|
|
|
1999-07-28 12:09:02 +04:00
|
|
|
PRInt32 nsTableFrame::AddCellToTable(nsTableCellFrame* aCellFrame,
|
|
|
|
PRInt32 aRowIndex)
|
1998-06-17 20:38:24 +04:00
|
|
|
{
|
1999-07-28 12:09:02 +04:00
|
|
|
NS_ASSERTION(nsnull != aCellFrame, "bad aCellFrame arg");
|
|
|
|
NS_ASSERTION(nsnull != mCellMap, "bad cellMap");
|
1998-09-01 01:23:28 +04:00
|
|
|
|
1998-08-18 03:37:04 +04:00
|
|
|
// XXX: must be called only on first-in-flow!
|
1998-10-20 09:05:17 +04:00
|
|
|
if (gsDebug==PR_TRUE) printf("TIF AddCellToTable: frame %p\n", aCellFrame);
|
1998-06-17 20:38:24 +04:00
|
|
|
|
1999-07-28 12:09:02 +04:00
|
|
|
return mCellMap->AppendCell(aCellFrame, aRowIndex);
|
|
|
|
}
|
1998-07-02 02:22:28 +04:00
|
|
|
|
1999-07-28 12:09:02 +04:00
|
|
|
void nsTableFrame::RemoveCellFromTable(nsTableCellFrame* aCellFrame,
|
|
|
|
PRInt32 aRowIndex)
|
|
|
|
{
|
|
|
|
nsCellMap* cellMap = GetCellMap();
|
|
|
|
PRInt32 numCols = cellMap->GetColCount();
|
|
|
|
cellMap->RemoveCell(aCellFrame, aRowIndex);
|
|
|
|
if (numCols != cellMap->GetColCount()) {
|
|
|
|
// XXX need to remove the anonymous col frames at the end
|
|
|
|
//nsTableColFrame* colFrame = nsnull;
|
|
|
|
//GetColumnFrame(colIndex, colFrame);
|
|
|
|
//if (colFrame && colFrame->IsAnonymous()) {
|
|
|
|
// nsTableColGroupFrame* colGroupFrame = nsnull;
|
|
|
|
//colFrame->GetParent((nsIFrame **)&colGroupFrame);
|
|
|
|
//if (colGroupFrame) {
|
|
|
|
// colGroupFrame->DeleteColFrame(aPresContext, colFrame);
|
1998-06-17 20:38:24 +04:00
|
|
|
}
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-06-14 12:01:00 +04:00
|
|
|
static nsresult BuildCellMapForRowGroup(nsIFrame* rowGroupFrame)
|
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
nsIFrame *rowFrame;
|
|
|
|
rowGroupFrame->FirstChild(nsnull, &rowFrame);
|
|
|
|
for ( ; nsnull!=rowFrame; rowFrame->GetNextSibling(&rowFrame))
|
|
|
|
{
|
|
|
|
const nsStyleDisplay *rowDisplay;
|
|
|
|
rowFrame->GetStyleData(eStyleStruct_Display, (const nsStyleStruct *&)rowDisplay);
|
|
|
|
if (NS_STYLE_DISPLAY_TABLE_ROW==rowDisplay->mDisplay)
|
|
|
|
{
|
|
|
|
rv = ((nsTableRowFrame *)rowFrame)->InitChildren();
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
else if (NS_STYLE_DISPLAY_TABLE_ROW_GROUP==rowDisplay->mDisplay)
|
|
|
|
{
|
|
|
|
BuildCellMapForRowGroup(rowFrame);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
NS_METHOD nsTableFrame::ReBuildCellMap()
|
|
|
|
{
|
1998-10-20 03:43:06 +04:00
|
|
|
if (PR_TRUE==gsDebugIR) printf("TIF: ReBuildCellMap.\n");
|
1998-10-14 20:32:45 +04:00
|
|
|
nsresult rv=NS_OK;
|
1999-01-16 01:52:05 +03:00
|
|
|
nsIFrame *rowGroupFrame=mFrames.FirstChild();
|
1999-02-10 09:13:38 +03:00
|
|
|
for ( ; nsnull!=rowGroupFrame; rowGroupFrame->GetNextSibling(&rowGroupFrame))
|
1998-10-14 20:32:45 +04:00
|
|
|
{
|
|
|
|
const nsStyleDisplay *rowGroupDisplay;
|
1998-12-02 19:45:20 +03:00
|
|
|
rowGroupFrame->GetStyleData(eStyleStruct_Display, (const nsStyleStruct *&)rowGroupDisplay);
|
1998-10-14 20:32:45 +04:00
|
|
|
if (PR_TRUE==IsRowGroup(rowGroupDisplay->mDisplay))
|
|
|
|
{
|
1999-06-14 12:01:00 +04:00
|
|
|
BuildCellMapForRowGroup(rowGroupFrame);
|
1998-10-14 20:32:45 +04:00
|
|
|
}
|
|
|
|
}
|
1998-10-20 03:43:06 +04:00
|
|
|
mCellMapValid=PR_TRUE;
|
1998-10-14 20:32:45 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1998-06-17 20:38:24 +04:00
|
|
|
/* ***** Column Layout Data methods ***** */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Lists the column layout data which turns
|
|
|
|
* around and lists the cell layout data.
|
|
|
|
* This is for debugging purposes only.
|
|
|
|
*/
|
1998-11-06 00:42:46 +03:00
|
|
|
#ifdef NS_DEBUG
|
1998-07-24 20:51:16 +04:00
|
|
|
void nsTableFrame::ListColumnLayoutData(FILE* out, PRInt32 aIndent)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-07-11 04:00:31 +04:00
|
|
|
nsTableFrame * firstInFlow = (nsTableFrame *)GetFirstInFlow();
|
|
|
|
if (this!=firstInFlow)
|
|
|
|
{
|
|
|
|
firstInFlow->ListColumnLayoutData(out, aIndent);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1998-08-18 03:37:04 +04:00
|
|
|
nsCellMap *cellMap = GetCellMap();
|
|
|
|
if (nsnull!=cellMap)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
fprintf(out,"Column Layout Data \n");
|
|
|
|
|
1998-10-20 09:05:17 +04:00
|
|
|
PRInt32 numCols = cellMap->GetColCount();
|
1998-08-18 03:37:04 +04:00
|
|
|
PRInt32 numRows = cellMap->GetRowCount();
|
1998-07-11 04:00:31 +04:00
|
|
|
for (PRInt32 colIndex = 0; colIndex<numCols; colIndex++)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-07-11 04:00:31 +04:00
|
|
|
for (PRInt32 indent = aIndent; --indent >= 0; )
|
|
|
|
fputs(" ", out);
|
|
|
|
fprintf(out,"Column Data [%d] \n",colIndex);
|
|
|
|
for (PRInt32 rowIndex = 0; rowIndex < numRows; rowIndex++)
|
|
|
|
{
|
1998-08-18 03:37:04 +04:00
|
|
|
nsTableCellFrame *cellFrame = cellMap->GetCellFrameAt(rowIndex, colIndex);
|
1998-07-11 04:00:31 +04:00
|
|
|
PRInt32 rowIndent;
|
|
|
|
for (rowIndent = aIndent+2; --rowIndent >= 0; ) fputs(" ", out);
|
|
|
|
fprintf(out,"Cell Data [%d] \n",rowIndex);
|
|
|
|
for (rowIndent = aIndent+2; --rowIndent >= 0; ) fputs(" ", out);
|
|
|
|
nsMargin margin;
|
|
|
|
cellFrame->GetMargin(margin);
|
|
|
|
fprintf(out,"Margin -- Top: %d Left: %d Bottom: %d Right: %d \n",
|
1998-08-01 03:34:45 +04:00
|
|
|
NSTwipsToIntPoints(margin.top),
|
|
|
|
NSTwipsToIntPoints(margin.left),
|
|
|
|
NSTwipsToIntPoints(margin.bottom),
|
|
|
|
NSTwipsToIntPoints(margin.right));
|
1998-07-11 04:00:31 +04:00
|
|
|
|
|
|
|
for (rowIndent = aIndent+2; --rowIndent >= 0; ) fputs(" ", out);
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1998-11-06 00:42:46 +03:00
|
|
|
#endif
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
/**
|
1998-07-11 04:00:31 +04:00
|
|
|
* For the TableCell in CellData, add it to the list
|
|
|
|
*/
|
1998-06-17 20:38:24 +04:00
|
|
|
void nsTableFrame::AppendLayoutData(nsVoidArray* aList, nsTableCellFrame* aTableCell)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
if (aTableCell != nsnull)
|
|
|
|
{
|
1998-07-11 04:00:31 +04:00
|
|
|
aList->AppendElement((void*)aTableCell);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-12-21 09:38:18 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void nsTableFrame::SetBorderEdgeLength(PRUint8 aSide, PRInt32 aIndex, nscoord aLength)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-12-21 09:38:18 +03:00
|
|
|
nsBorderEdge *border = (nsBorderEdge *)(mBorderEdges.mEdges[aSide].ElementAt(aIndex));
|
|
|
|
border->mLength = aLength;
|
|
|
|
}
|
|
|
|
|
1998-12-23 18:47:43 +03:00
|
|
|
void nsTableFrame::DidComputeHorizontalCollapsingBorders(nsIPresContext& aPresContext,
|
|
|
|
PRInt32 aStartRowIndex,
|
|
|
|
PRInt32 aEndRowIndex)
|
|
|
|
{
|
|
|
|
// XXX: for now, this only does table edges. May need to do interior edges also? Probably not.
|
1998-12-30 09:48:15 +03:00
|
|
|
nsCellMap *cellMap = GetCellMap();
|
|
|
|
PRInt32 lastRowIndex = cellMap->GetRowCount()-1;
|
|
|
|
PRInt32 lastColIndex = cellMap->GetColCount()-1;
|
1998-12-23 18:47:43 +03:00
|
|
|
if (0==aStartRowIndex)
|
|
|
|
{
|
|
|
|
nsTableCellFrame *cellFrame = mCellMap->GetCellFrameAt(0, 0);
|
1998-12-30 09:48:15 +03:00
|
|
|
if (nsnull==cellFrame)
|
|
|
|
{
|
|
|
|
CellData *cellData = mCellMap->GetCellAt(0, 0);
|
|
|
|
if (nsnull!=cellData)
|
1999-07-28 12:09:02 +04:00
|
|
|
cellFrame = cellData->mSpanData->mOrigCell;
|
1998-12-30 09:48:15 +03:00
|
|
|
}
|
1998-12-23 18:47:43 +03:00
|
|
|
nsRect rowRect(0,0,0,0);
|
|
|
|
if (nsnull!=cellFrame)
|
|
|
|
{
|
|
|
|
nsIFrame *rowFrame;
|
1999-02-10 04:36:30 +03:00
|
|
|
cellFrame->GetParent(&rowFrame);
|
1998-12-23 18:47:43 +03:00
|
|
|
rowFrame->GetRect(rowRect);
|
|
|
|
nsBorderEdge *leftBorder = (nsBorderEdge *)(mBorderEdges.mEdges[NS_SIDE_LEFT].ElementAt(0));
|
|
|
|
nsBorderEdge *rightBorder = (nsBorderEdge *)(mBorderEdges.mEdges[NS_SIDE_RIGHT].ElementAt(0));
|
|
|
|
nsBorderEdge *topBorder = (nsBorderEdge *)(mBorderEdges.mEdges[NS_SIDE_TOP].ElementAt(0));
|
|
|
|
leftBorder->mLength = rowRect.height + topBorder->mWidth;
|
|
|
|
topBorder = (nsBorderEdge *)(mBorderEdges.mEdges[NS_SIDE_TOP].ElementAt(lastColIndex));
|
|
|
|
rightBorder->mLength = rowRect.height + topBorder->mWidth;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lastRowIndex<=aEndRowIndex)
|
|
|
|
{
|
|
|
|
nsTableCellFrame *cellFrame = mCellMap->GetCellFrameAt(lastRowIndex, 0);
|
1998-12-30 09:48:15 +03:00
|
|
|
if (nsnull==cellFrame)
|
|
|
|
{
|
|
|
|
CellData *cellData = mCellMap->GetCellAt(lastRowIndex, 0);
|
|
|
|
if (nsnull!=cellData)
|
1999-07-28 12:09:02 +04:00
|
|
|
cellFrame = cellData->mSpanData->mOrigCell;
|
1998-12-30 09:48:15 +03:00
|
|
|
}
|
1998-12-23 18:47:43 +03:00
|
|
|
nsRect rowRect(0,0,0,0);
|
|
|
|
if (nsnull!=cellFrame)
|
|
|
|
{
|
|
|
|
nsIFrame *rowFrame;
|
1999-02-10 04:36:30 +03:00
|
|
|
cellFrame->GetParent(&rowFrame);
|
1998-12-23 18:47:43 +03:00
|
|
|
rowFrame->GetRect(rowRect);
|
|
|
|
nsBorderEdge *leftBorder = (nsBorderEdge *)(mBorderEdges.mEdges[NS_SIDE_LEFT].ElementAt(lastRowIndex));
|
|
|
|
nsBorderEdge *rightBorder = (nsBorderEdge *)(mBorderEdges.mEdges[NS_SIDE_RIGHT].ElementAt(lastRowIndex));
|
1998-12-30 09:48:15 +03:00
|
|
|
nsBorderEdge *bottomBorder = (nsBorderEdge *)(mBorderEdges.mEdges[NS_SIDE_BOTTOM].ElementAt(0));
|
|
|
|
leftBorder->mLength = rowRect.height + bottomBorder->mWidth;
|
|
|
|
bottomBorder = (nsBorderEdge *)(mBorderEdges.mEdges[NS_SIDE_BOTTOM].ElementAt(lastColIndex));
|
|
|
|
rightBorder->mLength = rowRect.height + bottomBorder->mWidth;
|
1998-12-23 18:47:43 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
1998-12-16 20:05:14 +03:00
|
|
|
|
1998-12-23 18:47:43 +03:00
|
|
|
// For every row between aStartRowIndex and aEndRowIndex (-1 == the end of the table),
|
1998-12-16 20:05:14 +03:00
|
|
|
// walk across every edge and compute the border at that edge.
|
1998-12-17 01:19:23 +03:00
|
|
|
// We compute each edge only once, arbitrarily choosing to compute right and bottom edges,
|
|
|
|
// except for exterior cells that share a left or top edge with the table itself.
|
1998-12-16 20:05:14 +03:00
|
|
|
// Distribute half the computed border to the appropriate adjacent objects
|
|
|
|
// (always a cell frame or the table frame.) In the case of odd width,
|
|
|
|
// the object on the right/bottom gets the extra portion
|
1998-12-21 09:38:18 +03:00
|
|
|
|
1998-12-23 18:47:43 +03:00
|
|
|
/* compute the top and bottom collapsed borders between aStartRowIndex and aEndRowIndex, inclusive */
|
1998-12-21 21:54:23 +03:00
|
|
|
void nsTableFrame::ComputeHorizontalCollapsingBorders(nsIPresContext& aPresContext,
|
|
|
|
PRInt32 aStartRowIndex,
|
1998-12-21 09:38:18 +03:00
|
|
|
PRInt32 aEndRowIndex)
|
|
|
|
{
|
|
|
|
// this method just uses mCellMap, because it can't get called unless nCellMap!=nsnull
|
|
|
|
PRInt32 colCount = mCellMap->GetColCount();
|
|
|
|
PRInt32 rowCount = mCellMap->GetRowCount();
|
|
|
|
if (aStartRowIndex>=rowCount)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(PR_FALSE, "aStartRowIndex>=rowCount in ComputeHorizontalCollapsingBorders");
|
|
|
|
return; // we don't have the requested row yet
|
|
|
|
}
|
|
|
|
|
1998-12-16 20:05:14 +03:00
|
|
|
PRInt32 rowIndex = aStartRowIndex;
|
|
|
|
for ( ; rowIndex<rowCount && rowIndex <=aEndRowIndex; rowIndex++)
|
|
|
|
{
|
|
|
|
PRInt32 colIndex=0;
|
|
|
|
for ( ; colIndex<colCount; colIndex++)
|
|
|
|
{
|
|
|
|
if (0==rowIndex)
|
1998-12-17 01:19:23 +03:00
|
|
|
{ // table is top neighbor
|
1998-12-21 21:54:23 +03:00
|
|
|
ComputeTopBorderForEdgeAt(aPresContext, rowIndex, colIndex);
|
1998-12-16 20:05:14 +03:00
|
|
|
}
|
1998-12-21 21:54:23 +03:00
|
|
|
ComputeBottomBorderForEdgeAt(aPresContext, rowIndex, colIndex);
|
1998-12-17 01:19:23 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-12-23 18:47:43 +03:00
|
|
|
/* compute the left and right collapsed borders between aStartRowIndex and aEndRowIndex, inclusive */
|
1998-12-21 21:54:23 +03:00
|
|
|
void nsTableFrame::ComputeVerticalCollapsingBorders(nsIPresContext& aPresContext,
|
|
|
|
PRInt32 aStartRowIndex,
|
1998-12-21 09:38:18 +03:00
|
|
|
PRInt32 aEndRowIndex)
|
|
|
|
{
|
1998-12-23 18:47:43 +03:00
|
|
|
nsCellMap *cellMap = GetCellMap();
|
|
|
|
if (nsnull==cellMap)
|
|
|
|
return; // no info yet, so nothing useful to do
|
|
|
|
|
1999-01-29 21:49:32 +03:00
|
|
|
CacheColFramesInCellMap();
|
|
|
|
|
1998-12-23 18:47:43 +03:00
|
|
|
// compute all the collapsing border values for the entire table
|
|
|
|
// XXX: we have to make this more incremental!
|
|
|
|
const nsStyleTable *tableStyle=nsnull;
|
|
|
|
GetStyleData(eStyleStruct_Table, (const nsStyleStruct *&)tableStyle);
|
|
|
|
if (NS_STYLE_BORDER_COLLAPSE!=tableStyle->mBorderCollapse)
|
|
|
|
return;
|
|
|
|
|
1998-12-21 09:38:18 +03:00
|
|
|
PRInt32 colCount = mCellMap->GetColCount();
|
|
|
|
PRInt32 rowCount = mCellMap->GetRowCount();
|
1998-12-23 18:47:43 +03:00
|
|
|
PRInt32 endRowIndex = aEndRowIndex;
|
|
|
|
if (-1==endRowIndex)
|
|
|
|
endRowIndex=rowCount-1;
|
1998-12-21 09:38:18 +03:00
|
|
|
if (aStartRowIndex>=rowCount)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(PR_FALSE, "aStartRowIndex>=rowCount in ComputeVerticalCollapsingBorders");
|
|
|
|
return; // we don't have the requested row yet
|
|
|
|
}
|
|
|
|
|
|
|
|
PRInt32 rowIndex = aStartRowIndex;
|
1998-12-23 18:47:43 +03:00
|
|
|
for ( ; rowIndex<rowCount && rowIndex <=endRowIndex; rowIndex++)
|
1998-12-21 09:38:18 +03:00
|
|
|
{
|
|
|
|
PRInt32 colIndex=0;
|
|
|
|
for ( ; colIndex<colCount; colIndex++)
|
|
|
|
{
|
|
|
|
if (0==colIndex)
|
|
|
|
{ // table is left neighbor
|
1998-12-21 21:54:23 +03:00
|
|
|
ComputeLeftBorderForEdgeAt(aPresContext, rowIndex, colIndex);
|
1998-12-21 09:38:18 +03:00
|
|
|
}
|
1998-12-21 21:54:23 +03:00
|
|
|
ComputeRightBorderForEdgeAt(aPresContext, rowIndex, colIndex);
|
1998-12-21 09:38:18 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-12-21 21:54:23 +03:00
|
|
|
void nsTableFrame::ComputeLeftBorderForEdgeAt(nsIPresContext& aPresContext,
|
|
|
|
PRInt32 aRowIndex,
|
|
|
|
PRInt32 aColIndex)
|
1998-12-17 01:19:23 +03:00
|
|
|
{
|
|
|
|
// this method just uses mCellMap, because it can't get called unless nCellMap!=nsnull
|
1998-12-18 01:59:40 +03:00
|
|
|
PRInt32 numSegments = mBorderEdges.mEdges[NS_SIDE_LEFT].Count();
|
1998-12-17 01:19:23 +03:00
|
|
|
while (numSegments<=aRowIndex)
|
|
|
|
{
|
1998-12-17 10:04:42 +03:00
|
|
|
nsBorderEdge *borderToAdd = new nsBorderEdge();
|
1998-12-18 01:59:40 +03:00
|
|
|
mBorderEdges.mEdges[NS_SIDE_LEFT].AppendElement(borderToAdd);
|
1998-12-17 01:19:23 +03:00
|
|
|
numSegments++;
|
|
|
|
}
|
|
|
|
// "border" is the border segment we are going to set
|
1998-12-18 01:59:40 +03:00
|
|
|
nsBorderEdge *border = (nsBorderEdge *)(mBorderEdges.mEdges[NS_SIDE_LEFT].ElementAt(aRowIndex));
|
1998-12-16 20:05:14 +03:00
|
|
|
|
1998-12-17 01:19:23 +03:00
|
|
|
// collect all the incident frames and compute the dominant border
|
|
|
|
nsVoidArray styles;
|
|
|
|
// styles are added to the array in the order least dominant -> most dominant
|
|
|
|
// 1. table
|
|
|
|
const nsStyleSpacing *spacing;
|
|
|
|
GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)spacing));
|
|
|
|
styles.AppendElement((void*)spacing);
|
|
|
|
// 2. colgroup
|
|
|
|
nsTableColFrame *colFrame = mCellMap->GetColumnFrame(aColIndex);
|
|
|
|
nsIFrame *colGroupFrame;
|
1999-02-10 04:36:30 +03:00
|
|
|
colFrame->GetParent(&colGroupFrame);
|
1998-12-17 01:19:23 +03:00
|
|
|
colGroupFrame->GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)spacing));
|
|
|
|
styles.AppendElement((void*)spacing);
|
|
|
|
// 3. col
|
|
|
|
colFrame->GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)spacing));
|
|
|
|
styles.AppendElement((void*)spacing);
|
|
|
|
// 4. rowgroup
|
|
|
|
nsTableCellFrame *cellFrame = mCellMap->GetCellFrameAt(aRowIndex, aColIndex);
|
1998-12-30 09:48:15 +03:00
|
|
|
if (nsnull==cellFrame)
|
|
|
|
{
|
|
|
|
CellData *cellData = mCellMap->GetCellAt(aRowIndex, aColIndex);
|
|
|
|
if (nsnull!=cellData)
|
1999-07-28 12:09:02 +04:00
|
|
|
cellFrame = cellData->mSpanData->mOrigCell;
|
1998-12-30 09:48:15 +03:00
|
|
|
}
|
1998-12-21 09:38:18 +03:00
|
|
|
nsRect rowRect(0,0,0,0);
|
1998-12-17 01:19:23 +03:00
|
|
|
if (nsnull!=cellFrame)
|
|
|
|
{
|
|
|
|
nsIFrame *rowFrame;
|
1999-02-10 04:36:30 +03:00
|
|
|
cellFrame->GetParent(&rowFrame);
|
1998-12-21 09:38:18 +03:00
|
|
|
rowFrame->GetRect(rowRect);
|
1998-12-17 01:19:23 +03:00
|
|
|
nsIFrame *rowGroupFrame;
|
1999-02-10 04:36:30 +03:00
|
|
|
rowFrame->GetParent(&rowGroupFrame);
|
1998-12-17 01:19:23 +03:00
|
|
|
rowGroupFrame->GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)spacing));
|
|
|
|
styles.AppendElement((void*)spacing);
|
|
|
|
// 5. row
|
|
|
|
rowFrame->GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)spacing));
|
|
|
|
styles.AppendElement((void*)spacing);
|
1998-12-17 10:04:42 +03:00
|
|
|
// 6. cell (need to do something smart for rowspanner with row frame)
|
1998-12-17 01:19:23 +03:00
|
|
|
cellFrame->GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)spacing));
|
|
|
|
styles.AppendElement((void*)spacing);
|
|
|
|
}
|
1998-12-18 01:59:40 +03:00
|
|
|
ComputeCollapsedBorderSegment(NS_SIDE_LEFT, &styles, *border, PR_FALSE);
|
|
|
|
// now give half the computed border to the table segment, and half to the cell
|
1998-12-21 21:54:23 +03:00
|
|
|
// to avoid rounding errors, we convert up to pixels, divide by 2, and
|
|
|
|
// we give the odd pixel to the table border
|
1999-02-12 20:45:58 +03:00
|
|
|
float t2p;
|
|
|
|
aPresContext.GetTwipsToPixels(&t2p);
|
|
|
|
float p2t;
|
|
|
|
aPresContext.GetPixelsToTwips(&p2t);
|
1998-12-21 21:54:23 +03:00
|
|
|
nscoord widthAsPixels = NSToCoordRound((float)(border->mWidth)*t2p);
|
|
|
|
nscoord widthToAdd = 0;
|
|
|
|
border->mWidth = widthAsPixels/2;
|
|
|
|
if ((border->mWidth*2)!=widthAsPixels)
|
|
|
|
widthToAdd = NSToCoordCeil(p2t);
|
|
|
|
border->mWidth *= NSToCoordCeil(p2t);
|
1998-12-21 09:38:18 +03:00
|
|
|
border->mLength = rowRect.height;
|
1998-12-30 09:48:15 +03:00
|
|
|
border->mInsideNeighbor = &cellFrame->mBorderEdges;
|
1998-12-23 18:47:43 +03:00
|
|
|
// we need to factor in the table's horizontal borders.
|
|
|
|
// but we can't compute that length here because we don't know how thick top and bottom borders are
|
|
|
|
// see DidComputeHorizontalCollapsingBorders
|
1998-12-21 09:38:18 +03:00
|
|
|
if (nsnull!=cellFrame)
|
|
|
|
{
|
1998-12-21 21:54:23 +03:00
|
|
|
cellFrame->SetBorderEdge(NS_SIDE_LEFT, aRowIndex, aColIndex, border, 0); // set the left edge of the cell frame
|
1998-12-21 09:38:18 +03:00
|
|
|
}
|
1998-12-21 21:54:23 +03:00
|
|
|
border->mWidth += widthToAdd;
|
|
|
|
mBorderEdges.mMaxBorderWidth.left = PR_MAX(border->mWidth, mBorderEdges.mMaxBorderWidth.left);
|
1998-12-17 01:19:23 +03:00
|
|
|
}
|
1998-12-16 20:05:14 +03:00
|
|
|
|
1998-12-21 21:54:23 +03:00
|
|
|
void nsTableFrame::ComputeRightBorderForEdgeAt(nsIPresContext& aPresContext,
|
|
|
|
PRInt32 aRowIndex,
|
|
|
|
PRInt32 aColIndex)
|
1998-12-17 01:19:23 +03:00
|
|
|
{
|
|
|
|
// this method just uses mCellMap, because it can't get called unless nCellMap!=nsnull
|
|
|
|
PRInt32 colCount = mCellMap->GetColCount();
|
1998-12-18 01:59:40 +03:00
|
|
|
PRInt32 numSegments = mBorderEdges.mEdges[NS_SIDE_RIGHT].Count();
|
1998-12-17 10:56:24 +03:00
|
|
|
while (numSegments<=aRowIndex)
|
|
|
|
{
|
|
|
|
nsBorderEdge *borderToAdd = new nsBorderEdge();
|
1998-12-18 01:59:40 +03:00
|
|
|
mBorderEdges.mEdges[NS_SIDE_RIGHT].AppendElement(borderToAdd);
|
1998-12-17 10:56:24 +03:00
|
|
|
numSegments++;
|
|
|
|
}
|
|
|
|
// "border" is the border segment we are going to set
|
1998-12-21 09:38:18 +03:00
|
|
|
nsBorderEdge border;
|
1998-12-16 20:05:14 +03:00
|
|
|
|
1998-12-17 10:56:24 +03:00
|
|
|
// collect all the incident frames and compute the dominant border
|
|
|
|
nsVoidArray styles;
|
|
|
|
// styles are added to the array in the order least dominant -> most dominant
|
|
|
|
// 1. table, only if this cell is in the right-most column and no rowspanning cell is
|
1998-12-18 01:59:40 +03:00
|
|
|
// to it's right. Otherwise, we remember what cell is the right neighbor
|
|
|
|
nsTableCellFrame *rightNeighborFrame=nsnull;
|
|
|
|
if ((colCount-1)!=aColIndex)
|
1998-12-17 10:56:24 +03:00
|
|
|
{
|
|
|
|
PRInt32 colIndex = aColIndex+1;
|
|
|
|
for ( ; colIndex<colCount; colIndex++)
|
|
|
|
{
|
1998-12-18 01:59:40 +03:00
|
|
|
CellData *cd = mCellMap->GetCellAt(aRowIndex, colIndex);
|
1998-12-17 10:56:24 +03:00
|
|
|
if (cd != nsnull)
|
|
|
|
{ // there's really a cell at (aRowIndex, colIndex)
|
1999-07-28 12:09:02 +04:00
|
|
|
if (nsnull==cd->mOrigCell)
|
1998-12-17 10:56:24 +03:00
|
|
|
{ // the cell at (aRowIndex, colIndex) is the result of a span
|
1999-07-28 12:09:02 +04:00
|
|
|
nsTableCellFrame *cell = cd->mSpanData->mOrigCell;
|
1998-12-17 10:56:24 +03:00
|
|
|
NS_ASSERTION(nsnull!=cell, "bad cell map state, missing real cell");
|
1999-02-11 04:16:28 +03:00
|
|
|
PRInt32 realRowIndex;
|
|
|
|
cell->GetRowIndex (realRowIndex);
|
1998-12-17 10:56:24 +03:00
|
|
|
if (realRowIndex!=aRowIndex)
|
|
|
|
{ // the span is caused by a rowspan
|
1999-07-28 12:09:02 +04:00
|
|
|
rightNeighborFrame = cd->mSpanData->mOrigCell;
|
1998-12-17 10:56:24 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1998-12-18 01:59:40 +03:00
|
|
|
else
|
|
|
|
{
|
1999-07-28 12:09:02 +04:00
|
|
|
rightNeighborFrame = cd->mOrigCell;
|
1998-12-18 01:59:40 +03:00
|
|
|
break;
|
|
|
|
}
|
1998-12-17 10:56:24 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const nsStyleSpacing *spacing;
|
1998-12-18 01:59:40 +03:00
|
|
|
if (nsnull==rightNeighborFrame)
|
|
|
|
{ // if rightNeighborFrame is null, our right neighbor is the table
|
|
|
|
GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)spacing));
|
|
|
|
styles.AppendElement((void*)spacing);
|
|
|
|
}
|
1998-12-30 09:48:15 +03:00
|
|
|
// 2. colgroup //XXX: need to test if we're really on a colgroup border
|
1998-12-17 10:56:24 +03:00
|
|
|
nsTableColFrame *colFrame = mCellMap->GetColumnFrame(aColIndex);
|
|
|
|
nsIFrame *colGroupFrame;
|
1999-02-10 04:36:30 +03:00
|
|
|
colFrame->GetParent(&colGroupFrame);
|
1998-12-17 10:56:24 +03:00
|
|
|
colGroupFrame->GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)spacing));
|
|
|
|
styles.AppendElement((void*)spacing);
|
|
|
|
// 3. col
|
|
|
|
colFrame->GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)spacing));
|
|
|
|
styles.AppendElement((void*)spacing);
|
|
|
|
// 4. rowgroup
|
|
|
|
nsTableCellFrame *cellFrame = mCellMap->GetCellFrameAt(aRowIndex, aColIndex);
|
1998-12-30 09:48:15 +03:00
|
|
|
if (nsnull==cellFrame)
|
|
|
|
{
|
|
|
|
CellData *cellData = mCellMap->GetCellAt(aRowIndex, aColIndex);
|
|
|
|
if (nsnull!=cellData)
|
1999-07-28 12:09:02 +04:00
|
|
|
cellFrame = cellData->mSpanData->mOrigCell;
|
1998-12-30 09:48:15 +03:00
|
|
|
}
|
1998-12-21 09:38:18 +03:00
|
|
|
nsRect rowRect(0,0,0,0);
|
1998-12-17 10:56:24 +03:00
|
|
|
if (nsnull!=cellFrame)
|
|
|
|
{
|
|
|
|
nsIFrame *rowFrame;
|
1999-02-10 04:36:30 +03:00
|
|
|
cellFrame->GetParent(&rowFrame);
|
1998-12-21 09:38:18 +03:00
|
|
|
rowFrame->GetRect(rowRect);
|
1998-12-17 10:56:24 +03:00
|
|
|
nsIFrame *rowGroupFrame;
|
1999-02-10 04:36:30 +03:00
|
|
|
rowFrame->GetParent(&rowGroupFrame);
|
1998-12-30 09:48:15 +03:00
|
|
|
if (nsnull==rightNeighborFrame)
|
|
|
|
{ // if rightNeighborFrame is null, our right neighbor is the table so we include the rowgroup and row
|
|
|
|
rowGroupFrame->GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)spacing));
|
|
|
|
styles.AppendElement((void*)spacing);
|
|
|
|
// 5. row
|
|
|
|
rowFrame->GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)spacing));
|
|
|
|
styles.AppendElement((void*)spacing);
|
|
|
|
}
|
1998-12-17 10:56:24 +03:00
|
|
|
// 6. cell (need to do something smart for rowspanner with row frame)
|
|
|
|
cellFrame->GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)spacing));
|
|
|
|
styles.AppendElement((void*)spacing);
|
|
|
|
}
|
1998-12-18 01:59:40 +03:00
|
|
|
// 7. left edge of rightNeighborCell, if there is one
|
|
|
|
if (nsnull!=rightNeighborFrame)
|
|
|
|
{
|
|
|
|
rightNeighborFrame->GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)spacing));
|
|
|
|
styles.AppendElement((void*)spacing);
|
|
|
|
}
|
1998-12-21 09:38:18 +03:00
|
|
|
ComputeCollapsedBorderSegment(NS_SIDE_RIGHT, &styles, border, PRBool(nsnull!=rightNeighborFrame));
|
|
|
|
// now give half the computed border to each of the two neighbors
|
|
|
|
// (the 2 cells, or the cell and the table)
|
1998-12-21 21:54:23 +03:00
|
|
|
// to avoid rounding errors, we convert up to pixels, divide by 2, and
|
|
|
|
// we give the odd pixel to the right cell border
|
1999-02-12 20:45:58 +03:00
|
|
|
float t2p;
|
|
|
|
aPresContext.GetTwipsToPixels(&t2p);
|
|
|
|
float p2t;
|
|
|
|
aPresContext.GetPixelsToTwips(&p2t);
|
1998-12-21 21:54:23 +03:00
|
|
|
nscoord widthAsPixels = NSToCoordRound((float)(border.mWidth)*t2p);
|
|
|
|
nscoord widthToAdd = 0;
|
|
|
|
border.mWidth = widthAsPixels/2;
|
|
|
|
if ((border.mWidth*2)!=widthAsPixels)
|
|
|
|
widthToAdd = NSToCoordCeil(p2t);
|
|
|
|
border.mWidth *= NSToCoordCeil(p2t);
|
1998-12-21 09:38:18 +03:00
|
|
|
border.mLength = rowRect.height;
|
1998-12-31 01:40:36 +03:00
|
|
|
if (nsnull!=cellFrame)
|
|
|
|
{
|
|
|
|
cellFrame->SetBorderEdge(NS_SIDE_RIGHT, aRowIndex, aColIndex, &border, widthToAdd);
|
|
|
|
}
|
1998-12-21 09:38:18 +03:00
|
|
|
if (nsnull==rightNeighborFrame)
|
|
|
|
{
|
|
|
|
nsBorderEdge * tableBorder = (nsBorderEdge *)(mBorderEdges.mEdges[NS_SIDE_RIGHT].ElementAt(aRowIndex));
|
|
|
|
*tableBorder = border;
|
1998-12-30 09:48:15 +03:00
|
|
|
tableBorder->mInsideNeighbor = &cellFrame->mBorderEdges;
|
1998-12-21 09:38:18 +03:00
|
|
|
mBorderEdges.mMaxBorderWidth.right = PR_MAX(border.mWidth, mBorderEdges.mMaxBorderWidth.right);
|
1998-12-23 18:47:43 +03:00
|
|
|
// since the table is our right neightbor, we need to factor in the table's horizontal borders.
|
|
|
|
// can't compute that length here because we don't know how thick top and bottom borders are
|
|
|
|
// see DidComputeHorizontalCollapsingBorders
|
1998-12-21 09:38:18 +03:00
|
|
|
}
|
|
|
|
else
|
1998-12-30 09:48:15 +03:00
|
|
|
{
|
1998-12-21 21:54:23 +03:00
|
|
|
rightNeighborFrame->SetBorderEdge(NS_SIDE_LEFT, aRowIndex, aColIndex, &border, 0);
|
1998-12-30 09:48:15 +03:00
|
|
|
}
|
1998-12-17 01:19:23 +03:00
|
|
|
}
|
|
|
|
|
1998-12-21 21:54:23 +03:00
|
|
|
void nsTableFrame::ComputeTopBorderForEdgeAt(nsIPresContext& aPresContext,
|
|
|
|
PRInt32 aRowIndex,
|
|
|
|
PRInt32 aColIndex)
|
1998-12-17 01:19:23 +03:00
|
|
|
{
|
|
|
|
// this method just uses mCellMap, because it can't get called unless nCellMap!=nsnull
|
1998-12-21 09:38:18 +03:00
|
|
|
PRInt32 numSegments = mBorderEdges.mEdges[NS_SIDE_TOP].Count();
|
|
|
|
while (numSegments<=aColIndex)
|
|
|
|
{
|
|
|
|
nsBorderEdge *borderToAdd = new nsBorderEdge();
|
|
|
|
mBorderEdges.mEdges[NS_SIDE_TOP].AppendElement(borderToAdd);
|
|
|
|
numSegments++;
|
|
|
|
}
|
|
|
|
// "border" is the border segment we are going to set
|
|
|
|
nsBorderEdge *border = (nsBorderEdge *)(mBorderEdges.mEdges[NS_SIDE_TOP].ElementAt(aColIndex));
|
|
|
|
|
|
|
|
// collect all the incident frames and compute the dominant border
|
|
|
|
nsVoidArray styles;
|
|
|
|
// styles are added to the array in the order least dominant -> most dominant
|
|
|
|
// 1. table
|
|
|
|
const nsStyleSpacing *spacing;
|
|
|
|
GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)spacing));
|
|
|
|
styles.AppendElement((void*)spacing);
|
|
|
|
// 2. colgroup
|
|
|
|
nsTableColFrame *colFrame = mCellMap->GetColumnFrame(aColIndex);
|
|
|
|
nsIFrame *colGroupFrame;
|
1999-02-10 04:36:30 +03:00
|
|
|
colFrame->GetParent(&colGroupFrame);
|
1998-12-21 09:38:18 +03:00
|
|
|
colGroupFrame->GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)spacing));
|
|
|
|
styles.AppendElement((void*)spacing);
|
|
|
|
// 3. col
|
|
|
|
colFrame->GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)spacing));
|
|
|
|
styles.AppendElement((void*)spacing);
|
|
|
|
// 4. rowgroup
|
|
|
|
nsTableCellFrame *cellFrame = mCellMap->GetCellFrameAt(aRowIndex, aColIndex);
|
1998-12-30 09:48:15 +03:00
|
|
|
if (nsnull==cellFrame)
|
|
|
|
{
|
|
|
|
CellData *cellData = mCellMap->GetCellAt(aRowIndex, aColIndex);
|
|
|
|
if (nsnull!=cellData)
|
1999-07-28 12:09:02 +04:00
|
|
|
cellFrame = cellData->mSpanData->mOrigCell;
|
1998-12-30 09:48:15 +03:00
|
|
|
}
|
1998-12-21 09:38:18 +03:00
|
|
|
if (nsnull!=cellFrame)
|
|
|
|
{
|
|
|
|
nsIFrame *rowFrame;
|
1999-02-10 04:36:30 +03:00
|
|
|
cellFrame->GetParent(&rowFrame);
|
1998-12-21 09:38:18 +03:00
|
|
|
nsIFrame *rowGroupFrame;
|
1999-02-10 04:36:30 +03:00
|
|
|
rowFrame->GetParent(&rowGroupFrame);
|
1998-12-21 09:38:18 +03:00
|
|
|
rowGroupFrame->GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)spacing));
|
|
|
|
styles.AppendElement((void*)spacing);
|
|
|
|
// 5. row
|
|
|
|
rowFrame->GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)spacing));
|
|
|
|
styles.AppendElement((void*)spacing);
|
|
|
|
// 6. cell (need to do something smart for rowspanner with row frame)
|
|
|
|
cellFrame->GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)spacing));
|
|
|
|
styles.AppendElement((void*)spacing);
|
|
|
|
}
|
|
|
|
ComputeCollapsedBorderSegment(NS_SIDE_TOP, &styles, *border, PR_FALSE);
|
|
|
|
// now give half the computed border to the table segment, and half to the cell
|
1998-12-21 21:54:23 +03:00
|
|
|
// to avoid rounding errors, we convert up to pixels, divide by 2, and
|
|
|
|
// we give the odd pixel to the right border
|
1999-02-12 20:45:58 +03:00
|
|
|
float t2p;
|
|
|
|
aPresContext.GetTwipsToPixels(&t2p);
|
|
|
|
float p2t;
|
|
|
|
aPresContext.GetPixelsToTwips(&p2t);
|
1998-12-21 21:54:23 +03:00
|
|
|
nscoord widthAsPixels = NSToCoordRound((float)(border->mWidth)*t2p);
|
|
|
|
nscoord widthToAdd = 0;
|
|
|
|
border->mWidth = widthAsPixels/2;
|
|
|
|
if ((border->mWidth*2)!=widthAsPixels)
|
|
|
|
widthToAdd = NSToCoordCeil(p2t);
|
|
|
|
border->mWidth *= NSToCoordCeil(p2t);
|
1998-12-21 09:38:18 +03:00
|
|
|
border->mLength = GetColumnWidth(aColIndex);
|
1998-12-30 09:48:15 +03:00
|
|
|
border->mInsideNeighbor = &cellFrame->mBorderEdges;
|
1998-12-23 18:47:43 +03:00
|
|
|
if (0==aColIndex)
|
|
|
|
{ // if we're the first column, factor in the thickness of the left table border
|
|
|
|
nsBorderEdge *leftBorder = (nsBorderEdge *)(mBorderEdges.mEdges[NS_SIDE_LEFT].ElementAt(0));
|
|
|
|
border->mLength += leftBorder->mWidth;
|
|
|
|
}
|
|
|
|
if ((mCellMap->GetColCount()-1)==aColIndex)
|
|
|
|
{ // if we're the last column, factor in the thickness of the right table border
|
|
|
|
nsBorderEdge *rightBorder = (nsBorderEdge *)(mBorderEdges.mEdges[NS_SIDE_RIGHT].ElementAt(0));
|
|
|
|
border->mLength += rightBorder->mWidth;
|
|
|
|
}
|
1998-12-21 09:38:18 +03:00
|
|
|
if (nsnull!=cellFrame)
|
|
|
|
{
|
1998-12-21 21:54:23 +03:00
|
|
|
cellFrame->SetBorderEdge(NS_SIDE_TOP, aRowIndex, aColIndex, border, 0); // set the top edge of the cell frame
|
1998-12-21 09:38:18 +03:00
|
|
|
}
|
1998-12-21 21:54:23 +03:00
|
|
|
border->mWidth += widthToAdd;
|
|
|
|
mBorderEdges.mMaxBorderWidth.top = PR_MAX(border->mWidth, mBorderEdges.mMaxBorderWidth.top);
|
1998-12-17 01:19:23 +03:00
|
|
|
}
|
|
|
|
|
1998-12-21 21:54:23 +03:00
|
|
|
void nsTableFrame::ComputeBottomBorderForEdgeAt(nsIPresContext& aPresContext,
|
|
|
|
PRInt32 aRowIndex,
|
|
|
|
PRInt32 aColIndex)
|
1998-12-17 01:19:23 +03:00
|
|
|
{
|
|
|
|
// this method just uses mCellMap, because it can't get called unless nCellMap!=nsnull
|
|
|
|
PRInt32 rowCount = mCellMap->GetRowCount();
|
1998-12-21 09:38:18 +03:00
|
|
|
PRInt32 numSegments = mBorderEdges.mEdges[NS_SIDE_BOTTOM].Count();
|
|
|
|
while (numSegments<=aColIndex)
|
|
|
|
{
|
|
|
|
nsBorderEdge *borderToAdd = new nsBorderEdge();
|
|
|
|
mBorderEdges.mEdges[NS_SIDE_BOTTOM].AppendElement(borderToAdd);
|
|
|
|
numSegments++;
|
|
|
|
}
|
|
|
|
// "border" is the border segment we are going to set
|
|
|
|
nsBorderEdge border;
|
1998-12-16 20:05:14 +03:00
|
|
|
|
1998-12-21 09:38:18 +03:00
|
|
|
// collect all the incident frames and compute the dominant border
|
|
|
|
nsVoidArray styles;
|
|
|
|
// styles are added to the array in the order least dominant -> most dominant
|
|
|
|
// 1. table, only if this cell is in the bottom-most row and no colspanning cell is
|
|
|
|
// beneath it. Otherwise, we remember what cell is the bottom neighbor
|
|
|
|
nsTableCellFrame *bottomNeighborFrame=nsnull;
|
|
|
|
if ((rowCount-1)!=aRowIndex)
|
|
|
|
{
|
|
|
|
PRInt32 rowIndex = aRowIndex+1;
|
|
|
|
for ( ; rowIndex<rowCount; rowIndex++)
|
|
|
|
{
|
|
|
|
CellData *cd = mCellMap->GetCellAt(rowIndex, aColIndex);
|
|
|
|
if (cd != nsnull)
|
|
|
|
{ // there's really a cell at (rowIndex, aColIndex)
|
1999-07-28 12:09:02 +04:00
|
|
|
if (nsnull==cd->mOrigCell)
|
1998-12-21 09:38:18 +03:00
|
|
|
{ // the cell at (rowIndex, aColIndex) is the result of a span
|
1999-07-28 12:09:02 +04:00
|
|
|
nsTableCellFrame *cell = cd->mSpanData->mOrigCell;
|
1998-12-21 09:38:18 +03:00
|
|
|
NS_ASSERTION(nsnull!=cell, "bad cell map state, missing real cell");
|
1999-02-11 04:16:28 +03:00
|
|
|
PRInt32 realColIndex;
|
|
|
|
cell->GetColIndex (realColIndex);
|
1998-12-21 09:38:18 +03:00
|
|
|
if (realColIndex!=aColIndex)
|
|
|
|
{ // the span is caused by a colspan
|
1999-07-28 12:09:02 +04:00
|
|
|
bottomNeighborFrame = cd->mSpanData->mOrigCell;
|
1998-12-21 09:38:18 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1999-07-28 12:09:02 +04:00
|
|
|
bottomNeighborFrame = cd->mOrigCell;
|
1998-12-21 09:38:18 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const nsStyleSpacing *spacing;
|
|
|
|
if (nsnull==bottomNeighborFrame)
|
|
|
|
{ // if bottomNeighborFrame is null, our bottom neighbor is the table
|
|
|
|
GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)spacing));
|
|
|
|
styles.AppendElement((void*)spacing);
|
1998-12-30 09:48:15 +03:00
|
|
|
|
|
|
|
// 2. colgroup // XXX: need to deterine if we're on a colgroup boundary
|
|
|
|
nsTableColFrame *colFrame = mCellMap->GetColumnFrame(aColIndex);
|
|
|
|
nsIFrame *colGroupFrame;
|
1999-02-10 04:36:30 +03:00
|
|
|
colFrame->GetParent(&colGroupFrame);
|
1998-12-30 09:48:15 +03:00
|
|
|
colGroupFrame->GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)spacing));
|
|
|
|
styles.AppendElement((void*)spacing);
|
|
|
|
// 3. col
|
|
|
|
colFrame->GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)spacing));
|
|
|
|
styles.AppendElement((void*)spacing);
|
1998-12-21 09:38:18 +03:00
|
|
|
}
|
|
|
|
// 4. rowgroup // XXX: use rowgroup only if we're on a table edge
|
|
|
|
nsTableCellFrame *cellFrame = mCellMap->GetCellFrameAt(aRowIndex, aColIndex);
|
1998-12-30 09:48:15 +03:00
|
|
|
if (nsnull==cellFrame)
|
|
|
|
{
|
|
|
|
CellData *cellData = mCellMap->GetCellAt(aRowIndex, aColIndex);
|
|
|
|
if (nsnull!=cellData)
|
1999-07-28 12:09:02 +04:00
|
|
|
cellFrame = cellData->mSpanData->mOrigCell;
|
1998-12-30 09:48:15 +03:00
|
|
|
}
|
1998-12-21 09:38:18 +03:00
|
|
|
nsRect rowRect(0,0,0,0);
|
|
|
|
if (nsnull!=cellFrame)
|
|
|
|
{
|
|
|
|
nsIFrame *rowFrame;
|
1999-02-10 04:36:30 +03:00
|
|
|
cellFrame->GetParent(&rowFrame);
|
1998-12-21 09:38:18 +03:00
|
|
|
rowFrame->GetRect(rowRect);
|
|
|
|
nsIFrame *rowGroupFrame;
|
1999-02-10 04:36:30 +03:00
|
|
|
rowFrame->GetParent(&rowGroupFrame);
|
1998-12-21 09:38:18 +03:00
|
|
|
rowGroupFrame->GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)spacing));
|
|
|
|
styles.AppendElement((void*)spacing);
|
|
|
|
// 5. row
|
|
|
|
rowFrame->GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)spacing));
|
|
|
|
styles.AppendElement((void*)spacing);
|
|
|
|
// 6. cell (need to do something smart for rowspanner with row frame)
|
|
|
|
cellFrame->GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)spacing));
|
|
|
|
styles.AppendElement((void*)spacing);
|
|
|
|
}
|
|
|
|
// 7. top edge of bottomNeighborCell, if there is one
|
|
|
|
if (nsnull!=bottomNeighborFrame)
|
|
|
|
{
|
|
|
|
bottomNeighborFrame->GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)spacing));
|
|
|
|
styles.AppendElement((void*)spacing);
|
|
|
|
}
|
|
|
|
ComputeCollapsedBorderSegment(NS_SIDE_BOTTOM, &styles, border, PRBool(nsnull!=bottomNeighborFrame));
|
|
|
|
// now give half the computed border to each of the two neighbors
|
|
|
|
// (the 2 cells, or the cell and the table)
|
1998-12-21 21:54:23 +03:00
|
|
|
// to avoid rounding errors, we convert up to pixels, divide by 2, and
|
|
|
|
// we give the odd pixel to the right cell border
|
1999-02-12 20:45:58 +03:00
|
|
|
float t2p;
|
|
|
|
aPresContext.GetTwipsToPixels(&t2p);
|
|
|
|
float p2t;
|
|
|
|
aPresContext.GetPixelsToTwips(&p2t);
|
1998-12-21 21:54:23 +03:00
|
|
|
nscoord widthAsPixels = NSToCoordRound((float)(border.mWidth)*t2p);
|
|
|
|
nscoord widthToAdd = 0;
|
|
|
|
border.mWidth = widthAsPixels/2;
|
|
|
|
if ((border.mWidth*2)!=widthAsPixels)
|
|
|
|
widthToAdd = NSToCoordCeil(p2t);
|
|
|
|
border.mWidth *= NSToCoordCeil(p2t);
|
1998-12-21 09:38:18 +03:00
|
|
|
border.mLength = GetColumnWidth(aColIndex);
|
1998-12-31 01:40:36 +03:00
|
|
|
if (nsnull!=cellFrame)
|
|
|
|
{
|
|
|
|
cellFrame->SetBorderEdge(NS_SIDE_BOTTOM, aRowIndex, aColIndex, &border, widthToAdd);
|
|
|
|
}
|
1998-12-21 09:38:18 +03:00
|
|
|
if (nsnull==bottomNeighborFrame)
|
|
|
|
{
|
|
|
|
nsBorderEdge * tableBorder = (nsBorderEdge *)(mBorderEdges.mEdges[NS_SIDE_BOTTOM].ElementAt(aColIndex));
|
|
|
|
*tableBorder = border;
|
1998-12-30 09:48:15 +03:00
|
|
|
tableBorder->mInsideNeighbor = &cellFrame->mBorderEdges;
|
1998-12-21 09:38:18 +03:00
|
|
|
mBorderEdges.mMaxBorderWidth.bottom = PR_MAX(border.mWidth, mBorderEdges.mMaxBorderWidth.bottom);
|
1998-12-23 18:47:43 +03:00
|
|
|
// since the table is our bottom neightbor, we need to factor in the table's vertical borders.
|
|
|
|
PRInt32 lastColIndex = mCellMap->GetColCount()-1;
|
|
|
|
if (0==aColIndex)
|
|
|
|
{ // if we're the first column, factor in the thickness of the left table border
|
|
|
|
nsBorderEdge *leftBorder = (nsBorderEdge *)(mBorderEdges.mEdges[NS_SIDE_LEFT].ElementAt(rowCount-1));
|
|
|
|
tableBorder->mLength += leftBorder->mWidth;
|
|
|
|
}
|
|
|
|
if (lastColIndex==aColIndex)
|
|
|
|
{ // if we're the last column, factor in the thickness of the right table border
|
|
|
|
nsBorderEdge *rightBorder = (nsBorderEdge *)(mBorderEdges.mEdges[NS_SIDE_RIGHT].ElementAt(rowCount-1));
|
|
|
|
tableBorder->mLength += rightBorder->mWidth;
|
|
|
|
}
|
1998-12-21 09:38:18 +03:00
|
|
|
}
|
|
|
|
else
|
1998-12-30 09:48:15 +03:00
|
|
|
{
|
1998-12-21 21:54:23 +03:00
|
|
|
bottomNeighborFrame->SetBorderEdge(NS_SIDE_TOP, aRowIndex, aColIndex, &border, 0);
|
1998-12-30 09:48:15 +03:00
|
|
|
}
|
1998-12-16 20:05:14 +03:00
|
|
|
}
|
|
|
|
|
1998-12-17 10:04:42 +03:00
|
|
|
nscoord nsTableFrame::GetWidthForSide(const nsMargin &aBorder, PRUint8 aSide)
|
|
|
|
{
|
|
|
|
if (NS_SIDE_LEFT == aSide) return aBorder.left;
|
|
|
|
else if (NS_SIDE_RIGHT == aSide) return aBorder.right;
|
|
|
|
else if (NS_SIDE_TOP == aSide) return aBorder.top;
|
|
|
|
else return aBorder.bottom;
|
|
|
|
}
|
|
|
|
|
1998-12-18 01:59:40 +03:00
|
|
|
/* Given an Edge, find the opposing edge (top<-->bottom, left<-->right) */
|
|
|
|
PRUint8 nsTableFrame::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;
|
|
|
|
}
|
|
|
|
|
1998-12-17 10:04:42 +03:00
|
|
|
/* returns BORDER_PRECEDENT_LOWER if aStyle1 is lower precedent that aStyle2
|
|
|
|
* BORDER_PRECEDENT_HIGHER if aStyle1 is higher precedent that aStyle2
|
|
|
|
* BORDER_PRECEDENT_EQUAL if aStyle1 and aStyle2 have the same precedence
|
|
|
|
* (note, this is not necessarily the same as saying aStyle1==aStyle2)
|
|
|
|
* this is a method on nsTableFrame because other objects might define their
|
|
|
|
* own border precedence rules.
|
|
|
|
*/
|
|
|
|
PRUint8 nsTableFrame::CompareBorderStyles(PRUint8 aStyle1, PRUint8 aStyle2)
|
|
|
|
{
|
|
|
|
PRUint8 result=BORDER_PRECEDENT_HIGHER; // if we get illegal types for table borders, HIGHER is the default
|
|
|
|
if (aStyle1==aStyle2)
|
|
|
|
result = BORDER_PRECEDENT_EQUAL;
|
|
|
|
else if (NS_STYLE_BORDER_STYLE_HIDDEN==aStyle1)
|
|
|
|
result = BORDER_PRECEDENT_HIGHER;
|
|
|
|
else if (NS_STYLE_BORDER_STYLE_NONE==aStyle1)
|
|
|
|
result = BORDER_PRECEDENT_LOWER;
|
|
|
|
else if (NS_STYLE_BORDER_STYLE_NONE==aStyle2)
|
|
|
|
result = BORDER_PRECEDENT_HIGHER;
|
|
|
|
else if (NS_STYLE_BORDER_STYLE_HIDDEN==aStyle2)
|
|
|
|
result = BORDER_PRECEDENT_LOWER;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch (aStyle1)
|
|
|
|
{
|
1999-01-23 01:38:34 +03:00
|
|
|
case NS_STYLE_BORDER_STYLE_BG_INSET:
|
1998-12-17 10:04:42 +03:00
|
|
|
result = BORDER_PRECEDENT_LOWER;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_STYLE_BORDER_STYLE_GROOVE:
|
1999-01-23 01:38:34 +03:00
|
|
|
if (NS_STYLE_BORDER_STYLE_BG_INSET==aStyle2)
|
1998-12-17 10:04:42 +03:00
|
|
|
result = BORDER_PRECEDENT_HIGHER;
|
|
|
|
else
|
|
|
|
result = BORDER_PRECEDENT_LOWER;
|
|
|
|
break;
|
|
|
|
|
1999-01-23 01:38:34 +03:00
|
|
|
case NS_STYLE_BORDER_STYLE_BG_OUTSET:
|
|
|
|
if (NS_STYLE_BORDER_STYLE_BG_INSET==aStyle2 ||
|
1998-12-17 10:04:42 +03:00
|
|
|
NS_STYLE_BORDER_STYLE_GROOVE==aStyle2)
|
|
|
|
result = BORDER_PRECEDENT_HIGHER;
|
|
|
|
else
|
|
|
|
result = BORDER_PRECEDENT_LOWER;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_STYLE_BORDER_STYLE_RIDGE:
|
1999-01-23 01:38:34 +03:00
|
|
|
if (NS_STYLE_BORDER_STYLE_BG_INSET==aStyle2 ||
|
1998-12-17 10:04:42 +03:00
|
|
|
NS_STYLE_BORDER_STYLE_GROOVE==aStyle2 ||
|
1999-01-23 01:38:34 +03:00
|
|
|
NS_STYLE_BORDER_STYLE_BG_OUTSET==aStyle2)
|
1998-12-17 10:04:42 +03:00
|
|
|
result = BORDER_PRECEDENT_HIGHER;
|
|
|
|
else
|
|
|
|
result = BORDER_PRECEDENT_LOWER;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_STYLE_BORDER_STYLE_DOTTED:
|
1999-01-23 01:38:34 +03:00
|
|
|
if (NS_STYLE_BORDER_STYLE_BG_INSET==aStyle2 ||
|
1998-12-17 10:04:42 +03:00
|
|
|
NS_STYLE_BORDER_STYLE_GROOVE==aStyle2 ||
|
1999-01-23 01:38:34 +03:00
|
|
|
NS_STYLE_BORDER_STYLE_BG_OUTSET==aStyle2 ||
|
1998-12-17 10:04:42 +03:00
|
|
|
NS_STYLE_BORDER_STYLE_RIDGE==aStyle2)
|
|
|
|
result = BORDER_PRECEDENT_HIGHER;
|
|
|
|
else
|
|
|
|
result = BORDER_PRECEDENT_LOWER;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_STYLE_BORDER_STYLE_DASHED:
|
1999-01-23 01:38:34 +03:00
|
|
|
if (NS_STYLE_BORDER_STYLE_BG_INSET==aStyle2 ||
|
1998-12-17 10:04:42 +03:00
|
|
|
NS_STYLE_BORDER_STYLE_GROOVE==aStyle2 ||
|
1999-01-23 01:38:34 +03:00
|
|
|
NS_STYLE_BORDER_STYLE_BG_OUTSET==aStyle2 ||
|
1998-12-17 10:04:42 +03:00
|
|
|
NS_STYLE_BORDER_STYLE_RIDGE==aStyle2 ||
|
|
|
|
NS_STYLE_BORDER_STYLE_DOTTED==aStyle2)
|
|
|
|
result = BORDER_PRECEDENT_HIGHER;
|
|
|
|
else
|
|
|
|
result = BORDER_PRECEDENT_LOWER;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_STYLE_BORDER_STYLE_SOLID:
|
1999-01-23 01:38:34 +03:00
|
|
|
if (NS_STYLE_BORDER_STYLE_BG_INSET==aStyle2 ||
|
1998-12-17 10:04:42 +03:00
|
|
|
NS_STYLE_BORDER_STYLE_GROOVE==aStyle2 ||
|
1999-01-23 01:38:34 +03:00
|
|
|
NS_STYLE_BORDER_STYLE_BG_OUTSET==aStyle2 ||
|
1998-12-17 10:04:42 +03:00
|
|
|
NS_STYLE_BORDER_STYLE_RIDGE==aStyle2 ||
|
|
|
|
NS_STYLE_BORDER_STYLE_DOTTED==aStyle2 ||
|
|
|
|
NS_STYLE_BORDER_STYLE_DASHED==aStyle2)
|
|
|
|
result = BORDER_PRECEDENT_HIGHER;
|
|
|
|
else
|
|
|
|
result = BORDER_PRECEDENT_LOWER;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_STYLE_BORDER_STYLE_DOUBLE:
|
|
|
|
result = BORDER_PRECEDENT_LOWER;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
This method is the CSS2 border conflict resolution algorithm
|
|
|
|
The spec says to resolve conflicts in this order:
|
|
|
|
1. any border with the style HIDDEN wins
|
|
|
|
2. the widest border with a style that is not NONE wins
|
|
|
|
3. the border styles are ranked in this order, highest to lowest precedence:
|
|
|
|
double, solid, dashed, dotted, ridge, outset, groove, inset
|
|
|
|
4. borders that are of equal width and style (differ only in color) have this precedence:
|
|
|
|
cell, row, rowgroup, col, colgroup, table
|
|
|
|
5. if all border styles are NONE, then that's the computed border style.
|
|
|
|
This method assumes that the styles were added to aStyles in the reverse precedence order
|
|
|
|
of their frame type, so that styles that come later in the list win over style
|
|
|
|
earlier in the list if the tie-breaker gets down to #4.
|
|
|
|
This method sets the out-param aBorder with the resolved border attributes
|
|
|
|
*/
|
1998-12-18 01:59:40 +03:00
|
|
|
void nsTableFrame::ComputeCollapsedBorderSegment(PRUint8 aSide,
|
|
|
|
nsVoidArray *aStyles,
|
|
|
|
nsBorderEdge &aBorder,
|
|
|
|
PRBool aFlipLastSide)
|
1998-12-17 10:04:42 +03:00
|
|
|
{
|
|
|
|
if (nsnull!=aStyles)
|
|
|
|
{
|
|
|
|
PRInt32 styleCount=aStyles->Count();
|
|
|
|
if (0!=styleCount)
|
|
|
|
{
|
|
|
|
nsVoidArray sameWidthBorders;
|
|
|
|
nsStyleSpacing * spacing;
|
1998-12-18 01:59:40 +03:00
|
|
|
nsStyleSpacing * lastSpacing=nsnull;
|
1998-12-17 10:04:42 +03:00
|
|
|
nsMargin border;
|
|
|
|
PRInt32 maxWidth=0;
|
|
|
|
PRInt32 i;
|
1998-12-18 01:59:40 +03:00
|
|
|
PRUint8 side = aSide;
|
1998-12-17 10:04:42 +03:00
|
|
|
for (i=0; i<styleCount; i++)
|
|
|
|
{
|
|
|
|
spacing = (nsStyleSpacing *)(aStyles->ElementAt(i));
|
1998-12-18 01:59:40 +03:00
|
|
|
if ((PR_TRUE==aFlipLastSide) && (i==styleCount-1))
|
|
|
|
{
|
|
|
|
side = GetOpposingEdge(aSide);
|
|
|
|
lastSpacing = spacing;
|
|
|
|
}
|
|
|
|
if (spacing->GetBorderStyle(side)==NS_STYLE_BORDER_STYLE_HIDDEN)
|
1998-12-17 10:04:42 +03:00
|
|
|
{
|
|
|
|
aBorder.mStyle=NS_STYLE_BORDER_STYLE_HIDDEN;
|
|
|
|
aBorder.mWidth=0;
|
|
|
|
return;
|
|
|
|
}
|
1998-12-18 01:59:40 +03:00
|
|
|
else if (spacing->GetBorderStyle(side)!=NS_STYLE_BORDER_STYLE_NONE)
|
1998-12-17 10:04:42 +03:00
|
|
|
{
|
|
|
|
spacing->GetBorder(border);
|
1998-12-18 01:59:40 +03:00
|
|
|
nscoord borderWidth = GetWidthForSide(border, side);
|
1998-12-17 10:04:42 +03:00
|
|
|
if (borderWidth==maxWidth)
|
|
|
|
sameWidthBorders.AppendElement(spacing);
|
|
|
|
else if (borderWidth>maxWidth)
|
|
|
|
{
|
|
|
|
maxWidth=borderWidth;
|
|
|
|
sameWidthBorders.Clear();
|
|
|
|
sameWidthBorders.AppendElement(spacing);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
aBorder.mWidth=maxWidth;
|
|
|
|
// now we've gone through each overlapping border once, and we have a list
|
|
|
|
// of all styles with the same width. If there's more than one, resolve the
|
|
|
|
// conflict based on border style
|
|
|
|
styleCount = sameWidthBorders.Count();
|
|
|
|
if (0==styleCount)
|
|
|
|
{ // all borders were of style NONE
|
|
|
|
aBorder.mWidth=0;
|
|
|
|
aBorder.mStyle=NS_STYLE_BORDER_STYLE_NONE;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if (1==styleCount)
|
|
|
|
{ // there was just one border of the largest width
|
|
|
|
spacing = (nsStyleSpacing *)(sameWidthBorders.ElementAt(0));
|
1998-12-18 01:59:40 +03:00
|
|
|
side=aSide;
|
|
|
|
if (spacing==lastSpacing)
|
|
|
|
side=GetOpposingEdge(aSide);
|
1999-03-28 08:32:39 +04:00
|
|
|
if (! spacing->GetBorderColor(side, aBorder.mColor)) {
|
|
|
|
// XXX EEEK handle transparent border color somehow...
|
|
|
|
}
|
1998-12-18 01:59:40 +03:00
|
|
|
aBorder.mStyle=spacing->GetBorderStyle(side);
|
1998-12-17 10:04:42 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nsStyleSpacing *winningStyleBorder;
|
|
|
|
PRUint8 winningStyle=NS_STYLE_BORDER_STYLE_NONE;
|
|
|
|
for (i=0; i<styleCount; i++)
|
|
|
|
{
|
1998-12-30 09:48:15 +03:00
|
|
|
spacing = (nsStyleSpacing *)(sameWidthBorders.ElementAt(i));
|
1998-12-18 01:59:40 +03:00
|
|
|
side=aSide;
|
|
|
|
if (spacing==lastSpacing)
|
|
|
|
side=GetOpposingEdge(aSide);
|
|
|
|
PRUint8 thisStyle = spacing->GetBorderStyle(side);
|
1998-12-17 10:04:42 +03:00
|
|
|
PRUint8 borderCompare = CompareBorderStyles(thisStyle, winningStyle);
|
|
|
|
if (BORDER_PRECEDENT_HIGHER==borderCompare)
|
|
|
|
{
|
|
|
|
winningStyle=thisStyle;
|
|
|
|
winningStyleBorder = spacing;
|
|
|
|
}
|
|
|
|
else if (BORDER_PRECEDENT_EQUAL==borderCompare)
|
|
|
|
{ // we're in lowest-to-highest precedence order, so later border styles win
|
|
|
|
winningStyleBorder=spacing;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
aBorder.mStyle = winningStyle;
|
1998-12-18 01:59:40 +03:00
|
|
|
side=aSide;
|
|
|
|
if (winningStyleBorder==lastSpacing)
|
|
|
|
side=GetOpposingEdge(aSide);
|
1999-03-28 08:32:39 +04:00
|
|
|
if (! winningStyleBorder->GetBorderColor(side, aBorder.mColor)) {
|
|
|
|
// XXX handle transparent border colors somehow
|
|
|
|
}
|
1998-12-17 10:04:42 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
1998-12-21 21:54:23 +03:00
|
|
|
void nsTableFrame::RecalcLayoutData(nsIPresContext& aPresContext)
|
1998-12-16 20:05:14 +03:00
|
|
|
{
|
|
|
|
nsCellMap *cellMap = GetCellMap();
|
|
|
|
if (nsnull==cellMap)
|
|
|
|
return; // no info yet, so nothing useful to do
|
|
|
|
PRInt32 colCount = cellMap->GetColCount();
|
|
|
|
PRInt32 rowCount = cellMap->GetRowCount();
|
|
|
|
|
|
|
|
//XXX need to determine how much of what follows is really necessary
|
|
|
|
// it does collapsing margins between table elements
|
1998-06-17 20:38:24 +04:00
|
|
|
PRInt32 row = 0;
|
|
|
|
PRInt32 col = 0;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-06-17 20:38:24 +04:00
|
|
|
nsTableCellFrame* above = nsnull;
|
|
|
|
nsTableCellFrame* below = nsnull;
|
|
|
|
nsTableCellFrame* left = nsnull;
|
|
|
|
nsTableCellFrame* right = nsnull;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
|
|
|
|
PRInt32 edge = 0;
|
|
|
|
nsVoidArray* boundaryCells[4];
|
|
|
|
|
|
|
|
for (edge = 0; edge < 4; edge++)
|
|
|
|
boundaryCells[edge] = new nsVoidArray();
|
|
|
|
|
|
|
|
|
|
|
|
if (colCount != 0 && rowCount != 0)
|
|
|
|
{
|
|
|
|
for (row = 0; row < rowCount; row++)
|
|
|
|
{
|
|
|
|
for (col = 0; col < colCount; col++)
|
|
|
|
{
|
1998-06-17 20:38:24 +04:00
|
|
|
nsTableCellFrame* cell = nsnull;
|
1998-08-18 03:37:04 +04:00
|
|
|
CellData* cellData = cellMap->GetCellAt(row,col);
|
1998-05-27 00:57:24 +04:00
|
|
|
|
|
|
|
if (cellData)
|
1999-07-28 12:09:02 +04:00
|
|
|
cell = cellData->mOrigCell;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-06-17 20:38:24 +04:00
|
|
|
if (nsnull==cell)
|
1998-04-14 00:24:54 +04:00
|
|
|
continue;
|
|
|
|
|
1998-06-17 20:38:24 +04:00
|
|
|
PRInt32 colSpan = cell->GetColSpan();
|
|
|
|
PRInt32 rowSpan = cell->GetRowSpan();
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
// clear the cells for all for edges
|
|
|
|
for (edge = 0; edge < 4; edge++)
|
|
|
|
boundaryCells[edge]->Clear();
|
|
|
|
|
|
|
|
// Check to see if the cell data represents the top,left
|
|
|
|
// corner of a a table cell
|
|
|
|
|
1998-05-22 03:43:18 +04:00
|
|
|
// Check to see if cell the represents a top edge cell
|
1998-06-17 20:38:24 +04:00
|
|
|
if (0 == row)
|
1998-04-14 00:24:54 +04:00
|
|
|
above = nsnull;
|
|
|
|
else
|
|
|
|
{
|
1998-08-18 03:37:04 +04:00
|
|
|
cellData = cellMap->GetCellAt(row-1,col);
|
1998-06-17 20:38:24 +04:00
|
|
|
if (nsnull != cellData)
|
1999-07-28 12:09:02 +04:00
|
|
|
// XXX was above = cellData->mSpanData->mOrigCell;
|
|
|
|
above = (cellData->mOrigCell) ? cellData->mOrigCell : cellData->mSpanData->mOrigCell;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
// Does the cell data point to the same cell?
|
|
|
|
// If it is, then continue
|
1998-06-17 20:38:24 +04:00
|
|
|
if ((nsnull != above) && (above == cell))
|
1998-04-14 00:24:54 +04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
1998-05-22 03:43:18 +04:00
|
|
|
// Check to see if cell the represents a left edge cell
|
1998-06-17 20:38:24 +04:00
|
|
|
if (0 == col)
|
1998-04-26 06:59:29 +04:00
|
|
|
left = nsnull;
|
1998-04-14 00:24:54 +04:00
|
|
|
else
|
|
|
|
{
|
1998-08-18 03:37:04 +04:00
|
|
|
cellData = cellMap->GetCellAt(row,col-1);
|
1998-04-14 00:24:54 +04:00
|
|
|
if (cellData != nsnull)
|
1999-07-28 12:09:02 +04:00
|
|
|
// XXX was left = cellData->mSpanData->mOrigCell;
|
|
|
|
left = (cellData->mOrigCell) ? cellData->mOrigCell : cellData->mSpanData->mOrigCell;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-06-17 20:38:24 +04:00
|
|
|
if ((nsnull != left) && (left == cell))
|
1998-04-14 00:24:54 +04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If this is the top,left edged cell
|
|
|
|
// Then add the cells on the for edges to the array
|
|
|
|
|
|
|
|
// Do the top and bottom edge
|
|
|
|
PRInt32 r,c;
|
|
|
|
PRInt32 r1,r2;
|
|
|
|
PRInt32 c1,c2;
|
|
|
|
PRInt32 last;
|
|
|
|
|
|
|
|
|
|
|
|
r1 = row - 1;
|
|
|
|
r2 = row + rowSpan;
|
|
|
|
c = col;
|
|
|
|
last = col + colSpan -1;
|
1998-05-28 22:31:44 +04:00
|
|
|
last = PR_MIN(last,colCount-1);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
while (c <= last)
|
|
|
|
{
|
|
|
|
if (r1 != -1)
|
|
|
|
{
|
|
|
|
// Add top edge cells
|
|
|
|
if (c != col)
|
|
|
|
{
|
1998-08-18 03:37:04 +04:00
|
|
|
cellData = cellMap->GetCellAt(r1,c);
|
1999-07-28 12:09:02 +04:00
|
|
|
if ((cellData != nsnull) && (cellData->mOrigCell != above))
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-07-28 12:09:02 +04:00
|
|
|
above = cellData->mOrigCell;
|
1998-04-14 00:24:54 +04:00
|
|
|
if (above != nsnull)
|
|
|
|
AppendLayoutData(boundaryCells[NS_SIDE_TOP],above);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (above != nsnull)
|
|
|
|
{
|
|
|
|
AppendLayoutData(boundaryCells[NS_SIDE_TOP],above);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (r2 < rowCount)
|
|
|
|
{
|
|
|
|
// Add bottom edge cells
|
1998-08-18 03:37:04 +04:00
|
|
|
cellData = cellMap->GetCellAt(r2,c);
|
1999-07-28 12:09:02 +04:00
|
|
|
if ((cellData != nsnull) && cellData->mOrigCell != below)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-07-28 12:09:02 +04:00
|
|
|
below = cellData->mOrigCell;
|
1998-04-14 00:24:54 +04:00
|
|
|
if (below != nsnull)
|
|
|
|
AppendLayoutData(boundaryCells[NS_SIDE_BOTTOM],below);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
c++;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Do the left and right edge
|
|
|
|
c1 = col - 1;
|
|
|
|
c2 = col + colSpan;
|
|
|
|
r = row ;
|
|
|
|
last = row + rowSpan-1;
|
1998-05-28 22:31:44 +04:00
|
|
|
last = PR_MIN(last,rowCount-1);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
while (r <= last)
|
|
|
|
{
|
|
|
|
// Add left edge cells
|
|
|
|
if (c1 != -1)
|
|
|
|
{
|
|
|
|
if (r != row)
|
|
|
|
{
|
1998-08-18 03:37:04 +04:00
|
|
|
cellData = cellMap->GetCellAt(r,c1);
|
1999-07-28 12:09:02 +04:00
|
|
|
if ((cellData != nsnull) && (cellData->mOrigCell != left))
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-07-28 12:09:02 +04:00
|
|
|
left = cellData->mOrigCell;
|
1998-04-14 00:24:54 +04:00
|
|
|
if (left != nsnull)
|
|
|
|
AppendLayoutData(boundaryCells[NS_SIDE_LEFT],left);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (left != nsnull)
|
|
|
|
{
|
|
|
|
AppendLayoutData(boundaryCells[NS_SIDE_LEFT],left);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (c2 < colCount)
|
|
|
|
{
|
|
|
|
// Add right edge cells
|
1998-08-18 03:37:04 +04:00
|
|
|
cellData = cellMap->GetCellAt(r,c2);
|
1999-07-28 12:09:02 +04:00
|
|
|
if ((cellData != nsnull) && (cellData->mOrigCell != right))
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-07-28 12:09:02 +04:00
|
|
|
right = cellData->mOrigCell;
|
1998-04-14 00:24:54 +04:00
|
|
|
if (right != nsnull)
|
|
|
|
AppendLayoutData(boundaryCells[NS_SIDE_RIGHT],right);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
r++;
|
|
|
|
}
|
|
|
|
|
1998-07-11 04:00:31 +04:00
|
|
|
cell->RecalcLayoutData(this,boundaryCells);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (edge = 0; edge < 4; edge++)
|
|
|
|
delete boundaryCells[edge];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-12-03 21:01:35 +03:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Child frame enumeration
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-02-10 05:25:01 +03:00
|
|
|
nsTableFrame::FirstChild(nsIAtom* aListName, nsIFrame** aFirstChild) const
|
1998-12-03 21:01:35 +03:00
|
|
|
{
|
|
|
|
if (nsnull == aListName) {
|
1999-02-10 05:25:01 +03:00
|
|
|
*aFirstChild = mFrames.FirstChild();
|
1998-12-03 21:01:35 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-12-09 08:30:17 +03:00
|
|
|
else if (aListName == nsLayoutAtoms::colGroupList) {
|
1999-02-10 05:25:01 +03:00
|
|
|
*aFirstChild = mColGroups.FirstChild();
|
1998-12-03 21:01:35 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-02-10 05:25:01 +03:00
|
|
|
*aFirstChild = nsnull;
|
1998-12-03 21:01:35 +03:00
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-12-03 21:01:35 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableFrame::GetAdditionalChildListName(PRInt32 aIndex,
|
1999-02-10 05:25:01 +03:00
|
|
|
nsIAtom** aListName) const
|
1998-12-03 21:01:35 +03:00
|
|
|
{
|
1999-02-10 05:25:01 +03:00
|
|
|
NS_PRECONDITION(nsnull != aListName, "null OUT parameter pointer");
|
1998-12-03 21:01:35 +03:00
|
|
|
if (aIndex < 0) {
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
1999-02-10 05:25:01 +03:00
|
|
|
*aListName = nsnull;
|
1998-12-03 21:01:35 +03:00
|
|
|
switch (aIndex) {
|
|
|
|
case NS_TABLE_FRAME_COLGROUP_LIST_INDEX:
|
1999-02-10 05:25:01 +03:00
|
|
|
*aListName = nsLayoutAtoms::colGroupList;
|
|
|
|
NS_ADDREF(*aListName);
|
1998-12-03 21:01:35 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
/* SEC: TODO: adjust the rect for captions */
|
1998-04-17 05:41:24 +04:00
|
|
|
NS_METHOD nsTableFrame::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-21 09:38:18 +03:00
|
|
|
// table paint code is concerned primarily with borders and bg color
|
1999-03-26 03:39:35 +03:00
|
|
|
if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) {
|
1998-12-18 18:54:23 +03:00
|
|
|
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);
|
|
|
|
const nsStyleTable* tableStyle =
|
|
|
|
(const nsStyleTable*)mStyleContext->GetStyleData(eStyleStruct_Table);
|
|
|
|
|
|
|
|
nsRect rect(0, 0, mRect.width, mRect.height);
|
1999-06-08 01:10:25 +04:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
1998-12-18 18:54:23 +03:00
|
|
|
PRIntn skipSides = GetSkipSides();
|
|
|
|
if (NS_STYLE_BORDER_SEPARATE==tableStyle->mBorderCollapse)
|
|
|
|
{
|
|
|
|
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
|
1999-01-23 01:38:34 +03:00
|
|
|
aDirtyRect, rect, *spacing, mStyleContext, skipSides);
|
1998-12-18 18:54:23 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1998-12-31 02:23:45 +03:00
|
|
|
//printf("paint table frame\n");
|
1998-12-21 09:38:18 +03:00
|
|
|
nsCSSRendering::PaintBorderEdges(aPresContext, aRenderingContext, this,
|
1999-01-23 01:38:34 +03:00
|
|
|
aDirtyRect, rect, &mBorderEdges, mStyleContext, skipSides);
|
1998-12-18 18:54:23 +03:00
|
|
|
}
|
1998-12-18 01:59:40 +03:00
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
// for debug...
|
1999-03-26 03:39:35 +03:00
|
|
|
if ((NS_FRAME_PAINT_LAYER_DEBUG == aWhichLayer) && GetShowFrameBorders()) {
|
1998-12-23 18:47:43 +03:00
|
|
|
aRenderingContext.SetColor(NS_RGB(0,255,0));
|
1998-04-14 00:24:54 +04:00
|
|
|
aRenderingContext.DrawRect(0, 0, mRect.width, mRect.height);
|
|
|
|
}
|
|
|
|
|
1998-12-18 18:54:23 +03:00
|
|
|
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
|
1999-05-20 04:52:00 +04:00
|
|
|
return nsFrame::Paint(aPresContext,
|
|
|
|
aRenderingContext,
|
|
|
|
aDirtyRect,
|
|
|
|
aWhichLayer);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1999-05-20 04:52:00 +04:00
|
|
|
|
|
|
|
//null range means the whole thing
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableFrame::SetSelected(nsIDOMRange *aRange,PRBool aSelected, nsSpread aSpread)
|
|
|
|
{
|
|
|
|
//traverse through children unselect tables
|
1999-06-02 03:04:13 +04:00
|
|
|
if ((aSpread == eSpreadDown) && aSelected){
|
1999-05-20 04:52:00 +04:00
|
|
|
nsIFrame* kid;
|
|
|
|
nsresult rv = FirstChild(nsnull, &kid);
|
|
|
|
while (nsnull != kid) {
|
|
|
|
kid->SetSelected(nsnull,PR_FALSE,eSpreadDown);
|
|
|
|
|
|
|
|
kid->GetNextSibling(&kid);
|
|
|
|
}
|
|
|
|
}
|
1999-06-02 03:04:13 +04:00
|
|
|
return nsFrame::SetSelected(aRange,aSelected,eSpreadNone);
|
1999-05-20 04:52:00 +04:00
|
|
|
}
|
|
|
|
|
1999-06-02 03:04:13 +04:00
|
|
|
PRBool nsTableFrame::ParentDisablesSelection() const //override default behavior
|
|
|
|
{
|
|
|
|
PRBool returnval;
|
|
|
|
if (NS_FAILED(GetSelected(&returnval)))
|
|
|
|
return PR_FALSE;
|
|
|
|
if (returnval)
|
|
|
|
return PR_TRUE;
|
|
|
|
return nsFrame::ParentDisablesSelection();
|
|
|
|
}
|
1999-05-20 04:52:00 +04:00
|
|
|
|
1998-10-20 21:45:07 +04:00
|
|
|
PRIntn
|
|
|
|
nsTableFrame::GetSkipSides() const
|
|
|
|
{
|
|
|
|
PRIntn skip = 0;
|
1998-11-11 22:56:02 +03:00
|
|
|
// frame attribute was accounted for in nsHTMLTableElement::MapTableBorderInto
|
|
|
|
// account for pagination
|
1998-10-20 21:45:07 +04:00
|
|
|
if (nsnull != mPrevInFlow) {
|
|
|
|
skip |= 1 << NS_SIDE_TOP;
|
|
|
|
}
|
|
|
|
if (nsnull != mNextInFlow) {
|
|
|
|
skip |= 1 << NS_SIDE_BOTTOM;
|
|
|
|
}
|
|
|
|
return skip;
|
|
|
|
}
|
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
PRBool nsTableFrame::NeedsReflow(const nsHTMLReflowState& aReflowState, const nsSize& aMaxSize)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
PRBool result = PR_TRUE;
|
1998-10-14 20:32:45 +04:00
|
|
|
if (eReflowReason_Incremental != aReflowState.reason)
|
|
|
|
{ // incremental reflows always need to be reflowed (for now)
|
|
|
|
if (PR_TRUE==mIsInvariantWidth)
|
|
|
|
result = PR_FALSE;
|
|
|
|
// XXX TODO: other optimization cases...
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1998-12-03 21:01:35 +03:00
|
|
|
nsresult nsTableFrame::AdjustSiblingsAfterReflow(nsIPresContext& aPresContext,
|
1998-10-21 00:05:44 +04:00
|
|
|
InnerTableReflowState& aReflowState,
|
1998-07-07 01:39:23 +04:00
|
|
|
nsIFrame* aKidFrame,
|
|
|
|
nscoord aDeltaY)
|
|
|
|
{
|
|
|
|
nsIFrame* lastKidFrame = aKidFrame;
|
|
|
|
|
|
|
|
if (aDeltaY != 0) {
|
|
|
|
// Move the frames that follow aKidFrame by aDeltaY
|
|
|
|
nsIFrame* kidFrame;
|
|
|
|
|
1999-02-10 09:13:38 +03:00
|
|
|
aKidFrame->GetNextSibling(&kidFrame);
|
1998-07-07 01:39:23 +04:00
|
|
|
while (nsnull != kidFrame) {
|
1998-10-01 08:46:11 +04:00
|
|
|
nsPoint origin;
|
|
|
|
nsIHTMLReflow* htmlReflow;
|
1998-07-07 01:39:23 +04:00
|
|
|
|
|
|
|
// XXX We can't just slide the child if it has a next-in-flow
|
|
|
|
kidFrame->GetOrigin(origin);
|
|
|
|
origin.y += aDeltaY;
|
|
|
|
|
|
|
|
// XXX We need to send move notifications to the frame...
|
1998-10-01 08:46:11 +04:00
|
|
|
if (NS_OK == kidFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) {
|
1998-10-11 13:18:27 +04:00
|
|
|
htmlReflow->WillReflow(aPresContext);
|
1998-10-01 08:46:11 +04:00
|
|
|
}
|
1998-07-07 01:39:23 +04:00
|
|
|
kidFrame->MoveTo(origin.x, origin.y);
|
|
|
|
|
|
|
|
// Get the next frame
|
|
|
|
lastKidFrame = kidFrame;
|
1999-02-10 09:13:38 +03:00
|
|
|
kidFrame->GetNextSibling(&kidFrame);
|
1998-07-07 01:39:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
// Get the last frame
|
1999-01-16 01:52:05 +03:00
|
|
|
lastKidFrame = mFrames.LastChild();
|
1998-07-07 01:39:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Update our running y-offset to reflect the bottommost child
|
|
|
|
nsRect rect;
|
|
|
|
lastKidFrame->GetRect(rect);
|
1998-10-21 00:05:44 +04:00
|
|
|
aReflowState.y = rect.YMost();
|
1998-07-07 01:39:23 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-06-08 01:10:25 +04:00
|
|
|
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);
|
1999-07-28 12:09:02 +04:00
|
|
|
PRInt32 numCols = GetColCount();
|
1999-06-08 01:10:25 +04:00
|
|
|
while (nsnull != colGroupFrame) {
|
|
|
|
nscoord colGroupWidth = 0;
|
|
|
|
nsIFrame* colFrame = nsnull;
|
|
|
|
colGroupFrame->FirstChild(nsnull, &colFrame);
|
|
|
|
nsPoint colOrigin(0, 0);
|
|
|
|
while (nsnull != colFrame) {
|
1999-07-28 12:09:02 +04:00
|
|
|
NS_ASSERTION(colX < numCols, "invalid number of columns");
|
|
|
|
nscoord colWidth = mColumnWidths[colX];
|
|
|
|
if (numCols == 1) {
|
|
|
|
colWidth += cellSpacingX + cellSpacingX;
|
|
|
|
}
|
|
|
|
else if ((0 == colX) || (numCols - 1 == colX)) {
|
|
|
|
colWidth += cellSpacingX + halfCellSpacingX;
|
1999-06-08 01:10:25 +04:00
|
|
|
}
|
1999-07-28 12:09:02 +04:00
|
|
|
else if (GetNumCellsOriginatingIn(colX) > 0) {
|
|
|
|
colWidth += cellSpacingX;
|
1999-06-08 01:10:25 +04:00
|
|
|
}
|
1999-07-28 12:09:02 +04:00
|
|
|
|
1999-06-08 01:10:25 +04:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
// SEC: TODO need to worry about continuing frames prev/next in flow for splitting across pages.
|
|
|
|
|
|
|
|
/* overview:
|
|
|
|
if mFirstPassValid is false, this is our first time through since content was last changed
|
|
|
|
do pass 1
|
|
|
|
get min/max info for all cells in an infinite space
|
1998-11-16 09:46:00 +03:00
|
|
|
do column balancing
|
|
|
|
do pass 2
|
|
|
|
use column widths to size table and ResizeReflow rowgroups (and therefore rows and cells)
|
1998-04-14 00:24:54 +04:00
|
|
|
*/
|
|
|
|
|
1998-05-29 01:39:22 +04:00
|
|
|
/* Layout the entire inner table. */
|
1998-07-15 06:53:09 +04:00
|
|
|
NS_METHOD nsTableFrame::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
|
|
|
{
|
|
|
|
if (gsDebug==PR_TRUE)
|
|
|
|
{
|
|
|
|
printf("-----------------------------------------------------------------\n");
|
1998-08-08 01:53:27 +04:00
|
|
|
printf("nsTableFrame::Reflow: table %p reason %d given maxSize=%d,%d\n",
|
1999-01-06 02:31:18 +03:00
|
|
|
this, aReflowState.reason, aReflowState.availableWidth, aReflowState.availableHeight);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-07-07 01:39:23 +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-04-14 00:24:54 +04:00
|
|
|
|
1998-10-11 13:18:27 +04:00
|
|
|
nsresult rv = NS_OK;
|
1998-10-01 08:46:11 +04:00
|
|
|
|
1998-10-11 13:18:27 +04:00
|
|
|
if (eReflowReason_Incremental == aReflowState.reason) {
|
|
|
|
rv = IncrementalReflow(aPresContext, aDesiredSize, aReflowState, aStatus);
|
1998-06-23 09:43:27 +04:00
|
|
|
}
|
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
// NeedsReflow and IsFirstPassValid take into account reflow type = Initial_Reflow
|
1999-01-06 02:31:18 +03:00
|
|
|
if (PR_TRUE==NeedsReflow(aReflowState, nsSize(aReflowState.availableWidth, aReflowState.availableHeight)))
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-10-14 20:32:45 +04:00
|
|
|
PRBool needsRecalc=PR_FALSE;
|
1998-10-20 03:43:06 +04:00
|
|
|
if (PR_TRUE==gsDebug || PR_TRUE==gsDebugIR) printf("TIF Reflow: needs reflow\n");
|
1998-10-14 20:32:45 +04:00
|
|
|
if (eReflowReason_Initial!=aReflowState.reason && PR_FALSE==IsCellMapValid())
|
|
|
|
{
|
1998-10-20 03:43:06 +04:00
|
|
|
if (PR_TRUE==gsDebug || PR_TRUE==gsDebugIR) printf("TIF Reflow: cell map invalid, rebuilding...\n");
|
1998-10-14 20:32:45 +04:00
|
|
|
if (nsnull!=mCellMap)
|
|
|
|
delete mCellMap;
|
|
|
|
mCellMap = new nsCellMap(0,0);
|
|
|
|
ReBuildCellMap();
|
1998-11-06 05:38:17 +03:00
|
|
|
#ifdef NS_DEBUG
|
1998-10-22 02:29:00 +04:00
|
|
|
if (PR_TRUE==gsDebugIR)
|
|
|
|
{
|
1999-07-28 12:09:02 +04:00
|
|
|
if (mCellMap) mCellMap->Dump();
|
1998-10-22 02:29:00 +04:00
|
|
|
}
|
1998-11-06 05:38:17 +03:00
|
|
|
#endif
|
1998-10-14 20:32:45 +04:00
|
|
|
needsRecalc=PR_TRUE;
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
if (PR_FALSE==IsFirstPassValid())
|
1998-09-24 01:48:26 +04:00
|
|
|
{
|
1998-10-16 01:07:37 +04:00
|
|
|
if (PR_TRUE==gsDebug || PR_TRUE==gsDebugIR) printf("TIF Reflow: first pass is invalid, rebuilding...\n");
|
1998-10-30 10:57:44 +03:00
|
|
|
nsReflowReason reason = aReflowState.reason;
|
|
|
|
if (eReflowReason_Initial!=reason)
|
|
|
|
reason = eReflowReason_Resize;
|
1998-12-23 18:47:43 +03:00
|
|
|
ComputeVerticalCollapsingBorders(aPresContext, 0, -1);
|
1998-10-30 10:57:44 +03:00
|
|
|
rv = ResizeReflowPass1(aPresContext, aDesiredSize, aReflowState, aStatus, nsnull, reason, PR_TRUE);
|
1998-10-11 13:18:27 +04:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
1998-10-14 20:32:45 +04:00
|
|
|
needsRecalc=PR_TRUE;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1998-10-15 02:51:50 +04:00
|
|
|
if (PR_FALSE==IsColumnCacheValid())
|
1998-10-16 01:07:37 +04:00
|
|
|
{
|
|
|
|
if (PR_TRUE==gsDebug || PR_TRUE==gsDebugIR) printf("TIF Reflow: column cache is invalid, rebuilding...\n");
|
1998-10-15 02:51:50 +04:00
|
|
|
needsRecalc=PR_TRUE;
|
1998-10-16 01:07:37 +04:00
|
|
|
}
|
1998-10-14 20:32:45 +04:00
|
|
|
if (PR_TRUE==needsRecalc)
|
|
|
|
{
|
1998-10-20 03:43:06 +04:00
|
|
|
if (PR_TRUE==gsDebug || PR_TRUE==gsDebugIR) printf("TIF Reflow: needs recalc. Calling BuildColumnCache...\n");
|
|
|
|
BuildColumnCache(aPresContext, aDesiredSize, aReflowState, aStatus);
|
1998-12-21 21:54:23 +03:00
|
|
|
RecalcLayoutData(aPresContext); // Recalculate Layout Dependencies
|
1998-10-20 03:43:06 +04:00
|
|
|
// if we needed to rebuild the column cache, the data stored in the layout strategy is invalid
|
1998-10-14 20:32:45 +04:00
|
|
|
if (nsnull!=mTableLayoutStrategy)
|
|
|
|
{
|
1998-10-20 03:43:06 +04:00
|
|
|
if (PR_TRUE==gsDebug || PR_TRUE==gsDebugIR) printf("TIF Reflow: Re-init layout strategy\n");
|
1999-07-20 07:41:03 +04:00
|
|
|
mTableLayoutStrategy->Initialize(aDesiredSize.maxElementSize, GetColCount(), aReflowState.mComputedWidth);
|
1998-10-20 03:43:06 +04:00
|
|
|
mColumnWidthsValid=PR_TRUE; //so we don't do this a second time below
|
1998-10-14 20:32:45 +04:00
|
|
|
}
|
|
|
|
}
|
1998-10-16 01:07:37 +04:00
|
|
|
if (PR_FALSE==IsColumnWidthsValid())
|
|
|
|
{
|
1998-10-20 03:43:06 +04:00
|
|
|
if (PR_TRUE==gsDebug || PR_TRUE==gsDebugIR) printf("TIF Reflow: Re-init layout strategy\n");
|
1998-10-16 01:07:37 +04:00
|
|
|
if (nsnull!=mTableLayoutStrategy)
|
|
|
|
{
|
1999-07-20 07:41:03 +04:00
|
|
|
mTableLayoutStrategy->Initialize(aDesiredSize.maxElementSize, GetColCount(), aReflowState.mComputedWidth);
|
1998-10-16 01:07:37 +04:00
|
|
|
mColumnWidthsValid=PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-08-14 20:16:43 +04:00
|
|
|
if (nsnull==mPrevInFlow)
|
1998-10-14 20:32:45 +04:00
|
|
|
{ // only do this for a first-in-flow table frame
|
1998-08-14 20:16:43 +04:00
|
|
|
// assign column widths, and assign aMaxElementSize->width
|
1999-01-06 02:31:18 +03:00
|
|
|
BalanceColumnWidths(aPresContext, aReflowState, nsSize(aReflowState.availableWidth, aReflowState.availableHeight),
|
1998-08-14 20:16:43 +04:00
|
|
|
aDesiredSize.maxElementSize);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-08-14 20:16:43 +04:00
|
|
|
// assign table width
|
1998-10-11 13:18:27 +04:00
|
|
|
SetTableWidth(aPresContext);
|
1998-08-14 20:16:43 +04:00
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-03-09 18:35:08 +03:00
|
|
|
// Constrain our reflow width to the computed table width. Note: this is based
|
|
|
|
// on the width of the first-in-flow
|
1999-05-12 08:15:44 +04:00
|
|
|
nsHTMLReflowState reflowState(aReflowState);
|
|
|
|
PRInt32 pass1Width = mRect.width;
|
1999-03-09 18:35:08 +03:00
|
|
|
if (mPrevInFlow) {
|
|
|
|
nsTableFrame* table = (nsTableFrame*)GetFirstInFlow();
|
1999-05-12 08:15:44 +04:00
|
|
|
pass1Width = table->mRect.width;
|
1999-03-09 18:35:08 +03:00
|
|
|
}
|
1999-05-12 08:15:44 +04:00
|
|
|
reflowState.availableWidth = pass1Width;
|
1998-10-11 13:18:27 +04:00
|
|
|
rv = ResizeReflowPass2(aPresContext, aDesiredSize, reflowState, aStatus);
|
1999-05-12 08:15:44 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
aDesiredSize.width = PR_MIN(aDesiredSize.width, pass1Width);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// set aDesiredSize and aMaxElementSize
|
|
|
|
}
|
|
|
|
|
1998-10-23 01:59:13 +04:00
|
|
|
if (PR_TRUE==gsDebug || PR_TRUE==gsDebugNT)
|
1998-07-07 01:39:23 +04:00
|
|
|
{
|
|
|
|
if (nsnull!=aDesiredSize.maxElementSize)
|
|
|
|
printf("%p: Inner table reflow complete, returning aDesiredSize = %d,%d and aMaxElementSize=%d,%d\n",
|
|
|
|
this, aDesiredSize.width, aDesiredSize.height,
|
|
|
|
aDesiredSize.maxElementSize->width, aDesiredSize.maxElementSize->height);
|
|
|
|
else
|
|
|
|
printf("%p: Inner table reflow complete, returning aDesiredSize = %d,%d and NSNULL aMaxElementSize\n",
|
|
|
|
this, aDesiredSize.width, aDesiredSize.height);
|
|
|
|
}
|
|
|
|
|
1999-06-08 01:10:25 +04:00
|
|
|
SetColumnDimensions(aDesiredSize.height);
|
|
|
|
|
1999-07-14 19:21:52 +04:00
|
|
|
// If this is an incremental reflow, then we need to make sure that any
|
|
|
|
// damaged areas are repainted
|
|
|
|
if (eReflowReason_Incremental == aReflowState.reason) {
|
|
|
|
nsRect damageRect;
|
|
|
|
|
|
|
|
// XXX We need finer granularity than this...
|
|
|
|
damageRect.x = 0;
|
|
|
|
damageRect.y = 0;
|
|
|
|
damageRect.width = mRect.width;
|
|
|
|
damageRect.height = mRect.height;
|
|
|
|
Invalidate(damageRect);
|
|
|
|
}
|
|
|
|
|
1998-06-08 19:47:03 +04:00
|
|
|
if (PR_TRUE==gsDebug) printf("end reflow for table %p\n", this);
|
1998-10-11 13:18:27 +04:00
|
|
|
return rv;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/** the first of 2 reflow passes
|
|
|
|
* lay out the captions and row groups in an infinite space (NS_UNCONSTRAINEDSIZE)
|
|
|
|
* cache the results for each caption and cell.
|
|
|
|
* if successful, set mFirstPassValid=PR_TRUE, so we know we can skip this step
|
|
|
|
* next time. mFirstPassValid is set to PR_FALSE when content is changed.
|
|
|
|
* NOTE: should never get called on a continuing frame! All cached pass1 state
|
|
|
|
* is stored in the inner table first-in-flow.
|
|
|
|
*/
|
1998-10-15 11:46:16 +04:00
|
|
|
NS_METHOD nsTableFrame::ResizeReflowPass1(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus,
|
|
|
|
nsTableRowGroupFrame * aStartingFrame,
|
1998-10-20 03:43:06 +04:00
|
|
|
nsReflowReason aReason,
|
|
|
|
PRBool aDoSiblingFrames)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-05-30 00:36:05 +04:00
|
|
|
NS_PRECONDITION(aReflowState.frame == this, "bad reflow state");
|
1999-01-14 08:16:23 +03:00
|
|
|
NS_PRECONDITION(aReflowState.parentReflowState->frame == mParent,
|
1998-05-30 00:36:05 +04:00
|
|
|
"bad parent reflow state");
|
1998-04-14 00:24:54 +04:00
|
|
|
NS_ASSERTION(nsnull==mPrevInFlow, "illegal call, cannot call pass 1 on a continuing frame.");
|
1998-06-17 20:38:24 +04:00
|
|
|
NS_ASSERTION(nsnull != mContent, "null content");
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-06-24 03:23:21 +04:00
|
|
|
if (PR_TRUE==gsDebugNT) printf("%p nsTableFrame::ResizeReflow Pass1: maxSize=%d,%d\n",
|
1999-01-06 02:31:18 +03:00
|
|
|
this, aReflowState.availableWidth, aReflowState.availableHeight);
|
1998-10-11 13:18:27 +04:00
|
|
|
nsresult rv=NS_OK;
|
|
|
|
// set out params
|
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
nsSize availSize(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE); // availSize is the space available at any given time in the process
|
|
|
|
nsSize maxSize(0, 0); // maxSize is the size of the largest child so far in the process
|
|
|
|
nsSize kidMaxSize(0,0);
|
1998-10-01 08:46:11 +04:00
|
|
|
nsHTMLReflowMetrics kidSize(&kidMaxSize);
|
1998-04-14 00:24:54 +04:00
|
|
|
nscoord y = 0;
|
|
|
|
|
|
|
|
// Compute the insets (sum of border and padding)
|
1998-12-23 18:47:43 +03:00
|
|
|
// XXX: since this is pass1 reflow and where we place the rowgroup frames is irrelevant, insets are probably a waste
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-10-21 00:05:44 +04:00
|
|
|
if (PR_TRUE==RequiresPass1Layout())
|
1998-09-23 03:36:06 +04:00
|
|
|
{
|
1998-10-15 11:46:16 +04:00
|
|
|
nsIFrame* kidFrame = aStartingFrame;
|
|
|
|
if (nsnull==kidFrame)
|
1999-01-16 01:52:05 +03:00
|
|
|
kidFrame=mFrames.FirstChild();
|
1999-02-10 09:13:38 +03:00
|
|
|
for ( ; nsnull != kidFrame; kidFrame->GetNextSibling(&kidFrame))
|
1998-09-24 20:37:22 +04:00
|
|
|
{
|
|
|
|
const nsStyleDisplay *childDisplay;
|
1998-12-02 19:45:20 +03:00
|
|
|
kidFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)childDisplay));
|
1998-09-24 20:37:22 +04:00
|
|
|
if ((NS_STYLE_DISPLAY_TABLE_HEADER_GROUP != childDisplay->mDisplay) &&
|
|
|
|
(NS_STYLE_DISPLAY_TABLE_FOOTER_GROUP != childDisplay->mDisplay) &&
|
1998-12-03 21:01:35 +03:00
|
|
|
(NS_STYLE_DISPLAY_TABLE_ROW_GROUP != childDisplay->mDisplay) )
|
1998-10-23 21:24:57 +04:00
|
|
|
{ // it's an unknown frame type, give it a generic reflow and ignore the results
|
1999-03-05 07:19:09 +03:00
|
|
|
nsHTMLReflowState kidReflowState(aPresContext, aReflowState, kidFrame,
|
1998-10-23 21:24:57 +04:00
|
|
|
availSize, aReason);
|
|
|
|
if (PR_TRUE==gsDebugIR) printf("\nTIF IR: Reflow Pass 1 of unknown frame %p of type %d with reason=%d\n",
|
|
|
|
kidFrame, childDisplay->mDisplay, aReason);
|
1998-10-30 10:57:44 +03:00
|
|
|
// rv intentionally not set here
|
1998-10-23 21:24:57 +04:00
|
|
|
ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState, aStatus);
|
1998-09-24 20:37:22 +04:00
|
|
|
continue;
|
|
|
|
}
|
1999-03-05 07:19:09 +03:00
|
|
|
nsHTMLReflowState kidReflowState(aPresContext, aReflowState, kidFrame,
|
1998-10-15 11:46:16 +04:00
|
|
|
availSize, aReason);
|
1998-12-14 04:24:11 +03:00
|
|
|
// Note: we don't bother checking here for whether we should clear the
|
|
|
|
// isTopOfPage reflow state flag, because we're dealing with an unconstrained
|
|
|
|
// height and it isn't an issue...
|
1998-10-20 03:43:06 +04:00
|
|
|
if (PR_TRUE==gsDebugIR) printf("\nTIF IR: Reflow Pass 1 of frame %p with reason=%d\n", kidFrame, aReason);
|
1998-10-11 13:18:27 +04:00
|
|
|
ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState, aStatus);
|
1998-10-01 08:46:11 +04:00
|
|
|
|
1998-10-06 04:27:22 +04:00
|
|
|
// Place the child since some of its content fit in us.
|
|
|
|
if (PR_TRUE==gsDebugNT) {
|
|
|
|
printf ("%p: reflow of row group returned desired=%d,%d, max-element=%d,%d\n",
|
|
|
|
this, kidSize.width, kidSize.height, kidMaxSize.width, kidMaxSize.height);
|
|
|
|
}
|
1998-12-23 18:47:43 +03:00
|
|
|
kidFrame->SetRect(nsRect(0, 0, kidSize.width, kidSize.height));
|
1998-10-06 04:27:22 +04:00
|
|
|
if (NS_UNCONSTRAINEDSIZE==kidSize.height)
|
|
|
|
y = NS_UNCONSTRAINEDSIZE;
|
|
|
|
else
|
|
|
|
y += kidSize.height;
|
|
|
|
if (kidMaxSize.width > maxSize.width) {
|
|
|
|
maxSize.width = kidMaxSize.width;
|
|
|
|
}
|
|
|
|
if (kidMaxSize.height > maxSize.height) {
|
|
|
|
maxSize.height = kidMaxSize.height;
|
|
|
|
}
|
1998-09-16 21:19:20 +04:00
|
|
|
|
1998-10-11 13:18:27 +04:00
|
|
|
if (NS_FRAME_IS_NOT_COMPLETE(aStatus)) {
|
1998-10-06 04:27:22 +04:00
|
|
|
// If the child didn't finish layout then it means that it used
|
|
|
|
// up all of our available space (or needs us to split).
|
|
|
|
break;
|
1998-09-23 03:36:06 +04:00
|
|
|
}
|
1998-10-20 03:43:06 +04:00
|
|
|
if (PR_FALSE==aDoSiblingFrames)
|
|
|
|
break;
|
1998-09-16 21:19:20 +04:00
|
|
|
}
|
1998-12-03 21:01:35 +03:00
|
|
|
|
|
|
|
// if required, give the colgroups their initial reflows
|
|
|
|
if (PR_TRUE==aDoSiblingFrames)
|
|
|
|
{
|
1999-01-16 01:52:05 +03:00
|
|
|
kidFrame=mColGroups.FirstChild();
|
1999-02-10 09:13:38 +03:00
|
|
|
for ( ; nsnull != kidFrame; kidFrame->GetNextSibling(&kidFrame))
|
1998-12-03 21:01:35 +03:00
|
|
|
{
|
1999-03-05 07:19:09 +03:00
|
|
|
nsHTMLReflowState kidReflowState(aPresContext, aReflowState, kidFrame,
|
1998-12-03 21:01:35 +03:00
|
|
|
availSize, aReason);
|
|
|
|
if (PR_TRUE==gsDebugIR) printf("\nTIF IR: Reflow Pass 1 of colgroup frame %p with reason=%d\n", kidFrame, aReason);
|
|
|
|
ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState, aStatus);
|
|
|
|
kidFrame->SetRect(nsRect(0, 0, 0, 0));
|
|
|
|
}
|
|
|
|
}
|
1998-09-16 21:19:20 +04:00
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-06-24 03:23:21 +04:00
|
|
|
aDesiredSize.width = kidSize.width;
|
1998-04-14 00:24:54 +04:00
|
|
|
mFirstPassValid = PR_TRUE;
|
|
|
|
|
1998-10-11 13:18:27 +04:00
|
|
|
return rv;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1999-03-09 08:29:37 +03:00
|
|
|
|
|
|
|
nsIFrame*
|
|
|
|
nsTableFrame::GetFirstBodyRowGroupFrame()
|
|
|
|
{
|
|
|
|
nsIFrame* headerFrame = nsnull;
|
|
|
|
nsIFrame* footerFrame = nsnull;
|
|
|
|
|
|
|
|
for (nsIFrame* kidFrame = mFrames.FirstChild(); nsnull != kidFrame; ) {
|
|
|
|
const nsStyleDisplay *childDisplay;
|
|
|
|
kidFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)childDisplay));
|
|
|
|
|
|
|
|
// We expect the header and footer row group frames to be first, and we only
|
|
|
|
// allow one header and one footer
|
|
|
|
if (NS_STYLE_DISPLAY_TABLE_HEADER_GROUP == childDisplay->mDisplay) {
|
|
|
|
if (headerFrame) {
|
|
|
|
// We already have a header frame and so this header frame is treated
|
|
|
|
// like an ordinary body row group frame
|
|
|
|
return kidFrame;
|
|
|
|
}
|
|
|
|
headerFrame = kidFrame;
|
|
|
|
|
|
|
|
} else if (NS_STYLE_DISPLAY_TABLE_FOOTER_GROUP == childDisplay->mDisplay) {
|
|
|
|
if (footerFrame) {
|
|
|
|
// We already have a footer frame and so this footer frame is treated
|
|
|
|
// like an ordinary body row group frame
|
|
|
|
return kidFrame;
|
|
|
|
}
|
|
|
|
footerFrame = kidFrame;
|
|
|
|
|
|
|
|
} else if (NS_STYLE_DISPLAY_TABLE_ROW_GROUP == childDisplay->mDisplay) {
|
|
|
|
return kidFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get the next child
|
|
|
|
kidFrame->GetNextSibling(&kidFrame);
|
|
|
|
}
|
|
|
|
|
|
|
|
return nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Table specific version that takes into account repeated header and footer
|
|
|
|
// frames when continuing table frames
|
|
|
|
void
|
|
|
|
nsTableFrame::PushChildren(nsIFrame* aFromChild, nsIFrame* aPrevSibling)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aFromChild, "null pointer");
|
|
|
|
NS_PRECONDITION(nsnull != aPrevSibling, "pushing first child");
|
|
|
|
#ifdef NS_DEBUG
|
|
|
|
nsIFrame* prevNextSibling;
|
|
|
|
aPrevSibling->GetNextSibling(&prevNextSibling);
|
|
|
|
NS_PRECONDITION(prevNextSibling == aFromChild, "bad prev sibling");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Disconnect aFromChild from its previous sibling
|
|
|
|
aPrevSibling->SetNextSibling(nsnull);
|
|
|
|
|
|
|
|
if (nsnull != mNextInFlow) {
|
|
|
|
nsTableFrame* nextInFlow = (nsTableFrame*)mNextInFlow;
|
|
|
|
|
|
|
|
// Insert the frames after any repeated header and footer frames
|
|
|
|
nsIFrame* firstBodyFrame = nextInFlow->GetFirstBodyRowGroupFrame();
|
|
|
|
nsIFrame* prevSibling = nsnull;
|
|
|
|
if (firstBodyFrame) {
|
|
|
|
prevSibling = nextInFlow->mFrames.GetPrevSiblingFor(firstBodyFrame);
|
|
|
|
}
|
1999-04-13 06:38:09 +04:00
|
|
|
// When pushing and pulling frames we need to check for whether any
|
|
|
|
// views need to be reparented.
|
|
|
|
for (nsIFrame* f = aFromChild; f; f->GetNextSibling(&f)) {
|
|
|
|
nsHTMLContainerFrame::ReparentFrameView(f, this, nextInFlow);
|
|
|
|
}
|
1999-03-09 08:29:37 +03:00
|
|
|
nextInFlow->mFrames.InsertFrames(mNextInFlow, prevSibling, aFromChild);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Add the frames to our overflow list
|
|
|
|
NS_ASSERTION(mOverflowFrames.IsEmpty(), "bad overflow list");
|
|
|
|
mOverflowFrames.SetFrames(aFromChild);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Table specific version that takes into account header and footer row group
|
|
|
|
// frames that are repeated for continuing table frames
|
|
|
|
//
|
|
|
|
// Appends the overflow frames to the end of the child list, just like the
|
|
|
|
// nsContainerFrame version does, except that there are no assertions that
|
|
|
|
// the child list is empty (it may not be empty, because there may be repeated
|
|
|
|
// header/footer frames)
|
|
|
|
PRBool
|
|
|
|
nsTableFrame::MoveOverflowToChildList()
|
|
|
|
{
|
|
|
|
PRBool result = PR_FALSE;
|
|
|
|
|
|
|
|
// Check for an overflow list with our prev-in-flow
|
|
|
|
nsTableFrame* prevInFlow = (nsTableFrame*)mPrevInFlow;
|
|
|
|
if (nsnull != prevInFlow) {
|
|
|
|
if (prevInFlow->mOverflowFrames.NotEmpty()) {
|
1999-04-13 06:38:09 +04:00
|
|
|
// When pushing and pulling frames we need to check for whether any
|
|
|
|
// views need to be reparented.
|
|
|
|
for (nsIFrame* f = prevInFlow->mOverflowFrames.FirstChild(); f; f->GetNextSibling(&f)) {
|
|
|
|
nsHTMLContainerFrame::ReparentFrameView(f, prevInFlow, this);
|
|
|
|
}
|
|
|
|
mFrames.InsertFrames(this, nsnull, prevInFlow->mOverflowFrames);
|
1999-03-09 08:29:37 +03:00
|
|
|
result = PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// It's also possible that we have an overflow list for ourselves
|
|
|
|
if (mOverflowFrames.NotEmpty()) {
|
1999-04-13 04:06:17 +04:00
|
|
|
mFrames.AppendFrames(nsnull, mOverflowFrames);
|
1999-03-09 08:29:37 +03:00
|
|
|
result = PR_TRUE;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
/** the second of 2 reflow passes
|
|
|
|
*/
|
1998-10-11 13:18:27 +04:00
|
|
|
NS_METHOD nsTableFrame::ResizeReflowPass2(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-05-30 00:36:05 +04:00
|
|
|
NS_PRECONDITION(aReflowState.frame == this, "bad reflow state");
|
1999-01-14 08:16:23 +03:00
|
|
|
NS_PRECONDITION(aReflowState.parentReflowState->frame == mParent,
|
1998-05-30 00:36:05 +04:00
|
|
|
"bad parent reflow state");
|
1998-06-24 03:23:21 +04:00
|
|
|
if (PR_TRUE==gsDebugNT)
|
|
|
|
printf("%p nsTableFrame::ResizeReflow Pass2: 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
|
|
|
|
1998-10-11 13:18:27 +04:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
// set out param
|
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-07-07 01:39:23 +04:00
|
|
|
const nsStyleSpacing* mySpacing = (const nsStyleSpacing*)
|
|
|
|
mStyleContext->GetStyleData(eStyleStruct_Spacing);
|
1998-12-23 18:47:43 +03:00
|
|
|
nsMargin borderPadding;
|
|
|
|
GetTableBorder (borderPadding); // this gets the max border thickness at each edge
|
|
|
|
nsMargin padding;
|
|
|
|
mySpacing->GetPadding(padding);
|
|
|
|
borderPadding += padding;
|
1998-07-07 01:39:23 +04:00
|
|
|
|
1998-12-23 18:47:43 +03:00
|
|
|
InnerTableReflowState state(aPresContext, aReflowState, borderPadding);
|
1998-07-07 01:39:23 +04:00
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
// now that we've computed the column width information, reflow all children
|
|
|
|
|
|
|
|
#ifdef NS_DEBUG
|
1998-04-23 21:29:07 +04:00
|
|
|
//PreReflowCheck();
|
1998-04-14 00:24:54 +04:00
|
|
|
#endif
|
|
|
|
|
1999-03-03 19:33:57 +03:00
|
|
|
// Check for an overflow list, and append any row group frames being
|
|
|
|
// pushed
|
1999-03-09 08:29:37 +03:00
|
|
|
MoveOverflowToChildList();
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
// Reflow the existing frames
|
1999-01-16 01:52:05 +03:00
|
|
|
if (mFrames.NotEmpty()) {
|
1998-10-21 00:05:44 +04:00
|
|
|
rv = ReflowMappedChildren(aPresContext, aDesiredSize, state, aStatus);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-04-15 01:45:28 +04:00
|
|
|
// Did we successfully reflow our mapped children?
|
1998-10-21 00:05:44 +04:00
|
|
|
if (NS_FRAME_COMPLETE == aStatus) {
|
1998-04-14 00:24:54 +04:00
|
|
|
// Any space left?
|
1998-08-30 00:20:38 +04:00
|
|
|
PRInt32 numKids;
|
|
|
|
mContent->ChildCount(numKids);
|
1998-09-24 07:36:52 +04:00
|
|
|
if (state.availSize.height > 0) {
|
1998-04-14 00:24:54 +04:00
|
|
|
// Try and pull-up some children from a next-in-flow
|
1998-10-21 00:05:44 +04:00
|
|
|
rv = PullUpChildren(aPresContext, aDesiredSize, state, aStatus);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return our size and our status
|
1998-09-01 01:23:28 +04:00
|
|
|
aDesiredSize.width = ComputeDesiredWidth(aReflowState);
|
1998-12-23 18:47:43 +03:00
|
|
|
nscoord defaultHeight = state.y + borderPadding.top + borderPadding.bottom;
|
1998-11-20 04:01:25 +03:00
|
|
|
aDesiredSize.height = ComputeDesiredHeight(aPresContext, aReflowState, defaultHeight);
|
1999-02-11 09:22:33 +03:00
|
|
|
|
|
|
|
AdjustForCollapsingRows(aPresContext, aDesiredSize.height);
|
|
|
|
AdjustForCollapsingCols(aPresContext, aDesiredSize.width);
|
|
|
|
|
1998-12-30 09:48:15 +03:00
|
|
|
// once horizontal borders are computed and all row heights are set,
|
|
|
|
// we need to fix up length of vertical edges
|
|
|
|
// XXX need to figure start row and end row correctly
|
|
|
|
if (NS_STYLE_BORDER_COLLAPSE==GetBorderCollapseStyle())
|
|
|
|
DidComputeHorizontalCollapsingBorders(aPresContext, 0, 10000);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
#ifdef NS_DEBUG
|
1998-10-11 13:18:27 +04:00
|
|
|
//PostReflowCheck(aStatus);
|
1998-04-14 00:24:54 +04:00
|
|
|
#endif
|
|
|
|
|
1998-10-11 13:18:27 +04:00
|
|
|
return rv;
|
|
|
|
|
|
|
|
}
|
1998-10-14 20:32:45 +04:00
|
|
|
|
1999-02-11 09:22:33 +03:00
|
|
|
// collapsing row groups, rows, col groups and cols are accounted for after both passes of
|
|
|
|
// reflow so that it has no effect on the calculations of reflow.
|
1999-06-14 12:01:00 +04:00
|
|
|
NS_METHOD nsTableFrame::AdjustForCollapsingRowGroup(nsIFrame* aRowGroupFrame,
|
|
|
|
PRInt32& aRowX)
|
|
|
|
{
|
1999-07-28 12:09:02 +04:00
|
|
|
nsCellMap* cellMap = GetCellMap(); // XXX is this right
|
1999-06-14 12:01:00 +04:00
|
|
|
const nsStyleDisplay* groupDisplay;
|
|
|
|
aRowGroupFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)groupDisplay));
|
|
|
|
PRBool groupIsCollapsed = (NS_STYLE_VISIBILITY_COLLAPSE == groupDisplay->mVisible);
|
|
|
|
|
|
|
|
nsTableRowFrame* rowFrame = nsnull;
|
|
|
|
aRowGroupFrame->FirstChild(nsnull, (nsIFrame**)&rowFrame);
|
|
|
|
while (nsnull != rowFrame) {
|
|
|
|
const nsStyleDisplay *rowDisplay;
|
|
|
|
rowFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)rowDisplay));
|
|
|
|
if (NS_STYLE_DISPLAY_TABLE_ROW == rowDisplay->mDisplay) {
|
|
|
|
if (groupIsCollapsed || (NS_STYLE_VISIBILITY_COLLAPSE == rowDisplay->mVisible)) {
|
1999-07-28 12:09:02 +04:00
|
|
|
cellMap->SetRowCollapsedAt(aRowX, PR_TRUE);
|
1999-06-14 12:01:00 +04:00
|
|
|
}
|
|
|
|
aRowX++;
|
|
|
|
}
|
|
|
|
else if (NS_STYLE_DISPLAY_TABLE_ROW_GROUP == rowDisplay->mDisplay) {
|
|
|
|
AdjustForCollapsingRowGroup(rowFrame, aRowX);
|
|
|
|
}
|
|
|
|
|
|
|
|
rowFrame->GetNextSibling((nsIFrame**)&rowFrame);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_METHOD nsTableFrame::CollapseRowGroup(nsIFrame* aRowGroupFrame,
|
|
|
|
const nscoord& aYTotalOffset,
|
|
|
|
nscoord& aYGroupOffset, PRInt32& aRowX)
|
|
|
|
{
|
|
|
|
const nsStyleDisplay* groupDisplay;
|
|
|
|
aRowGroupFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)groupDisplay));
|
|
|
|
|
|
|
|
PRBool collapseGroup = (NS_STYLE_VISIBILITY_COLLAPSE == groupDisplay->mVisible);
|
|
|
|
nsIFrame* rowFrame;
|
|
|
|
aRowGroupFrame->FirstChild(nsnull, &rowFrame);
|
|
|
|
|
|
|
|
while (nsnull != rowFrame) {
|
|
|
|
const nsStyleDisplay* rowDisplay;
|
|
|
|
rowFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)rowDisplay));
|
|
|
|
if (NS_STYLE_DISPLAY_TABLE_ROW_GROUP == rowDisplay->mDisplay) {
|
|
|
|
CollapseRowGroup(rowFrame, aYTotalOffset, aYGroupOffset, aRowX);
|
|
|
|
}
|
|
|
|
else if (NS_STYLE_DISPLAY_TABLE_ROW == rowDisplay->mDisplay) {
|
|
|
|
nsRect rowRect;
|
|
|
|
rowFrame->GetRect(rowRect);
|
|
|
|
if (collapseGroup || (NS_STYLE_VISIBILITY_COLLAPSE == rowDisplay->mVisible)) {
|
|
|
|
aYGroupOffset += rowRect.height;
|
|
|
|
rowRect.height = 0;
|
|
|
|
rowFrame->SetRect(rowRect);
|
|
|
|
nsIFrame* cellFrame;
|
|
|
|
rowFrame->FirstChild(nsnull, &cellFrame);
|
|
|
|
while (nsnull != cellFrame) {
|
|
|
|
const nsStyleDisplay* cellDisplay;
|
|
|
|
cellFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)cellDisplay));
|
|
|
|
if (NS_STYLE_DISPLAY_TABLE_CELL == cellDisplay->mDisplay) {
|
|
|
|
nsTableCellFrame* cFrame = (nsTableCellFrame*)cellFrame;
|
|
|
|
nsRect cRect;
|
|
|
|
cFrame->GetRect(cRect);
|
|
|
|
cRect.height -= rowRect.height;
|
|
|
|
cFrame->SetCollapseOffsetY(-aYGroupOffset);
|
|
|
|
cFrame->SetRect(cRect);
|
|
|
|
}
|
|
|
|
cellFrame->GetNextSibling(&cellFrame);
|
|
|
|
}
|
|
|
|
// check if a cell above spans into here
|
|
|
|
//if (!collapseGroup) {
|
|
|
|
PRInt32 numCols = mCellMap->GetColCount();
|
|
|
|
nsTableCellFrame* lastCell = nsnull;
|
|
|
|
for (int colX = 0; colX < numCols; colX++) {
|
|
|
|
CellData* cellData = mCellMap->GetCellAt(aRowX, colX);
|
1999-07-28 12:09:02 +04:00
|
|
|
if (cellData && !cellData->mOrigCell) { // a cell above is spanning into here
|
1999-06-14 12:01:00 +04:00
|
|
|
// adjust the real cell's rect only once
|
1999-07-28 12:09:02 +04:00
|
|
|
nsTableCellFrame* realCell = cellData->mSpanData->mOrigCell;
|
1999-06-14 12:01:00 +04:00
|
|
|
if (realCell != lastCell) {
|
|
|
|
nsRect realRect;
|
|
|
|
realCell->GetRect(realRect);
|
|
|
|
realRect.height -= rowRect.height;
|
|
|
|
realCell->SetRect(realRect);
|
|
|
|
}
|
|
|
|
lastCell = realCell;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//}
|
|
|
|
} else { // row is not collapsed but needs to be adjusted by those that are
|
|
|
|
rowRect.y -= aYGroupOffset;
|
|
|
|
rowFrame->SetRect(rowRect);
|
|
|
|
}
|
|
|
|
aRowX++;
|
|
|
|
}
|
|
|
|
rowFrame->GetNextSibling(&rowFrame);
|
|
|
|
} // end row frame while
|
|
|
|
|
|
|
|
nsRect groupRect;
|
|
|
|
aRowGroupFrame->GetRect(groupRect);
|
|
|
|
groupRect.height -= aYGroupOffset;
|
|
|
|
groupRect.y -= aYTotalOffset;
|
|
|
|
aRowGroupFrame->SetRect(groupRect);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-02-11 09:22:33 +03:00
|
|
|
NS_METHOD nsTableFrame::AdjustForCollapsingRows(nsIPresContext& aPresContext,
|
|
|
|
nscoord& aHeight)
|
|
|
|
{
|
|
|
|
// determine which row groups and rows are collapsed
|
1999-06-14 12:01:00 +04:00
|
|
|
PRInt32 rowX = 0;
|
1999-02-11 09:22:33 +03:00
|
|
|
nsIFrame* childFrame;
|
|
|
|
FirstChild(nsnull, &childFrame);
|
|
|
|
while (nsnull != childFrame) {
|
|
|
|
const nsStyleDisplay* groupDisplay;
|
|
|
|
childFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)groupDisplay));
|
|
|
|
if (IsRowGroup(groupDisplay->mDisplay)) {
|
1999-06-14 12:01:00 +04:00
|
|
|
AdjustForCollapsingRowGroup(childFrame, rowX);
|
1999-02-11 09:22:33 +03:00
|
|
|
}
|
|
|
|
childFrame->GetNextSibling(&childFrame);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mCellMap->GetNumCollapsedRows() <= 0) {
|
|
|
|
return NS_OK; // no collapsed rows, we're done
|
|
|
|
}
|
|
|
|
|
|
|
|
// collapse the rows and/or row groups
|
|
|
|
nsIFrame* groupFrame = mFrames.FirstChild();
|
|
|
|
nscoord yGroupOffset = 0; // total offset among rows within a single row group
|
|
|
|
nscoord yTotalOffset = 0; // total offset among all rows in all row groups
|
1999-06-14 12:01:00 +04:00
|
|
|
rowX = 0;
|
|
|
|
|
1999-02-11 09:22:33 +03:00
|
|
|
while (nsnull != groupFrame) {
|
|
|
|
const nsStyleDisplay* groupDisplay;
|
|
|
|
groupFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)groupDisplay));
|
1999-06-14 12:01:00 +04:00
|
|
|
if (IsRowGroup(groupDisplay->mDisplay)) {
|
|
|
|
CollapseRowGroup(groupFrame, yTotalOffset, yGroupOffset, rowX);
|
1999-02-11 09:22:33 +03:00
|
|
|
}
|
|
|
|
yTotalOffset += yGroupOffset;
|
|
|
|
yGroupOffset = 0;
|
|
|
|
groupFrame->GetNextSibling(&groupFrame);
|
|
|
|
} // end group frame while
|
|
|
|
|
|
|
|
aHeight -= yTotalOffset;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_METHOD nsTableFrame::AdjustForCollapsingCols(nsIPresContext& aPresContext,
|
|
|
|
nscoord& aWidth)
|
|
|
|
{
|
|
|
|
// determine which col groups and cols are collapsed
|
|
|
|
nsIFrame* childFrame = mColGroups.FirstChild();
|
1999-04-22 07:51:58 +04:00
|
|
|
PRInt32 colX = 0;
|
1999-02-11 09:22:33 +03:00
|
|
|
while (nsnull != childFrame) {
|
|
|
|
const nsStyleDisplay* groupDisplay;
|
|
|
|
GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)groupDisplay));
|
|
|
|
PRBool groupIsCollapsed = (NS_STYLE_VISIBILITY_COLLAPSE == groupDisplay->mVisible);
|
|
|
|
|
|
|
|
nsTableColFrame* colFrame = nsnull;
|
|
|
|
childFrame->FirstChild(nsnull, (nsIFrame**)&colFrame);
|
|
|
|
while (nsnull != colFrame) {
|
|
|
|
const nsStyleDisplay *colDisplay;
|
|
|
|
colFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)colDisplay));
|
|
|
|
if (NS_STYLE_DISPLAY_TABLE_COLUMN == colDisplay->mDisplay) {
|
|
|
|
if (groupIsCollapsed || (NS_STYLE_VISIBILITY_COLLAPSE == colDisplay->mVisible)) {
|
|
|
|
mCellMap->SetColCollapsedAt(colX, PR_TRUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
colFrame->GetNextSibling((nsIFrame**)&colFrame);
|
|
|
|
colX++;
|
|
|
|
}
|
|
|
|
childFrame->GetNextSibling(&childFrame);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mCellMap->GetNumCollapsedCols() <= 0) {
|
|
|
|
return NS_OK; // no collapsed cols, we're done
|
|
|
|
}
|
|
|
|
|
1999-04-22 07:51:58 +04:00
|
|
|
PRInt32 numCols = colX;
|
|
|
|
|
1999-02-11 09:22:33 +03:00
|
|
|
// collapse the cols and/or col groups
|
|
|
|
PRInt32 numRows = mCellMap->GetRowCount();
|
1999-05-04 23:15:56 +04:00
|
|
|
nsTableIterator groupIter(mColGroups, eTableDIR);
|
1999-04-22 07:51:58 +04:00
|
|
|
nsIFrame* groupFrame = groupIter.First();
|
1999-02-11 09:22:33 +03:00
|
|
|
nscoord cellSpacingX = GetCellSpacingX();
|
|
|
|
nscoord xOffset = 0;
|
1999-04-22 07:51:58 +04:00
|
|
|
colX = (groupIter.IsLeftToRight()) ? 0 : numCols - 1;
|
|
|
|
PRInt32 direction = (groupIter.IsLeftToRight()) ? 1 : -1;
|
1999-02-11 09:22:33 +03:00
|
|
|
while (nsnull != groupFrame) {
|
|
|
|
const nsStyleDisplay* groupDisplay;
|
|
|
|
groupFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)groupDisplay));
|
|
|
|
PRBool collapseGroup = (NS_STYLE_VISIBILITY_COLLAPSE == groupDisplay->mVisible);
|
1999-05-04 23:15:56 +04:00
|
|
|
nsTableIterator colIter(*groupFrame, eTableDIR);
|
1999-04-22 07:51:58 +04:00
|
|
|
nsIFrame* colFrame = colIter.First();
|
1999-02-11 09:22:33 +03:00
|
|
|
while (nsnull != colFrame) {
|
|
|
|
const nsStyleDisplay* colDisplay;
|
|
|
|
colFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)colDisplay));
|
|
|
|
if (NS_STYLE_DISPLAY_TABLE_COLUMN == colDisplay->mDisplay) {
|
|
|
|
PRBool collapseCol = (NS_STYLE_VISIBILITY_COLLAPSE == colDisplay->mVisible);
|
|
|
|
PRInt32 colSpan = ((nsTableColFrame*)colFrame)->GetSpan();
|
|
|
|
for (PRInt32 spanX = 0; spanX < colSpan; spanX++) {
|
1999-04-22 07:51:58 +04:00
|
|
|
PRInt32 col2X = colX + (direction * spanX);
|
|
|
|
PRInt32 colWidth = GetColumnWidth(col2X);
|
1999-02-11 09:22:33 +03:00
|
|
|
if (collapseGroup || collapseCol) {
|
|
|
|
xOffset += colWidth + cellSpacingX;
|
|
|
|
}
|
|
|
|
nsTableCellFrame* lastCell = nsnull;
|
|
|
|
nsTableCellFrame* cellFrame = nsnull;
|
|
|
|
for (PRInt32 rowX = 0; rowX < numRows; rowX++) {
|
1999-04-22 07:51:58 +04:00
|
|
|
CellData* cellData = mCellMap->GetCellAt(rowX, col2X);
|
1999-02-11 09:22:33 +03:00
|
|
|
nsRect cellRect;
|
|
|
|
if (cellData) {
|
1999-07-28 12:09:02 +04:00
|
|
|
cellFrame = cellData->mOrigCell;
|
1999-02-11 09:22:33 +03:00
|
|
|
if (cellFrame) { // the cell originates at (rowX, colX)
|
|
|
|
cellFrame->GetRect(cellRect);
|
|
|
|
if (collapseGroup || collapseCol) {
|
|
|
|
if (lastCell != cellFrame) { // do it only once if there is a row span
|
|
|
|
cellRect.width -= colWidth;
|
|
|
|
cellFrame->SetCollapseOffsetX(-xOffset);
|
|
|
|
}
|
|
|
|
} else { // the cell is not in a collapsed col but needs to move
|
|
|
|
cellRect.x -= xOffset;
|
|
|
|
}
|
|
|
|
cellFrame->SetRect(cellRect);
|
|
|
|
// if the cell does not originate at (rowX, colX), adjust the real cells width
|
|
|
|
} else if (collapseGroup || collapseCol) {
|
1999-07-28 12:09:02 +04:00
|
|
|
cellFrame = cellData->mSpanData->mOrigCell;
|
1999-02-11 09:22:33 +03:00
|
|
|
if ((cellFrame) && (lastCell != cellFrame)) {
|
|
|
|
cellFrame->GetRect(cellRect);
|
|
|
|
cellRect.width -= colWidth + cellSpacingX;
|
|
|
|
cellFrame->SetRect(cellRect);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
lastCell = cellFrame;
|
|
|
|
}
|
|
|
|
}
|
1999-04-22 07:51:58 +04:00
|
|
|
colX += direction * colSpan;
|
1999-02-11 09:22:33 +03:00
|
|
|
}
|
1999-04-22 07:51:58 +04:00
|
|
|
colFrame = colIter.Next();
|
1999-02-11 09:22:33 +03:00
|
|
|
} // inner while
|
1999-04-22 07:51:58 +04:00
|
|
|
groupFrame = groupIter.Next();
|
1999-02-11 09:22:33 +03:00
|
|
|
} // outer while
|
|
|
|
|
|
|
|
aWidth -= xOffset;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-06-15 05:19:18 +04:00
|
|
|
NS_METHOD nsTableFrame::GetBorderPlusMarginPadding(nsMargin& aResult)
|
|
|
|
{
|
|
|
|
const nsStyleSpacing* mySpacing = (const nsStyleSpacing*)
|
|
|
|
mStyleContext->GetStyleData(eStyleStruct_Spacing);
|
|
|
|
nsMargin borderPadding;
|
|
|
|
GetTableBorder (borderPadding);
|
|
|
|
nsMargin padding;
|
|
|
|
mySpacing->GetPadding(padding);
|
|
|
|
borderPadding += padding;
|
|
|
|
aResult = borderPadding;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-10-11 13:18:27 +04:00
|
|
|
NS_METHOD nsTableFrame::IncrementalReflow(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
|
|
|
if (PR_TRUE==gsDebugIR) printf("\nTIF IR: IncrementalReflow\n");
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
1998-12-23 18:47:43 +03:00
|
|
|
nsMargin borderPadding;
|
1999-06-15 05:19:18 +04:00
|
|
|
GetBorderPlusMarginPadding(borderPadding);
|
1998-12-23 18:47:43 +03:00
|
|
|
InnerTableReflowState state(aPresContext, aReflowState, borderPadding);
|
1998-10-11 13:18:27 +04:00
|
|
|
|
|
|
|
// 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))
|
|
|
|
{
|
1998-10-14 20:32:45 +04:00
|
|
|
// this is the target if target is either this or the outer table frame containing this inner frame
|
|
|
|
nsIFrame *outerTableFrame=nsnull;
|
1999-02-10 04:36:30 +03:00
|
|
|
GetParent(&outerTableFrame);
|
1998-10-14 20:32:45 +04:00
|
|
|
if ((this==target) || (outerTableFrame==target))
|
1998-10-11 13:18:27 +04:00
|
|
|
rv = IR_TargetIsMe(aPresContext, aDesiredSize, state, aStatus);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Get the next frame in the reflow chain
|
|
|
|
nsIFrame* nextFrame;
|
|
|
|
aReflowState.reflowCommand->GetNext(nextFrame);
|
|
|
|
|
|
|
|
// Recover our reflow state
|
|
|
|
//RecoverState(state, nextFrame);
|
|
|
|
rv = IR_TargetIsChild(aPresContext, aDesiredSize, state, aStatus, nextFrame);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_METHOD nsTableFrame::IR_TargetIsMe(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
InnerTableReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
1998-10-16 01:07:37 +04:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
1998-10-11 13:18:27 +04:00
|
|
|
nsIReflowCommand::ReflowType type;
|
|
|
|
aReflowState.reflowState.reflowCommand->GetType(type);
|
|
|
|
nsIFrame *objectFrame;
|
|
|
|
aReflowState.reflowState.reflowCommand->GetChildFrame(objectFrame);
|
1998-10-30 10:57:44 +03:00
|
|
|
const nsStyleDisplay *childDisplay=nsnull;
|
|
|
|
if (nsnull!=objectFrame)
|
1998-12-02 19:45:20 +03:00
|
|
|
objectFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)childDisplay));
|
1998-10-11 13:18:27 +04:00
|
|
|
if (PR_TRUE==gsDebugIR) printf("TIF IR: IncrementalReflow_TargetIsMe with type=%d\n", type);
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case nsIReflowCommand::FrameInserted :
|
1998-10-30 10:57:44 +03:00
|
|
|
NS_ASSERTION(nsnull!=objectFrame, "bad objectFrame");
|
|
|
|
NS_ASSERTION(nsnull!=childDisplay, "bad childDisplay");
|
1998-10-11 13:18:27 +04:00
|
|
|
if (NS_STYLE_DISPLAY_TABLE_COLUMN_GROUP == childDisplay->mDisplay)
|
|
|
|
{
|
|
|
|
rv = IR_ColGroupInserted(aPresContext, aDesiredSize, aReflowState, aStatus,
|
1998-10-15 02:51:50 +04:00
|
|
|
(nsTableColGroupFrame*)objectFrame, PR_FALSE);
|
1998-10-11 13:18:27 +04:00
|
|
|
}
|
|
|
|
else if (IsRowGroup(childDisplay->mDisplay))
|
|
|
|
{
|
|
|
|
rv = IR_RowGroupInserted(aPresContext, aDesiredSize, aReflowState, aStatus,
|
1999-01-18 02:35:56 +03:00
|
|
|
GetRowGroupFrameFor(objectFrame, childDisplay), PR_FALSE);
|
1998-10-11 13:18:27 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1998-10-20 21:45:07 +04:00
|
|
|
rv = AddFrame(aReflowState.reflowState, objectFrame);
|
1998-10-11 13:18:27 +04:00
|
|
|
}
|
|
|
|
break;
|
1998-10-14 20:32:45 +04:00
|
|
|
|
|
|
|
case nsIReflowCommand::FrameAppended :
|
1999-06-23 07:02:21 +04:00
|
|
|
if (!objectFrame)
|
|
|
|
break;
|
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
if (NS_STYLE_DISPLAY_TABLE_COLUMN_GROUP == childDisplay->mDisplay)
|
|
|
|
{
|
1998-10-15 02:51:50 +04:00
|
|
|
rv = IR_ColGroupAppended(aPresContext, aDesiredSize, aReflowState, aStatus,
|
|
|
|
(nsTableColGroupFrame*)objectFrame);
|
1998-10-14 20:32:45 +04:00
|
|
|
}
|
|
|
|
else if (IsRowGroup(childDisplay->mDisplay))
|
|
|
|
{
|
1998-10-15 02:51:50 +04:00
|
|
|
rv = IR_RowGroupAppended(aPresContext, aDesiredSize, aReflowState, aStatus,
|
1999-01-18 02:35:56 +03:00
|
|
|
GetRowGroupFrameFor(objectFrame, childDisplay));
|
1998-10-14 20:32:45 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // no optimization to be done for Unknown frame types, so just reuse the Inserted method
|
1998-10-20 21:45:07 +04:00
|
|
|
rv = AddFrame(aReflowState.reflowState, objectFrame);
|
1998-10-14 20:32:45 +04:00
|
|
|
}
|
|
|
|
break;
|
1998-10-11 13:18:27 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
case nsIReflowCommand::FrameReplaced :
|
1998-10-30 10:57:44 +03:00
|
|
|
NS_ASSERTION(nsnull!=objectFrame, "bad objectFrame");
|
|
|
|
NS_ASSERTION(nsnull!=childDisplay, "bad childDisplay");
|
1998-10-11 13:18:27 +04:00
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
case nsIReflowCommand::FrameRemoved :
|
1999-07-10 05:10:40 +04:00
|
|
|
if (!objectFrame)
|
|
|
|
break;
|
|
|
|
|
1998-10-30 10:57:44 +03:00
|
|
|
NS_ASSERTION(nsnull!=childDisplay, "bad childDisplay");
|
1998-10-11 13:18:27 +04:00
|
|
|
if (NS_STYLE_DISPLAY_TABLE_COLUMN_GROUP == childDisplay->mDisplay)
|
|
|
|
{
|
|
|
|
rv = IR_ColGroupRemoved(aPresContext, aDesiredSize, aReflowState, aStatus,
|
1998-10-15 02:51:50 +04:00
|
|
|
(nsTableColGroupFrame*)objectFrame);
|
1998-10-11 13:18:27 +04:00
|
|
|
}
|
|
|
|
else if (IsRowGroup(childDisplay->mDisplay))
|
|
|
|
{
|
|
|
|
rv = IR_RowGroupRemoved(aPresContext, aDesiredSize, aReflowState, aStatus,
|
1999-01-18 02:35:56 +03:00
|
|
|
GetRowGroupFrameFor(objectFrame, childDisplay));
|
1998-10-11 13:18:27 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1999-07-22 08:00:57 +04:00
|
|
|
rv = mFrames.DestroyFrame(aPresContext, objectFrame);
|
1998-10-11 13:18:27 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case nsIReflowCommand::StyleChanged :
|
1998-10-30 10:57:44 +03:00
|
|
|
rv = IR_StyleChanged(aPresContext, aDesiredSize, aReflowState, aStatus);
|
1998-10-11 13:18:27 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case nsIReflowCommand::ContentChanged :
|
|
|
|
NS_ASSERTION(PR_FALSE, "illegal reflow type: ContentChanged");
|
|
|
|
rv = NS_ERROR_ILLEGAL_VALUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case nsIReflowCommand::PullupReflow:
|
|
|
|
case nsIReflowCommand::PushReflow:
|
|
|
|
case nsIReflowCommand::CheckPullupReflow :
|
|
|
|
case nsIReflowCommand::UserDefined :
|
1999-03-05 07:19:09 +03:00
|
|
|
default:
|
1998-10-11 13:18:27 +04:00
|
|
|
NS_NOTYETIMPLEMENTED("unimplemented reflow command type");
|
|
|
|
rv = NS_ERROR_NOT_IMPLEMENTED;
|
1998-10-16 01:07:37 +04:00
|
|
|
if (PR_TRUE==gsDebugIR) printf("TIF IR: reflow command not implemented.\n");
|
1998-10-11 13:18:27 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_METHOD nsTableFrame::IR_ColGroupInserted(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
InnerTableReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus,
|
1998-10-15 02:51:50 +04:00
|
|
|
nsTableColGroupFrame * aInsertedFrame,
|
1998-10-11 13:18:27 +04:00
|
|
|
PRBool aReplace)
|
|
|
|
{
|
1998-10-23 07:23:29 +04:00
|
|
|
if (PR_TRUE==gsDebugIR) printf("TIF IR: IR_ColGroupInserted for frame %p\n", aInsertedFrame);
|
1998-10-15 02:51:50 +04:00
|
|
|
nsresult rv=NS_OK;
|
|
|
|
PRBool adjustStartingColIndex=PR_FALSE;
|
|
|
|
PRInt32 startingColIndex=0;
|
|
|
|
// find out what frame to insert aInsertedFrame after
|
|
|
|
nsIFrame *frameToInsertAfter=nsnull;
|
|
|
|
rv = aReflowState.reflowState.reflowCommand->GetPrevSiblingFrame(frameToInsertAfter);
|
|
|
|
// insert aInsertedFrame as the first child. Set its start col index to 0
|
|
|
|
if (nsnull==frameToInsertAfter)
|
|
|
|
{
|
1999-01-16 01:52:05 +03:00
|
|
|
mColGroups.InsertFrame(nsnull, nsnull, aInsertedFrame);
|
1998-10-15 02:51:50 +04:00
|
|
|
startingColIndex += aInsertedFrame->SetStartColumnIndex(0);
|
|
|
|
adjustStartingColIndex=PR_TRUE;
|
|
|
|
}
|
1999-01-16 01:52:05 +03:00
|
|
|
nsIFrame *childFrame=mColGroups.FirstChild();
|
1998-10-15 02:51:50 +04:00
|
|
|
nsIFrame *prevSib=nsnull;
|
|
|
|
while ((NS_SUCCEEDED(rv)) && (nsnull!=childFrame))
|
|
|
|
{
|
|
|
|
if ((nsnull!=frameToInsertAfter) && (childFrame==frameToInsertAfter))
|
|
|
|
{
|
|
|
|
nsIFrame *nextSib=nsnull;
|
1999-02-10 09:13:38 +03:00
|
|
|
frameToInsertAfter->GetNextSibling(&nextSib);
|
1998-10-15 02:51:50 +04:00
|
|
|
aInsertedFrame->SetNextSibling(nextSib);
|
|
|
|
frameToInsertAfter->SetNextSibling(aInsertedFrame);
|
|
|
|
// account for childFrame being a COLGROUP now
|
1998-12-03 21:01:35 +03:00
|
|
|
if (PR_FALSE==adjustStartingColIndex) // we haven't gotten to aDeletedFrame yet
|
|
|
|
startingColIndex += ((nsTableColGroupFrame *)childFrame)->GetColumnCount();
|
1998-10-15 02:51:50 +04:00
|
|
|
// skip ahead to aInsertedFrame, since we just handled the frame we inserted after
|
|
|
|
childFrame=aInsertedFrame;
|
|
|
|
adjustStartingColIndex=PR_TRUE; // now that we've inserted aInsertedFrame,
|
|
|
|
// start adjusting subsequent col groups' starting col index including aInsertedFrame
|
|
|
|
}
|
1998-12-03 21:01:35 +03:00
|
|
|
if (PR_FALSE==adjustStartingColIndex) // we haven't gotten to aDeletedFrame yet
|
|
|
|
startingColIndex += ((nsTableColGroupFrame *)childFrame)->GetColumnCount();
|
|
|
|
else // we've removed aDeletedFrame, now adjust the starting col index of all subsequent col groups
|
|
|
|
startingColIndex += ((nsTableColGroupFrame *)childFrame)->SetStartColumnIndex(startingColIndex);
|
1998-10-15 02:51:50 +04:00
|
|
|
prevSib=childFrame;
|
1999-02-10 09:13:38 +03:00
|
|
|
rv = childFrame->GetNextSibling(&childFrame);
|
1998-10-15 02:51:50 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
InvalidateColumnCache();
|
|
|
|
//XXX: what we want to do here is determine if the new COL information changes anything about layout
|
|
|
|
// if not, skip invalidating the first passs
|
|
|
|
// if so, and we can fix the first pass info
|
1998-10-11 13:18:27 +04:00
|
|
|
return rv;
|
1998-10-15 02:51:50 +04:00
|
|
|
|
1998-10-11 13:18:27 +04:00
|
|
|
}
|
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
NS_METHOD nsTableFrame::IR_ColGroupAppended(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
InnerTableReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus,
|
1998-10-15 02:51:50 +04:00
|
|
|
nsTableColGroupFrame * aAppendedFrame)
|
1998-10-14 20:32:45 +04:00
|
|
|
{
|
1998-10-23 07:23:29 +04:00
|
|
|
if (PR_TRUE==gsDebugIR) printf("TIF IR: IR_ColGroupAppended for frame %p\n", aAppendedFrame);
|
1998-10-14 20:32:45 +04:00
|
|
|
nsresult rv=NS_OK;
|
1998-10-15 02:51:50 +04:00
|
|
|
PRInt32 startingColIndex=0;
|
1999-01-16 01:52:05 +03:00
|
|
|
nsIFrame *childFrame=mColGroups.FirstChild();
|
|
|
|
nsIFrame *lastChild=childFrame;
|
1998-10-14 20:32:45 +04:00
|
|
|
while ((NS_SUCCEEDED(rv)) && (nsnull!=childFrame))
|
|
|
|
{
|
1998-12-03 21:01:35 +03:00
|
|
|
startingColIndex += ((nsTableColGroupFrame *)childFrame)->GetColumnCount();
|
1998-10-14 20:32:45 +04:00
|
|
|
lastChild=childFrame;
|
1999-02-10 09:13:38 +03:00
|
|
|
rv = childFrame->GetNextSibling(&childFrame);
|
1998-10-14 20:32:45 +04:00
|
|
|
}
|
1999-01-16 01:52:05 +03:00
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
// append aAppendedFrame
|
|
|
|
if (nsnull!=lastChild)
|
|
|
|
lastChild->SetNextSibling(aAppendedFrame);
|
|
|
|
else
|
1999-01-16 01:52:05 +03:00
|
|
|
mColGroups.SetFrames(aAppendedFrame);
|
1998-10-14 20:32:45 +04:00
|
|
|
|
1998-10-15 02:51:50 +04:00
|
|
|
aAppendedFrame->SetStartColumnIndex(startingColIndex);
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
|
|
|
we would only want to do this if manufactured col groups were invisible to the DOM. Since they
|
|
|
|
currently are visible, they should behave just as if they were content-backed "real" colgroups
|
|
|
|
If this decision is changed, the code below is a half-finished attempt to rationalize the situation.
|
|
|
|
It requires having built a list of the colGroups before we get to this point.
|
|
|
|
|
|
|
|
// look at the last col group. If it is implicit, and it's cols are implicit, then
|
|
|
|
// it and its cols were manufactured for table layout.
|
|
|
|
// Delete it if possible, otherwise move it to the end of the list
|
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
if (0<colGroupCount)
|
|
|
|
{
|
1998-10-15 02:51:50 +04:00
|
|
|
nsTableColGroupFrame *colGroup = (nsTableColGroupFrame *)(colGroupList.ElementAt(colGroupCount-1));
|
|
|
|
if (PR_TRUE==colGroup->IsManufactured())
|
|
|
|
{ // account for the new COLs that were added in aAppendedFrame
|
|
|
|
// first, try to delete the implicit colgroup
|
|
|
|
|
|
|
|
// if we couldn't delete it, move the implicit colgroup to the end of the list
|
|
|
|
// and adjust it's col indexes
|
|
|
|
nsIFrame *colGroupNextSib;
|
|
|
|
colGroup->GetNextSibling(colGroupNextSib);
|
1999-01-16 01:52:05 +03:00
|
|
|
childFrame=mColGroups.FirstChild();
|
1998-10-15 02:51:50 +04:00
|
|
|
nsIFrame * prevSib=nsnull;
|
|
|
|
rv = NS_OK;
|
|
|
|
while ((NS_SUCCEEDED(rv)) && (nsnull!=childFrame))
|
|
|
|
{
|
|
|
|
if (childFrame==colGroup)
|
1998-10-14 20:32:45 +04:00
|
|
|
{
|
1998-10-15 02:51:50 +04:00
|
|
|
if (nsnull!=prevSib) // colGroup is in the middle of the list, remove it
|
|
|
|
prevSib->SetNextSibling(colGroupNextSib);
|
|
|
|
else // colGroup was the first child, so set it's next sib to first child
|
1999-01-16 01:52:05 +03:00
|
|
|
mColGroups.SetFrames(colGroupNextSib);
|
1998-10-15 02:51:50 +04:00
|
|
|
aAppendedFrame->SetNextSibling(colGroup); // place colGroup at the end of the list
|
|
|
|
colGroup->SetNextSibling(nsnull);
|
|
|
|
break;
|
1998-10-14 20:32:45 +04:00
|
|
|
}
|
1998-10-15 02:51:50 +04:00
|
|
|
prevSib=childFrame;
|
|
|
|
rv = childFrame->GetNextSibling(childFrame);
|
1998-10-14 20:32:45 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1998-10-15 02:51:50 +04:00
|
|
|
#endif
|
1998-10-14 20:32:45 +04:00
|
|
|
|
1998-10-15 02:51:50 +04:00
|
|
|
|
|
|
|
InvalidateColumnCache();
|
1998-10-14 20:32:45 +04:00
|
|
|
//XXX: what we want to do here is determine if the new COL information changes anything about layout
|
|
|
|
// if not, skip invalidating the first passs
|
|
|
|
// if so, and we can fix the first pass info
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-10-11 13:18:27 +04:00
|
|
|
NS_METHOD nsTableFrame::IR_ColGroupRemoved(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
InnerTableReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus,
|
1998-10-15 02:51:50 +04:00
|
|
|
nsTableColGroupFrame * aDeletedFrame)
|
1998-10-11 13:18:27 +04:00
|
|
|
{
|
1998-10-23 07:23:29 +04:00
|
|
|
if (PR_TRUE==gsDebugIR) printf("TIF IR: IR_ColGroupRemoved for frame %p\n", aDeletedFrame);
|
1998-10-15 02:51:50 +04:00
|
|
|
nsresult rv=NS_OK;
|
|
|
|
PRBool adjustStartingColIndex=PR_FALSE;
|
|
|
|
PRInt32 startingColIndex=0;
|
1999-01-16 01:52:05 +03:00
|
|
|
nsIFrame *childFrame=mColGroups.FirstChild();
|
1998-10-15 02:51:50 +04:00
|
|
|
nsIFrame *prevSib=nsnull;
|
|
|
|
while ((NS_SUCCEEDED(rv)) && (nsnull!=childFrame))
|
|
|
|
{
|
|
|
|
if (childFrame==aDeletedFrame)
|
|
|
|
{
|
|
|
|
nsIFrame *deleteFrameNextSib=nsnull;
|
1999-02-10 09:13:38 +03:00
|
|
|
aDeletedFrame->GetNextSibling(&deleteFrameNextSib);
|
1998-10-15 02:51:50 +04:00
|
|
|
if (nsnull!=prevSib)
|
|
|
|
prevSib->SetNextSibling(deleteFrameNextSib);
|
|
|
|
else
|
1999-01-16 01:52:05 +03:00
|
|
|
mColGroups.SetFrames(deleteFrameNextSib);
|
1998-10-15 02:51:50 +04:00
|
|
|
childFrame=deleteFrameNextSib;
|
|
|
|
if (nsnull==childFrame)
|
|
|
|
break;
|
|
|
|
adjustStartingColIndex=PR_TRUE; // now that we've removed aDeletedFrame, start adjusting subsequent col groups' starting col index
|
|
|
|
}
|
|
|
|
const nsStyleDisplay *display;
|
1998-12-02 19:45:20 +03:00
|
|
|
childFrame->GetStyleData(eStyleStruct_Display, (const nsStyleStruct *&)display);
|
1998-10-15 02:51:50 +04:00
|
|
|
if (NS_STYLE_DISPLAY_TABLE_COLUMN_GROUP == display->mDisplay)
|
|
|
|
{
|
|
|
|
if (PR_FALSE==adjustStartingColIndex) // we haven't gotten to aDeletedFrame yet
|
|
|
|
startingColIndex += ((nsTableColGroupFrame *)childFrame)->GetColumnCount();
|
|
|
|
else // we've removed aDeletedFrame, now adjust the starting col index of all subsequent col groups
|
|
|
|
startingColIndex += ((nsTableColGroupFrame *)childFrame)->SetStartColumnIndex(startingColIndex);
|
|
|
|
}
|
|
|
|
prevSib=childFrame;
|
1999-02-10 09:13:38 +03:00
|
|
|
rv = childFrame->GetNextSibling(&childFrame);
|
1998-10-15 02:51:50 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
InvalidateColumnCache();
|
|
|
|
//XXX: what we want to do here is determine if the new COL information changes anything about layout
|
|
|
|
// if not, skip invalidating the first passs
|
|
|
|
// if so, and we can fix the first pass info
|
1998-10-11 13:18:27 +04:00
|
|
|
return rv;
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-10-30 10:57:44 +03:00
|
|
|
NS_METHOD nsTableFrame::IR_StyleChanged(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
InnerTableReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
|
|
|
if (PR_TRUE==gsDebugIR) printf("TIF 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
|
|
|
|
// if something like border changes, we need to do pass1 again
|
1998-10-31 02:08:34 +03:00
|
|
|
// but if something like width changes from 100 to 200, we just need to do pass2
|
1998-10-30 10:57:44 +03:00
|
|
|
InvalidateFirstPassCache();
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1998-10-11 13:18:27 +04:00
|
|
|
NS_METHOD nsTableFrame::IR_RowGroupInserted(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
InnerTableReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus,
|
1998-10-15 02:51:50 +04:00
|
|
|
nsTableRowGroupFrame * aInsertedFrame,
|
1998-10-11 13:18:27 +04:00
|
|
|
PRBool aReplace)
|
|
|
|
{
|
1998-10-23 07:23:29 +04:00
|
|
|
if (PR_TRUE==gsDebugIR) printf("TIF IR: IR_RowGroupInserted for frame %p\n", aInsertedFrame);
|
1998-10-20 21:45:07 +04:00
|
|
|
nsresult rv = AddFrame(aReflowState.reflowState, aInsertedFrame);
|
1998-10-20 03:43:06 +04:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
// do a pass-1 layout of all the cells in all the rows of the rowgroup
|
|
|
|
rv = ResizeReflowPass1(aPresContext, aDesiredSize, aReflowState.reflowState, aStatus,
|
|
|
|
aInsertedFrame, eReflowReason_Initial, PR_FALSE);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
InvalidateCellMap();
|
|
|
|
InvalidateColumnCache();
|
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
// since we know we're doing an append here, we can optimize
|
|
|
|
NS_METHOD nsTableFrame::IR_RowGroupAppended(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
InnerTableReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus,
|
1998-10-15 02:51:50 +04:00
|
|
|
nsTableRowGroupFrame * aAppendedFrame)
|
1998-10-14 20:32:45 +04:00
|
|
|
{
|
1998-10-23 07:23:29 +04:00
|
|
|
if (PR_TRUE==gsDebugIR) printf("TIF IR: IR_RowGroupAppended for frame %p\n", aAppendedFrame);
|
1998-10-14 20:32:45 +04:00
|
|
|
// hook aAppendedFrame into the child list
|
1998-10-20 21:45:07 +04:00
|
|
|
nsresult rv = AddFrame(aReflowState.reflowState, aAppendedFrame);
|
1998-10-15 11:46:16 +04:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
1998-10-14 20:32:45 +04:00
|
|
|
|
|
|
|
// account for the cells in the rows that are children of aAppendedFrame
|
1998-10-16 01:07:37 +04:00
|
|
|
// this will add the content of the rowgroup to the cell map
|
1999-01-18 02:35:56 +03:00
|
|
|
rv = DidAppendRowGroup(aAppendedFrame);
|
1998-10-20 03:43:06 +04:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
1998-10-14 20:32:45 +04:00
|
|
|
|
|
|
|
// do a pass-1 layout of all the cells in all the rows of the rowgroup
|
1998-10-15 11:46:16 +04:00
|
|
|
rv = ResizeReflowPass1(aPresContext, aDesiredSize, aReflowState.reflowState, aStatus,
|
1998-10-20 03:43:06 +04:00
|
|
|
aAppendedFrame, eReflowReason_Initial, PR_TRUE);
|
1998-10-15 11:46:16 +04:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
1998-10-14 20:32:45 +04:00
|
|
|
|
1998-10-23 07:23:29 +04:00
|
|
|
// if we've added any columns, we need to rebuild the column cache
|
|
|
|
// XXX: it would be nice to have a mechanism to just extend the column cache, rather than rebuild it completely
|
|
|
|
InvalidateColumnCache();
|
1998-10-22 09:27:11 +04:00
|
|
|
|
1998-10-15 11:46:16 +04:00
|
|
|
// if any column widths have to change due to this, rebalance column widths
|
1998-10-16 01:07:37 +04:00
|
|
|
//XXX need to calculate this, but for now just do it
|
|
|
|
InvalidateColumnWidths();
|
1998-10-14 20:32:45 +04:00
|
|
|
|
1998-10-11 13:18:27 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_METHOD nsTableFrame::IR_RowGroupRemoved(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
InnerTableReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus,
|
1998-10-15 02:51:50 +04:00
|
|
|
nsTableRowGroupFrame * aDeletedFrame)
|
1998-10-11 13:18:27 +04:00
|
|
|
{
|
1998-10-23 07:23:29 +04:00
|
|
|
if (PR_TRUE==gsDebugIR) printf("TIF IR: IR_RowGroupRemoved for frame %p\n", aDeletedFrame);
|
1999-07-22 08:00:57 +04:00
|
|
|
nsresult rv = mFrames.DestroyFrame(aPresContext, aDeletedFrame);
|
1998-10-20 03:43:06 +04:00
|
|
|
InvalidateCellMap();
|
|
|
|
InvalidateColumnCache();
|
1998-10-16 01:07:37 +04:00
|
|
|
|
|
|
|
// if any column widths have to change due to this, rebalance column widths
|
|
|
|
//XXX need to calculate this, but for now just do it
|
|
|
|
InvalidateColumnWidths();
|
|
|
|
|
1998-10-11 13:18:27 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_METHOD nsTableFrame::IR_TargetIsChild(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
InnerTableReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus,
|
|
|
|
nsIFrame * aNextFrame)
|
|
|
|
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
if (PR_TRUE==gsDebugIR) printf("\nTIF IR: IR_TargetIsChild\n");
|
|
|
|
|
|
|
|
// Remember the old rect
|
|
|
|
nsRect oldKidRect;
|
|
|
|
aNextFrame->GetRect(oldKidRect);
|
|
|
|
|
|
|
|
// Pass along the reflow command
|
|
|
|
nsHTMLReflowMetrics desiredSize(nsnull);
|
|
|
|
// XXX Correctly compute the available space...
|
1999-01-06 02:31:18 +03:00
|
|
|
nsSize availSpace(aReflowState.reflowState.availableWidth, aReflowState.reflowState.availableHeight);
|
1999-03-05 07:19:09 +03:00
|
|
|
nsHTMLReflowState kidReflowState(aPresContext, aReflowState.reflowState,
|
|
|
|
aNextFrame, availSpace);
|
1998-10-11 13:18:27 +04:00
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
rv = ReflowChild(aNextFrame, aPresContext, desiredSize, kidReflowState, aStatus);
|
1998-10-11 13:18:27 +04:00
|
|
|
|
|
|
|
// Resize the row group frame
|
|
|
|
nsRect kidRect;
|
|
|
|
aNextFrame->GetRect(kidRect);
|
|
|
|
aNextFrame->SizeTo(desiredSize.width, desiredSize.height);
|
|
|
|
|
|
|
|
#if 1
|
|
|
|
// XXX For the time being just fall through and treat it like a
|
|
|
|
// pass 2 reflow...
|
|
|
|
// calling intialize here resets all the cached info based on new table content
|
1998-10-16 01:07:37 +04:00
|
|
|
InvalidateColumnWidths();
|
1998-10-11 13:18:27 +04:00
|
|
|
#else
|
|
|
|
// XXX Hack...
|
|
|
|
AdjustSiblingsAfterReflow(&aPresContext, aReflowState, aNextFrame, desiredSize.height -
|
|
|
|
oldKidRect.height);
|
|
|
|
aDesiredSize.width = mRect.width;
|
|
|
|
aDesiredSize.height = state.y + myBorderPadding.top + myBorderPadding.bottom;
|
|
|
|
return NS_OK;
|
|
|
|
#endif
|
|
|
|
return rv;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-10-02 08:10:00 +04:00
|
|
|
nscoord nsTableFrame::ComputeDesiredWidth(const nsHTMLReflowState& aReflowState) const
|
1998-09-01 01:23:28 +04:00
|
|
|
{
|
1999-01-06 02:31:18 +03:00
|
|
|
nscoord desiredWidth=aReflowState.availableWidth;
|
1998-09-01 01:23:28 +04:00
|
|
|
// this is the biggest hack in the world. But there's no other rational way to handle nested percent tables
|
1998-12-02 19:45:20 +03:00
|
|
|
const nsStylePosition* position;
|
1998-09-01 01:23:28 +04:00
|
|
|
PRBool isNested=IsNested(aReflowState, position);
|
|
|
|
if((eReflowReason_Initial==aReflowState.reason) &&
|
|
|
|
(PR_TRUE==isNested) && (eStyleUnit_Percent==position->mWidth.GetUnit()))
|
|
|
|
{
|
1999-03-06 20:01:15 +03:00
|
|
|
nsITableLayoutStrategy* tableLayoutStrategy = mTableLayoutStrategy;
|
|
|
|
if (mPrevInFlow) {
|
|
|
|
// Get the table layout strategy from the first-in-flow
|
|
|
|
nsTableFrame* table = (nsTableFrame*)GetFirstInFlow();
|
|
|
|
tableLayoutStrategy = table->mTableLayoutStrategy;
|
|
|
|
}
|
1999-07-28 12:09:02 +04:00
|
|
|
desiredWidth = tableLayoutStrategy->GetTableMaxContentWidth();
|
1998-09-01 01:23:28 +04:00
|
|
|
}
|
|
|
|
return desiredWidth;
|
|
|
|
}
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
// Position and size aKidFrame and update our reflow state. The origin of
|
1999-01-05 03:41:40 +03:00
|
|
|
// aKidRect is relative to the upper-left origin of our frame
|
1998-10-11 13:18:27 +04:00
|
|
|
void nsTableFrame::PlaceChild(nsIPresContext& aPresContext,
|
1998-10-21 00:05:44 +04:00
|
|
|
InnerTableReflowState& aReflowState,
|
1998-04-14 00:24:54 +04:00
|
|
|
nsIFrame* aKidFrame,
|
|
|
|
const nsRect& aKidRect,
|
|
|
|
nsSize* aMaxElementSize,
|
|
|
|
nsSize& aKidMaxElementSize)
|
|
|
|
{
|
1998-04-21 02:49:15 +04:00
|
|
|
if (PR_TRUE==gsDebug)
|
|
|
|
printf ("table: placing row group at %d, %d, %d, %d\n",
|
|
|
|
aKidRect.x, aKidRect.y, aKidRect.width, aKidRect.height);
|
1998-04-14 00:24:54 +04:00
|
|
|
// Place and size the child
|
|
|
|
aKidFrame->SetRect(aKidRect);
|
|
|
|
|
|
|
|
// Adjust the running y-offset
|
1998-10-21 00:05:44 +04:00
|
|
|
aReflowState.y += aKidRect.height;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-03-05 09:00:40 +03:00
|
|
|
// If our height is constrained, then update the available height
|
1998-10-21 00:05:44 +04:00
|
|
|
if (PR_FALSE == aReflowState.unconstrainedHeight) {
|
|
|
|
aReflowState.availSize.height -= aKidRect.height;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1999-03-05 09:00:40 +03:00
|
|
|
// If this is a footer row group, remember it
|
1998-06-17 20:38:24 +04:00
|
|
|
const nsStyleDisplay *childDisplay;
|
1998-12-02 19:45:20 +03:00
|
|
|
aKidFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)childDisplay));
|
1999-03-05 09:00:40 +03:00
|
|
|
|
|
|
|
// We only allow a single footer frame, and the footer frame must occur before
|
|
|
|
// any body section row groups
|
|
|
|
if ((NS_STYLE_DISPLAY_TABLE_FOOTER_GROUP == childDisplay->mDisplay) &&
|
|
|
|
!aReflowState.footerFrame && !aReflowState.firstBodySection)
|
1998-04-23 21:29:07 +04:00
|
|
|
{
|
1999-03-05 09:00:40 +03:00
|
|
|
aReflowState.footerFrame = aKidFrame;
|
1998-04-23 21:29:07 +04:00
|
|
|
}
|
1999-03-05 09:00:40 +03:00
|
|
|
else if (aReflowState.footerFrame)
|
1998-04-23 21:29:07 +04:00
|
|
|
{
|
1999-03-05 09:00:40 +03:00
|
|
|
// Place the row group frame
|
|
|
|
nsSize footerSize;
|
|
|
|
nsPoint origin;
|
|
|
|
aKidFrame->GetOrigin(origin);
|
|
|
|
aReflowState.footerFrame->GetSize(footerSize);
|
|
|
|
origin.y -= footerSize.height;
|
|
|
|
aKidFrame->MoveTo(origin.x, origin.y);
|
|
|
|
|
|
|
|
// Move the footer below the body row group frame
|
|
|
|
aReflowState.footerFrame->GetOrigin(origin);
|
|
|
|
origin.y += aKidRect.height;
|
|
|
|
aReflowState.footerFrame->MoveTo(origin.x, origin.y);
|
1998-04-23 21:29:07 +04:00
|
|
|
}
|
1999-03-05 09:00:40 +03:00
|
|
|
|
1998-10-09 23:59:45 +04:00
|
|
|
//XXX: this should call into layout strategy to get the width field
|
1998-08-07 06:11:51 +04:00
|
|
|
if (nsnull != aMaxElementSize)
|
|
|
|
{
|
|
|
|
const nsStyleSpacing* tableSpacing;
|
1998-12-02 19:45:20 +03:00
|
|
|
GetStyleData(eStyleStruct_Spacing , ((const nsStyleStruct *&)tableSpacing));
|
1998-12-23 18:47:43 +03:00
|
|
|
nsMargin borderPadding;
|
|
|
|
GetTableBorder (borderPadding); // gets the max border thickness for each edge
|
|
|
|
nsMargin padding;
|
|
|
|
tableSpacing->GetPadding(padding);
|
|
|
|
borderPadding += padding;
|
1998-12-09 09:37:18 +03:00
|
|
|
nscoord cellSpacing = GetCellSpacingX();
|
1998-08-07 06:11:51 +04:00
|
|
|
nscoord kidWidth = aKidMaxElementSize.width + borderPadding.left + borderPadding.right + cellSpacing*2;
|
|
|
|
aMaxElementSize->width = PR_MAX(aMaxElementSize->width, kidWidth);
|
|
|
|
aMaxElementSize->height += aKidMaxElementSize.height;
|
|
|
|
if (gsDebug)
|
|
|
|
printf("%p placeChild set MES->width to %d\n",
|
|
|
|
this, aMaxElementSize->width);
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reflow the frames we've already created
|
|
|
|
*
|
|
|
|
* @param aPresContext presentation context to use
|
1998-10-21 00:05:44 +04:00
|
|
|
* @param aReflowState current inline state
|
1998-04-14 00:24:54 +04:00
|
|
|
* @return true if we successfully reflowed all the mapped children and false
|
|
|
|
* otherwise, e.g. we pushed children to the next in flow
|
|
|
|
*/
|
1998-10-21 00:05:44 +04:00
|
|
|
NS_METHOD nsTableFrame::ReflowMappedChildren(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
InnerTableReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-01-16 01:52:05 +03:00
|
|
|
NS_PRECONDITION(mFrames.NotEmpty(), "no children");
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
PRInt32 childCount = 0;
|
|
|
|
nsIFrame* prevKidFrame = nsnull;
|
1998-06-03 04:43:53 +04:00
|
|
|
nsSize kidMaxElementSize(0,0);
|
1998-10-21 00:05:44 +04:00
|
|
|
nsSize* pKidMaxElementSize = (nsnull != aDesiredSize.maxElementSize) ? &kidMaxElementSize : nsnull;
|
1998-10-23 21:24:57 +04:00
|
|
|
nsresult rv = NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-09-24 01:48:26 +04:00
|
|
|
nsReflowReason reason;
|
1998-10-21 00:05:44 +04:00
|
|
|
if (PR_FALSE==RequiresPass1Layout())
|
1998-09-24 01:48:26 +04:00
|
|
|
{
|
1998-10-21 00:05:44 +04:00
|
|
|
reason = aReflowState.reflowState.reason;
|
1998-12-08 04:00:14 +03:00
|
|
|
if (eReflowReason_Incremental==reason)
|
|
|
|
reason = eReflowReason_Resize;
|
1998-09-24 01:48:26 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
reason = eReflowReason_Resize;
|
|
|
|
|
1998-12-03 21:01:35 +03:00
|
|
|
// this never passes reflows down to colgroups
|
1999-01-16 01:52:05 +03:00
|
|
|
for (nsIFrame* kidFrame = mFrames.FirstChild(); nsnull != kidFrame; )
|
1998-09-24 20:37:22 +04:00
|
|
|
{
|
1998-10-21 00:05:44 +04:00
|
|
|
nsSize kidAvailSize(aReflowState.availSize);
|
1998-10-01 08:46:11 +04:00
|
|
|
nsHTMLReflowMetrics desiredSize(pKidMaxElementSize);
|
1998-06-03 04:43:53 +04:00
|
|
|
desiredSize.width=desiredSize.height=desiredSize.ascent=desiredSize.descent=0;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-06-17 20:38:24 +04:00
|
|
|
const nsStyleDisplay *childDisplay;
|
1998-12-05 04:47:37 +03:00
|
|
|
kidFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)childDisplay));
|
1998-12-03 21:01:35 +03:00
|
|
|
if (PR_TRUE==IsRowGroup(childDisplay->mDisplay))
|
1998-12-14 04:24:11 +03:00
|
|
|
{
|
1999-03-05 09:00:40 +03:00
|
|
|
// Keep track of the first body section row group
|
|
|
|
if (nsnull == aReflowState.firstBodySection) {
|
1998-12-14 04:24:11 +03:00
|
|
|
if (NS_STYLE_DISPLAY_TABLE_ROW_GROUP == childDisplay->mDisplay) {
|
1999-03-05 09:00:40 +03:00
|
|
|
aReflowState.firstBodySection = kidFrame;
|
1998-12-14 04:24:11 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-12-23 18:47:43 +03:00
|
|
|
nsMargin borderPadding;
|
1999-01-30 18:52:19 +03:00
|
|
|
GetTableBorderForRowGroup(GetRowGroupFrameFor(kidFrame, childDisplay), borderPadding);
|
1998-12-23 18:47:43 +03:00
|
|
|
const nsStyleSpacing* tableSpacing;
|
|
|
|
GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)tableSpacing));
|
|
|
|
nsMargin padding;
|
|
|
|
tableSpacing->GetPadding(padding);
|
|
|
|
borderPadding += padding;
|
|
|
|
|
1998-04-17 02:21:32 +04:00
|
|
|
// Reflow the child into the available space
|
1999-03-05 07:19:09 +03:00
|
|
|
nsHTMLReflowState kidReflowState(aPresContext, aReflowState.reflowState,
|
|
|
|
kidFrame, kidAvailSize, reason);
|
1999-03-05 09:00:40 +03:00
|
|
|
if (aReflowState.firstBodySection && (kidFrame != aReflowState.firstBodySection)) {
|
1998-12-14 04:24:11 +03:00
|
|
|
// If this isn't the first row group frame or the header or footer, then
|
|
|
|
// we can't be at the top of the page anymore...
|
|
|
|
kidReflowState.isTopOfPage = PR_FALSE;
|
|
|
|
}
|
1998-10-01 08:46:11 +04:00
|
|
|
|
1999-01-05 03:41:40 +03:00
|
|
|
nscoord x = borderPadding.left;
|
|
|
|
nscoord y = borderPadding.top + aReflowState.y;
|
1998-10-20 03:43:06 +04:00
|
|
|
if (PR_TRUE==gsDebugIR) printf("\nTIF IR: Reflow Pass 2 of frame %p with reason=%d\n", kidFrame, reason);
|
1999-06-23 07:02:21 +04:00
|
|
|
|
|
|
|
if (RowGroupsShouldBeConstrained()) {
|
|
|
|
// Only applies to the tree widget.
|
|
|
|
nscoord tableSpecifiedHeight;
|
|
|
|
GetTableSpecifiedHeight(tableSpecifiedHeight, kidReflowState);
|
|
|
|
if (tableSpecifiedHeight != -1) {
|
|
|
|
kidReflowState.availableHeight = tableSpecifiedHeight - y;
|
|
|
|
if (kidReflowState.availableHeight < 0)
|
|
|
|
kidReflowState.availableHeight = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-10-23 21:24:57 +04:00
|
|
|
rv = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState, aStatus);
|
1998-10-06 04:27:22 +04:00
|
|
|
// Did the child fit?
|
1998-12-14 04:24:11 +03:00
|
|
|
if (desiredSize.height > kidAvailSize.height) {
|
1999-03-05 09:00:40 +03:00
|
|
|
if (aReflowState.firstBodySection && (kidFrame != aReflowState.firstBodySection)) {
|
|
|
|
// The child is too tall to fit at all in the available space, and it's
|
|
|
|
// not a header/footer or our first row group frame
|
1998-12-14 04:24:11 +03:00
|
|
|
PushChildren(kidFrame, prevKidFrame);
|
|
|
|
aStatus = NS_FRAME_NOT_COMPLETE;
|
|
|
|
break;
|
|
|
|
}
|
1998-10-06 04:27:22 +04:00
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-01-05 03:41:40 +03:00
|
|
|
// Place the child
|
1998-10-06 04:27:22 +04:00
|
|
|
nsRect kidRect (x, y, desiredSize.width, desiredSize.height);
|
1998-10-11 13:18:27 +04:00
|
|
|
if (PR_TRUE==IsRowGroup(childDisplay->mDisplay))
|
1998-10-06 04:27:22 +04:00
|
|
|
{
|
|
|
|
// we don't want to adjust the maxElementSize if this is an initial reflow
|
|
|
|
// it was set by the TableLayoutStrategy and shouldn't be changed.
|
|
|
|
nsSize *requestedMaxElementSize = nsnull;
|
1998-10-21 00:05:44 +04:00
|
|
|
if (eReflowReason_Initial != aReflowState.reflowState.reason)
|
|
|
|
requestedMaxElementSize = aDesiredSize.maxElementSize;
|
|
|
|
PlaceChild(aPresContext, aReflowState, kidFrame, kidRect,
|
1998-10-06 04:27:22 +04:00
|
|
|
requestedMaxElementSize, kidMaxElementSize);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
childCount++;
|
|
|
|
|
1998-04-17 02:21:32 +04:00
|
|
|
// Remember where we just were in case we end up pushing children
|
|
|
|
prevKidFrame = kidFrame;
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
// Special handling for incomplete children
|
1998-10-21 00:05:44 +04:00
|
|
|
if (NS_FRAME_IS_NOT_COMPLETE(aStatus)) {
|
1998-04-17 05:41:24 +04:00
|
|
|
nsIFrame* kidNextInFlow;
|
|
|
|
|
1999-02-24 07:48:08 +03:00
|
|
|
kidFrame->GetNextInFlow(&kidNextInFlow);
|
1998-04-14 00:24:54 +04:00
|
|
|
if (nsnull == kidNextInFlow) {
|
1998-04-17 02:21:32 +04:00
|
|
|
// The child doesn't have a next-in-flow so create a continuing
|
|
|
|
// frame. This hooks the child into the flow
|
1999-02-24 07:03:50 +03:00
|
|
|
nsIFrame* continuingFrame;
|
|
|
|
nsIPresShell* presShell;
|
|
|
|
nsIStyleSet* styleSet;
|
|
|
|
|
|
|
|
aPresContext.GetShell(&presShell);
|
|
|
|
presShell->GetStyleSet(&styleSet);
|
|
|
|
NS_RELEASE(presShell);
|
|
|
|
styleSet->CreateContinuingFrame(&aPresContext, kidFrame, this, &continuingFrame);
|
|
|
|
NS_RELEASE(styleSet);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-04-17 02:21:32 +04:00
|
|
|
// Add the continuing frame to the sibling list
|
1998-04-17 05:41:24 +04:00
|
|
|
nsIFrame* nextSib;
|
|
|
|
|
1999-02-10 09:13:38 +03:00
|
|
|
kidFrame->GetNextSibling(&nextSib);
|
1998-04-14 00:24:54 +04:00
|
|
|
continuingFrame->SetNextSibling(nextSib);
|
|
|
|
kidFrame->SetNextSibling(continuingFrame);
|
|
|
|
}
|
1998-04-17 02:21:32 +04:00
|
|
|
// We've used up all of our available space so push the remaining
|
|
|
|
// children to the next-in-flow
|
1998-04-17 05:41:24 +04:00
|
|
|
nsIFrame* nextSibling;
|
|
|
|
|
1999-02-10 09:13:38 +03:00
|
|
|
kidFrame->GetNextSibling(&nextSibling);
|
1998-04-17 02:21:32 +04:00
|
|
|
if (nsnull != nextSibling) {
|
1998-09-24 08:18:58 +04:00
|
|
|
PushChildren(nextSibling, kidFrame);
|
1998-04-17 02:21:32 +04:00
|
|
|
}
|
|
|
|
break;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
}
|
1998-10-23 21:24:57 +04:00
|
|
|
else
|
|
|
|
{// it's an unknown frame type, give it a generic reflow and ignore the results
|
1999-03-05 07:19:09 +03:00
|
|
|
nsHTMLReflowState kidReflowState(aPresContext,
|
|
|
|
aReflowState.reflowState, kidFrame,
|
1998-10-23 21:24:57 +04:00
|
|
|
nsSize(0,0), eReflowReason_Resize);
|
1999-06-28 17:44:40 +04:00
|
|
|
nsHTMLReflowMetrics unusedDesiredSize(nsnull);
|
1998-10-23 21:24:57 +04:00
|
|
|
if (PR_TRUE==gsDebug) printf("\nTIF : Reflow Pass 2 of unknown frame %p of type %d with reason=%d\n",
|
|
|
|
kidFrame, childDisplay->mDisplay, eReflowReason_Resize);
|
1999-06-28 17:44:40 +04:00
|
|
|
ReflowChild(kidFrame, aPresContext, unusedDesiredSize, kidReflowState, aStatus);
|
1998-10-23 21:24:57 +04:00
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
// Get the next child
|
1999-02-10 09:13:38 +03:00
|
|
|
kidFrame->GetNextSibling(&kidFrame);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Update the child count
|
1998-10-23 21:24:57 +04:00
|
|
|
return rv;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Try and pull-up frames from our next-in-flow
|
|
|
|
*
|
|
|
|
* @param aPresContext presentation context to use
|
1998-10-21 00:05:44 +04:00
|
|
|
* @param aReflowState current inline state
|
1998-04-14 00:24:54 +04:00
|
|
|
* @return true if we successfully pulled-up all the children and false
|
|
|
|
* otherwise, e.g. child didn't fit
|
|
|
|
*/
|
1998-10-21 00:05:44 +04:00
|
|
|
NS_METHOD nsTableFrame::PullUpChildren(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
InnerTableReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-09-21 07:40:32 +04:00
|
|
|
nsTableFrame* nextInFlow = (nsTableFrame*)mNextInFlow;
|
1998-06-03 04:43:53 +04:00
|
|
|
nsSize kidMaxElementSize(0,0);
|
1998-10-21 00:05:44 +04:00
|
|
|
nsSize* pKidMaxElementSize = (nsnull != aDesiredSize.maxElementSize) ? &kidMaxElementSize : nsnull;
|
1999-01-16 01:52:05 +03:00
|
|
|
nsIFrame* prevKidFrame = mFrames.LastChild();
|
1998-10-21 00:05:44 +04:00
|
|
|
nsresult rv = NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
while (nsnull != nextInFlow) {
|
1998-10-01 08:46:11 +04:00
|
|
|
nsHTMLReflowMetrics kidSize(pKidMaxElementSize);
|
1998-06-03 04:43:53 +04:00
|
|
|
kidSize.width=kidSize.height=kidSize.ascent=kidSize.descent=0;
|
1998-04-17 02:21:32 +04:00
|
|
|
|
1999-01-16 01:52:05 +03:00
|
|
|
// XXX change to use nsFrameList::PullFrame
|
|
|
|
|
1998-04-17 02:21:32 +04:00
|
|
|
// Get the next child
|
1999-01-16 01:52:05 +03:00
|
|
|
nsIFrame* kidFrame = nextInFlow->mFrames.FirstChild();
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-04-17 02:21:32 +04:00
|
|
|
// Any more child frames?
|
1998-04-14 00:24:54 +04:00
|
|
|
if (nsnull == kidFrame) {
|
1998-04-17 02:21:32 +04:00
|
|
|
// No. Any frames on its overflow list?
|
1999-01-16 01:52:05 +03:00
|
|
|
if (nextInFlow->mOverflowFrames.NotEmpty()) {
|
1998-04-17 02:21:32 +04:00
|
|
|
// Move the overflow list to become the child list
|
1999-04-13 03:46:02 +04:00
|
|
|
nextInFlow->mFrames.AppendFrames(nsnull, nextInFlow->mOverflowFrames);
|
1999-01-16 01:52:05 +03:00
|
|
|
kidFrame = nextInFlow->mFrames.FirstChild();
|
1998-04-17 02:21:32 +04:00
|
|
|
} else {
|
|
|
|
// We've pulled up all the children, so move to the next-in-flow.
|
1999-02-24 07:48:08 +03:00
|
|
|
nextInFlow->GetNextInFlow((nsIFrame**)&nextInFlow);
|
1998-04-17 02:21:32 +04:00
|
|
|
continue;
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-04-17 02:21:32 +04:00
|
|
|
// See if the child fits in the available space. If it fits or
|
|
|
|
// it's splittable then reflow it. The reason we can't just move
|
|
|
|
// it is that we still need ascent/descent information
|
1998-06-03 04:43:53 +04:00
|
|
|
nsSize kidFrameSize(0,0);
|
1998-05-22 08:54:11 +04:00
|
|
|
nsSplittableType kidIsSplittable;
|
1998-04-17 05:41:24 +04:00
|
|
|
|
|
|
|
kidFrame->GetSize(kidFrameSize);
|
|
|
|
kidFrame->IsSplittable(kidIsSplittable);
|
1998-10-21 00:05:44 +04:00
|
|
|
if ((kidFrameSize.height > aReflowState.availSize.height) &&
|
1998-05-22 08:54:11 +04:00
|
|
|
NS_FRAME_IS_NOT_SPLITTABLE(kidIsSplittable)) {
|
1998-10-21 00:05:44 +04:00
|
|
|
//XXX: Troy
|
|
|
|
aStatus = NS_FRAME_NOT_COMPLETE;
|
1998-04-17 02:21:32 +04:00
|
|
|
break;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1999-03-05 07:19:09 +03:00
|
|
|
nsHTMLReflowState kidReflowState(aPresContext, aReflowState.reflowState,
|
|
|
|
kidFrame, aReflowState.availSize,
|
1998-10-02 08:10:00 +04:00
|
|
|
eReflowReason_Resize);
|
1998-04-17 02:21:32 +04:00
|
|
|
|
1998-10-21 00:05:44 +04:00
|
|
|
rv = ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState, aStatus);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-10-06 04:27:22 +04:00
|
|
|
// Did the child fit?
|
1999-01-16 01:52:05 +03:00
|
|
|
if ((kidSize.height > aReflowState.availSize.height) && mFrames.NotEmpty()) {
|
1998-10-06 04:27:22 +04:00
|
|
|
// The child is too wide to fit in the available space, and it's
|
|
|
|
// not our first child
|
1998-10-21 00:05:44 +04:00
|
|
|
//XXX: Troy
|
|
|
|
aStatus = NS_FRAME_NOT_COMPLETE;
|
1998-10-06 04:27:22 +04:00
|
|
|
break;
|
|
|
|
}
|
1998-10-01 08:46:11 +04:00
|
|
|
|
1998-10-06 04:27:22 +04:00
|
|
|
nsRect kidRect (0, 0, kidSize.width, kidSize.height);
|
1998-10-21 00:05:44 +04:00
|
|
|
kidRect.y += aReflowState.y;
|
1998-10-06 04:27:22 +04:00
|
|
|
const nsStyleDisplay *childDisplay;
|
1998-12-02 19:45:20 +03:00
|
|
|
kidFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)childDisplay));
|
1998-10-11 13:18:27 +04:00
|
|
|
if (PR_TRUE==IsRowGroup(childDisplay->mDisplay))
|
1998-10-06 04:27:22 +04:00
|
|
|
{
|
1998-10-21 00:05:44 +04:00
|
|
|
PlaceChild(aPresContext, aReflowState, kidFrame, kidRect, aDesiredSize.maxElementSize, *pKidMaxElementSize);
|
1998-05-29 01:39:22 +04:00
|
|
|
}
|
1998-04-17 02:21:32 +04:00
|
|
|
|
|
|
|
// Remove the frame from its current parent
|
1999-01-16 01:52:05 +03:00
|
|
|
nextInFlow->mFrames.RemoveFirstChild();
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-04-17 02:21:32 +04:00
|
|
|
// Link the frame into our list of children
|
1999-01-14 08:16:23 +03:00
|
|
|
kidFrame->SetParent(this);
|
1998-04-17 05:41:24 +04:00
|
|
|
|
1998-04-17 02:21:32 +04:00
|
|
|
if (nsnull == prevKidFrame) {
|
1999-01-16 01:52:05 +03:00
|
|
|
mFrames.SetFrames(kidFrame);
|
1998-04-17 02:21:32 +04:00
|
|
|
} else {
|
|
|
|
prevKidFrame->SetNextSibling(kidFrame);
|
|
|
|
}
|
|
|
|
kidFrame->SetNextSibling(nsnull);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-04-17 02:21:32 +04:00
|
|
|
// Remember where we just were in case we end up pushing children
|
|
|
|
prevKidFrame = kidFrame;
|
1998-10-21 00:05:44 +04:00
|
|
|
if (NS_FRAME_IS_NOT_COMPLETE(aStatus)) {
|
1998-04-17 02:21:32 +04:00
|
|
|
// No the child isn't complete
|
1998-04-17 05:41:24 +04:00
|
|
|
nsIFrame* kidNextInFlow;
|
|
|
|
|
1999-02-24 07:48:08 +03:00
|
|
|
kidFrame->GetNextInFlow(&kidNextInFlow);
|
1998-04-17 02:21:32 +04:00
|
|
|
if (nsnull == kidNextInFlow) {
|
|
|
|
// The child doesn't have a next-in-flow so create a
|
|
|
|
// continuing frame. The creation appends it to the flow and
|
|
|
|
// prepares it for reflow.
|
1999-02-24 07:03:50 +03:00
|
|
|
nsIFrame* continuingFrame;
|
|
|
|
nsIPresShell* presShell;
|
|
|
|
nsIStyleSet* styleSet;
|
|
|
|
aPresContext.GetShell(&presShell);
|
|
|
|
presShell->GetStyleSet(&styleSet);
|
|
|
|
NS_RELEASE(presShell);
|
|
|
|
styleSet->CreateContinuingFrame(&aPresContext, kidFrame, this, &continuingFrame);
|
|
|
|
NS_RELEASE(styleSet);
|
1998-04-17 02:21:32 +04:00
|
|
|
|
|
|
|
// Add the continuing frame to our sibling list and then push
|
|
|
|
// it to the next-in-flow. This ensures the next-in-flow's
|
|
|
|
// content offsets and child count are set properly. Note that
|
|
|
|
// we can safely assume that the continuation is complete so
|
1998-09-21 07:40:32 +04:00
|
|
|
// we pass PR_TRUE into PushChidren
|
1998-04-17 02:21:32 +04:00
|
|
|
kidFrame->SetNextSibling(continuingFrame);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-09-24 08:18:58 +04:00
|
|
|
PushChildren(continuingFrame, kidFrame);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1998-04-17 02:21:32 +04:00
|
|
|
break;
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-10-21 00:05:44 +04:00
|
|
|
return rv;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Now I've got all the cells laid out in an infinite space.
|
|
|
|
For each column, use the min size for each cell in that column
|
|
|
|
along with the attributes of the table, column group, and column
|
|
|
|
to assign widths to each column.
|
|
|
|
*/
|
|
|
|
// use the cell map to determine which cell is in which column.
|
1998-10-11 13:18:27 +04:00
|
|
|
void nsTableFrame::BalanceColumnWidths(nsIPresContext& aPresContext,
|
1998-10-02 08:10:00 +04:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
1998-04-14 00:24:54 +04:00
|
|
|
const nsSize& aMaxSize,
|
|
|
|
nsSize* aMaxElementSize)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(nsnull==mPrevInFlow, "never ever call me on a continuing frame!");
|
1998-09-01 01:23:28 +04:00
|
|
|
NS_ASSERTION(nsnull!=mCellMap, "never ever call me until the cell map is built!");
|
1998-10-10 01:53:07 +04:00
|
|
|
NS_ASSERTION(nsnull!=mColumnWidths, "never ever call me until the col widths array is built!");
|
1998-07-07 04:20:21 +04:00
|
|
|
|
1998-10-20 09:05:17 +04:00
|
|
|
PRInt32 numCols = mCellMap->GetColCount();
|
1998-10-10 01:53:07 +04:00
|
|
|
if (numCols>mColumnWidthsLength)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-10-10 01:53:07 +04:00
|
|
|
PRInt32 priorColumnWidthsLength=mColumnWidthsLength;
|
|
|
|
while (numCols>mColumnWidthsLength)
|
|
|
|
mColumnWidthsLength += kColumnWidthIncrement;
|
|
|
|
PRInt32 * newColumnWidthsArray = new PRInt32[mColumnWidthsLength];
|
|
|
|
nsCRT::memset (newColumnWidthsArray, 0, mColumnWidthsLength*sizeof(PRInt32));
|
|
|
|
nsCRT::memcpy (newColumnWidthsArray, mColumnWidths, priorColumnWidthsLength*sizeof(PRInt32));
|
|
|
|
delete [] mColumnWidths;
|
|
|
|
mColumnWidths = newColumnWidthsArray;
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
// need to figure out the overall table width constraint
|
1998-04-25 22:48:48 +04:00
|
|
|
// default case, get 100% of available space
|
1998-07-11 04:00:31 +04:00
|
|
|
|
1998-09-30 03:15:01 +04:00
|
|
|
PRInt32 maxWidth = aMaxSize.width;
|
1998-06-05 10:09:09 +04:00
|
|
|
const nsStylePosition* position =
|
|
|
|
(const nsStylePosition*)mStyleContext->GetStyleData(eStyleStruct_Position);
|
1998-09-30 03:15:01 +04:00
|
|
|
if (eStyleUnit_Coord==position->mWidth.GetUnit())
|
1998-11-25 21:43:56 +03:00
|
|
|
{
|
|
|
|
nscoord coordWidth=0;
|
|
|
|
coordWidth = position->mWidth.GetCoordValue();
|
|
|
|
// NAV4 compatibility: 0-coord-width == auto-width
|
|
|
|
if (0!=coordWidth)
|
|
|
|
maxWidth = coordWidth;
|
|
|
|
}
|
1998-08-07 06:11:51 +04:00
|
|
|
|
1998-07-18 01:02:28 +04:00
|
|
|
if (0>maxWidth) // nonsense style specification
|
|
|
|
maxWidth = 0;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-06-24 03:23:21 +04:00
|
|
|
if (PR_TRUE==gsDebug || PR_TRUE==gsDebugNT)
|
|
|
|
printf ("%p: maxWidth=%d from aMaxSize=%d,%d\n",
|
|
|
|
this, maxWidth, aMaxSize.width, aMaxSize.height);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-04-30 21:57:09 +04:00
|
|
|
// based on the compatibility mode, create a table layout strategy
|
1999-06-03 06:42:33 +04:00
|
|
|
if (nsnull == mTableLayoutStrategy) {
|
1999-05-27 02:22:23 +04:00
|
|
|
nsCompatibility mode;
|
|
|
|
aPresContext.GetCompatibilityMode(&mode);
|
1998-10-21 00:05:44 +04:00
|
|
|
if (PR_FALSE==RequiresPass1Layout())
|
1998-10-20 03:43:06 +04:00
|
|
|
mTableLayoutStrategy = new FixedTableLayoutStrategy(this);
|
1998-09-23 03:36:06 +04:00
|
|
|
else
|
1999-05-27 02:22:23 +04:00
|
|
|
mTableLayoutStrategy = new BasicTableLayoutStrategy(this, eCompatibility_NavQuirks == mode);
|
1999-07-20 07:41:03 +04:00
|
|
|
mTableLayoutStrategy->Initialize(aMaxElementSize, GetColCount(), aReflowState.mComputedWidth);
|
1998-10-16 01:07:37 +04:00
|
|
|
mColumnWidthsValid=PR_TRUE;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1999-06-03 06:42:33 +04:00
|
|
|
// fixed-layout tables need to reinitialize the layout strategy. When there are scroll bars
|
|
|
|
// reflow gets called twice and the 2nd time has the correct space available.
|
|
|
|
else if (!RequiresPass1Layout()) {
|
1999-07-20 07:41:03 +04:00
|
|
|
mTableLayoutStrategy->Initialize(aMaxElementSize, GetColCount(), aReflowState.mComputedWidth);
|
1999-06-03 06:42:33 +04:00
|
|
|
}
|
|
|
|
|
1998-07-17 03:23:31 +04:00
|
|
|
mTableLayoutStrategy->BalanceColumnWidths(mStyleContext, aReflowState, maxWidth);
|
1999-07-28 12:09:02 +04:00
|
|
|
//Dump(PR_TRUE, PR_TRUE);
|
1998-10-11 13:18:27 +04:00
|
|
|
mColumnWidthsSet=PR_TRUE;
|
1998-12-23 18:47:43 +03:00
|
|
|
|
|
|
|
// if collapsing borders, compute the top and bottom edges now that we have column widths
|
|
|
|
const nsStyleTable* tableStyle =
|
|
|
|
(const nsStyleTable*)mStyleContext->GetStyleData(eStyleStruct_Table);
|
1998-12-21 09:38:18 +03:00
|
|
|
if (NS_STYLE_BORDER_COLLAPSE==tableStyle->mBorderCollapse)
|
|
|
|
{
|
1998-12-21 21:54:23 +03:00
|
|
|
ComputeHorizontalCollapsingBorders(aPresContext, 0, mCellMap->GetRowCount()-1);
|
1998-12-21 09:38:18 +03:00
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
sum the width of each column
|
|
|
|
add in table insets
|
|
|
|
set rect
|
|
|
|
*/
|
1998-10-11 13:18:27 +04:00
|
|
|
void nsTableFrame::SetTableWidth(nsIPresContext& aPresContext)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
NS_ASSERTION(nsnull==mPrevInFlow, "never ever call me on a continuing frame!");
|
1998-09-01 01:23:28 +04:00
|
|
|
NS_ASSERTION(nsnull!=mCellMap, "never ever call me until the cell map is built!");
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-12-09 09:37:18 +03:00
|
|
|
nscoord cellSpacing = GetCellSpacingX();
|
1998-07-22 09:38:41 +04:00
|
|
|
if (gsDebug==PR_TRUE)
|
|
|
|
printf ("SetTableWidth with cellSpacing = %d ", cellSpacing);
|
1999-07-28 12:09:02 +04:00
|
|
|
PRInt32 tableWidth = 0;
|
1998-07-07 04:20:21 +04:00
|
|
|
|
1998-10-26 21:42:22 +03:00
|
|
|
PRInt32 numCols = GetColCount();
|
1999-07-28 12:09:02 +04:00
|
|
|
for (PRInt32 colIndex = 0; colIndex < numCols; colIndex++) {
|
1998-07-11 04:00:31 +04:00
|
|
|
nscoord totalColWidth = mColumnWidths[colIndex];
|
1999-07-28 12:09:02 +04:00
|
|
|
if (GetNumCellsOriginatingIn(colIndex) > 0) { // skip degenerate cols
|
|
|
|
totalColWidth += cellSpacing; // add cell spacing to left of col
|
|
|
|
}
|
|
|
|
if (gsDebug == PR_TRUE) printf (" += %d ", totalColWidth);
|
1998-07-11 04:00:31 +04:00
|
|
|
tableWidth += totalColWidth;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1999-07-28 12:09:02 +04:00
|
|
|
if (numCols > 0) {
|
|
|
|
tableWidth += cellSpacing; // add last cellspacing
|
|
|
|
}
|
|
|
|
else if (0 == tableWidth) {
|
|
|
|
nsRect tableRect = mRect;
|
|
|
|
tableRect.width = 0;
|
|
|
|
SetRect(tableRect);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
// 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-13 02:28:01 +04:00
|
|
|
nsMargin borderPadding;
|
1998-12-23 18:47:43 +03:00
|
|
|
GetTableBorder (borderPadding); // this gets the max border value at every edge
|
|
|
|
nsMargin padding;
|
|
|
|
spacing->GetPadding(padding);
|
|
|
|
borderPadding += padding;
|
1998-05-13 02:28:01 +04:00
|
|
|
|
|
|
|
nscoord rightInset = borderPadding.right;
|
|
|
|
nscoord leftInset = borderPadding.left;
|
1998-04-14 00:24:54 +04:00
|
|
|
tableWidth += (leftInset + rightInset);
|
1998-04-17 05:41:24 +04:00
|
|
|
nsRect tableSize = mRect;
|
1998-04-14 00:24:54 +04:00
|
|
|
tableSize.width = tableWidth;
|
1998-06-24 03:23:21 +04:00
|
|
|
if (PR_TRUE==gsDebug || PR_TRUE==gsDebugNT)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-06-24 03:23:21 +04:00
|
|
|
printf ("%p: setting table rect to %d, %d after adding insets %d, %d\n",
|
|
|
|
this, tableSize.width, tableSize.height, rightInset, leftInset);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1999-01-18 02:35:56 +03:00
|
|
|
|
|
|
|
// account for scroll bars. XXX needs optimization/caching
|
|
|
|
if (mHasScrollableRowGroup) {
|
|
|
|
float sbWidth, sbHeight;
|
1999-02-12 20:45:58 +03:00
|
|
|
nsCOMPtr<nsIDeviceContext> dc;
|
|
|
|
aPresContext.GetDeviceContext(getter_AddRefs(dc));
|
1999-01-18 02:35:56 +03:00
|
|
|
dc->GetScrollBarDimensions(sbWidth, sbHeight);
|
|
|
|
tableSize.width += NSToCoordRound(sbWidth);
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
SetRect(tableSize);
|
|
|
|
}
|
|
|
|
|
1998-11-20 04:01:25 +03:00
|
|
|
/* get the height of this table's container. ignore all containers who have unconstrained height.
|
|
|
|
* take into account the possibility that this table is nested.
|
|
|
|
* if nested within an auto-height table, this method returns 0.
|
|
|
|
* this method may also return NS_UNCONSTRAINEDSIZE, meaning no container provided any height constraint
|
|
|
|
*/
|
|
|
|
nscoord nsTableFrame::GetEffectiveContainerHeight(const nsHTMLReflowState& aReflowState)
|
|
|
|
{
|
|
|
|
nscoord result=-1;
|
|
|
|
const nsHTMLReflowState* rs = &aReflowState;
|
|
|
|
while (nsnull!=rs)
|
|
|
|
{
|
|
|
|
const nsStyleDisplay *display;
|
1998-12-02 19:45:20 +03:00
|
|
|
rs->frame->GetStyleData(eStyleStruct_Display, (const nsStyleStruct *&)display);
|
1998-11-20 04:01:25 +03:00
|
|
|
if (NS_STYLE_DISPLAY_TABLE==display->mDisplay)
|
|
|
|
{
|
|
|
|
const nsStylePosition *position;
|
1998-12-02 19:45:20 +03:00
|
|
|
rs->frame->GetStyleData(eStyleStruct_Position, (const nsStyleStruct *&)position);
|
1998-11-20 04:01:25 +03:00
|
|
|
nsStyleUnit unit = position->mHeight.GetUnit();
|
|
|
|
if (eStyleUnit_Null==unit || eStyleUnit_Auto==unit)
|
|
|
|
{
|
|
|
|
result = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1999-07-20 07:41:03 +04:00
|
|
|
if (NS_AUTOHEIGHT != rs->mComputedHeight)
|
1998-11-20 04:01:25 +03:00
|
|
|
{
|
1999-07-20 07:41:03 +04:00
|
|
|
result = rs->mComputedHeight;
|
1998-11-20 04:01:25 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
// XXX: evil cast!
|
|
|
|
rs = (nsHTMLReflowState *)(rs->parentReflowState);
|
|
|
|
}
|
|
|
|
NS_ASSERTION(-1!=result, "bad state: no constrained height in reflow chain");
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
get the table height attribute
|
|
|
|
if it is auto, table height = SUM(height of rowgroups)
|
|
|
|
else if (resolved table height attribute > SUM(height of rowgroups))
|
|
|
|
proportionately distribute extra height to each row
|
|
|
|
we assume we are passed in the default table height==the sum of the heights of the table's rowgroups
|
|
|
|
in aDesiredSize.height.
|
|
|
|
*/
|
1999-06-15 03:42:16 +04:00
|
|
|
void nsTableFrame::DistributeSpaceToCells(nsIPresContext& aPresContext,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsIFrame* aRowGroupFrame)
|
|
|
|
{
|
|
|
|
// now that all of the rows have been resized, resize the cells
|
1999-06-23 13:07:59 +04:00
|
|
|
nsTableRowGroupFrame* rowGroupFrame = (nsTableRowGroupFrame*)aRowGroupFrame;
|
|
|
|
nsIFrame * rowFrame = rowGroupFrame->GetFirstFrame();
|
1999-06-15 03:42:16 +04:00
|
|
|
while (nsnull!=rowFrame) {
|
|
|
|
const nsStyleDisplay *rowDisplay;
|
|
|
|
rowFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)rowDisplay));
|
|
|
|
if (NS_STYLE_DISPLAY_TABLE_ROW == rowDisplay->mDisplay) {
|
|
|
|
((nsTableRowFrame *)rowFrame)->DidResize(aPresContext, aReflowState);
|
|
|
|
}
|
|
|
|
// The calling function, DistributeSpaceToRows, takes care of the recursive row
|
|
|
|
// group descent, which is why there's no NS_STYLE_DISPLAY_TABLE_ROW_GROUP case
|
|
|
|
// here.
|
1999-06-23 13:07:59 +04:00
|
|
|
rowGroupFrame->GetNextFrame(rowFrame, &rowFrame);
|
1999-06-15 03:42:16 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsTableFrame::DistributeSpaceToRows(nsIPresContext& aPresContext,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsIFrame* aRowGroupFrame, const nscoord& aSumOfRowHeights,
|
|
|
|
const nscoord& aExcess, const nsStyleTable* aTableStyle,
|
|
|
|
nscoord& aExcessForRowGroup,
|
|
|
|
nscoord& aRowGroupYPos)
|
|
|
|
{
|
|
|
|
// the rows in rowGroupFrame need to be expanded by rowHeightDelta[i]
|
|
|
|
// and the rowgroup itself needs to be expanded by SUM(row height deltas)
|
1999-06-23 13:07:59 +04:00
|
|
|
nsTableRowGroupFrame* rowGroupFrame = (nsTableRowGroupFrame*)aRowGroupFrame;
|
|
|
|
nsIFrame * rowFrame = rowGroupFrame->GetFirstFrame();
|
1999-06-15 03:42:16 +04:00
|
|
|
nscoord y = 0;
|
|
|
|
while (nsnull!=rowFrame)
|
|
|
|
{
|
|
|
|
const nsStyleDisplay *rowDisplay;
|
|
|
|
rowFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)rowDisplay));
|
|
|
|
if (NS_STYLE_DISPLAY_TABLE_ROW_GROUP == rowDisplay->mDisplay) {
|
|
|
|
DistributeSpaceToRows(aPresContext, aReflowState, rowFrame, aSumOfRowHeights,
|
|
|
|
aExcess, aTableStyle, aExcessForRowGroup, y);
|
|
|
|
}
|
|
|
|
else if (NS_STYLE_DISPLAY_TABLE_ROW == rowDisplay->mDisplay)
|
|
|
|
{ // the row needs to be expanded by the proportion this row contributed to the original height
|
|
|
|
nsRect rowRect;
|
|
|
|
rowFrame->GetRect(rowRect);
|
|
|
|
float percent = ((float)(rowRect.height)) / ((float)(aSumOfRowHeights));
|
|
|
|
nscoord excessForRow = NSToCoordRound((float)aExcess*percent);
|
1999-06-23 13:07:59 +04:00
|
|
|
|
|
|
|
if (rowGroupFrame->RowsDesireExcessSpace()) {
|
|
|
|
nsRect newRowRect(rowRect.x, y, rowRect.width, excessForRow+rowRect.height);
|
|
|
|
rowFrame->SetRect(newRowRect);
|
|
|
|
if (NS_STYLE_BORDER_COLLAPSE==aTableStyle->mBorderCollapse)
|
|
|
|
{
|
|
|
|
nsBorderEdge *border = (nsBorderEdge *)
|
|
|
|
(mBorderEdges.mEdges[NS_SIDE_LEFT].ElementAt(((nsTableRowFrame*)rowFrame)->GetRowIndex()));
|
|
|
|
border->mLength=newRowRect.height;
|
|
|
|
border = (nsBorderEdge *)
|
|
|
|
(mBorderEdges.mEdges[NS_SIDE_RIGHT].ElementAt(((nsTableRowFrame*)rowFrame)->GetRowIndex()));
|
|
|
|
border->mLength=newRowRect.height;
|
|
|
|
}
|
|
|
|
// better if this were part of an overloaded row::SetRect
|
|
|
|
y += excessForRow+rowRect.height;
|
1999-06-15 03:42:16 +04:00
|
|
|
}
|
1999-06-23 13:07:59 +04:00
|
|
|
|
1999-06-15 03:42:16 +04:00
|
|
|
aExcessForRowGroup += excessForRow;
|
|
|
|
}
|
1999-06-23 07:02:21 +04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
nsRect rowRect;
|
|
|
|
rowFrame->GetRect(rowRect);
|
|
|
|
y += rowRect.height;
|
|
|
|
}
|
|
|
|
|
1999-06-23 13:07:59 +04:00
|
|
|
rowGroupFrame->GetNextFrame(rowFrame, &rowFrame);
|
1999-06-15 03:42:16 +04:00
|
|
|
}
|
|
|
|
|
1999-06-23 13:07:59 +04:00
|
|
|
nsRect rowGroupRect;
|
|
|
|
aRowGroupFrame->GetRect(rowGroupRect);
|
|
|
|
if (rowGroupFrame->RowGroupDesiresExcessSpace()) {
|
|
|
|
nsRect newRowGroupRect(rowGroupRect.x, aRowGroupYPos, rowGroupRect.width, aExcessForRowGroup+rowGroupRect.height);
|
|
|
|
aRowGroupFrame->SetRect(newRowGroupRect);
|
|
|
|
aRowGroupYPos += aExcessForRowGroup + rowGroupRect.height;
|
|
|
|
}
|
|
|
|
else aRowGroupYPos += rowGroupRect.height;
|
1999-06-15 03:42:16 +04:00
|
|
|
|
|
|
|
DistributeSpaceToCells(aPresContext, aReflowState, aRowGroupFrame);
|
|
|
|
}
|
|
|
|
|
1999-06-23 07:02:21 +04:00
|
|
|
NS_IMETHODIMP nsTableFrame::GetTableSpecifiedHeight(nscoord& aResult, const nsHTMLReflowState& aReflowState)
|
|
|
|
{
|
|
|
|
const nsStylePosition* tablePosition;
|
|
|
|
GetStyleData(eStyleStruct_Position, (const nsStyleStruct *&)tablePosition);
|
|
|
|
|
|
|
|
const nsStyleTable* tableStyle;
|
|
|
|
GetStyleData(eStyleStruct_Table, (const nsStyleStruct *&)tableStyle);
|
|
|
|
nscoord tableSpecifiedHeight=-1;
|
|
|
|
if (eStyleUnit_Coord == tablePosition->mHeight.GetUnit())
|
|
|
|
tableSpecifiedHeight = tablePosition->mHeight.GetCoordValue();
|
|
|
|
else if (eStyleUnit_Percent == tablePosition->mHeight.GetUnit())
|
|
|
|
{
|
|
|
|
float percent = tablePosition->mHeight.GetPercentValue();
|
|
|
|
nscoord parentHeight = GetEffectiveContainerHeight(aReflowState);
|
|
|
|
if (NS_UNCONSTRAINEDSIZE!=parentHeight && 0!=parentHeight)
|
|
|
|
tableSpecifiedHeight = NSToCoordRound((float)parentHeight * percent);
|
|
|
|
}
|
|
|
|
aResult = tableSpecifiedHeight;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-11-20 04:01:25 +03:00
|
|
|
nscoord nsTableFrame::ComputeDesiredHeight(nsIPresContext& aPresContext,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nscoord aDefaultHeight)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(nsnull!=mCellMap, "never ever call me until the cell map is built!");
|
|
|
|
nscoord result = aDefaultHeight;
|
|
|
|
const nsStylePosition* tablePosition;
|
|
|
|
GetStyleData(eStyleStruct_Position, (const nsStyleStruct *&)tablePosition);
|
|
|
|
if (eStyleUnit_Auto == tablePosition->mHeight.GetUnit())
|
|
|
|
return result; // auto width tables are sized by the row heights, which we already have
|
|
|
|
|
1998-12-21 09:38:18 +03:00
|
|
|
const nsStyleTable* tableStyle;
|
|
|
|
GetStyleData(eStyleStruct_Table, (const nsStyleStruct *&)tableStyle);
|
1998-11-20 04:01:25 +03:00
|
|
|
nscoord tableSpecifiedHeight=-1;
|
|
|
|
if (eStyleUnit_Coord == tablePosition->mHeight.GetUnit())
|
|
|
|
tableSpecifiedHeight = tablePosition->mHeight.GetCoordValue();
|
|
|
|
else if (eStyleUnit_Percent == tablePosition->mHeight.GetUnit())
|
|
|
|
{
|
|
|
|
float percent = tablePosition->mHeight.GetPercentValue();
|
|
|
|
nscoord parentHeight = GetEffectiveContainerHeight(aReflowState);
|
|
|
|
if (NS_UNCONSTRAINEDSIZE!=parentHeight && 0!=parentHeight)
|
|
|
|
tableSpecifiedHeight = NSToCoordRound((float)parentHeight * percent);
|
|
|
|
}
|
|
|
|
if (-1!=tableSpecifiedHeight)
|
|
|
|
{
|
|
|
|
if (tableSpecifiedHeight>aDefaultHeight)
|
|
|
|
{ // proportionately distribute the excess height to each row
|
|
|
|
result = tableSpecifiedHeight;
|
|
|
|
nscoord excess = tableSpecifiedHeight-aDefaultHeight;
|
|
|
|
nscoord sumOfRowHeights=0;
|
1999-01-16 01:52:05 +03:00
|
|
|
nsIFrame * rowGroupFrame=mFrames.FirstChild();
|
1998-11-20 04:01:25 +03:00
|
|
|
while (nsnull!=rowGroupFrame)
|
|
|
|
{
|
|
|
|
const nsStyleDisplay *rowGroupDisplay;
|
1998-12-02 19:45:20 +03:00
|
|
|
rowGroupFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)rowGroupDisplay));
|
1999-06-23 07:02:21 +04:00
|
|
|
if (PR_TRUE==IsRowGroup(rowGroupDisplay->mDisplay) &&
|
|
|
|
((nsTableRowGroupFrame*)rowGroupFrame)->RowGroupReceivesExcessSpace())
|
1999-06-14 12:22:47 +04:00
|
|
|
{
|
|
|
|
((nsTableRowGroupFrame*)rowGroupFrame)->GetHeightOfRows(sumOfRowHeights);
|
1998-11-20 04:01:25 +03:00
|
|
|
}
|
1999-02-10 09:13:38 +03:00
|
|
|
rowGroupFrame->GetNextSibling(&rowGroupFrame);
|
1998-11-20 04:01:25 +03:00
|
|
|
}
|
1999-01-16 01:52:05 +03:00
|
|
|
rowGroupFrame=mFrames.FirstChild();
|
1999-06-15 11:06:55 +04:00
|
|
|
nscoord rowGroupYPos = 0;
|
1998-11-20 04:01:25 +03:00
|
|
|
while (nsnull!=rowGroupFrame)
|
|
|
|
{
|
|
|
|
const nsStyleDisplay *rowGroupDisplay;
|
1998-12-02 19:45:20 +03:00
|
|
|
rowGroupFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)rowGroupDisplay));
|
1999-06-23 07:02:21 +04:00
|
|
|
if (PR_TRUE==IsRowGroup(rowGroupDisplay->mDisplay)) {
|
|
|
|
if (((nsTableRowGroupFrame*)rowGroupFrame)->RowGroupReceivesExcessSpace())
|
|
|
|
{
|
|
|
|
nscoord excessForGroup = 0;
|
|
|
|
DistributeSpaceToRows(aPresContext, aReflowState, rowGroupFrame, sumOfRowHeights,
|
|
|
|
excess, tableStyle, excessForGroup, rowGroupYPos);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nsRect rowGroupRect;
|
|
|
|
rowGroupFrame->GetRect(rowGroupRect);
|
|
|
|
rowGroupYPos += rowGroupRect.height;
|
|
|
|
}
|
1998-11-20 04:01:25 +03:00
|
|
|
}
|
1999-02-10 09:13:38 +03:00
|
|
|
rowGroupFrame->GetNextSibling(&rowGroupFrame);
|
1998-11-20 04:01:25 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1998-07-26 08:23:01 +04:00
|
|
|
void nsTableFrame::AdjustColumnsForCOLSAttribute()
|
|
|
|
{
|
1999-07-28 12:09:02 +04:00
|
|
|
// XXX this is not right,
|
|
|
|
#if 0
|
1998-08-18 03:37:04 +04:00
|
|
|
nsCellMap *cellMap = GetCellMap();
|
|
|
|
NS_ASSERTION(nsnull!=cellMap, "bad cell map");
|
1998-07-26 08:23:01 +04:00
|
|
|
|
|
|
|
// any specified-width column turns off COLS attribute
|
|
|
|
nsStyleTable* tableStyle = (nsStyleTable *)mStyleContext->GetMutableStyleData(eStyleStruct_Table);
|
|
|
|
if (tableStyle->mCols != NS_STYLE_TABLE_COLS_NONE)
|
|
|
|
{
|
1998-10-20 09:05:17 +04:00
|
|
|
PRInt32 numCols = cellMap->GetColCount();
|
|
|
|
PRInt32 numRows = cellMap->GetRowCount();
|
1998-07-26 08:23:01 +04:00
|
|
|
for (PRInt32 rowIndex=0; rowIndex<numRows; rowIndex++)
|
|
|
|
{
|
|
|
|
for (PRInt32 colIndex=0; colIndex<numCols; colIndex++)
|
|
|
|
{
|
1998-08-18 03:37:04 +04:00
|
|
|
nsTableCellFrame *cellFrame = cellMap->GetCellFrameAt(rowIndex, colIndex);
|
1998-07-26 08:23:01 +04:00
|
|
|
// get the cell style info
|
|
|
|
const nsStylePosition* cellPosition;
|
|
|
|
if (nsnull!=cellFrame)
|
|
|
|
{
|
|
|
|
cellFrame->GetStyleData(eStyleStruct_Position, (const nsStyleStruct *&)cellPosition);
|
|
|
|
if ((eStyleUnit_Coord == cellPosition->mWidth.GetUnit()) ||
|
|
|
|
(eStyleUnit_Percent==cellPosition->mWidth.GetUnit()))
|
|
|
|
{
|
|
|
|
tableStyle->mCols = NS_STYLE_TABLE_COLS_NONE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-07-28 12:09:02 +04:00
|
|
|
#endif
|
1998-07-26 08:23:01 +04:00
|
|
|
}
|
|
|
|
|
1998-11-16 09:46:00 +03:00
|
|
|
/*
|
|
|
|
The rule is: use whatever width is greatest among those specified widths
|
|
|
|
that span a column. It doesn't matter what comes first, just what is biggest.
|
|
|
|
Specified widths (when colspan==1) and span widths need to be stored separately,
|
|
|
|
because specified widths tell us what proportion of the span width to give to each column
|
|
|
|
(in their absence, we use the desired width of the cell.)
|
|
|
|
*/
|
1999-07-28 12:09:02 +04:00
|
|
|
|
|
|
|
// XXX this is being phased out. cells with colspans will potentially overwrite
|
|
|
|
// col info stored by cells that don't span just because they are a bigger value.
|
|
|
|
// The fixed width column info should be gotten from nsTableColFrame::GetFixedWidth
|
1998-06-17 20:38:24 +04:00
|
|
|
NS_METHOD
|
1998-10-11 13:18:27 +04:00
|
|
|
nsTableFrame::SetColumnStyleFromCell(nsIPresContext & aPresContext,
|
1998-06-17 20:38:24 +04:00
|
|
|
nsTableCellFrame* aCellFrame,
|
|
|
|
nsTableRowFrame * aRowFrame)
|
|
|
|
{
|
1999-07-28 12:09:02 +04:00
|
|
|
#if 0
|
1998-07-26 08:23:01 +04:00
|
|
|
// if the cell has a colspan, the width is used provisionally, divided equally among
|
1998-11-16 09:46:00 +03:00
|
|
|
// the spanned columns until the table layout strategy computes the real column width.
|
1998-10-30 10:57:44 +03:00
|
|
|
if (PR_TRUE==gsDebug) printf("TIF SetCSFromCell: cell %p in row %p\n", aCellFrame, aRowFrame);
|
1998-10-11 13:18:27 +04:00
|
|
|
if ((nsnull!=aCellFrame) && (nsnull!=aRowFrame))
|
1998-06-17 20:38:24 +04:00
|
|
|
{
|
1998-07-22 07:53:43 +04:00
|
|
|
// get the cell style info
|
|
|
|
const nsStylePosition* cellPosition;
|
|
|
|
aCellFrame->GetStyleData(eStyleStruct_Position, (const nsStyleStruct *&)cellPosition);
|
|
|
|
if ((eStyleUnit_Coord == cellPosition->mWidth.GetUnit()) ||
|
|
|
|
(eStyleUnit_Percent==cellPosition->mWidth.GetUnit())) {
|
|
|
|
// compute the width per column spanned
|
1999-02-11 04:16:28 +03:00
|
|
|
PRInt32 baseColIndex;
|
|
|
|
aCellFrame->GetColIndex(baseColIndex);
|
|
|
|
PRInt32 colSpan = GetEffectiveColSpan(baseColIndex, aCellFrame);
|
1998-10-03 00:36:35 +04:00
|
|
|
if (PR_TRUE==gsDebug)
|
1999-02-11 04:16:28 +03:00
|
|
|
printf("TIF SetCSFromCell: for col %d with colspan %d\n",baseColIndex, colSpan);
|
1998-07-22 07:53:43 +04:00
|
|
|
for (PRInt32 i=0; i<colSpan; i++)
|
|
|
|
{
|
|
|
|
// get the appropriate column frame
|
|
|
|
nsTableColFrame *colFrame;
|
1999-02-11 04:16:28 +03:00
|
|
|
GetColumnFrame(i+baseColIndex, colFrame);
|
1998-10-03 00:36:35 +04:00
|
|
|
if (PR_TRUE==gsDebug)
|
1999-02-11 04:16:28 +03:00
|
|
|
printf("TIF SetCSFromCell: for col %d (%p)\n",i+baseColIndex, colFrame);
|
1998-11-16 09:46:00 +03:00
|
|
|
// if the colspan is 1 and we already have a cell that set this column's width
|
|
|
|
// then ignore this width attribute
|
|
|
|
if ((1==colSpan) && (nsTableColFrame::eWIDTH_SOURCE_CELL == colFrame->GetWidthSource()))
|
1998-06-17 20:38:24 +04:00
|
|
|
{
|
1998-10-03 00:36:35 +04:00
|
|
|
if (PR_TRUE==gsDebug)
|
1998-11-16 09:46:00 +03:00
|
|
|
printf("TIF SetCSFromCell: width already set from a cell with colspan=1, no-op this cell's width attr\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// get the column style
|
|
|
|
nsIStyleContext *colSC;
|
1999-02-10 03:42:56 +03:00
|
|
|
colFrame->GetStyleContext(&colSC);
|
1998-11-16 09:46:00 +03:00
|
|
|
nsStylePosition* colPosition = (nsStylePosition*) colSC->GetMutableStyleData(eStyleStruct_Position);
|
|
|
|
// if colSpan==1, then we can just set the column width
|
|
|
|
if (1==colSpan)
|
|
|
|
{ // set the column width attribute
|
|
|
|
if (eStyleUnit_Coord == cellPosition->mWidth.GetUnit())
|
1998-06-17 20:38:24 +04:00
|
|
|
{
|
1998-11-16 09:46:00 +03:00
|
|
|
nscoord width = cellPosition->mWidth.GetCoordValue();
|
|
|
|
colPosition->mWidth.SetCoordValue(width);
|
1998-10-03 00:36:35 +04:00
|
|
|
if (PR_TRUE==gsDebug)
|
1998-11-16 09:46:00 +03:00
|
|
|
printf("TIF SetCSFromCell: col fixed width set to %d from cell", width);
|
1998-06-17 20:38:24 +04:00
|
|
|
}
|
1998-11-16 09:46:00 +03:00
|
|
|
else
|
|
|
|
{
|
|
|
|
float width = cellPosition->mWidth.GetPercentValue();
|
|
|
|
colPosition->mWidth.SetPercentValue(width);
|
|
|
|
if (PR_TRUE==gsDebug)
|
1999-03-05 07:19:09 +03:00
|
|
|
printf("TIF SetCSFromCell: col percent width set to %g from cell", width);
|
1998-11-16 09:46:00 +03:00
|
|
|
}
|
|
|
|
colFrame->SetWidthSource(nsTableColFrame::eWIDTH_SOURCE_CELL);
|
|
|
|
}
|
|
|
|
else // we have a colspan > 1. so we need to set the column table style spanWidth
|
|
|
|
{ // if the cell is a coord width...
|
|
|
|
nsStyleTable* colTableStyle = (nsStyleTable*) colSC->GetMutableStyleData(eStyleStruct_Table);
|
|
|
|
if (eStyleUnit_Coord == cellPosition->mWidth.GetUnit())
|
|
|
|
{
|
|
|
|
// set the column width attribute iff this span's contribution to this column
|
|
|
|
// is greater than any previous information
|
|
|
|
nscoord cellWidth = cellPosition->mWidth.GetCoordValue();
|
|
|
|
nscoord widthPerColumn = cellWidth/colSpan;
|
|
|
|
nscoord widthForThisColumn = widthPerColumn;
|
|
|
|
if (eStyleUnit_Coord == colTableStyle->mSpanWidth.GetUnit())
|
|
|
|
widthForThisColumn = PR_MAX(widthForThisColumn, colTableStyle->mSpanWidth.GetCoordValue());
|
|
|
|
colTableStyle->mSpanWidth.SetCoordValue(widthForThisColumn);
|
|
|
|
if (PR_TRUE==gsDebug)
|
|
|
|
printf("TIF SetCSFromCell: col span width set to %d from spanning cell", widthForThisColumn);
|
|
|
|
}
|
|
|
|
// else if the cell has a percent width...
|
|
|
|
else if (eStyleUnit_Percent == cellPosition->mWidth.GetUnit())
|
|
|
|
{
|
|
|
|
// set the column width attribute iff this span's contribution to this column
|
|
|
|
// is greater than any previous information
|
|
|
|
float cellWidth = cellPosition->mWidth.GetPercentValue();
|
|
|
|
float percentPerColumn = cellWidth/(float)colSpan;
|
|
|
|
float percentForThisColumn = percentPerColumn;
|
|
|
|
if (eStyleUnit_Percent == colTableStyle->mSpanWidth.GetUnit())
|
|
|
|
percentForThisColumn = PR_MAX(percentForThisColumn, colTableStyle->mSpanWidth.GetPercentValue());
|
|
|
|
colTableStyle->mSpanWidth.SetPercentValue(percentForThisColumn);
|
|
|
|
if (PR_TRUE==gsDebug)
|
|
|
|
printf("TIF SetCSFromCell: col span width set to %d from spanning cell", (nscoord)percentForThisColumn);
|
|
|
|
}
|
|
|
|
colFrame->SetWidthSource(nsTableColFrame::eWIDTH_SOURCE_CELL_WITH_SPAN);
|
1998-06-17 20:38:24 +04:00
|
|
|
}
|
1998-11-16 09:46:00 +03:00
|
|
|
NS_RELEASE(colSC);
|
1998-06-17 20:38:24 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-07-28 12:09:02 +04:00
|
|
|
#endif
|
1998-06-17 20:38:24 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-06-05 06:36:25 +04:00
|
|
|
/* there's an easy way and a hard way. The easy way is to look in our
|
|
|
|
* cache and pull the frame from there.
|
|
|
|
* If the cache isn't built yet, then we have to go hunting.
|
|
|
|
*/
|
|
|
|
NS_METHOD nsTableFrame::GetColumnFrame(PRInt32 aColIndex, nsTableColFrame *&aColFrame)
|
|
|
|
{
|
|
|
|
aColFrame = nsnull; // initialize out parameter
|
1998-08-18 03:37:04 +04:00
|
|
|
nsCellMap *cellMap = GetCellMap();
|
|
|
|
if (nsnull!=cellMap)
|
1998-06-05 06:36:25 +04:00
|
|
|
{ // hooray, we get to do this the easy way because the info is cached
|
1998-08-18 03:37:04 +04:00
|
|
|
aColFrame = cellMap->GetColumnFrame(aColIndex);
|
1998-06-05 06:36:25 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // ah shucks, we have to go hunt for the column frame brute-force style
|
1999-01-16 01:52:05 +03:00
|
|
|
nsIFrame *childFrame = mColGroups.FirstChild();
|
1998-06-05 06:36:25 +04:00
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
if (nsnull==childFrame)
|
|
|
|
{
|
|
|
|
NS_ASSERTION (PR_FALSE, "scanned the frame hierarchy and no column frame could be found.");
|
|
|
|
break;
|
|
|
|
}
|
1998-12-03 21:01:35 +03:00
|
|
|
PRInt32 colGroupStartingIndex = ((nsTableColGroupFrame *)childFrame)->GetStartColumnIndex();
|
|
|
|
if (aColIndex >= colGroupStartingIndex)
|
|
|
|
{ // the cell's col might be in this col group
|
|
|
|
PRInt32 colCount = ((nsTableColGroupFrame *)childFrame)->GetColumnCount();
|
|
|
|
if (aColIndex < colGroupStartingIndex + colCount)
|
|
|
|
{ // yep, we've found it. GetColumnAt gives us the column at the offset colCount, not the absolute colIndex for the whole table
|
|
|
|
aColFrame = ((nsTableColGroupFrame *)childFrame)->GetColumnAt(colCount);
|
|
|
|
break;
|
1998-06-05 06:36:25 +04:00
|
|
|
}
|
|
|
|
}
|
1999-02-10 09:13:38 +03:00
|
|
|
childFrame->GetNextSibling(&childFrame);
|
1998-06-05 06:36:25 +04:00
|
|
|
}
|
|
|
|
}
|
1998-09-24 20:37:22 +04:00
|
|
|
NS_POSTCONDITION(nsnull!=aColFrame, "no column frame could be found.");
|
1998-06-05 06:36:25 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-10-11 13:18:27 +04:00
|
|
|
PRBool nsTableFrame::IsColumnWidthsSet()
|
|
|
|
{
|
|
|
|
nsTableFrame * firstInFlow = (nsTableFrame *)GetFirstInFlow();
|
|
|
|
NS_ASSERTION(nsnull!=firstInFlow, "illegal state -- no first in flow");
|
|
|
|
return firstInFlow->mColumnWidthsSet;
|
|
|
|
}
|
|
|
|
|
1998-06-30 04:37:03 +04:00
|
|
|
/* We have to go through our child list twice.
|
|
|
|
* The first time, we scan until we find the first row.
|
|
|
|
* We set column style from the cells in the first row.
|
|
|
|
* Then we terminate that loop and start a second pass.
|
|
|
|
* In the second pass, we build column and cell cache info.
|
|
|
|
*/
|
1999-06-15 03:42:16 +04:00
|
|
|
void nsTableFrame::SetColumnStylesFromCells(nsIPresContext& aPresContext, nsIFrame* aRowGroupFrame)
|
|
|
|
{
|
|
|
|
nsIFrame *rowFrame;
|
|
|
|
aRowGroupFrame->FirstChild(nsnull, &rowFrame);
|
|
|
|
while (nsnull!=rowFrame)
|
|
|
|
{
|
|
|
|
const nsStyleDisplay *rowDisplay;
|
|
|
|
rowFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)rowDisplay));
|
|
|
|
if (NS_STYLE_DISPLAY_TABLE_ROW_GROUP == rowDisplay->mDisplay) {
|
|
|
|
SetColumnStylesFromCells(aPresContext, rowFrame);
|
|
|
|
}
|
|
|
|
else if (NS_STYLE_DISPLAY_TABLE_ROW == rowDisplay->mDisplay)
|
|
|
|
{
|
|
|
|
nsIFrame *cellFrame;
|
|
|
|
rowFrame->FirstChild(nsnull, &cellFrame);
|
|
|
|
while (nsnull!=cellFrame)
|
|
|
|
{
|
|
|
|
/* this is the first time we are guaranteed to have both the cell frames
|
|
|
|
* and the column frames, so it's a good time to
|
|
|
|
* set the column style from the cell's width attribute (if this is the first row)
|
|
|
|
*/
|
|
|
|
const nsStyleDisplay *cellDisplay;
|
|
|
|
cellFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)cellDisplay));
|
|
|
|
if (NS_STYLE_DISPLAY_TABLE_CELL == cellDisplay->mDisplay)
|
|
|
|
SetColumnStyleFromCell(aPresContext, (nsTableCellFrame *)cellFrame, (nsTableRowFrame *)rowFrame);
|
|
|
|
cellFrame->GetNextSibling(&cellFrame);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
rowFrame->GetNextSibling(&rowFrame);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-10-16 01:07:37 +04:00
|
|
|
void nsTableFrame::BuildColumnCache( nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
1998-10-02 08:10:00 +04:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
1998-10-16 01:07:37 +04:00
|
|
|
nsReflowStatus& aStatus)
|
1998-06-17 20:38:24 +04:00
|
|
|
{
|
1998-10-14 20:32:45 +04:00
|
|
|
NS_ASSERTION(nsnull==mPrevInFlow, "never ever call me on a continuing frame!");
|
1998-09-01 01:23:28 +04:00
|
|
|
NS_ASSERTION(nsnull!=mCellMap, "never ever call me until the cell map is built!");
|
1998-10-22 10:04:37 +04:00
|
|
|
PRInt32 colIndex=0;
|
1998-12-02 19:45:20 +03:00
|
|
|
const nsStyleTable* tableStyle;
|
|
|
|
GetStyleData(eStyleStruct_Table, (const nsStyleStruct *&)tableStyle);
|
1998-09-24 01:48:26 +04:00
|
|
|
EnsureColumns(aPresContext);
|
1998-10-14 20:32:45 +04:00
|
|
|
if (nsnull!=mColCache)
|
1998-06-17 20:38:24 +04:00
|
|
|
{
|
1998-10-20 03:43:06 +04:00
|
|
|
if (PR_TRUE==gsDebugIR) printf("TIF BCC: clearing column cache and cell map column frame cache.\n");
|
1998-10-14 20:32:45 +04:00
|
|
|
mCellMap->ClearColumnCache();
|
|
|
|
delete mColCache;
|
1999-07-01 11:12:46 +04:00
|
|
|
mColCache = nsnull;
|
1998-10-14 20:32:45 +04:00
|
|
|
}
|
1998-07-11 04:00:31 +04:00
|
|
|
|
1998-10-26 22:15:31 +03:00
|
|
|
mColCache = new ColumnInfoCache(GetColCount());
|
1999-01-29 21:49:32 +03:00
|
|
|
CacheColFramesInCellMap();
|
1998-12-03 21:01:35 +03:00
|
|
|
|
|
|
|
// handle rowgroups
|
1999-06-15 03:42:16 +04:00
|
|
|
PRBool requiresPass1Layout = RequiresPass1Layout();
|
|
|
|
|
1999-01-29 21:49:32 +03:00
|
|
|
nsIFrame * childFrame = mFrames.FirstChild();
|
1998-12-03 21:01:35 +03:00
|
|
|
while (nsnull!=childFrame)
|
1999-01-29 21:49:32 +03:00
|
|
|
{ // in this loop, set column style info from cells
|
1998-12-03 21:01:35 +03:00
|
|
|
const nsStyleDisplay *childDisplay;
|
1998-12-05 04:47:37 +03:00
|
|
|
childFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)childDisplay));
|
1999-06-15 03:42:16 +04:00
|
|
|
if (PR_TRUE==IsRowGroup(childDisplay->mDisplay) && requiresPass1Layout)
|
1998-10-14 20:32:45 +04:00
|
|
|
{ // if it's a row group, get the cells and set the column style if appropriate
|
1999-06-15 03:42:16 +04:00
|
|
|
SetColumnStylesFromCells(aPresContext, childFrame);
|
1998-06-30 04:37:03 +04:00
|
|
|
}
|
1999-02-10 09:13:38 +03:00
|
|
|
childFrame->GetNextSibling(&childFrame);
|
1998-10-14 20:32:45 +04:00
|
|
|
}
|
1998-07-11 04:00:31 +04:00
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
// second time through, set column cache info for each column
|
1998-11-20 04:01:25 +03:00
|
|
|
// we can't do this until the loop above has set the column style info from the cells
|
1999-01-16 01:52:05 +03:00
|
|
|
childFrame = mColGroups.FirstChild();
|
1998-10-14 20:32:45 +04:00
|
|
|
while (nsnull!=childFrame)
|
|
|
|
{ // for every child, if it's a col group then get the columns
|
1998-12-03 21:01:35 +03:00
|
|
|
nsTableColFrame *colFrame=nsnull;
|
1999-02-10 05:25:01 +03:00
|
|
|
childFrame->FirstChild(nsnull, (nsIFrame **)&colFrame);
|
1998-12-03 21:01:35 +03:00
|
|
|
while (nsnull!=colFrame)
|
|
|
|
{ // for every column, create an entry in the column cache
|
|
|
|
// assumes that the col style has been twiddled to account for first cell width attribute
|
|
|
|
const nsStyleDisplay *colDisplay;
|
1998-12-05 04:47:37 +03:00
|
|
|
colFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)colDisplay));
|
1998-12-03 21:01:35 +03:00
|
|
|
if (NS_STYLE_DISPLAY_TABLE_COLUMN == colDisplay->mDisplay)
|
|
|
|
{
|
|
|
|
const nsStylePosition* colPosition;
|
1998-12-05 04:47:37 +03:00
|
|
|
colFrame->GetStyleData(eStyleStruct_Position, ((const nsStyleStruct *&)colPosition));
|
1998-12-03 21:01:35 +03:00
|
|
|
PRInt32 repeat = colFrame->GetSpan();
|
|
|
|
colIndex = colFrame->GetColumnIndex();
|
|
|
|
for (PRInt32 i=0; i<repeat; i++)
|
1998-10-14 20:32:45 +04:00
|
|
|
{
|
1998-12-03 21:01:35 +03:00
|
|
|
mColCache->AddColumnInfo(colPosition->mWidth.GetUnit(), colIndex+i);
|
1998-06-17 20:38:24 +04:00
|
|
|
}
|
|
|
|
}
|
1999-02-10 09:13:38 +03:00
|
|
|
colFrame->GetNextSibling((nsIFrame **)&colFrame);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1999-02-10 09:13:38 +03:00
|
|
|
childFrame->GetNextSibling(&childFrame);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1998-10-20 03:43:06 +04:00
|
|
|
if (PR_TRUE==gsDebugIR) printf("TIF BCC: mColumnCacheValid=PR_TRUE.\n");
|
1998-10-15 02:51:50 +04:00
|
|
|
mColumnCacheValid=PR_TRUE;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1999-01-29 21:49:32 +03:00
|
|
|
void nsTableFrame::CacheColFramesInCellMap()
|
|
|
|
{
|
|
|
|
nsIFrame * childFrame = mColGroups.FirstChild();
|
|
|
|
while (nsnull!=childFrame)
|
|
|
|
{ // in this loop, we cache column info
|
|
|
|
nsTableColFrame *colFrame=nsnull;
|
1999-02-10 05:25:01 +03:00
|
|
|
childFrame->FirstChild(nsnull, (nsIFrame **)&colFrame);
|
1999-01-29 21:49:32 +03:00
|
|
|
while (nsnull!=colFrame)
|
|
|
|
{
|
|
|
|
PRInt32 colIndex = colFrame->GetColumnIndex();
|
|
|
|
PRInt32 repeat = colFrame->GetSpan();
|
|
|
|
for (PRInt32 i=0; i<repeat; i++)
|
|
|
|
{
|
1999-07-28 12:09:02 +04:00
|
|
|
nsTableColFrame *cachedColFrame = mCellMap->GetColumnFrame(colIndex+i);
|
1999-01-29 21:49:32 +03:00
|
|
|
if (nsnull==cachedColFrame)
|
|
|
|
{
|
|
|
|
if (gsDebug)
|
|
|
|
printf("TIF BCB: adding column frame %p\n", colFrame);
|
|
|
|
mCellMap->AppendColumnFrame(colFrame);
|
|
|
|
}
|
|
|
|
colIndex++;
|
|
|
|
}
|
1999-02-10 09:13:38 +03:00
|
|
|
colFrame->GetNextSibling((nsIFrame **)&colFrame);
|
1999-01-29 21:49:32 +03:00
|
|
|
}
|
1999-02-10 09:13:38 +03:00
|
|
|
childFrame->GetNextSibling(&childFrame);
|
1999-01-29 21:49:32 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-10-16 01:07:37 +04:00
|
|
|
void nsTableFrame::InvalidateColumnWidths()
|
|
|
|
{
|
|
|
|
nsTableFrame * firstInFlow = (nsTableFrame *)GetFirstInFlow();
|
|
|
|
NS_ASSERTION(nsnull!=firstInFlow, "illegal state -- no first in flow");
|
|
|
|
firstInFlow->mColumnWidthsValid=PR_FALSE;
|
1998-10-20 03:43:06 +04:00
|
|
|
if (PR_TRUE==gsDebugIR) printf("TIF: ColWidths invalidated.\n");
|
1998-10-16 01:07:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
PRBool nsTableFrame::IsColumnWidthsValid() const
|
|
|
|
{
|
|
|
|
nsTableFrame * firstInFlow = (nsTableFrame *)GetFirstInFlow();
|
|
|
|
NS_ASSERTION(nsnull!=firstInFlow, "illegal state -- no first in flow");
|
|
|
|
return firstInFlow->mColumnWidthsValid;
|
|
|
|
}
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
PRBool nsTableFrame::IsFirstPassValid() const
|
|
|
|
{
|
|
|
|
nsTableFrame * firstInFlow = (nsTableFrame *)GetFirstInFlow();
|
|
|
|
NS_ASSERTION(nsnull!=firstInFlow, "illegal state -- no first in flow");
|
|
|
|
return firstInFlow->mFirstPassValid;
|
|
|
|
}
|
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
void nsTableFrame::InvalidateFirstPassCache()
|
|
|
|
{
|
|
|
|
nsTableFrame * firstInFlow = (nsTableFrame *)GetFirstInFlow();
|
|
|
|
NS_ASSERTION(nsnull!=firstInFlow, "illegal state -- no first in flow");
|
|
|
|
firstInFlow->mFirstPassValid=PR_FALSE;
|
1998-10-20 03:43:06 +04:00
|
|
|
if (PR_TRUE==gsDebugIR) printf("TIF: FirstPass invalidated.\n");
|
1998-10-14 20:32:45 +04:00
|
|
|
}
|
|
|
|
|
1998-10-15 02:51:50 +04:00
|
|
|
PRBool nsTableFrame::IsColumnCacheValid() const
|
|
|
|
{
|
|
|
|
nsTableFrame * firstInFlow = (nsTableFrame *)GetFirstInFlow();
|
|
|
|
NS_ASSERTION(nsnull!=firstInFlow, "illegal state -- no first in flow");
|
|
|
|
return firstInFlow->mColumnCacheValid;
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsTableFrame::InvalidateColumnCache()
|
|
|
|
{
|
|
|
|
nsTableFrame * firstInFlow = (nsTableFrame *)GetFirstInFlow();
|
|
|
|
NS_ASSERTION(nsnull!=firstInFlow, "illegal state -- no first in flow");
|
|
|
|
firstInFlow->mColumnCacheValid=PR_FALSE;
|
1998-10-20 03:43:06 +04:00
|
|
|
if (PR_TRUE==gsDebugIR) printf("TIF: ColCache invalidated.\n");
|
1998-10-15 02:51:50 +04:00
|
|
|
}
|
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
PRBool nsTableFrame::IsCellMapValid() const
|
|
|
|
{
|
|
|
|
nsTableFrame * firstInFlow = (nsTableFrame *)GetFirstInFlow();
|
|
|
|
NS_ASSERTION(nsnull!=firstInFlow, "illegal state -- no first in flow");
|
|
|
|
return firstInFlow->mCellMapValid;
|
|
|
|
}
|
|
|
|
|
1999-06-15 03:45:14 +04:00
|
|
|
static void InvalidateCellMapForRowGroup(nsIFrame* aRowGroupFrame)
|
|
|
|
{
|
|
|
|
nsIFrame *rowFrame;
|
|
|
|
aRowGroupFrame->FirstChild(nsnull, &rowFrame);
|
|
|
|
for ( ; nsnull!=rowFrame; rowFrame->GetNextSibling(&rowFrame))
|
|
|
|
{
|
|
|
|
const nsStyleDisplay *rowDisplay;
|
|
|
|
rowFrame->GetStyleData(eStyleStruct_Display, (const nsStyleStruct *&)rowDisplay);
|
|
|
|
if (NS_STYLE_DISPLAY_TABLE_ROW==rowDisplay->mDisplay)
|
|
|
|
{
|
|
|
|
((nsTableRowFrame *)rowFrame)->ResetInitChildren();
|
|
|
|
}
|
|
|
|
else if (NS_STYLE_DISPLAY_TABLE_ROW_GROUP==rowDisplay->mDisplay)
|
|
|
|
{
|
|
|
|
InvalidateCellMapForRowGroup(rowFrame);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
void nsTableFrame::InvalidateCellMap()
|
|
|
|
{
|
|
|
|
nsTableFrame * firstInFlow = (nsTableFrame *)GetFirstInFlow();
|
|
|
|
NS_ASSERTION(nsnull!=firstInFlow, "illegal state -- no first in flow");
|
|
|
|
firstInFlow->mCellMapValid=PR_FALSE;
|
|
|
|
// reset the state in each row
|
1999-01-16 01:52:05 +03:00
|
|
|
nsIFrame *rowGroupFrame=mFrames.FirstChild();
|
1999-02-10 09:13:38 +03:00
|
|
|
for ( ; nsnull!=rowGroupFrame; rowGroupFrame->GetNextSibling(&rowGroupFrame))
|
1998-10-14 20:32:45 +04:00
|
|
|
{
|
|
|
|
const nsStyleDisplay *rowGroupDisplay;
|
1998-12-02 19:45:20 +03:00
|
|
|
rowGroupFrame->GetStyleData(eStyleStruct_Display, (const nsStyleStruct *&)rowGroupDisplay);
|
1998-10-14 20:32:45 +04:00
|
|
|
if (PR_TRUE==IsRowGroup(rowGroupDisplay->mDisplay))
|
|
|
|
{
|
1999-06-15 03:45:14 +04:00
|
|
|
InvalidateCellMapForRowGroup(rowGroupFrame);
|
1998-10-14 20:32:45 +04:00
|
|
|
}
|
|
|
|
}
|
1998-10-20 03:43:06 +04:00
|
|
|
if (PR_TRUE==gsDebugIR) printf("TIF: CellMap invalidated.\n");
|
1998-10-14 20:32:45 +04:00
|
|
|
}
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
PRInt32 nsTableFrame::GetColumnWidth(PRInt32 aColIndex)
|
|
|
|
{
|
|
|
|
nsTableFrame * firstInFlow = (nsTableFrame *)GetFirstInFlow();
|
|
|
|
NS_ASSERTION(nsnull!=firstInFlow, "illegal state -- no first in flow");
|
|
|
|
PRInt32 result = 0;
|
|
|
|
if (this!=firstInFlow)
|
|
|
|
result = firstInFlow->GetColumnWidth(aColIndex);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
NS_ASSERTION(nsnull!=mColumnWidths, "illegal state");
|
1998-11-30 18:10:20 +03:00
|
|
|
// can't assert on IsColumnWidthsSet because we might want to call this
|
|
|
|
// while we're in the process of setting column widths, and we don't
|
|
|
|
// want to complicate IsColumnWidthsSet by making it a multiple state return value
|
|
|
|
// (like eNotSet, eSetting, eIsSet)
|
1998-09-01 01:23:28 +04:00
|
|
|
#ifdef NS_DEBUG
|
|
|
|
NS_ASSERTION(nsnull!=mCellMap, "no cell map");
|
1998-10-20 09:05:17 +04:00
|
|
|
PRInt32 numCols = mCellMap->GetColCount();
|
1998-04-17 02:21:32 +04:00
|
|
|
NS_ASSERTION (numCols > aColIndex, "bad arg, col index out of bounds");
|
|
|
|
#endif
|
1998-04-14 00:24:54 +04:00
|
|
|
if (nsnull!=mColumnWidths)
|
|
|
|
result = mColumnWidths[aColIndex];
|
|
|
|
}
|
1998-04-17 02:21:32 +04:00
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1998-06-05 22:11:20 +04:00
|
|
|
void nsTableFrame::SetColumnWidth(PRInt32 aColIndex, nscoord aWidth)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
nsTableFrame * firstInFlow = (nsTableFrame *)GetFirstInFlow();
|
|
|
|
NS_ASSERTION(nsnull!=firstInFlow, "illegal state -- no first in flow");
|
1998-09-01 01:23:28 +04:00
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
if (this!=firstInFlow)
|
|
|
|
firstInFlow->SetColumnWidth(aColIndex, aWidth);
|
|
|
|
else
|
|
|
|
{
|
1998-10-11 13:18:27 +04:00
|
|
|
NS_ASSERTION(nsnull!=mColumnWidths, "illegal state, nsnull mColumnWidths");
|
|
|
|
NS_ASSERTION(aColIndex<mColumnWidthsLength, "illegal state, aColIndex<mColumnWidthsLength");
|
|
|
|
if (nsnull!=mColumnWidths && aColIndex<mColumnWidthsLength)
|
1998-04-14 00:24:54 +04:00
|
|
|
mColumnWidths[aColIndex] = aWidth;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-05-27 00:57:24 +04:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Update the border style to map to the HTML border style
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void nsTableFrame::MapHTMLBorderStyle(nsStyleSpacing& aSpacingStyle, nscoord aBorderWidth)
|
|
|
|
{
|
|
|
|
nsStyleCoord width;
|
|
|
|
width.SetCoordValue(aBorderWidth);
|
|
|
|
aSpacingStyle.mBorder.SetTop(width);
|
|
|
|
aSpacingStyle.mBorder.SetLeft(width);
|
|
|
|
aSpacingStyle.mBorder.SetBottom(width);
|
|
|
|
aSpacingStyle.mBorder.SetRight(width);
|
|
|
|
|
1999-01-23 01:38:34 +03:00
|
|
|
aSpacingStyle.SetBorderStyle(NS_SIDE_TOP, NS_STYLE_BORDER_STYLE_BG_OUTSET);
|
|
|
|
aSpacingStyle.SetBorderStyle(NS_SIDE_LEFT, NS_STYLE_BORDER_STYLE_BG_OUTSET);
|
|
|
|
aSpacingStyle.SetBorderStyle(NS_SIDE_BOTTOM, NS_STYLE_BORDER_STYLE_BG_OUTSET);
|
|
|
|
aSpacingStyle.SetBorderStyle(NS_SIDE_RIGHT, NS_STYLE_BORDER_STYLE_BG_OUTSET);
|
1998-05-27 00:57:24 +04:00
|
|
|
|
|
|
|
nsIStyleContext* styleContext = mStyleContext;
|
1998-06-17 20:38:24 +04:00
|
|
|
const nsStyleColor* colorData = (const nsStyleColor*)
|
|
|
|
styleContext->GetStyleData(eStyleStruct_Color);
|
1998-05-27 00:57:24 +04:00
|
|
|
|
|
|
|
// Look until we find a style context with a NON-transparent background color
|
|
|
|
while (styleContext)
|
|
|
|
{
|
|
|
|
if ((colorData->mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT)!=0)
|
|
|
|
{
|
|
|
|
nsIStyleContext* temp = styleContext;
|
|
|
|
styleContext = styleContext->GetParent();
|
|
|
|
if (temp != mStyleContext)
|
|
|
|
NS_RELEASE(temp);
|
1998-06-05 10:09:09 +04:00
|
|
|
colorData = (const nsStyleColor*)styleContext->GetStyleData(eStyleStruct_Color);
|
1998-05-27 00:57:24 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Yaahoo, we found a style context which has a background color
|
|
|
|
|
|
|
|
nscolor borderColor = 0xFFC0C0C0;
|
|
|
|
|
|
|
|
if (styleContext != nsnull)
|
|
|
|
{
|
|
|
|
borderColor = colorData->mBackgroundColor;
|
|
|
|
if (styleContext != mStyleContext)
|
|
|
|
NS_RELEASE(styleContext);
|
|
|
|
}
|
|
|
|
|
|
|
|
// if the border color is white, then shift to grey
|
|
|
|
if (borderColor == 0xFFFFFFFF)
|
|
|
|
borderColor = 0xFFC0C0C0;
|
|
|
|
|
1998-12-07 22:07:45 +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-05-27 00:57:24 +04:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PRBool nsTableFrame::ConvertToPixelValue(nsHTMLValue& aValue, PRInt32 aDefault, PRInt32& aResult)
|
|
|
|
{
|
|
|
|
if (aValue.GetUnit() == eHTMLUnit_Pixel)
|
|
|
|
aResult = aValue.GetPixelValue();
|
|
|
|
else if (aValue.GetUnit() == eHTMLUnit_Empty)
|
|
|
|
aResult = aDefault;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
NS_ERROR("Unit must be pixel or empty");
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
|
1998-10-11 13:18:27 +04:00
|
|
|
void nsTableFrame::MapBorderMarginPadding(nsIPresContext& aPresContext)
|
1998-05-27 00:57:24 +04:00
|
|
|
{
|
1998-09-15 21:58:24 +04:00
|
|
|
#if 0
|
1998-05-27 00:57:24 +04:00
|
|
|
// 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
|
|
|
|
|
|
|
|
nsHTMLValue padding_value;
|
|
|
|
nsHTMLValue spacing_value;
|
|
|
|
nsHTMLValue border_value;
|
|
|
|
|
|
|
|
|
1998-08-30 00:20:38 +04:00
|
|
|
nsresult border_result;
|
1998-05-27 00:57:24 +04:00
|
|
|
|
|
|
|
nscoord padding = 0;
|
|
|
|
nscoord spacing = 0;
|
|
|
|
nscoord border = 1;
|
|
|
|
|
1998-10-11 13:18:27 +04:00
|
|
|
float p2t = aPresContext.GetPixelsToTwips();
|
1998-05-27 00:57:24 +04:00
|
|
|
|
1998-09-15 21:58:24 +04:00
|
|
|
nsIHTMLContent* table = (nsIHTMLContent*)mContent;
|
1998-05-27 00:57:24 +04:00
|
|
|
|
|
|
|
NS_ASSERTION(table,"Table Must not be null");
|
|
|
|
if (!table)
|
|
|
|
return;
|
|
|
|
|
1998-06-05 10:09:09 +04:00
|
|
|
nsStyleSpacing* spacingData = (nsStyleSpacing*)mStyleContext->GetMutableStyleData(eStyleStruct_Spacing);
|
1998-05-27 00:57:24 +04:00
|
|
|
|
|
|
|
border_result = table->GetAttribute(nsHTMLAtoms::border,border_value);
|
1998-08-30 00:20:38 +04:00
|
|
|
if (border_result == NS_CONTENT_ATTR_HAS_VALUE)
|
1998-05-27 00:57:24 +04:00
|
|
|
{
|
|
|
|
PRInt32 intValue = 0;
|
|
|
|
|
1998-11-14 04:52:27 +03:00
|
|
|
if (ConvertToPixelValue(border_value,1,intValue)) //XXX this is busted if this code is ever used again. MMP
|
1998-08-01 03:34:45 +04:00
|
|
|
border = NSIntPixelsToTwips(intValue, p2t);
|
1998-05-27 00:57:24 +04:00
|
|
|
}
|
|
|
|
MapHTMLBorderStyle(*spacingData,border);
|
1998-09-15 21:58:24 +04:00
|
|
|
#endif
|
1998-05-27 00:57:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-06-17 20:38:24 +04:00
|
|
|
NS_METHOD nsTableFrame::GetCellMarginData(nsTableCellFrame* aKidFrame, nsMargin& aMargin)
|
1998-05-22 03:43:18 +04:00
|
|
|
{
|
|
|
|
nsresult result = NS_ERROR_NOT_INITIALIZED;
|
|
|
|
|
1998-06-17 20:38:24 +04:00
|
|
|
if (nsnull != aKidFrame)
|
1998-05-22 03:43:18 +04:00
|
|
|
{
|
1998-07-11 04:00:31 +04:00
|
|
|
result = aKidFrame->GetMargin(aMargin);
|
1998-05-22 03:43:18 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1998-12-21 22:20:37 +03:00
|
|
|
//XXX: ok, this looks dumb now. but in a very short time this will get filled in
|
|
|
|
void nsTableFrame::GetTableBorder(nsMargin &aBorder)
|
|
|
|
{
|
|
|
|
if (NS_STYLE_BORDER_COLLAPSE==GetBorderCollapseStyle())
|
1998-12-23 18:47:43 +03:00
|
|
|
{
|
|
|
|
aBorder = mBorderEdges.mMaxBorderWidth;
|
|
|
|
}
|
|
|
|
else
|
1998-12-21 22:20:37 +03:00
|
|
|
{
|
|
|
|
const nsStyleSpacing* spacing =
|
|
|
|
(const nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing);
|
|
|
|
spacing->GetBorder(aBorder);
|
|
|
|
}
|
1998-12-23 18:47:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
now I need to actually use gettableborderat, instead of assuming that the table border is homogenous
|
|
|
|
across rows and columns. in tableFrame, LayoutStrategy, and cellFrame, maybe rowFrame
|
|
|
|
need something similar for cell (for those with spans?)
|
|
|
|
*/
|
|
|
|
|
|
|
|
void nsTableFrame::GetTableBorderAt(nsMargin &aBorder, PRInt32 aRowIndex, PRInt32 aColIndex)
|
|
|
|
{
|
|
|
|
if (NS_STYLE_BORDER_COLLAPSE==GetBorderCollapseStyle())
|
|
|
|
{
|
|
|
|
nsBorderEdge *border = (nsBorderEdge *)(mBorderEdges.mEdges[NS_SIDE_LEFT].ElementAt(aRowIndex));
|
1999-02-23 12:01:21 +03:00
|
|
|
if (border) {
|
1998-12-23 18:47:43 +03:00
|
|
|
aBorder.left = border->mWidth;
|
|
|
|
border = (nsBorderEdge *)(mBorderEdges.mEdges[NS_SIDE_RIGHT].ElementAt(aRowIndex));
|
|
|
|
aBorder.right = border->mWidth;
|
|
|
|
border = (nsBorderEdge *)(mBorderEdges.mEdges[NS_SIDE_TOP].ElementAt(aColIndex));
|
|
|
|
aBorder.top = border->mWidth;
|
|
|
|
border = (nsBorderEdge *)(mBorderEdges.mEdges[NS_SIDE_TOP].ElementAt(aColIndex));
|
|
|
|
aBorder.bottom = border->mWidth;
|
1999-02-23 12:01:21 +03:00
|
|
|
}
|
1998-12-23 18:47:43 +03:00
|
|
|
}
|
1998-12-21 22:20:37 +03:00
|
|
|
else
|
|
|
|
{
|
|
|
|
const nsStyleSpacing* spacing =
|
|
|
|
(const nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing);
|
|
|
|
spacing->GetBorder(aBorder);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-12-23 18:47:43 +03:00
|
|
|
void nsTableFrame::GetTableBorderForRowGroup(nsTableRowGroupFrame * aRowGroupFrame, nsMargin &aBorder)
|
|
|
|
{
|
|
|
|
aBorder.SizeTo(0,0,0,0);
|
|
|
|
if (nsnull!=aRowGroupFrame)
|
|
|
|
{
|
|
|
|
if (NS_STYLE_BORDER_COLLAPSE==GetBorderCollapseStyle())
|
|
|
|
{
|
|
|
|
PRInt32 rowIndex = aRowGroupFrame->GetStartRowIndex();
|
|
|
|
PRInt32 rowCount;
|
|
|
|
aRowGroupFrame->GetRowCount(rowCount);
|
|
|
|
for ( ; rowIndex<rowCount; rowIndex++)
|
|
|
|
{
|
|
|
|
PRInt32 colIndex = 0;
|
|
|
|
nsCellMap *cellMap = GetCellMap();
|
|
|
|
PRInt32 colCount = cellMap->GetColCount();
|
|
|
|
for ( ; colIndex<colCount; colIndex++)
|
|
|
|
{
|
|
|
|
nsMargin border;
|
|
|
|
GetTableBorderAt (border, rowIndex, colIndex);
|
|
|
|
aBorder.top = PR_MAX(aBorder.top, border.top);
|
|
|
|
aBorder.right = PR_MAX(aBorder.right, border.right);
|
|
|
|
aBorder.bottom = PR_MAX(aBorder.bottom, border.bottom);
|
|
|
|
aBorder.left = PR_MAX(aBorder.left, border.left);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GetTableBorder (aBorder);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-12-09 09:37:18 +03:00
|
|
|
PRUint8 nsTableFrame::GetBorderCollapseStyle()
|
|
|
|
{
|
|
|
|
const nsStyleTable* tableStyle;
|
|
|
|
GetStyleData(eStyleStruct_Table, (const nsStyleStruct *&)tableStyle);
|
|
|
|
return tableStyle->mBorderCollapse;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-12-05 08:27:21 +03:00
|
|
|
// XXX: could cache this. But be sure to check style changes if you do!
|
1998-12-09 09:37:18 +03:00
|
|
|
nscoord nsTableFrame::GetCellSpacingX()
|
1998-07-17 03:23:31 +04:00
|
|
|
{
|
1998-12-02 19:45:20 +03:00
|
|
|
const nsStyleTable* tableStyle;
|
|
|
|
GetStyleData(eStyleStruct_Table, (const nsStyleStruct *&)tableStyle);
|
1998-07-17 03:23:31 +04:00
|
|
|
nscoord cellSpacing = 0;
|
1998-12-09 09:37:18 +03:00
|
|
|
PRUint8 borderCollapseStyle = GetBorderCollapseStyle();
|
1999-05-18 09:18:16 +04:00
|
|
|
if (NS_STYLE_BORDER_COLLAPSE!=borderCollapseStyle) {
|
1998-12-09 09:37:18 +03:00
|
|
|
if (tableStyle->mBorderSpacingX.GetUnit() == eStyleUnit_Coord) {
|
|
|
|
cellSpacing = tableStyle->mBorderSpacingX.GetCoordValue();
|
|
|
|
}
|
1998-12-05 08:27:21 +03:00
|
|
|
}
|
1998-12-09 09:37:18 +03:00
|
|
|
return cellSpacing;
|
|
|
|
}
|
|
|
|
|
1999-05-18 09:18:16 +04:00
|
|
|
// XXX: could cache this. But be sure to check style changes if you do!
|
1998-12-09 09:37:18 +03:00
|
|
|
nscoord nsTableFrame::GetCellSpacingY()
|
|
|
|
{
|
|
|
|
const nsStyleTable* tableStyle;
|
|
|
|
GetStyleData(eStyleStruct_Table, (const nsStyleStruct *&)tableStyle);
|
|
|
|
nscoord cellSpacing = 0;
|
|
|
|
PRUint8 borderCollapseStyle = GetBorderCollapseStyle();
|
1999-05-18 09:18:16 +04:00
|
|
|
if (NS_STYLE_BORDER_COLLAPSE!=borderCollapseStyle) {
|
1998-12-09 09:37:18 +03:00
|
|
|
if (tableStyle->mBorderSpacingY.GetUnit() == eStyleUnit_Coord) {
|
|
|
|
cellSpacing = tableStyle->mBorderSpacingY.GetCoordValue();
|
|
|
|
}
|
1998-12-05 08:27:21 +03:00
|
|
|
}
|
1998-07-17 03:23:31 +04:00
|
|
|
return cellSpacing;
|
|
|
|
}
|
|
|
|
|
1999-05-18 09:18:16 +04:00
|
|
|
// Get the cellpadding defined on the table. Each cell can override this with style
|
1998-12-05 08:27:21 +03:00
|
|
|
nscoord nsTableFrame::GetCellPadding()
|
|
|
|
{
|
|
|
|
const nsStyleTable* tableStyle;
|
|
|
|
GetStyleData(eStyleStruct_Table, (const nsStyleStruct *&)tableStyle);
|
1999-05-18 09:18:16 +04:00
|
|
|
nscoord cellPadding = -1;
|
1998-12-05 08:27:21 +03:00
|
|
|
if (tableStyle->mCellPadding.GetUnit() == eStyleUnit_Coord) {
|
|
|
|
cellPadding = tableStyle->mCellPadding.GetCoordValue();
|
|
|
|
}
|
|
|
|
return cellPadding;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-06-05 06:36:25 +04:00
|
|
|
void nsTableFrame::GetColumnsByType(const nsStyleUnit aType,
|
|
|
|
PRInt32& aOutNumColumns,
|
|
|
|
PRInt32 *& aOutColumnIndexes)
|
|
|
|
{
|
|
|
|
mColCache->GetColumnsByType(aType, aOutNumColumns, aOutColumnIndexes);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-06-24 03:23:21 +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
|
1999-05-12 02:03:29 +04:00
|
|
|
NS_NewTableFrame(nsIFrame** aNewFrame)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-05-12 02:03:29 +04:00
|
|
|
NS_PRECONDITION(aNewFrame, "null OUT ptr");
|
|
|
|
if (nsnull == aNewFrame) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
nsTableFrame* it = new nsTableFrame;
|
1998-04-14 00:24:54 +04:00
|
|
|
if (nsnull == it) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
1999-05-12 02:03:29 +04:00
|
|
|
*aNewFrame = it;
|
1998-04-14 00:24:54 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
NS_METHOD nsTableFrame::GetTableFrame(nsIFrame *aSourceFrame, nsTableFrame *& aTableFrame)
|
1998-09-24 20:37:22 +04:00
|
|
|
{
|
1998-11-16 09:46:00 +03:00
|
|
|
nsresult rv = NS_ERROR_UNEXPECTED; // the value returned
|
|
|
|
aTableFrame = nsnull; // initialize out-param
|
|
|
|
nsIFrame *parentFrame=nsnull;
|
1998-09-24 20:37:22 +04:00
|
|
|
if (nsnull!=aSourceFrame)
|
|
|
|
{
|
1998-11-16 09:46:00 +03:00
|
|
|
// "result" is the result of intermediate calls, not the result we return from this method
|
1999-02-10 04:36:30 +03:00
|
|
|
nsresult result = aSourceFrame->GetParent((nsIFrame **)&parentFrame);
|
1998-11-16 09:46:00 +03:00
|
|
|
while ((NS_OK==result) && (nsnull!=parentFrame))
|
1998-09-24 20:37:22 +04:00
|
|
|
{
|
|
|
|
const nsStyleDisplay *display;
|
1998-12-02 19:45:20 +03:00
|
|
|
parentFrame->GetStyleData(eStyleStruct_Display, (const nsStyleStruct *&)display);
|
1998-09-24 20:37:22 +04:00
|
|
|
if (NS_STYLE_DISPLAY_TABLE == display->mDisplay)
|
1998-10-14 20:32:45 +04:00
|
|
|
{
|
1998-11-16 09:46:00 +03:00
|
|
|
aTableFrame = (nsTableFrame *)parentFrame;
|
|
|
|
rv = NS_OK; // only set if we found the table frame
|
1998-09-24 20:37:22 +04:00
|
|
|
break;
|
1998-10-14 20:32:45 +04:00
|
|
|
}
|
1999-02-10 04:36:30 +03:00
|
|
|
result = parentFrame->GetParent((nsIFrame **)&parentFrame);
|
1998-09-24 20:37:22 +04:00
|
|
|
}
|
|
|
|
}
|
1998-10-14 20:32:45 +04:00
|
|
|
NS_POSTCONDITION(nsnull!=aTableFrame, "unable to find table parent. aTableFrame null.");
|
1998-11-16 09:46:00 +03:00
|
|
|
NS_POSTCONDITION(NS_OK==rv, "unable to find table parent. result!=NS_OK");
|
|
|
|
return rv;
|
1998-09-24 20:37:22 +04:00
|
|
|
}
|
|
|
|
|
1998-09-01 01:23:28 +04:00
|
|
|
/* helper method for determining if this is a nested table or not */
|
1999-03-01 09:40:24 +03:00
|
|
|
// aReflowState must be the reflow state for this inner table frame, should have an assertion here for that
|
1998-12-02 19:45:20 +03:00
|
|
|
PRBool nsTableFrame::IsNested(const nsHTMLReflowState& aReflowState, const nsStylePosition *& aPosition) const
|
1998-09-01 01:23:28 +04:00
|
|
|
{
|
|
|
|
PRBool result = PR_FALSE;
|
|
|
|
// Walk up the reflow state chain until we find a cell or the root
|
1999-03-01 09:40:24 +03:00
|
|
|
const nsReflowState* rs = aReflowState.parentReflowState; // this is for the outer frame
|
|
|
|
if (rs)
|
|
|
|
rs = rs->parentReflowState; // and this is the parent of the outer frame
|
1998-09-01 01:23:28 +04:00
|
|
|
while (nsnull != rs)
|
|
|
|
{
|
1998-11-06 00:42:46 +03:00
|
|
|
const nsStyleDisplay *display;
|
1998-12-02 19:45:20 +03:00
|
|
|
rs->frame->GetStyleData(eStyleStruct_Display, (const nsStyleStruct *&)display);
|
1998-11-06 00:42:46 +03:00
|
|
|
if (NS_STYLE_DISPLAY_TABLE==display->mDisplay)
|
1998-09-01 01:23:28 +04:00
|
|
|
{
|
|
|
|
result = PR_TRUE;
|
1998-12-02 19:45:20 +03:00
|
|
|
rs->frame->GetStyleData(eStyleStruct_Position, ((const nsStyleStruct *&)aPosition));
|
1998-09-01 01:23:28 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
rs = rs->parentReflowState;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1998-09-24 08:57:30 +04:00
|
|
|
|
1998-06-05 06:36:25 +04:00
|
|
|
/* helper method for getting the width of the table's containing block */
|
1998-10-02 08:10:00 +04:00
|
|
|
nscoord nsTableFrame::GetTableContainerWidth(const nsHTMLReflowState& aReflowState)
|
1998-06-05 06:36:25 +04:00
|
|
|
{
|
1998-11-06 00:42:46 +03:00
|
|
|
const nsStyleDisplay *display;
|
1999-01-06 02:31:18 +03:00
|
|
|
nscoord parentWidth = aReflowState.availableWidth;
|
1998-06-05 06:36:25 +04:00
|
|
|
|
|
|
|
// Walk up the reflow state chain until we find a block
|
|
|
|
// frame. Our width is computed relative to there.
|
|
|
|
const nsReflowState* rs = &aReflowState;
|
1998-11-20 04:01:25 +03:00
|
|
|
nsTableCellFrame *lastCellFrame=nsnull;
|
1998-06-24 03:23:21 +04:00
|
|
|
while (nsnull != rs)
|
|
|
|
{
|
|
|
|
// if it's a block, use its max width
|
1998-12-02 19:45:20 +03:00
|
|
|
rs->frame->GetStyleData(eStyleStruct_Display, (const nsStyleStruct *&)display);
|
1998-11-06 00:42:46 +03:00
|
|
|
if (NS_STYLE_DISPLAY_BLOCK==display->mDisplay)
|
1998-06-24 03:23:21 +04:00
|
|
|
{ // we found a block, see if it's really a table cell (which means we're a nested table)
|
|
|
|
PRBool skipThisBlock=PR_FALSE;
|
1998-11-04 22:33:27 +03:00
|
|
|
const nsReflowState* parentRS = rs->parentReflowState;
|
|
|
|
if (nsnull!=parentRS)
|
1998-06-24 03:23:21 +04:00
|
|
|
{
|
1998-11-04 22:33:27 +03:00
|
|
|
parentRS = parentRS->parentReflowState;
|
1998-06-24 03:23:21 +04:00
|
|
|
if (nsnull!=parentRS)
|
|
|
|
{
|
1998-12-02 19:45:20 +03:00
|
|
|
parentRS->frame->GetStyleData(eStyleStruct_Display, (const nsStyleStruct *&)display);
|
1998-11-06 00:42:46 +03:00
|
|
|
if (NS_STYLE_DISPLAY_TABLE_CELL==display->mDisplay) {
|
1998-11-04 22:33:27 +03:00
|
|
|
if (PR_TRUE==gsDebugNT)
|
1998-11-06 00:42:46 +03:00
|
|
|
printf("%p: found a block pframe %p in a cell, skipping it.\n", aReflowState.frame, rs->frame);
|
1998-11-04 22:33:27 +03:00
|
|
|
skipThisBlock = PR_TRUE;
|
1998-06-24 03:23:21 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// at this point, we know we have a block. If we're sure it's not a table cell pframe,
|
|
|
|
// then we can use it
|
|
|
|
if (PR_FALSE==skipThisBlock)
|
|
|
|
{
|
1999-01-06 02:31:18 +03:00
|
|
|
if (NS_UNCONSTRAINEDSIZE!=rs->availableWidth)
|
1998-07-18 01:02:28 +04:00
|
|
|
{
|
1999-01-06 02:31:18 +03:00
|
|
|
parentWidth = rs->availableWidth;
|
1998-07-18 01:02:28 +04:00
|
|
|
if (PR_TRUE==gsDebugNT)
|
|
|
|
printf("%p: found a block frame %p, returning width %d\n",
|
1998-11-06 00:42:46 +03:00
|
|
|
aReflowState.frame, rs->frame, parentWidth);
|
1998-07-18 01:02:28 +04:00
|
|
|
break;
|
|
|
|
}
|
1998-06-24 03:23:21 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// or if it's another table (we're nested) use its computed width
|
1998-06-24 23:13:19 +04:00
|
|
|
if (rs->frame!=aReflowState.frame)
|
|
|
|
{
|
1998-06-26 04:48:44 +04:00
|
|
|
nsMargin borderPadding;
|
|
|
|
const nsStylePosition* tablePosition;
|
|
|
|
const nsStyleSpacing* spacing;
|
1998-12-02 19:45:20 +03:00
|
|
|
rs->frame->GetStyleData(eStyleStruct_Display, (const nsStyleStruct *&)display);
|
1998-11-06 00:42:46 +03:00
|
|
|
if (NS_STYLE_DISPLAY_TABLE_CELL==display->mDisplay)
|
|
|
|
{ // if it's a cell and the cell has a specified width, use it
|
1998-06-24 23:13:19 +04:00
|
|
|
// Compute and subtract out the insets (sum of border and padding) for the table
|
1998-11-20 04:01:25 +03:00
|
|
|
lastCellFrame = (nsTableCellFrame*)(rs->frame);
|
1998-09-16 04:48:14 +04:00
|
|
|
const nsStylePosition* cellPosition;
|
1998-12-02 19:45:20 +03:00
|
|
|
lastCellFrame->GetStyleData(eStyleStruct_Position, ((const nsStyleStruct *&)cellPosition));
|
1998-09-16 04:48:14 +04:00
|
|
|
if (eStyleUnit_Coord == cellPosition->mWidth.GetUnit())
|
1998-06-24 04:40:33 +04:00
|
|
|
{
|
1998-08-10 06:16:18 +04:00
|
|
|
nsTableFrame *tableParent;
|
1998-11-20 04:01:25 +03:00
|
|
|
nsresult rv=GetTableFrame(lastCellFrame, tableParent);
|
1998-09-24 20:37:22 +04:00
|
|
|
if ((NS_OK==rv) && (nsnull!=tableParent) && (nsnull!=tableParent->mColumnWidths))
|
1998-08-10 06:16:18 +04:00
|
|
|
{
|
1998-09-16 04:48:14 +04:00
|
|
|
parentWidth=0;
|
1999-02-11 04:16:28 +03:00
|
|
|
PRInt32 colIndex;
|
|
|
|
lastCellFrame->GetColIndex(colIndex);
|
1998-11-20 04:01:25 +03:00
|
|
|
PRInt32 colSpan = tableParent->GetEffectiveColSpan(colIndex, lastCellFrame);
|
1998-09-16 04:48:14 +04:00
|
|
|
for (PRInt32 i=0; i<colSpan; i++)
|
|
|
|
parentWidth += tableParent->GetColumnWidth(colIndex);
|
1998-08-10 06:16:18 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
// if the column width of this cell is already computed, it overrides the attribute
|
|
|
|
// otherwise, use the attribute becauase the actual column width has not yet been computed
|
|
|
|
else
|
|
|
|
{
|
1998-09-16 04:48:14 +04:00
|
|
|
parentWidth = cellPosition->mWidth.GetCoordValue();
|
1998-08-10 06:16:18 +04:00
|
|
|
// subtract out cell border and padding
|
1998-11-20 04:01:25 +03:00
|
|
|
lastCellFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing);
|
1998-12-23 18:47:43 +03:00
|
|
|
spacing->CalcBorderPaddingFor(lastCellFrame, borderPadding); //XXX: COLLAPSE
|
1998-08-10 06:16:18 +04:00
|
|
|
parentWidth -= (borderPadding.right + borderPadding.left);
|
|
|
|
if (PR_TRUE==gsDebugNT)
|
|
|
|
printf("%p: found a cell frame %p with fixed coord width %d, returning parentWidth %d\n",
|
1998-11-20 04:01:25 +03:00
|
|
|
aReflowState.frame, lastCellFrame, cellPosition->mWidth.GetCoordValue(), parentWidth);
|
1998-08-10 06:16:18 +04:00
|
|
|
break;
|
|
|
|
}
|
1998-06-26 04:48:44 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1998-12-02 19:45:20 +03:00
|
|
|
rs->frame->GetStyleData(eStyleStruct_Display, (const nsStyleStruct *&)display);
|
1998-11-06 00:42:46 +03:00
|
|
|
if (NS_STYLE_DISPLAY_TABLE==display->mDisplay)
|
|
|
|
{
|
|
|
|
// we only want to do this for inner table frames, so check the frame's parent to make sure it is an outer table frame
|
|
|
|
// we know that if both the frame and it's parent map to NS_STYLE_DISPLAY_TABLE, then we have an inner table frame
|
|
|
|
nsIFrame * tableFrameParent;
|
1999-02-10 04:36:30 +03:00
|
|
|
rs->frame->GetParent(&tableFrameParent);
|
1998-12-02 19:45:20 +03:00
|
|
|
tableFrameParent->GetStyleData(eStyleStruct_Display, (const nsStyleStruct *&)display);
|
1998-11-06 00:42:46 +03:00
|
|
|
if (NS_STYLE_DISPLAY_TABLE==display->mDisplay)
|
1998-06-24 23:13:19 +04:00
|
|
|
{
|
1998-11-06 00:42:46 +03:00
|
|
|
/* We found the nearest containing table (actually, the inner table).
|
|
|
|
This defines what our percentage size is relative to. Use its desired width
|
|
|
|
as the basis for computing our width.
|
|
|
|
**********************************************************************************
|
|
|
|
Nav4 compatibility code: if the inner table has a percent width and the outer
|
|
|
|
table has an auto width, the parentWidth is the width the containing cell would be
|
|
|
|
without the inner table.
|
|
|
|
**********************************************************************************
|
|
|
|
*/
|
|
|
|
// Compute and subtract out the insets (sum of border and padding) for the table
|
|
|
|
rs->frame->GetStyleData(eStyleStruct_Position, (const nsStyleStruct *&)tablePosition);
|
|
|
|
rs->frame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing);
|
|
|
|
if (eStyleUnit_Auto == tablePosition->mWidth.GetUnit())
|
1998-07-17 03:23:31 +04:00
|
|
|
{
|
1998-11-06 00:42:46 +03:00
|
|
|
parentWidth = NS_UNCONSTRAINEDSIZE;
|
1998-11-20 04:01:25 +03:00
|
|
|
if (nsnull != ((nsTableFrame*)(rs->frame))->mColumnWidths)
|
1998-08-18 03:37:04 +04:00
|
|
|
{
|
1998-11-06 00:42:46 +03:00
|
|
|
parentWidth=0;
|
1999-02-11 04:16:28 +03:00
|
|
|
PRInt32 colIndex;
|
|
|
|
lastCellFrame->GetColIndex(colIndex);
|
1998-11-20 04:01:25 +03:00
|
|
|
PRInt32 colSpan = ((nsTableFrame*)(rs->frame))->GetEffectiveColSpan(colIndex, lastCellFrame);
|
1998-11-06 00:42:46 +03:00
|
|
|
for (PRInt32 i = 0; i<colSpan; i++)
|
1998-11-20 04:01:25 +03:00
|
|
|
parentWidth += ((nsTableFrame*)(rs->frame))->GetColumnWidth(i+colIndex);
|
1998-11-06 00:42:46 +03:00
|
|
|
// subtract out cell border and padding
|
1998-11-20 04:01:25 +03:00
|
|
|
lastCellFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing);
|
1998-12-23 18:47:43 +03:00
|
|
|
spacing->CalcBorderPaddingFor(lastCellFrame, borderPadding); //XXX: COLLAPSE
|
1998-08-18 03:37:04 +04:00
|
|
|
parentWidth -= (borderPadding.right + borderPadding.left);
|
1998-11-06 00:42:46 +03:00
|
|
|
if (PR_TRUE==gsDebugNT)
|
|
|
|
printf("%p: found a table frame %p with auto width, returning parentWidth %d from cell in col %d with span %d\n",
|
|
|
|
aReflowState.frame, rs->frame, parentWidth, colIndex, colSpan);
|
1998-08-18 03:37:04 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1998-11-06 00:42:46 +03:00
|
|
|
if (PR_TRUE==gsDebugNT)
|
|
|
|
printf("%p: found a table frame %p with auto width, returning parentWidth %d because parent has no info yet.\n",
|
|
|
|
aReflowState.frame, rs->frame, parentWidth);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1998-11-30 18:10:20 +03:00
|
|
|
if (PR_TRUE==((nsTableFrame*)(rs->frame))->IsColumnWidthsSet())
|
1998-11-06 00:42:46 +03:00
|
|
|
{
|
|
|
|
parentWidth=0;
|
1999-02-11 04:16:28 +03:00
|
|
|
PRInt32 colIndex;
|
|
|
|
lastCellFrame->GetColIndex(colIndex);
|
1998-11-20 04:01:25 +03:00
|
|
|
PRInt32 colSpan = ((nsTableFrame*)(rs->frame))->GetEffectiveColSpan(colIndex, lastCellFrame);
|
1998-11-06 00:42:46 +03:00
|
|
|
for (PRInt32 i = 0; i<colSpan; i++)
|
1998-11-20 04:01:25 +03:00
|
|
|
parentWidth += ((nsTableFrame*)(rs->frame))->GetColumnWidth(i+colIndex);
|
1998-11-30 18:10:20 +03:00
|
|
|
// factor in the cell
|
|
|
|
lastCellFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing);
|
1998-12-23 18:47:43 +03:00
|
|
|
spacing->CalcBorderPaddingFor(lastCellFrame, borderPadding); //XXX: COLLAPSE
|
1998-11-30 18:10:20 +03:00
|
|
|
parentWidth -= (borderPadding.right + borderPadding.left);
|
1998-08-18 03:37:04 +04:00
|
|
|
}
|
1998-11-06 00:42:46 +03:00
|
|
|
else
|
|
|
|
{
|
|
|
|
nsSize tableSize;
|
|
|
|
rs->frame->GetSize(tableSize);
|
|
|
|
parentWidth = tableSize.width;
|
|
|
|
if (0!=tableSize.width)
|
|
|
|
{ // the table has been sized, so we can compute the available space for the child
|
1998-12-23 18:47:43 +03:00
|
|
|
((nsTableFrame *)(rs->frame))->GetTableBorder (borderPadding);
|
|
|
|
nsMargin padding;
|
|
|
|
spacing->GetPadding(padding);
|
|
|
|
borderPadding += padding;
|
1998-11-06 00:42:46 +03:00
|
|
|
parentWidth -= (borderPadding.right + borderPadding.left);
|
1998-11-20 04:01:25 +03:00
|
|
|
// factor in the cell
|
|
|
|
lastCellFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing);
|
1998-12-23 18:47:43 +03:00
|
|
|
spacing->CalcBorderPaddingFor(lastCellFrame, borderPadding); //XXX: COLLAPSE
|
1998-11-06 00:42:46 +03:00
|
|
|
parentWidth -= (borderPadding.right + borderPadding.left);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// the table has not yet been sized, so we need to infer the available space
|
1999-01-06 02:31:18 +03:00
|
|
|
parentWidth = rs->availableWidth;
|
1998-11-06 00:42:46 +03:00
|
|
|
if (eStyleUnit_Percent == tablePosition->mWidth.GetUnit())
|
|
|
|
{
|
|
|
|
float percent = tablePosition->mWidth.GetPercentValue();
|
|
|
|
parentWidth = (nscoord)(percent*((float)parentWidth));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (PR_TRUE==gsDebugNT)
|
|
|
|
printf("%p: found a table frame %p, returning parentWidth %d \n",
|
|
|
|
aReflowState.frame, rs->frame, parentWidth);
|
1998-07-17 03:23:31 +04:00
|
|
|
}
|
1998-11-06 00:42:46 +03:00
|
|
|
break;
|
1998-06-24 23:13:19 +04:00
|
|
|
}
|
1998-06-24 04:40:33 +04:00
|
|
|
}
|
|
|
|
}
|
1998-06-05 06:36:25 +04:00
|
|
|
}
|
1998-06-24 03:23:21 +04:00
|
|
|
|
1998-06-05 06:36:25 +04:00
|
|
|
rs = rs->parentReflowState;
|
|
|
|
}
|
|
|
|
return parentWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
// aSpecifiedTableWidth is filled if the table witdth is not auto
|
|
|
|
PRBool nsTableFrame::TableIsAutoWidth(nsTableFrame *aTableFrame,
|
|
|
|
nsIStyleContext *aTableStyle,
|
1998-10-02 08:10:00 +04:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
1998-06-05 06:36:25 +04:00
|
|
|
nscoord& aSpecifiedTableWidth)
|
|
|
|
{
|
1999-07-28 12:09:02 +04:00
|
|
|
NS_ASSERTION(nsnull != aTableStyle, "bad arg - aTableStyle");
|
1998-06-05 06:36:25 +04:00
|
|
|
PRBool result = PR_TRUE; // the default
|
1999-07-28 12:09:02 +04:00
|
|
|
if (aTableStyle) {
|
1998-09-15 21:58:24 +04:00
|
|
|
nsStylePosition* tablePosition = (nsStylePosition*)aTableStyle->GetStyleData(eStyleStruct_Position);
|
1998-06-24 03:23:21 +04:00
|
|
|
const nsStyleSpacing* spacing;
|
1998-06-05 06:36:25 +04:00
|
|
|
switch (tablePosition->mWidth.GetUnit()) {
|
|
|
|
case eStyleUnit_Auto: // specified auto width
|
|
|
|
case eStyleUnit_Proportional: // illegal for table, so ignored
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eStyleUnit_Inherit:
|
|
|
|
// get width of parent and see if it is a specified value or not
|
|
|
|
// XXX for now, just return true
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eStyleUnit_Coord:
|
1998-11-25 21:43:56 +03:00
|
|
|
{
|
|
|
|
nscoord coordWidth = tablePosition->mWidth.GetCoordValue();
|
|
|
|
// NAV4 compatibility. If coord width is 0, do nothing so we get same result as "auto"
|
1999-07-28 12:09:02 +04:00
|
|
|
if (0 != coordWidth) {
|
1998-11-25 21:43:56 +03:00
|
|
|
aSpecifiedTableWidth = coordWidth;
|
|
|
|
result = PR_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
1998-06-05 06:36:25 +04:00
|
|
|
|
|
|
|
case eStyleUnit_Percent:
|
1999-02-12 20:45:58 +03:00
|
|
|
{
|
1998-06-05 06:36:25 +04:00
|
|
|
// set aSpecifiedTableWidth to be the given percent of the parent.
|
1998-06-24 03:23:21 +04:00
|
|
|
// first, get the effective parent width (parent width - insets)
|
1998-06-05 06:36:25 +04:00
|
|
|
nscoord parentWidth = nsTableFrame::GetTableContainerWidth(aReflowState);
|
1999-07-28 12:09:02 +04:00
|
|
|
if (NS_UNCONSTRAINEDSIZE != parentWidth) {
|
1998-07-18 01:02:28 +04:00
|
|
|
aReflowState.frame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing);
|
1999-07-28 12:09:02 +04:00
|
|
|
nsMargin borderPadding;
|
1998-12-23 18:47:43 +03:00
|
|
|
spacing->CalcBorderPaddingFor(aReflowState.frame, borderPadding); //XXX: COLLAPSE
|
1998-07-18 01:02:28 +04:00
|
|
|
parentWidth -= (borderPadding.right + borderPadding.left);
|
|
|
|
|
|
|
|
// then set aSpecifiedTableWidth to the given percent of the computed parent width
|
|
|
|
float percent = tablePosition->mWidth.GetPercentValue();
|
|
|
|
aSpecifiedTableWidth = (PRInt32)(parentWidth*percent);
|
|
|
|
if (PR_TRUE==gsDebug || PR_TRUE==gsDebugNT)
|
|
|
|
printf("%p: TableIsAutoWidth setting aSpecifiedTableWidth = %d with parentWidth = %d and percent = %f\n",
|
|
|
|
aTableFrame, aSpecifiedTableWidth, parentWidth, percent);
|
|
|
|
}
|
1999-07-28 12:09:02 +04:00
|
|
|
else {
|
1998-07-18 01:02:28 +04:00
|
|
|
aSpecifiedTableWidth=parentWidth;
|
|
|
|
if (PR_TRUE==gsDebug || PR_TRUE==gsDebugNT)
|
|
|
|
printf("%p: TableIsAutoWidth setting aSpecifiedTableWidth = %d with parentWidth = %d\n",
|
|
|
|
aTableFrame, aSpecifiedTableWidth, parentWidth);
|
|
|
|
}
|
1998-06-05 06:36:25 +04:00
|
|
|
result = PR_FALSE;
|
1999-02-12 20:45:58 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
1998-06-05 06:36:25 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1998-09-30 03:15:01 +04:00
|
|
|
nscoord nsTableFrame::GetMinCaptionWidth()
|
|
|
|
{
|
|
|
|
nsIFrame *outerTableFrame=nsnull;
|
1999-02-10 04:36:30 +03:00
|
|
|
GetParent(&outerTableFrame);
|
1998-09-30 03:15:01 +04:00
|
|
|
return (((nsTableOuterFrame *)outerTableFrame)->GetMinCaptionWidth());
|
|
|
|
}
|
|
|
|
|
1998-10-08 19:34:48 +04:00
|
|
|
/** return the minimum width of the table. Return 0 if the min width is unknown. */
|
1999-07-28 12:09:02 +04:00
|
|
|
nscoord nsTableFrame::GetMinTableContentWidth()
|
1998-10-08 19:34:48 +04:00
|
|
|
{
|
|
|
|
nscoord result = 0;
|
|
|
|
if (nsnull!=mTableLayoutStrategy)
|
1999-07-28 12:09:02 +04:00
|
|
|
result = mTableLayoutStrategy->GetTableMinContentWidth();
|
1998-10-08 19:34:48 +04:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1998-11-11 22:56:02 +03:00
|
|
|
/** return the maximum width of the table. Return 0 if the max width is unknown. */
|
1999-07-28 12:09:02 +04:00
|
|
|
nscoord nsTableFrame::GetMaxTableContentWidth()
|
1998-10-08 19:34:48 +04:00
|
|
|
{
|
|
|
|
nscoord result = 0;
|
|
|
|
if (nsnull!=mTableLayoutStrategy)
|
1999-07-28 12:09:02 +04:00
|
|
|
result = mTableLayoutStrategy->GetTableMaxContentWidth();
|
1998-10-08 19:34:48 +04:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1998-10-09 23:59:45 +04:00
|
|
|
void nsTableFrame::SetMaxElementSize(nsSize* aMaxElementSize)
|
|
|
|
{
|
|
|
|
if (nsnull!=mTableLayoutStrategy)
|
|
|
|
mTableLayoutStrategy->SetMaxElementSize(aMaxElementSize);
|
|
|
|
}
|
|
|
|
|
1998-09-30 03:15:01 +04:00
|
|
|
|
1998-10-21 00:05:44 +04:00
|
|
|
PRBool nsTableFrame::RequiresPass1Layout()
|
|
|
|
{
|
1998-12-02 19:45:20 +03:00
|
|
|
const nsStyleTable* tableStyle;
|
|
|
|
GetStyleData(eStyleStruct_Table, (const nsStyleStruct *&)tableStyle);
|
1998-10-21 00:05:44 +04:00
|
|
|
return (PRBool)(NS_STYLE_TABLE_LAYOUT_FIXED!=tableStyle->mLayoutStrategy);
|
|
|
|
}
|
|
|
|
|
1998-11-19 20:22:29 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableFrame::GetFrameName(nsString& aResult) const
|
|
|
|
{
|
|
|
|
return MakeFrameName("Table", aResult);
|
|
|
|
}
|
1999-01-18 02:35:56 +03:00
|
|
|
|
1999-01-30 18:52:19 +03:00
|
|
|
// This assumes that aFrame is a scroll frame if
|
1999-01-18 02:35:56 +03:00
|
|
|
// XXX make this a macro if it becomes an issue
|
1999-01-30 18:52:19 +03:00
|
|
|
// XXX it has the side effect of setting mHasScrollableRowGroup
|
1999-01-18 02:35:56 +03:00
|
|
|
nsTableRowGroupFrame*
|
|
|
|
nsTableFrame::GetRowGroupFrameFor(nsIFrame* aFrame, const nsStyleDisplay* aDisplay)
|
|
|
|
{
|
1999-01-30 18:52:19 +03:00
|
|
|
nsIFrame* result = nsnull;
|
|
|
|
if (IsRowGroup(aDisplay->mDisplay)) {
|
|
|
|
nsresult rv = aFrame->QueryInterface(kITableRowGroupFrameIID, (void **)&result);
|
|
|
|
if (NS_SUCCEEDED(rv) && (nsnull != result)) {
|
|
|
|
;
|
|
|
|
} else { // it is a scroll frame that contains the row group frame
|
1999-02-10 05:25:01 +03:00
|
|
|
aFrame->FirstChild(nsnull, &result);
|
1999-01-30 18:52:19 +03:00
|
|
|
mHasScrollableRowGroup = PR_TRUE;
|
|
|
|
}
|
1999-01-18 02:35:56 +03:00
|
|
|
}
|
1999-01-30 18:52:19 +03:00
|
|
|
|
|
|
|
return (nsTableRowGroupFrame*)result;
|
1999-01-18 02:35:56 +03:00
|
|
|
}
|
|
|
|
|
1999-02-04 02:54:32 +03:00
|
|
|
PRBool
|
|
|
|
nsTableFrame::IsFinalPass(const nsReflowState& aState)
|
|
|
|
{
|
|
|
|
return (NS_UNCONSTRAINEDSIZE != aState.availableWidth) ||
|
|
|
|
(NS_UNCONSTRAINEDSIZE != aState.availableHeight);
|
|
|
|
}
|
1999-04-22 07:51:58 +04:00
|
|
|
|
1999-07-28 12:09:02 +04:00
|
|
|
void nsTableFrame::Dump(PRBool aDumpCols, PRBool aDumpCellMap)
|
|
|
|
{
|
|
|
|
printf("***START TABLE DUMP***, \n colWidths=");
|
|
|
|
PRInt32 colX;
|
|
|
|
PRInt32 numCols = GetColCount();
|
|
|
|
for (colX = 0; colX < numCols; colX++) {
|
|
|
|
printf("%d ", mColumnWidths[colX]);
|
|
|
|
}
|
|
|
|
if (aDumpCols) {
|
|
|
|
for (colX = 0; colX < numCols; colX++) {
|
|
|
|
printf("\n");
|
|
|
|
nsTableColFrame* colFrame = GetColFrame(colX);
|
|
|
|
colFrame->Dump(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (aDumpCellMap) {
|
|
|
|
printf("\n");
|
|
|
|
nsCellMap* cellMap = GetCellMap();
|
|
|
|
cellMap->Dump();
|
|
|
|
}
|
|
|
|
printf(" ***END TABLE DUMP*** \n");
|
|
|
|
}
|
|
|
|
|
1999-04-22 07:51:58 +04:00
|
|
|
// nsTableIterator
|
1999-05-04 23:15:56 +04:00
|
|
|
nsTableIterator::nsTableIterator(nsIFrame& aSource,
|
|
|
|
nsTableIteration aType)
|
1999-04-22 07:51:58 +04:00
|
|
|
{
|
|
|
|
nsIFrame* firstChild;
|
|
|
|
aSource.FirstChild(nsnull, &firstChild);
|
1999-05-04 23:15:56 +04:00
|
|
|
Init(firstChild, aType);
|
1999-04-22 07:51:58 +04:00
|
|
|
}
|
|
|
|
|
1999-05-04 23:15:56 +04:00
|
|
|
nsTableIterator::nsTableIterator(nsFrameList& aSource,
|
|
|
|
nsTableIteration aType)
|
1999-04-22 07:51:58 +04:00
|
|
|
{
|
|
|
|
nsIFrame* firstChild = aSource.FirstChild();
|
1999-05-04 23:15:56 +04:00
|
|
|
Init(firstChild, aType);
|
1999-04-22 07:51:58 +04:00
|
|
|
}
|
|
|
|
|
1999-05-04 23:15:56 +04:00
|
|
|
void nsTableIterator::Init(nsIFrame* aFirstChild,
|
|
|
|
nsTableIteration aType)
|
1999-04-22 07:51:58 +04:00
|
|
|
{
|
|
|
|
mFirstListChild = aFirstChild;
|
|
|
|
mFirstChild = aFirstChild;
|
|
|
|
mCurrentChild = nsnull;
|
1999-05-04 23:15:56 +04:00
|
|
|
mLeftToRight = (eTableRTL == aType) ? PR_FALSE : PR_TRUE;
|
1999-04-22 07:51:58 +04:00
|
|
|
mCount = -1;
|
|
|
|
|
|
|
|
if (!mFirstChild) {
|
|
|
|
return;
|
|
|
|
}
|
1999-05-04 23:15:56 +04:00
|
|
|
if (eTableDIR == aType) {
|
1999-04-22 07:51:58 +04:00
|
|
|
nsTableFrame* table = nsnull;
|
|
|
|
nsresult rv = nsTableFrame::GetTableFrame(mFirstChild, table);
|
|
|
|
if (NS_SUCCEEDED(rv) && (table != nsnull)) {
|
|
|
|
const nsStyleDisplay* display;
|
|
|
|
table->GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&)display);
|
|
|
|
mLeftToRight = (NS_STYLE_DIRECTION_LTR == display->mDirection);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
NS_ASSERTION(PR_FALSE, "source of table iterator is not part of a table");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!mLeftToRight) {
|
|
|
|
mCount = 0;
|
|
|
|
nsIFrame* nextChild;
|
|
|
|
mFirstChild->GetNextSibling(&nextChild);
|
|
|
|
while (nsnull != nextChild) {
|
|
|
|
mCount++;
|
|
|
|
mFirstChild = nextChild;
|
|
|
|
nextChild->GetNextSibling(&nextChild);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIFrame* nsTableIterator::First()
|
|
|
|
{
|
|
|
|
mCurrentChild = mFirstChild;
|
|
|
|
return mCurrentChild;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIFrame* nsTableIterator::Next()
|
|
|
|
{
|
|
|
|
if (!mCurrentChild) {
|
|
|
|
return nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mLeftToRight) {
|
|
|
|
mCurrentChild->GetNextSibling(&mCurrentChild);
|
|
|
|
return mCurrentChild;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
nsIFrame* targetChild = mCurrentChild;
|
|
|
|
mCurrentChild = nsnull;
|
|
|
|
nsIFrame* child = mFirstListChild;
|
|
|
|
while (child && (child != targetChild)) {
|
|
|
|
mCurrentChild = child;
|
|
|
|
child->GetNextSibling(&child);
|
|
|
|
}
|
|
|
|
return mCurrentChild;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool nsTableIterator::IsLeftToRight()
|
|
|
|
{
|
|
|
|
return mLeftToRight;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRInt32 nsTableIterator::Count()
|
|
|
|
{
|
|
|
|
if (-1 == mCount) {
|
|
|
|
mCount = 0;
|
|
|
|
nsIFrame* child = mFirstListChild;
|
|
|
|
while (nsnull != child) {
|
|
|
|
mCount++;
|
|
|
|
child->GetNextSibling(&child);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return mCount;
|
|
|
|
}
|
|
|
|
|
1999-07-28 12:09:02 +04:00
|
|
|
void nsTableFrame::GetCellInfoAt(PRInt32 aRowX,
|
|
|
|
PRInt32 aColX,
|
|
|
|
nsTableCellFrame*& aCellFrame,
|
|
|
|
PRBool& aOriginates,
|
|
|
|
PRInt32& aColSpan)
|
|
|
|
{
|
|
|
|
nsCellMap* cellMap = GetCellMap();
|
|
|
|
cellMap->GetCellInfoAt(aRowX, aColX, aCellFrame, aOriginates, aColSpan);
|
|
|
|
}
|
|
|
|
|
|
|
|
PRInt32 nsTableFrame::GetNumCellsOriginatingIn(PRInt32 aColIndex)
|
|
|
|
{
|
|
|
|
nsCellMap* cellMap = GetCellMap();
|
|
|
|
return cellMap->GetNumCellsOriginatingIn(aColIndex);
|
|
|
|
}
|
1999-04-22 07:51:58 +04:00
|
|
|
|
1999-07-28 12:09:02 +04:00
|
|
|
// The following are not used anywhere, but have been retained here just in case.
|
|
|
|
#if 0
|
|
|
|
/** returns PR_TRUE if the row at aRowIndex has any cells that are the result
|
|
|
|
* of a row-spanning cell.
|
|
|
|
* @see nsCellMap::RowIsSpannedInto
|
|
|
|
*/
|
|
|
|
PRBool nsTableFrame::RowIsSpannedInto(PRInt32 aRowIndex)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION (0<=aRowIndex && aRowIndex<GetRowCount(), "bad row index arg");
|
|
|
|
PRBool result = PR_FALSE;
|
|
|
|
nsCellMap * cellMap = GetCellMap();
|
|
|
|
NS_PRECONDITION (nsnull!=cellMap, "bad call, cellMap not yet allocated.");
|
|
|
|
if (nsnull!=cellMap)
|
|
|
|
{
|
|
|
|
result = cellMap->RowIsSpannedInto(aRowIndex);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** returns PR_TRUE if the row at aRowIndex has any cells that have a rowspan>1
|
|
|
|
* @see nsCellMap::RowHasSpanningCells
|
|
|
|
*/
|
|
|
|
PRBool nsTableFrame::RowHasSpanningCells(PRInt32 aRowIndex)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION (0<=aRowIndex && aRowIndex<GetRowCount(), "bad row index arg");
|
|
|
|
PRBool result = PR_FALSE;
|
|
|
|
nsCellMap * cellMap = GetCellMap();
|
|
|
|
NS_PRECONDITION (nsnull!=cellMap, "bad call, cellMap not yet allocated.");
|
|
|
|
if (nsnull!=cellMap)
|
|
|
|
{
|
|
|
|
result = cellMap->RowHasSpanningCells(aRowIndex);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** returns PR_TRUE if the col at aColIndex has any cells that are the result
|
|
|
|
* of a col-spanning cell.
|
|
|
|
* @see nsCellMap::ColIsSpannedInto
|
|
|
|
*/
|
|
|
|
PRBool nsTableFrame::ColIsSpannedInto(PRInt32 aColIndex)
|
|
|
|
{
|
|
|
|
PRBool result = PR_FALSE;
|
|
|
|
nsCellMap * cellMap = GetCellMap();
|
|
|
|
NS_PRECONDITION (nsnull!=cellMap, "bad call, cellMap not yet allocated.");
|
|
|
|
if (nsnull!=cellMap)
|
|
|
|
{
|
|
|
|
result = cellMap->ColIsSpannedInto(aColIndex);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** returns PR_TRUE if the row at aColIndex has any cells that have a colspan>1
|
|
|
|
* @see nsCellMap::ColHasSpanningCells
|
|
|
|
*/
|
|
|
|
PRBool nsTableFrame::ColHasSpanningCells(PRInt32 aColIndex)
|
|
|
|
{
|
|
|
|
PRBool result = PR_FALSE;
|
|
|
|
nsCellMap * cellMap = GetCellMap();
|
|
|
|
NS_PRECONDITION (nsnull!=cellMap, "bad call, cellMap not yet allocated.");
|
|
|
|
if (nsnull!=cellMap)
|
|
|
|
{
|
|
|
|
result = cellMap->ColHasSpanningCells(aColIndex);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
#endif
|