1998-04-14 00:24:54 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Netscape Public License
|
|
|
|
* Version 1.0 (the "NPL"); you may not use this file except in
|
|
|
|
* compliance with the NPL. You may obtain a copy of the NPL at
|
|
|
|
* http://www.mozilla.org/NPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* NPL.
|
|
|
|
*
|
|
|
|
* The Initial Developer of this code under the NPL is Netscape
|
|
|
|
* Communications Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
|
|
|
* Reserved.
|
|
|
|
*/
|
|
|
|
#include "nsTableColGroupFrame.h"
|
1998-06-17 20:38:24 +04:00
|
|
|
#include "nsTableColFrame.h"
|
1998-09-01 01:23:28 +04:00
|
|
|
#include "nsTableFrame.h"
|
1998-09-15 21:58:24 +04:00
|
|
|
#include "nsIHTMLTableColElement.h"
|
1998-06-09 08:51:44 +04:00
|
|
|
#include "nsIReflowCommand.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsIStyleContext.h"
|
|
|
|
#include "nsStyleConsts.h"
|
|
|
|
#include "nsIPresContext.h"
|
1998-09-24 01:48:26 +04:00
|
|
|
#include "nsIHTMLContent.h"
|
|
|
|
#include "nsHTMLParts.h"
|
1998-05-29 01:39:22 +04:00
|
|
|
#include "nsIPtr.h"
|
|
|
|
#include "nsHTMLAtoms.h"
|
1998-10-01 08:46:11 +04:00
|
|
|
#include "nsHTMLIIDs.h"
|
1998-05-29 01:39:22 +04:00
|
|
|
|
|
|
|
NS_DEF_PTR(nsIContent);
|
|
|
|
NS_DEF_PTR(nsIStyleContext);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-09-15 21:58:24 +04:00
|
|
|
static NS_DEFINE_IID(kIHTMLTableColElementIID, NS_IHTMLTABLECOLELEMENT_IID);
|
|
|
|
|
1998-08-26 21:26:38 +04:00
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
static PRBool gsDebug = PR_FALSE;
|
|
|
|
|
|
|
|
nsTableColGroupFrame::nsTableColGroupFrame(nsIContent* aContent,
|
|
|
|
nsIFrame* aParentFrame)
|
1998-05-06 03:56:50 +04:00
|
|
|
: nsContainerFrame(aContent, aParentFrame)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-06-17 20:38:24 +04:00
|
|
|
mColCount=0;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsTableColGroupFrame::~nsTableColGroupFrame()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
1998-09-16 21:19:20 +04:00
|
|
|
nsresult
|
1998-09-17 03:24:39 +04:00
|
|
|
nsTableColGroupFrame::InitNewFrames(nsIPresContext& aPresContext, nsIFrame* aChildList)
|
1998-09-16 21:19:20 +04:00
|
|
|
{
|
1998-09-24 01:48:26 +04:00
|
|
|
nsresult rv=NS_OK;
|
1998-10-14 20:32:45 +04:00
|
|
|
nsTableFrame* tableFrame=nsnull;
|
|
|
|
rv = nsTableFrame::GetTableFrame(this, tableFrame);
|
|
|
|
if ((NS_SUCCEEDED(rv)) && (nsnull!=tableFrame))
|
1998-09-24 01:48:26 +04:00
|
|
|
{
|
1998-10-14 20:32:45 +04:00
|
|
|
// Process the newly added column frames
|
|
|
|
for (nsIFrame* kidFrame = aChildList; nsnull != kidFrame; kidFrame->GetNextSibling(kidFrame)) {
|
|
|
|
// Set the preliminary values for the column frame
|
|
|
|
nsIContent* kid;
|
|
|
|
kidFrame->GetContent(kid);
|
|
|
|
// should use style to get this value
|
|
|
|
PRInt32 repeat=1;
|
|
|
|
nsIHTMLTableColElement* colContent = nsnull;
|
|
|
|
rv = kid->QueryInterface(kIHTMLTableColElementIID,
|
|
|
|
(void**) &colContent); // colContent: ADDREF++
|
|
|
|
NS_RELEASE(kid);
|
|
|
|
if (rv==NS_OK)
|
|
|
|
{
|
|
|
|
colContent->GetSpanValue(&repeat);
|
|
|
|
NS_RELEASE(colContent);
|
|
|
|
}
|
|
|
|
PRInt32 colIndex = mStartColIndex + mColCount;
|
|
|
|
((nsTableColFrame *)(kidFrame))->InitColFrame (colIndex, repeat);
|
|
|
|
mColCount+= repeat;
|
|
|
|
((nsTableColFrame *)kidFrame)->SetColumnIndex(colIndex);
|
|
|
|
tableFrame->AddColumnFrame((nsTableColFrame *)kidFrame);
|
1998-09-24 01:48:26 +04:00
|
|
|
}
|
1998-10-14 20:32:45 +04:00
|
|
|
// colgroup's span attribute is how many columns the group represents
|
|
|
|
// in the absence of any COL children
|
|
|
|
if (0==mColCount)
|
1998-09-24 01:48:26 +04:00
|
|
|
{
|
1998-10-14 20:32:45 +04:00
|
|
|
nsIFrame *firstImplicitColFrame=nsnull;
|
|
|
|
nsIFrame *prevColFrame=nsnull;
|
|
|
|
nsAutoString colTag;
|
|
|
|
nsHTMLAtoms::col->ToString(colTag);
|
|
|
|
mColCount = GetSpan();
|
|
|
|
for (PRInt32 colIndex=0; colIndex<mColCount; colIndex++)
|
1998-09-24 01:48:26 +04:00
|
|
|
{
|
1998-10-14 20:32:45 +04:00
|
|
|
nsIHTMLContent *col=nsnull;
|
|
|
|
// create an implicit col
|
|
|
|
rv = NS_CreateHTMLElement(&col, colTag); // ADDREF: col++
|
|
|
|
//XXX mark the col implicit
|
|
|
|
mContent->AppendChildTo((nsIContent*)col, PR_FALSE);
|
|
|
|
|
|
|
|
// Create a new col frame
|
|
|
|
nsIFrame* colFrame;
|
|
|
|
NS_NewTableColFrame(col, this, colFrame);
|
|
|
|
|
|
|
|
// Set its style context
|
|
|
|
nsIStyleContextPtr colStyleContext =
|
|
|
|
aPresContext.ResolveStyleContextFor(col, this, PR_TRUE);
|
|
|
|
colFrame->SetStyleContext(&aPresContext, colStyleContext);
|
|
|
|
colFrame->Init(aPresContext, nsnull);
|
|
|
|
|
|
|
|
// Set nsColFrame-specific information
|
|
|
|
PRInt32 absColIndex = mStartColIndex + colIndex;
|
|
|
|
((nsTableColFrame *)(colFrame))->InitColFrame (absColIndex, 1);
|
|
|
|
((nsTableColFrame *)colFrame)->SetColumnIndex(absColIndex);
|
|
|
|
tableFrame->AddColumnFrame((nsTableColFrame *)colFrame);
|
|
|
|
|
|
|
|
//hook into list of children
|
|
|
|
if (nsnull==firstImplicitColFrame)
|
|
|
|
firstImplicitColFrame = colFrame;
|
|
|
|
else
|
|
|
|
prevColFrame->SetNextSibling(colFrame);
|
|
|
|
prevColFrame = colFrame;
|
|
|
|
}
|
|
|
|
// hook new columns into col group child list
|
|
|
|
if (nsnull==mFirstChild)
|
|
|
|
mFirstChild = firstImplicitColFrame;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nsIFrame *lastChild = mFirstChild;
|
|
|
|
nsIFrame *nextChild = lastChild;
|
|
|
|
while (nsnull!=nextChild)
|
|
|
|
{
|
|
|
|
lastChild = nextChild;
|
|
|
|
nextChild->GetNextSibling(nextChild);
|
|
|
|
}
|
|
|
|
lastChild->SetNextSibling(firstImplicitColFrame);
|
1998-09-24 01:48:26 +04:00
|
|
|
}
|
|
|
|
}
|
1998-10-14 20:32:45 +04:00
|
|
|
SetStyleContextForFirstPass(aPresContext);
|
1998-09-24 01:48:26 +04:00
|
|
|
}
|
|
|
|
return rv;
|
1998-09-16 21:19:20 +04:00
|
|
|
}
|
|
|
|
|
1998-09-17 03:24:39 +04:00
|
|
|
nsresult
|
|
|
|
nsTableColGroupFrame::AppendNewFrames(nsIPresContext& aPresContext, nsIFrame* aChildList)
|
|
|
|
{
|
1998-09-19 07:24:26 +04:00
|
|
|
nsIFrame* lastChild = LastFrame(mFirstChild);
|
1998-09-17 03:24:39 +04:00
|
|
|
|
|
|
|
// Append the new frames to the child list
|
|
|
|
if (nsnull == lastChild) {
|
|
|
|
mFirstChild = aChildList;
|
|
|
|
} else {
|
|
|
|
lastChild->SetNextSibling(aChildList);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-09-16 21:19:20 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableColGroupFrame::Init(nsIPresContext& aPresContext, nsIFrame* aChildList)
|
|
|
|
{
|
1998-09-24 01:48:26 +04:00
|
|
|
nsresult result = AppendNewFrames(aPresContext, aChildList);
|
|
|
|
if (NS_OK==result)
|
1998-09-29 00:38:10 +04:00
|
|
|
result = InitNewFrames(aPresContext, aChildList);
|
1998-09-24 01:48:26 +04:00
|
|
|
return result;
|
1998-09-16 21:19:20 +04:00
|
|
|
}
|
|
|
|
|
1998-04-17 05:41:24 +04:00
|
|
|
NS_METHOD nsTableColGroupFrame::Paint(nsIPresContext& aPresContext,
|
|
|
|
nsIRenderingContext& aRenderingContext,
|
|
|
|
const nsRect& aDirtyRect)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
if (gsDebug==PR_TRUE) printf("nsTableColGroupFrame::Paint\n");
|
|
|
|
PaintChildren(aPresContext, aRenderingContext, aDirtyRect);
|
1998-04-17 05:41:24 +04:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-08-26 21:26:38 +04:00
|
|
|
// TODO: incremental reflow
|
|
|
|
// today, we just throw away the column frames and start over every time
|
|
|
|
// this is dumb, we should be able to maintain column frames and adjust incrementally
|
1998-10-02 08:10:00 +04:00
|
|
|
NS_METHOD nsTableColGroupFrame::Reflow(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-05-29 01:39:22 +04:00
|
|
|
NS_ASSERTION(nsnull!=mContent, "bad state -- null content for frame");
|
|
|
|
|
1998-08-26 21:26:38 +04:00
|
|
|
// for every content child that (is a column thingy and does not already have a frame)
|
|
|
|
// create a frame and adjust it's style
|
|
|
|
nsIFrame* kidFrame = nsnull;
|
|
|
|
|
1998-09-24 01:48:26 +04:00
|
|
|
if (eReflowReason_Incremental == aReflowState.reason) {
|
1998-09-16 21:19:20 +04:00
|
|
|
NS_ASSERTION(nsnull != aReflowState.reflowCommand, "null reflow command");
|
|
|
|
|
|
|
|
// Get the type of reflow command
|
|
|
|
nsIReflowCommand::ReflowType reflowCmdType;
|
|
|
|
aReflowState.reflowCommand->GetType(reflowCmdType);
|
|
|
|
|
|
|
|
// Currently we only expect appended reflow commands
|
|
|
|
NS_ASSERTION(nsIReflowCommand::FrameAppended == reflowCmdType,
|
|
|
|
"unexpected reflow command");
|
|
|
|
|
|
|
|
// Get the new column frames
|
|
|
|
nsIFrame* childList;
|
|
|
|
aReflowState.reflowCommand->GetChildFrame(childList);
|
|
|
|
|
|
|
|
// Append them to the child list
|
|
|
|
AppendNewFrames(aPresContext, childList);
|
1998-09-17 03:24:39 +04:00
|
|
|
InitNewFrames(aPresContext, childList);
|
1998-09-16 21:19:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
for (kidFrame = mFirstChild; nsnull != kidFrame; kidFrame->GetNextSibling(kidFrame)) {
|
|
|
|
// Give the child frame a chance to reflow, even though we know it'll have 0 size
|
1998-10-01 08:46:11 +04:00
|
|
|
nsHTMLReflowMetrics kidSize(nsnull);
|
1998-09-16 21:19:20 +04:00
|
|
|
// XXX Use a valid reason...
|
1998-10-12 18:48:02 +04:00
|
|
|
nsHTMLReflowState kidReflowState(aPresContext, kidFrame, aReflowState,
|
|
|
|
nsSize(0,0), eReflowReason_Initial);
|
1998-10-06 04:27:22 +04:00
|
|
|
|
|
|
|
nsReflowStatus status;
|
|
|
|
ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState, status);
|
|
|
|
// note that DidReflow is called as the result of some ancestor firing off a DidReflow above me
|
|
|
|
kidFrame->SetRect(nsRect(0,0,0,0));
|
1998-09-16 21:19:20 +04:00
|
|
|
}
|
1998-09-17 03:24:39 +04:00
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
aDesiredSize.width=0;
|
|
|
|
aDesiredSize.height=0;
|
1998-10-08 19:34:48 +04:00
|
|
|
aDesiredSize.ascent=aDesiredSize.height;
|
|
|
|
aDesiredSize.descent=0;
|
1998-05-25 21:31:49 +04:00
|
|
|
if (nsnull!=aDesiredSize.maxElementSize)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-05-25 21:31:49 +04:00
|
|
|
aDesiredSize.maxElementSize->width=0;
|
|
|
|
aDesiredSize.maxElementSize->height=0;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1998-05-12 08:17:56 +04:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
1998-04-17 05:41:24 +04:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-05-29 01:39:22 +04:00
|
|
|
// Subclass hook for style post processing
|
1998-10-11 13:18:27 +04:00
|
|
|
NS_METHOD nsTableColGroupFrame::SetStyleContextForFirstPass(nsIPresContext& aPresContext)
|
1998-05-29 01:39:22 +04:00
|
|
|
{
|
1998-06-11 21:50:51 +04:00
|
|
|
// get the table frame
|
1998-10-14 20:32:45 +04:00
|
|
|
nsTableFrame* tableFrame=nsnull;
|
|
|
|
nsresult rv = nsTableFrame::GetTableFrame(this, tableFrame);
|
|
|
|
if ((NS_SUCCEEDED(rv)) && (nsnull!=tableFrame))
|
|
|
|
{
|
|
|
|
// get the style for the table frame
|
|
|
|
nsStyleTable *tableStyle;
|
|
|
|
tableFrame->GetStyleData(eStyleStruct_Table, (nsStyleStruct *&)tableStyle);
|
|
|
|
|
|
|
|
// if COLS is set, then map it into the COL frames
|
|
|
|
if (NS_STYLE_TABLE_COLS_NONE != tableStyle->mCols)
|
1998-05-30 02:08:19 +04:00
|
|
|
{
|
1998-10-14 20:32:45 +04:00
|
|
|
// set numCols to the number of columns effected by the COLS attribute
|
|
|
|
PRInt32 numCols=0;
|
|
|
|
if (NS_STYLE_TABLE_COLS_ALL == tableStyle->mCols)
|
|
|
|
numCols = LengthOf(mFirstChild);
|
|
|
|
else
|
|
|
|
numCols = tableStyle->mCols;
|
|
|
|
|
|
|
|
// for every column effected, set its width style
|
|
|
|
PRInt32 colIndex=0;
|
|
|
|
nsIFrame *colFrame=mFirstChild;
|
|
|
|
while (nsnull!=colFrame)
|
1998-08-26 21:26:38 +04:00
|
|
|
{
|
1998-10-14 20:32:45 +04:00
|
|
|
nsStyleDisplay * colDisplay=nsnull;
|
|
|
|
colFrame->GetStyleData(eStyleStruct_Display, ((nsStyleStruct *&)colDisplay));
|
|
|
|
if (NS_STYLE_DISPLAY_TABLE_COLUMN == colDisplay->mDisplay)
|
1998-09-24 01:48:26 +04:00
|
|
|
{
|
1998-10-14 20:32:45 +04:00
|
|
|
nsIStyleContextPtr colStyleContext;
|
|
|
|
nsStylePosition * colPosition=nsnull;
|
|
|
|
colFrame->GetStyleContext(&aPresContext, colStyleContext.AssignRef());
|
|
|
|
colPosition = (nsStylePosition*)colStyleContext->GetMutableStyleData(eStyleStruct_Position);
|
|
|
|
if (colIndex<numCols)
|
|
|
|
{
|
|
|
|
nsStyleCoord width (1, eStyleUnit_Proportional);
|
|
|
|
colPosition->mWidth = width;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
colPosition->mWidth.SetCoordValue(0);
|
|
|
|
}
|
|
|
|
colStyleContext->RecalcAutomaticData(&aPresContext);
|
|
|
|
colIndex++;
|
1998-09-24 01:48:26 +04:00
|
|
|
}
|
1998-10-14 20:32:45 +04:00
|
|
|
colFrame->GetNextSibling(colFrame);
|
1998-08-26 21:26:38 +04:00
|
|
|
}
|
1998-10-14 20:32:45 +04:00
|
|
|
mStyleContext->RecalcAutomaticData(&aPresContext);
|
1998-05-30 02:08:19 +04:00
|
|
|
}
|
|
|
|
}
|
1998-10-14 20:32:45 +04:00
|
|
|
return rv;
|
1998-05-29 01:39:22 +04:00
|
|
|
}
|
|
|
|
|
1998-06-17 20:38:24 +04:00
|
|
|
|
|
|
|
/** returns the number of columns represented by this group.
|
|
|
|
* if there are col children, count them (taking into account the span of each)
|
|
|
|
* else, check my own span attribute.
|
|
|
|
*/
|
|
|
|
int nsTableColGroupFrame::GetColumnCount ()
|
|
|
|
{
|
1998-08-26 21:26:38 +04:00
|
|
|
mColCount=0;
|
1998-09-24 20:37:22 +04:00
|
|
|
nsIFrame *childFrame = mFirstChild;
|
|
|
|
while (nsnull!=childFrame)
|
1998-06-17 20:38:24 +04:00
|
|
|
{
|
1998-09-24 20:37:22 +04:00
|
|
|
const nsStyleDisplay *childDisplay;
|
|
|
|
childFrame->GetStyleData(eStyleStruct_Display, ((nsStyleStruct *&)childDisplay));
|
|
|
|
if (NS_STYLE_DISPLAY_TABLE_COLUMN == childDisplay->mDisplay)
|
1998-06-17 20:38:24 +04:00
|
|
|
{
|
1998-09-24 20:37:22 +04:00
|
|
|
nsTableColFrame *col = (nsTableColFrame *)childFrame;
|
1998-08-26 21:26:38 +04:00
|
|
|
col->SetColumnIndex (mStartColIndex + mColCount);
|
1998-09-24 20:37:22 +04:00
|
|
|
mColCount += col->GetRepeat();
|
1998-06-17 20:38:24 +04:00
|
|
|
}
|
1998-09-24 20:37:22 +04:00
|
|
|
childFrame->GetNextSibling(childFrame);
|
1998-06-17 20:38:24 +04:00
|
|
|
}
|
1998-09-24 20:37:22 +04:00
|
|
|
if (0==mColCount)
|
|
|
|
{ // there were no children of this colgroup that were columns. So use my span attribute
|
1998-08-26 21:26:38 +04:00
|
|
|
const nsStyleTable *tableStyle;
|
|
|
|
GetStyleData(eStyleStruct_Table, (nsStyleStruct *&)tableStyle);
|
|
|
|
mColCount = tableStyle->mSpan;
|
|
|
|
}
|
1998-06-17 20:38:24 +04:00
|
|
|
return mColCount;
|
|
|
|
}
|
|
|
|
|
1998-10-15 02:51:50 +04:00
|
|
|
nsTableColFrame * nsTableColGroupFrame::GetFirstColumn()
|
|
|
|
{
|
|
|
|
return GetNextColumn(nsnull);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsTableColFrame * nsTableColGroupFrame::GetNextColumn(nsIFrame *aChildFrame)
|
|
|
|
{
|
|
|
|
nsTableColFrame *result = nsnull;
|
|
|
|
nsIFrame *childFrame = aChildFrame;
|
|
|
|
if (nsnull==childFrame)
|
|
|
|
childFrame = mFirstChild;
|
|
|
|
while (nsnull!=childFrame)
|
|
|
|
{
|
|
|
|
const nsStyleDisplay *childDisplay;
|
|
|
|
childFrame->GetStyleData(eStyleStruct_Display, ((nsStyleStruct *&)childDisplay));
|
|
|
|
if (NS_STYLE_DISPLAY_TABLE_COLUMN == childDisplay->mDisplay)
|
|
|
|
{
|
|
|
|
result = (nsTableColFrame *)childFrame;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
childFrame->GetNextSibling(childFrame);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-09-24 20:37:22 +04:00
|
|
|
nsTableColFrame * nsTableColGroupFrame::GetColumnAt (PRInt32 aColIndex)
|
|
|
|
{
|
|
|
|
nsTableColFrame *result = nsnull;
|
|
|
|
PRInt32 count=0;
|
|
|
|
nsIFrame *childFrame = mFirstChild;
|
|
|
|
while (nsnull!=childFrame)
|
|
|
|
{
|
|
|
|
const nsStyleDisplay *childDisplay;
|
|
|
|
childFrame->GetStyleData(eStyleStruct_Display, ((nsStyleStruct *&)childDisplay));
|
|
|
|
if (NS_STYLE_DISPLAY_TABLE_COLUMN == childDisplay->mDisplay)
|
|
|
|
{
|
|
|
|
nsTableColFrame *col = (nsTableColFrame *)childFrame;
|
|
|
|
count += col->GetRepeat();
|
|
|
|
if (aColIndex<=count)
|
|
|
|
result = col;
|
|
|
|
}
|
|
|
|
childFrame->GetNextSibling(childFrame);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1998-09-24 01:48:26 +04:00
|
|
|
PRInt32 nsTableColGroupFrame::GetSpan()
|
|
|
|
{
|
|
|
|
PRInt32 span=1;
|
|
|
|
nsStyleTable* tableStyle=nsnull;
|
|
|
|
GetStyleData(eStyleStruct_Table, (nsStyleStruct *&)tableStyle);
|
|
|
|
if (nsnull!=tableStyle)
|
|
|
|
{
|
|
|
|
span = tableStyle->mSpan;
|
|
|
|
}
|
|
|
|
return span;
|
|
|
|
}
|
|
|
|
|
1998-10-15 02:51:50 +04:00
|
|
|
/* this may be needed when IsSynthetic is properly implemented
|
|
|
|
PRBool nsTableColGroupFrame::IsManufactured()
|
|
|
|
{
|
|
|
|
PRBool result = PR_FALSE;
|
|
|
|
nsIFrame *firstCol = GetFirstColumn();
|
|
|
|
if (nsTableFrame::IsSynthetic(this) &&
|
|
|
|
((nsnull==firstCol) || nsTableFrame::IsSynthetic(firstCol)))
|
|
|
|
result = PR_TRUE;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** returns colcount because it is frequently used in the context of
|
|
|
|
* shuffling relative colgroup order, and it's convenient to not have to
|
|
|
|
* call GetColumnCount redundantly.
|
|
|
|
*/
|
|
|
|
PRInt32 nsTableColGroupFrame::SetStartColumnIndex (int aIndex)
|
|
|
|
{
|
|
|
|
PRInt32 result = mColCount;
|
|
|
|
if (aIndex != mStartColIndex)
|
|
|
|
{
|
|
|
|
mStartColIndex = aIndex;
|
|
|
|
mColCount=0;
|
|
|
|
result = GetColumnCount(); // has the side effect of setting each column index based on new start index
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1998-09-15 21:58:24 +04:00
|
|
|
/* ----- global methods ----- */
|
1998-06-17 20:38:24 +04:00
|
|
|
|
1998-09-15 21:58:24 +04:00
|
|
|
nsresult
|
|
|
|
NS_NewTableColGroupFrame(nsIContent* aContent,
|
|
|
|
nsIFrame* aParentFrame,
|
|
|
|
nsIFrame*& aResult)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-09-15 21:58:24 +04:00
|
|
|
nsIFrame* it = new nsTableColGroupFrame(aContent, aParentFrame);
|
1998-04-14 00:24:54 +04:00
|
|
|
if (nsnull == it) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
1998-09-15 21:58:24 +04:00
|
|
|
aResult = it;
|
1998-04-14 00:24:54 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-06-17 20:38:24 +04:00
|
|
|
|
1998-09-03 01:59:54 +04:00
|
|
|
/* ----- debugging methods ----- */
|
|
|
|
NS_METHOD nsTableColGroupFrame::List(FILE* out, PRInt32 aIndent, nsIListFilter *aFilter) const
|
|
|
|
{
|
|
|
|
// if a filter is present, only output this frame if the filter says we should
|
|
|
|
// since this could be any "tag" with the right display type, we'll
|
|
|
|
// just pretend it's a colgroup
|
|
|
|
if (nsnull==aFilter)
|
|
|
|
return nsContainerFrame::List(out, aIndent, aFilter);
|
|
|
|
|
|
|
|
nsAutoString tagString("colgroup");
|
|
|
|
PRBool outputMe = aFilter->OutputTag(&tagString);
|
|
|
|
if (PR_TRUE==outputMe)
|
|
|
|
{
|
|
|
|
// Indent
|
|
|
|
for (PRInt32 i = aIndent; --i >= 0; ) fputs(" ", out);
|
|
|
|
|
|
|
|
// Output the tag and rect
|
|
|
|
nsIAtom* tag;
|
|
|
|
mContent->GetTag(tag);
|
|
|
|
if (tag != nsnull) {
|
|
|
|
nsAutoString buf;
|
|
|
|
tag->ToString(buf);
|
|
|
|
fputs(buf, out);
|
|
|
|
NS_RELEASE(tag);
|
|
|
|
}
|
|
|
|
|
1998-10-09 00:35:16 +04:00
|
|
|
fprintf(out, "(%d)", ContentIndexInContainer(this));
|
1998-09-03 01:59:54 +04:00
|
|
|
out << mRect;
|
|
|
|
if (0 != mState) {
|
|
|
|
fprintf(out, " [state=%08x]", mState);
|
|
|
|
}
|
|
|
|
fputs("\n", out);
|
|
|
|
}
|
|
|
|
// Output the children
|
1998-09-21 07:40:32 +04:00
|
|
|
if (nsnull != mFirstChild) {
|
1998-09-03 01:59:54 +04:00
|
|
|
if (PR_TRUE==outputMe)
|
|
|
|
{
|
|
|
|
if (0 != mState) {
|
|
|
|
fprintf(out, " [state=%08x]\n", mState);
|
|
|
|
}
|
|
|
|
}
|
1998-09-19 07:24:26 +04:00
|
|
|
for (nsIFrame* child = mFirstChild; child; child->GetNextSibling(child)) {
|
1998-09-03 01:59:54 +04:00
|
|
|
child->List(out, aIndent + 1, aFilter);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (PR_TRUE==outputMe)
|
|
|
|
{
|
|
|
|
if (0 != mState) {
|
|
|
|
fprintf(out, " [state=%08x]\n", mState);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-06-17 20:38:24 +04:00
|
|
|
|