зеркало из https://github.com/mozilla/gecko-dev.git
various small fixes and clean up
This commit is contained in:
Родитель
6214cab218
Коммит
f2bd19c65b
|
@ -454,6 +454,7 @@ PRBool BasicTableLayoutStrategy::AssignPreliminaryColumnWidths()
|
|||
specifiedFixedColWidth=effectiveMinColumnWidth;
|
||||
// do all the global bookkeeping, factoring in margins
|
||||
nscoord colInset = mTableFrame->GetCellSpacing();
|
||||
if (PR_TRUE==gsDebug) printf("* cellSpacing=%d\n", colInset);
|
||||
// keep a running total of the amount of space taken up by all fixed-width columns
|
||||
if ((PR_TRUE==haveColWidth) && (nsTableColFrame::eWIDTH_SOURCE_CELL==colFrame->GetWidthSource()))
|
||||
{
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
|
||||
NS_DEF_PTR(nsIStyleContext);
|
||||
|
||||
const nsIID kTableCellFrameCID = NS_TABLECELLFRAME_CID;
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
static PRBool gsDebug = PR_FALSE;
|
||||
|
@ -297,7 +296,6 @@ NS_METHOD nsTableCellFrame::Reflow(nsIPresContext& aPresContext,
|
|||
if (NS_UNCONSTRAINEDSIZE!=availSize.height)
|
||||
availSize.height -= topInset+bottomInset+margin.top+margin.bottom;
|
||||
|
||||
// XXX Kipp added this hack
|
||||
if (eReflowReason_Incremental == aReflowState.reason)
|
||||
{
|
||||
// XXX We *must* do this otherwise incremental reflow that's
|
||||
|
@ -636,10 +634,6 @@ nsTableCellFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
|||
if (NULL == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aIID.Equals(kTableCellFrameCID)) {
|
||||
*aInstancePtr = (void*) (this);
|
||||
return NS_OK;
|
||||
}
|
||||
return nsContainerFrame::QueryInterface(aIID, aInstancePtr);
|
||||
}
|
||||
|
||||
|
|
|
@ -25,11 +25,6 @@
|
|||
|
||||
struct nsStyleSpacing;
|
||||
|
||||
/* eb42f7b0-079e-11d2-8f37-006008159b0c */
|
||||
#define NS_TABLECELLFRAME_CID \
|
||||
{0xeb42f7b0, 0x079e, 0x11d2, {0x8f, 0x37, 0x00, 0x60, 0x08, 0x15, 0x9b, 0x0c}}
|
||||
|
||||
extern const nsIID kTableCellFrameCID;
|
||||
|
||||
/**
|
||||
* nsTableCellFrame
|
||||
|
|
|
@ -1,253 +0,0 @@
|
|||
/* -*- 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 "nsTableContent.h"
|
||||
#include "nsITableContent.h"
|
||||
#include "nsString.h"
|
||||
|
||||
const int nsITableContent::kTableRowGroupType=1;
|
||||
const int nsITableContent::kTableRowType=2;
|
||||
const int nsITableContent::kTableColGroupType=3;
|
||||
const int nsITableContent::kTableColType=4;
|
||||
const int nsITableContent::kTableCaptionType=5;
|
||||
const int nsITableContent::kTableCellType=6;
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
static PRBool gsDebug = PR_FALSE;
|
||||
static PRBool gsNoisyRefs = PR_FALSE;
|
||||
#else
|
||||
static const PRBool gsDebug = PR_FALSE;
|
||||
static const PRBool gsNoisyRefs = PR_FALSE;
|
||||
#endif
|
||||
|
||||
static NS_DEFINE_IID(kITableContentIID, NS_ITABLECONTENT_IID);
|
||||
|
||||
/**
|
||||
* default contstructor
|
||||
*/
|
||||
nsTableContent::nsTableContent (nsIAtom* aTag)
|
||||
: nsHTMLContainer(aTag)
|
||||
{
|
||||
mTable = nsnull;
|
||||
}
|
||||
|
||||
nsTableContent::~nsTableContent ()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
nsTableContent::nsTableContent (nsIAtom* aTag, PRBool aImplicit)
|
||||
: nsHTMLContainer(aTag),
|
||||
mImplicit(aImplicit)
|
||||
{
|
||||
}
|
||||
|
||||
nsrefcnt nsTableContent::AddRef(void)
|
||||
{
|
||||
if (gsNoisyRefs==PR_TRUE) printf("Add Ref: nsTableContent %d - %p cnt = %d \n",
|
||||
GetType(), this, mRefCnt+1);
|
||||
return ++mRefCnt;
|
||||
}
|
||||
|
||||
nsrefcnt nsTableContent::Release(void)
|
||||
{
|
||||
if (gsNoisyRefs==PR_TRUE) printf("Release: nsTableContent %d - %p cnt = %d \n",
|
||||
GetType(), this, mRefCnt-1);
|
||||
if (--mRefCnt == 0) {
|
||||
if (gsNoisyRefs==PR_TRUE) printf("Delete: nsTableContent \n");
|
||||
delete this;
|
||||
return 0;
|
||||
}
|
||||
return mRefCnt;
|
||||
}
|
||||
|
||||
|
||||
nsresult nsTableContent::QueryInterface(const nsIID& aIID,
|
||||
void** aInstancePtrResult)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aInstancePtrResult, "null pointer");
|
||||
if (nsnull == aInstancePtrResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aIID.Equals(kITableContentIID)) {
|
||||
*aInstancePtrResult = (void*) ((nsITableContent*)this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
return nsHTMLTagContent::QueryInterface(aIID, aInstancePtrResult);
|
||||
}
|
||||
|
||||
/**
|
||||
* Don't want to put out implicit tags when saving.
|
||||
*/
|
||||
PRBool nsTableContent::SkipSelfForSaving()
|
||||
{
|
||||
return mImplicit;
|
||||
}
|
||||
|
||||
nsTablePart* nsTableContent::GetTable ()
|
||||
{
|
||||
NS_IF_ADDREF(mTable);
|
||||
return mTable;
|
||||
}
|
||||
|
||||
void nsTableContent::SetTableForChildren(nsTablePart *aTable)
|
||||
{
|
||||
if (aTable != nsnull)
|
||||
{
|
||||
PRInt32 count;
|
||||
ChildCount(count);
|
||||
for (PRInt32 index = 0; index < count; index++)
|
||||
{
|
||||
nsIContent* child;
|
||||
ChildAt(index, child);
|
||||
SetTableForTableContent(child,aTable);
|
||||
NS_RELEASE(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void nsTableContent::SetTable (nsTablePart *aTable)
|
||||
{
|
||||
// Check to see if the current table was null, if it was, then call
|
||||
// method to reset children
|
||||
if (mTable == nsnull)
|
||||
SetTableForChildren(aTable);
|
||||
mTable = aTable;
|
||||
}
|
||||
|
||||
NS_METHOD nsTableContent::IsSynthetic(PRBool& aResult)
|
||||
{
|
||||
aResult = mImplicit;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the content is a nsTableContent then call SetTable on
|
||||
* aContent, otherwise, do nothing.
|
||||
*/
|
||||
void nsTableContent::SetTableForTableContent(nsIContent* aContent, nsTablePart *aTable)
|
||||
{
|
||||
if (aContent != nsnull)
|
||||
{
|
||||
nsITableContent* tableContent;
|
||||
nsresult result = aContent->QueryInterface(kITableContentIID, (void**) &tableContent);
|
||||
if (NS_OK == result)
|
||||
{
|
||||
tableContent->SetTable(aTable);
|
||||
NS_IF_RELEASE(tableContent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ----- overridable methods from nsHTMLContainer ----- */
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTableContent::List(FILE* out, PRInt32 aIndent) const
|
||||
{
|
||||
PRInt32 i;
|
||||
for (i = aIndent; --i >= 0; ) fputs(" ", out);
|
||||
nsIAtom* tag;
|
||||
GetTag(tag);
|
||||
if (tag != nsnull) {
|
||||
nsAutoString buf;
|
||||
tag->ToString(buf);
|
||||
fputs(buf, out);
|
||||
NS_RELEASE(tag);
|
||||
}
|
||||
|
||||
char *isImplicitString = "";
|
||||
if (PR_TRUE==mImplicit)
|
||||
isImplicitString = " (I)";
|
||||
|
||||
ListAttributes(out);
|
||||
|
||||
fprintf(out, " RefCount=%d<%s\n", mRefCnt, isImplicitString);
|
||||
|
||||
PRBool canHaveKids;
|
||||
CanContainChildren(canHaveKids);
|
||||
if (canHaveKids) {
|
||||
PRInt32 kids;
|
||||
ChildCount(kids);
|
||||
for (i = 0; i < kids; i++) {
|
||||
nsIContent* kid;
|
||||
ChildAt(i, kid);
|
||||
kid->List(out, aIndent + 1);
|
||||
NS_RELEASE(kid);
|
||||
}
|
||||
}
|
||||
for (i = aIndent; --i >= 0; ) fputs(" ", out);
|
||||
fputs(">\n", out);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTableContent::InsertChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify)
|
||||
{
|
||||
nsresult rv = nsHTMLContainer::InsertChildAt(aKid, aIndex, aNotify);
|
||||
if (NS_OK == rv) {
|
||||
SetTableForTableContent(aKid, mTable);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTableContent::ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify)
|
||||
{
|
||||
nsIContent* child;
|
||||
ChildAt(aIndex, child);
|
||||
nsresult rv = nsHTMLContainer::ReplaceChildAt(aKid, aIndex, aNotify);
|
||||
if (NS_OK == rv)
|
||||
{
|
||||
SetTableForTableContent(child,nsnull);
|
||||
SetTableForTableContent(aKid,mTable);
|
||||
}
|
||||
NS_IF_RELEASE(child);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTableContent::AppendChildTo(nsIContent* aKid, PRBool aNotify)
|
||||
{
|
||||
nsresult rv = nsHTMLContainer::AppendChildTo(aKid, aNotify);
|
||||
if (NS_OK == rv)
|
||||
SetTableForTableContent(aKid,mTable);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTableContent::RemoveChildAt(PRInt32 aIndex, PRBool aNotify)
|
||||
{
|
||||
nsTableContent* child;
|
||||
ChildAt(aIndex, (nsIContent*&) child);
|
||||
nsresult rv = nsHTMLContainer::RemoveChildAt(aIndex, aNotify);
|
||||
if (NS_OK == rv)
|
||||
SetTableForTableContent(child,nsnull);
|
||||
|
||||
NS_IF_RELEASE(child);
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* ---------- nsITableContent implementations ----------- */
|
||||
|
||||
nsITableContent::nsITableContent ()
|
||||
{}
|
||||
|
|
@ -61,8 +61,6 @@ static const PRBool gsDebugIR = PR_FALSE;
|
|||
NS_DEF_PTR(nsIStyleContext);
|
||||
NS_DEF_PTR(nsIContent);
|
||||
|
||||
const nsIID kTableFrameCID = NS_TABLEFRAME_CID;
|
||||
|
||||
static const PRInt32 kColumnWidthIncrement=100;
|
||||
|
||||
/* ----------- CellData ---------- */
|
||||
|
@ -762,128 +760,6 @@ void nsTableFrame::EnsureColumns(nsIPresContext& aPresContext)
|
|||
}
|
||||
}
|
||||
|
||||
/** 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.
|
||||
*/
|
||||
// XXX should be nsresult, not void
|
||||
void nsTableFrame::EnsureColumnFrameAt(PRInt32 aColIndex,
|
||||
nsIPresContext& aPresContext)
|
||||
{
|
||||
nsresult rv;
|
||||
PRInt32 actualColumns = 0;
|
||||
nsTableColGroupFrame *lastColGroupFrame = nsnull;
|
||||
nsIFrame * firstRowGroupFrame=nsnull;
|
||||
nsIFrame * prevSibFrame=nsnull; // this is the child just before the first row group frame
|
||||
nsIFrame * childFrame=mFirstChild;
|
||||
while (nsnull!=childFrame)
|
||||
{
|
||||
const nsStyleDisplay *childDisplay;
|
||||
childFrame->GetStyleData(eStyleStruct_Display, ((nsStyleStruct *&)childDisplay));
|
||||
if (NS_STYLE_DISPLAY_TABLE_COLUMN_GROUP == childDisplay->mDisplay)
|
||||
{
|
||||
PRInt32 numCols = ((nsTableColGroupFrame*)childFrame)->GetColumnCount();
|
||||
actualColumns += numCols;
|
||||
lastColGroupFrame = (nsTableColGroupFrame *)childFrame;
|
||||
if (actualColumns > aColIndex)
|
||||
break; // we have enough col frames at this point
|
||||
}
|
||||
else if (PR_TRUE==IsRowGroup(childDisplay->mDisplay))
|
||||
{
|
||||
if (nsnull==firstRowGroupFrame)
|
||||
firstRowGroupFrame = childFrame;
|
||||
}
|
||||
if (nsnull==firstRowGroupFrame)
|
||||
prevSibFrame = childFrame;
|
||||
childFrame->GetNextSibling(childFrame);
|
||||
}
|
||||
if (actualColumns <= aColIndex)
|
||||
{
|
||||
nsIHTMLContent *lastColGroup=nsnull;
|
||||
if (nsnull==lastColGroupFrame)
|
||||
{
|
||||
// create an implicit colgroup
|
||||
nsAutoString colGroupTag;
|
||||
nsHTMLAtoms::colgroup->ToString(colGroupTag);
|
||||
rv = NS_CreateHTMLElement(&lastColGroup, colGroupTag); // ADDREF a: lastColGroup++
|
||||
//XXX: make synthetic
|
||||
//XXX mark it as implicit!
|
||||
mContent->AppendChildTo(lastColGroup, PR_FALSE); // add the implicit colgroup to my content
|
||||
// Resolve style for the child
|
||||
nsIStyleContext* colGroupStyleContext =
|
||||
aPresContext.ResolveStyleContextFor(lastColGroup, mStyleContext, PR_TRUE); // kidStyleContext: REFCNT++
|
||||
|
||||
// Create a col group frame
|
||||
nsIFrame* newFrame;
|
||||
NS_NewTableColGroupFrame(lastColGroup, this, newFrame);
|
||||
lastColGroupFrame = (nsTableColGroupFrame*)newFrame;
|
||||
lastColGroupFrame->SetStyleContext(&aPresContext, colGroupStyleContext);
|
||||
NS_RELEASE(colGroupStyleContext); // kidStyleContenxt: REFCNT--
|
||||
|
||||
// hook lastColGroupFrame into child list
|
||||
if (nsnull==firstRowGroupFrame)
|
||||
{ // make lastColGroupFrame the last frame
|
||||
nsIFrame *lastChild = LastFrame(mFirstChild);
|
||||
lastChild->SetNextSibling(lastColGroupFrame);
|
||||
}
|
||||
else
|
||||
{ // insert lastColGroupFrame before the first row group frame
|
||||
if (nsnull!=prevSibFrame)
|
||||
{ // lastColGroupFrame is inserted between prevSibFrame and lastColGroupFrame
|
||||
prevSibFrame->SetNextSibling(lastColGroupFrame);
|
||||
}
|
||||
else
|
||||
{ // lastColGroupFrame is inserted as the first child of this table
|
||||
mFirstChild = lastColGroupFrame;
|
||||
}
|
||||
lastColGroupFrame->SetNextSibling(firstRowGroupFrame);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lastColGroupFrame->GetContent((nsIContent *&)lastColGroup); // ADDREF b: lastColGroup++
|
||||
}
|
||||
|
||||
nsAutoString colTag;
|
||||
nsHTMLAtoms::col->ToString(colTag);
|
||||
PRInt32 excessColumns = aColIndex - actualColumns;
|
||||
nsIFrame* firstNewColFrame = nsnull;
|
||||
nsIFrame* lastNewColFrame = nsnull;
|
||||
nsIStyleContextPtr lastColGroupStyle;
|
||||
lastColGroupFrame->GetStyleContext(lastColGroupStyle.AssignRef());
|
||||
for ( ; excessColumns >= 0; excessColumns--)
|
||||
{
|
||||
nsIHTMLContent *col=nsnull;
|
||||
// create an implicit col
|
||||
rv = NS_CreateHTMLElement(&col, colTag); // ADDREF: col++
|
||||
//XXX: make synthetic
|
||||
lastColGroup->AppendChildTo((nsIContent*)col, PR_FALSE);
|
||||
|
||||
// Create a new col frame
|
||||
nsIFrame* colFrame;
|
||||
NS_NewTableColFrame(col, lastColGroupFrame, colFrame);
|
||||
|
||||
// Set its style context
|
||||
nsIStyleContextPtr colStyleContext =
|
||||
aPresContext.ResolveStyleContextFor(col, lastColGroupStyle, PR_TRUE);
|
||||
colFrame->SetStyleContext(&aPresContext, colStyleContext);
|
||||
|
||||
// XXX Don't release this style context (or we'll end up with a double-free).\
|
||||
// This code is doing what nsTableColGroupFrame::Reflow() does...
|
||||
//NS_RELEASE(colStyleContext);
|
||||
|
||||
// Add it to our list
|
||||
if (nsnull == lastNewColFrame) {
|
||||
firstNewColFrame = colFrame;
|
||||
} else {
|
||||
lastNewColFrame->SetNextSibling(colFrame);
|
||||
}
|
||||
lastNewColFrame = colFrame;
|
||||
NS_RELEASE(col); // ADDREF: col--
|
||||
}
|
||||
NS_RELEASE(lastColGroup); // ADDREF: lastColGroup--
|
||||
}
|
||||
}
|
||||
|
||||
void nsTableFrame::AddColumnFrame (nsTableColFrame *aColFrame)
|
||||
{
|
||||
|
@ -957,7 +833,14 @@ void nsTableFrame::SetMinColSpanForTable()
|
|||
}
|
||||
}
|
||||
if (1<minColSpan)
|
||||
{
|
||||
mCellMap->SetMinColSpan(colIndex, minColSpan);
|
||||
if (gsDebug==PR_TRUE)
|
||||
{
|
||||
printf("minColSpan for col %d set to %d\n", colIndex, minColSpan);
|
||||
DumpCellMap();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1040,8 +923,7 @@ NS_METHOD nsTableFrame::ReBuildCellMap()
|
|||
return rv;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
#ifdef NS_DEBUG
|
||||
void nsTableFrame::DumpCellMap ()
|
||||
{
|
||||
printf("dumping CellMap:\n");
|
||||
|
@ -1113,6 +995,7 @@ void nsTableFrame::DumpCellMap ()
|
|||
else
|
||||
printf ("[nsnull]");
|
||||
}
|
||||
#endif
|
||||
|
||||
void nsTableFrame::BuildCellIntoMap (nsTableCellFrame *aCell, PRInt32 aRowIndex, PRInt32 aColIndex)
|
||||
{
|
||||
|
@ -1203,6 +1086,7 @@ void nsTableFrame::GrowCellMap (PRInt32 aColCount)
|
|||
* around and lists the cell layout data.
|
||||
* This is for debugging purposes only.
|
||||
*/
|
||||
#ifdef NS_DEBUG
|
||||
void nsTableFrame::ListColumnLayoutData(FILE* out, PRInt32 aIndent)
|
||||
{
|
||||
nsTableFrame * firstInFlow = (nsTableFrame *)GetFirstInFlow();
|
||||
|
@ -1258,6 +1142,7 @@ void nsTableFrame::ListColumnLayoutData(FILE* out, PRInt32 aIndent)
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* For the TableCell in CellData, add it to the list
|
||||
|
@ -1809,7 +1694,6 @@ NS_METHOD nsTableFrame::ResizeReflowPass2(nsIPresContext& aPresContext,
|
|||
const nsHTMLReflowState& aReflowState,
|
||||
nsReflowStatus& aStatus)
|
||||
{
|
||||
//DumpCellMap();
|
||||
NS_PRECONDITION(aReflowState.frame == this, "bad reflow state");
|
||||
NS_PRECONDITION(aReflowState.parentReflowState->frame == mGeometricParent,
|
||||
"bad parent reflow state");
|
||||
|
@ -2871,13 +2755,6 @@ void nsTableFrame::SetTableWidth(nsIPresContext& aPresContext)
|
|||
SetRect(tableSize);
|
||||
}
|
||||
|
||||
void nsTableFrame::VerticallyAlignChildren(nsIPresContext& aPresContext,
|
||||
nscoord* aAscents,
|
||||
nscoord aMaxAscent,
|
||||
nscoord aMaxHeight)
|
||||
{
|
||||
}
|
||||
|
||||
void nsTableFrame::AdjustColumnsForCOLSAttribute()
|
||||
{
|
||||
nsCellMap *cellMap = GetCellMap();
|
||||
|
@ -3507,10 +3384,6 @@ nsTableFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
|||
if (NULL == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aIID.Equals(kTableFrameCID)) {
|
||||
*aInstancePtr = (void*) (this);
|
||||
return NS_OK;
|
||||
}
|
||||
return nsContainerFrame::QueryInterface(aIID, aInstancePtr);
|
||||
}
|
||||
|
||||
|
@ -3575,7 +3448,6 @@ NS_METHOD nsTableFrame::GetTableFrame(nsIFrame *aSourceFrame, nsTableFrame *& aT
|
|||
/* helper method for determining if this is a nested table or not */
|
||||
PRBool nsTableFrame::IsNested(const nsHTMLReflowState& aReflowState, nsStylePosition *& aPosition) const
|
||||
{
|
||||
nsresult rv;
|
||||
PRBool result = PR_FALSE;
|
||||
#ifdef NS_DEBUG
|
||||
PRInt32 counter=0;
|
||||
|
@ -3589,12 +3461,12 @@ PRBool nsTableFrame::IsNested(const nsHTMLReflowState& aReflowState, nsStylePosi
|
|||
NS_ASSERTION(counter<100000, "infinite loop in IsNested");
|
||||
break;
|
||||
#endif
|
||||
nsIFrame* parentTable = nsnull;
|
||||
rv = rs->frame->QueryInterface(kTableFrameCID, (void**) &parentTable);
|
||||
if (NS_OK==rv)
|
||||
const nsStyleDisplay *display;
|
||||
rs->frame->GetStyleData(eStyleStruct_Display, (nsStyleStruct *&)display);
|
||||
if (NS_STYLE_DISPLAY_TABLE==display->mDisplay)
|
||||
{
|
||||
result = PR_TRUE;
|
||||
parentTable->GetStyleData(eStyleStruct_Position, ((nsStyleStruct *&)aPosition));
|
||||
rs->frame->GetStyleData(eStyleStruct_Position, ((nsStyleStruct *&)aPosition));
|
||||
break;
|
||||
}
|
||||
rs = rs->parentReflowState;
|
||||
|
@ -3606,7 +3478,7 @@ PRBool nsTableFrame::IsNested(const nsHTMLReflowState& aReflowState, nsStylePosi
|
|||
/* helper method for getting the width of the table's containing block */
|
||||
nscoord nsTableFrame::GetTableContainerWidth(const nsHTMLReflowState& aReflowState)
|
||||
{
|
||||
nsresult rv;
|
||||
const nsStyleDisplay *display;
|
||||
nscoord parentWidth = aReflowState.maxSize.width;
|
||||
|
||||
// Walk up the reflow state chain until we find a block
|
||||
|
@ -3618,9 +3490,8 @@ nscoord nsTableFrame::GetTableContainerWidth(const nsHTMLReflowState& aReflowSta
|
|||
while (nsnull != rs)
|
||||
{
|
||||
// if it's a block, use its max width
|
||||
nsIFrame* block = nsnull;
|
||||
rv = rs->frame->QueryInterface(kBlockFrameCID, (void**) &block);
|
||||
if (NS_OK==rv)
|
||||
rs->frame->GetStyleData(eStyleStruct_Display, (nsStyleStruct *&)display);
|
||||
if (NS_STYLE_DISPLAY_BLOCK==display->mDisplay)
|
||||
{ // we found a block, see if it's really a table cell (which means we're a nested table)
|
||||
PRBool skipThisBlock=PR_FALSE;
|
||||
const nsReflowState* parentRS = rs->parentReflowState;
|
||||
|
@ -3629,11 +3500,10 @@ nscoord nsTableFrame::GetTableContainerWidth(const nsHTMLReflowState& aReflowSta
|
|||
parentRS = parentRS->parentReflowState;
|
||||
if (nsnull!=parentRS)
|
||||
{
|
||||
nsIFrame* cell = nsnull;
|
||||
rv = parentRS->frame->QueryInterface(kTableCellFrameCID, (void**) &cell);
|
||||
if (rv == NS_OK) {
|
||||
parentRS->frame->GetStyleData(eStyleStruct_Display, (nsStyleStruct *&)display);
|
||||
if (NS_STYLE_DISPLAY_TABLE_CELL==display->mDisplay) {
|
||||
if (PR_TRUE==gsDebugNT)
|
||||
printf("%p: found a block pframe %p in a cell, skipping it.\n", aReflowState.frame, block);
|
||||
printf("%p: found a block pframe %p in a cell, skipping it.\n", aReflowState.frame, rs->frame);
|
||||
skipThisBlock = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
@ -3647,7 +3517,7 @@ nscoord nsTableFrame::GetTableContainerWidth(const nsHTMLReflowState& aReflowSta
|
|||
parentWidth = rs->maxSize.width;
|
||||
if (PR_TRUE==gsDebugNT)
|
||||
printf("%p: found a block frame %p, returning width %d\n",
|
||||
aReflowState.frame, block, parentWidth);
|
||||
aReflowState.frame, rs->frame, parentWidth);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -3658,23 +3528,21 @@ nscoord nsTableFrame::GetTableContainerWidth(const nsHTMLReflowState& aReflowSta
|
|||
nsMargin borderPadding;
|
||||
const nsStylePosition* tablePosition;
|
||||
const nsStyleSpacing* spacing;
|
||||
nsIFrame* cell = nsnull;
|
||||
rv = rs->frame->QueryInterface(kTableCellFrameCID, (void**) &cell);
|
||||
// if the cell has a specified width, use it
|
||||
if (NS_OK==rv)
|
||||
{
|
||||
rs->frame->GetStyleData(eStyleStruct_Display, (nsStyleStruct *&)display);
|
||||
if (NS_STYLE_DISPLAY_TABLE_CELL==display->mDisplay)
|
||||
{ // if it's a cell and the cell has a specified width, use it
|
||||
// Compute and subtract out the insets (sum of border and padding) for the table
|
||||
const nsStylePosition* cellPosition;
|
||||
cell->GetStyleData(eStyleStruct_Position, ((nsStyleStruct *&)cellPosition));
|
||||
rs->frame->GetStyleData(eStyleStruct_Position, ((nsStyleStruct *&)cellPosition));
|
||||
if (eStyleUnit_Coord == cellPosition->mWidth.GetUnit())
|
||||
{
|
||||
nsTableFrame *tableParent;
|
||||
rv=GetTableFrame(cell, tableParent);
|
||||
nsresult rv=GetTableFrame(rs->frame, tableParent);
|
||||
if ((NS_OK==rv) && (nsnull!=tableParent) && (nsnull!=tableParent->mColumnWidths))
|
||||
{
|
||||
parentWidth=0;
|
||||
PRInt32 colIndex = ((nsTableCellFrame *)cell)->GetColIndex();
|
||||
PRInt32 colSpan = tableParent->GetEffectiveColSpan(colIndex, (nsTableCellFrame *)cell);
|
||||
PRInt32 colIndex = ((nsTableCellFrame *)rs->frame)->GetColIndex();
|
||||
PRInt32 colSpan = tableParent->GetEffectiveColSpan(colIndex, (nsTableCellFrame *)rs->frame);
|
||||
for (PRInt32 i=0; i<colSpan; i++)
|
||||
parentWidth += tableParent->GetColumnWidth(colIndex);
|
||||
break;
|
||||
|
@ -3685,111 +3553,119 @@ nscoord nsTableFrame::GetTableContainerWidth(const nsHTMLReflowState& aReflowSta
|
|||
{
|
||||
parentWidth = cellPosition->mWidth.GetCoordValue();
|
||||
// subtract out cell border and padding
|
||||
cell->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing);
|
||||
spacing->CalcBorderPaddingFor(cell, borderPadding);
|
||||
rs->frame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing);
|
||||
spacing->CalcBorderPaddingFor(rs->frame, borderPadding);
|
||||
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",
|
||||
aReflowState.frame, cell, cellPosition->mWidth.GetCoordValue(), parentWidth);
|
||||
aReflowState.frame, rs->frame, cellPosition->mWidth.GetCoordValue(), parentWidth);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nsIFrame* table = nsnull;
|
||||
rv = rs->frame->QueryInterface(kTableFrameCID, (void**) &table);
|
||||
if (NS_OK==rv) {
|
||||
/* 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
|
||||
table->GetStyleData(eStyleStruct_Position, (const nsStyleStruct *&)tablePosition);
|
||||
table->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing);
|
||||
if (eStyleUnit_Auto == tablePosition->mWidth.GetUnit())
|
||||
rs->frame->GetStyleData(eStyleStruct_Display, (nsStyleStruct *&)display);
|
||||
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;
|
||||
rs->frame->GetGeometricParent(tableFrameParent);
|
||||
tableFrameParent->GetStyleData(eStyleStruct_Display, (nsStyleStruct *&)display);
|
||||
if (NS_STYLE_DISPLAY_TABLE==display->mDisplay)
|
||||
{
|
||||
parentWidth = NS_UNCONSTRAINEDSIZE;
|
||||
if (nsnull != ((nsTableFrame*)table)->mColumnWidths)
|
||||
/* 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())
|
||||
{
|
||||
parentWidth=0;
|
||||
PRInt32 colIndex = ((nsTableCellFrame *)greatgrandchildFrame)->GetColIndex();
|
||||
PRInt32 colSpan = ((nsTableFrame*)table)->GetEffectiveColSpan(colIndex, ((nsTableCellFrame *)greatgrandchildFrame));
|
||||
for (PRInt32 i = 0; i<colSpan; i++)
|
||||
parentWidth += ((nsTableFrame*)table)->GetColumnWidth(i+colIndex);
|
||||
// subtract out cell border and padding
|
||||
greatgrandchildFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing);
|
||||
spacing->CalcBorderPaddingFor(greatgrandchildFrame, borderPadding);
|
||||
parentWidth -= (borderPadding.right + borderPadding.left);
|
||||
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, table, parentWidth, colIndex, colSpan);
|
||||
}
|
||||
else
|
||||
{
|
||||
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, table, parentWidth);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (nsnull!=((nsTableFrame*)table)->mColumnWidths)
|
||||
{
|
||||
parentWidth=0;
|
||||
PRInt32 colIndex = ((nsTableCellFrame*)greatgrandchildFrame)->GetColIndex();
|
||||
PRInt32 colSpan = ((nsTableFrame*)table)->GetEffectiveColSpan(colIndex, ((nsTableCellFrame *)greatgrandchildFrame));
|
||||
for (PRInt32 i = 0; i<colSpan; i++)
|
||||
parentWidth += ((nsTableFrame*)table)->GetColumnWidth(i+colIndex);
|
||||
if (eStyleUnit_Percent == tablePosition->mWidth.GetUnit())
|
||||
parentWidth = NS_UNCONSTRAINEDSIZE;
|
||||
if (nsnull != ((nsTableFrame*)rs->frame)->mColumnWidths)
|
||||
{
|
||||
float percent = tablePosition->mWidth.GetPercentValue();
|
||||
parentWidth = (nscoord)(percent*((float)parentWidth));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nsSize tableSize;
|
||||
table->GetSize(tableSize);
|
||||
parentWidth = tableSize.width;
|
||||
if (0!=tableSize.width)
|
||||
{ // the table has been sized, so we can compute the available space for the child
|
||||
spacing->CalcBorderPaddingFor(rs->frame, borderPadding);
|
||||
parentWidth -= (borderPadding.right + borderPadding.left);
|
||||
// same for the row group
|
||||
childFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing);
|
||||
spacing->CalcBorderPaddingFor(childFrame, borderPadding);
|
||||
parentWidth -= (borderPadding.right + borderPadding.left);
|
||||
// same for the row
|
||||
grandchildFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing);
|
||||
spacing->CalcBorderPaddingFor(grandchildFrame, borderPadding);
|
||||
parentWidth -= (borderPadding.right + borderPadding.left);
|
||||
// same for the cell
|
||||
parentWidth=0;
|
||||
PRInt32 colIndex = ((nsTableCellFrame *)greatgrandchildFrame)->GetColIndex();
|
||||
PRInt32 colSpan = ((nsTableFrame*)rs->frame)->GetEffectiveColSpan(colIndex, ((nsTableCellFrame *)greatgrandchildFrame));
|
||||
for (PRInt32 i = 0; i<colSpan; i++)
|
||||
parentWidth += ((nsTableFrame*)rs->frame)->GetColumnWidth(i+colIndex);
|
||||
// subtract out cell border and padding
|
||||
greatgrandchildFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing);
|
||||
spacing->CalcBorderPaddingFor(greatgrandchildFrame, borderPadding);
|
||||
parentWidth -= (borderPadding.right + borderPadding.left);
|
||||
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);
|
||||
}
|
||||
else
|
||||
{
|
||||
// the table has not yet been sized, so we need to infer the available space
|
||||
parentWidth = rs->maxSize.width;
|
||||
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
|
||||
{
|
||||
if (nsnull!=((nsTableFrame*)rs->frame)->mColumnWidths)
|
||||
{
|
||||
parentWidth=0;
|
||||
PRInt32 colIndex = ((nsTableCellFrame*)greatgrandchildFrame)->GetColIndex();
|
||||
PRInt32 colSpan = ((nsTableFrame*)rs->frame)->GetEffectiveColSpan(colIndex, ((nsTableCellFrame *)greatgrandchildFrame));
|
||||
for (PRInt32 i = 0; i<colSpan; i++)
|
||||
parentWidth += ((nsTableFrame*)rs->frame)->GetColumnWidth(i+colIndex);
|
||||
if (eStyleUnit_Percent == tablePosition->mWidth.GetUnit())
|
||||
{
|
||||
float percent = tablePosition->mWidth.GetPercentValue();
|
||||
parentWidth = (nscoord)(percent*((float)parentWidth));
|
||||
}
|
||||
}
|
||||
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
|
||||
spacing->CalcBorderPaddingFor(rs->frame, borderPadding);
|
||||
parentWidth -= (borderPadding.right + borderPadding.left);
|
||||
// same for the row group
|
||||
childFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing);
|
||||
spacing->CalcBorderPaddingFor(childFrame, borderPadding);
|
||||
parentWidth -= (borderPadding.right + borderPadding.left);
|
||||
// same for the row
|
||||
grandchildFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing);
|
||||
spacing->CalcBorderPaddingFor(grandchildFrame, borderPadding);
|
||||
parentWidth -= (borderPadding.right + borderPadding.left);
|
||||
// same for the cell
|
||||
greatgrandchildFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing);
|
||||
spacing->CalcBorderPaddingFor(greatgrandchildFrame, borderPadding);
|
||||
parentWidth -= (borderPadding.right + borderPadding.left);
|
||||
}
|
||||
else
|
||||
{
|
||||
// the table has not yet been sized, so we need to infer the available space
|
||||
parentWidth = rs->maxSize.width;
|
||||
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);
|
||||
}
|
||||
if (PR_TRUE==gsDebugNT)
|
||||
printf("%p: found a table frame %p, returning parentWidth %d \n",
|
||||
aReflowState.frame, table, parentWidth);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,12 +39,6 @@ struct InnerTableReflowState;
|
|||
struct nsStylePosition;
|
||||
struct nsStyleSpacing;
|
||||
|
||||
/* ff1d2780-06d6-11d2-8f37-006008159b0c */
|
||||
#define NS_TABLEFRAME_CID \
|
||||
{0xff1d2780, 0x06d6, 0x11d2, {0x8f, 0x37, 0x00, 0x60, 0x08, 0x15, 0x9b, 0x0c}}
|
||||
|
||||
extern const nsIID kTableFrameCID;
|
||||
|
||||
/* ============================================================================ */
|
||||
|
||||
/** nsTableFrame maps the inner portion of a table (everything except captions.)
|
||||
|
@ -227,12 +221,6 @@ public:
|
|||
*/
|
||||
PRInt32 GetEffectiveCOLSAttribute();
|
||||
|
||||
/** verify that there are at least aColIndex column frames created.
|
||||
* if not, create the needed col frames
|
||||
*/
|
||||
virtual void EnsureColumnFrameAt(PRInt32 aColIndex,
|
||||
nsIPresContext& aPresContext);
|
||||
|
||||
/** return the index of the next row that is not yet assigned.
|
||||
* If no row is initialized, 0 is returned.
|
||||
*/
|
||||
|
@ -428,13 +416,6 @@ protected:
|
|||
/** sets the width of the table according to the computed widths of each column. */
|
||||
virtual void SetTableWidth(nsIPresContext& aPresContext);
|
||||
|
||||
/**
|
||||
*/
|
||||
virtual void VerticallyAlignChildren(nsIPresContext& aPresContext,
|
||||
nscoord* aAscents,
|
||||
nscoord aMaxAscent,
|
||||
nscoord aMaxHeight);
|
||||
|
||||
/** given the new parent size, do I really need to do a reflow? */
|
||||
virtual PRBool NeedsReflow(const nsHTMLReflowState& aReflowState,
|
||||
const nsSize& aMaxSize);
|
||||
|
@ -487,6 +468,7 @@ protected:
|
|||
*/
|
||||
virtual nsCellMap *GetCellMap() const;
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
/** for debugging only
|
||||
* prints out information about the cell map
|
||||
*/
|
||||
|
@ -496,6 +478,7 @@ protected:
|
|||
* prints out info about the table layout state, printing columns and their cells
|
||||
*/
|
||||
void ListColumnLayoutData(FILE* out, PRInt32 aIndent);
|
||||
#endif
|
||||
|
||||
/** sum the columns represented by all nsTableColGroup objects.
|
||||
* if the cell map says there are more columns than this,
|
||||
|
|
|
@ -638,7 +638,7 @@ void nsTableRowGroupFrame::ShrinkWrapChildren(nsIPresContext* aPresContext,
|
|||
* 1. optimization, if (PR_TRUE==atLeastOneRowSpanningCell) ... otherwise skip this step entirely
|
||||
*/
|
||||
PRInt32 rowGroupHeight;
|
||||
for (PRInt32 counter; counter<2; counter++)
|
||||
for (PRInt32 counter=0; counter<2; counter++)
|
||||
{
|
||||
rowGroupHeight = 0;
|
||||
rowFrame = mFirstChild;
|
||||
|
|
|
@ -454,6 +454,7 @@ PRBool BasicTableLayoutStrategy::AssignPreliminaryColumnWidths()
|
|||
specifiedFixedColWidth=effectiveMinColumnWidth;
|
||||
// do all the global bookkeeping, factoring in margins
|
||||
nscoord colInset = mTableFrame->GetCellSpacing();
|
||||
if (PR_TRUE==gsDebug) printf("* cellSpacing=%d\n", colInset);
|
||||
// keep a running total of the amount of space taken up by all fixed-width columns
|
||||
if ((PR_TRUE==haveColWidth) && (nsTableColFrame::eWIDTH_SOURCE_CELL==colFrame->GetWidthSource()))
|
||||
{
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
|
||||
NS_DEF_PTR(nsIStyleContext);
|
||||
|
||||
const nsIID kTableCellFrameCID = NS_TABLECELLFRAME_CID;
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
static PRBool gsDebug = PR_FALSE;
|
||||
|
@ -297,7 +296,6 @@ NS_METHOD nsTableCellFrame::Reflow(nsIPresContext& aPresContext,
|
|||
if (NS_UNCONSTRAINEDSIZE!=availSize.height)
|
||||
availSize.height -= topInset+bottomInset+margin.top+margin.bottom;
|
||||
|
||||
// XXX Kipp added this hack
|
||||
if (eReflowReason_Incremental == aReflowState.reason)
|
||||
{
|
||||
// XXX We *must* do this otherwise incremental reflow that's
|
||||
|
@ -636,10 +634,6 @@ nsTableCellFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
|||
if (NULL == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aIID.Equals(kTableCellFrameCID)) {
|
||||
*aInstancePtr = (void*) (this);
|
||||
return NS_OK;
|
||||
}
|
||||
return nsContainerFrame::QueryInterface(aIID, aInstancePtr);
|
||||
}
|
||||
|
||||
|
|
|
@ -25,11 +25,6 @@
|
|||
|
||||
struct nsStyleSpacing;
|
||||
|
||||
/* eb42f7b0-079e-11d2-8f37-006008159b0c */
|
||||
#define NS_TABLECELLFRAME_CID \
|
||||
{0xeb42f7b0, 0x079e, 0x11d2, {0x8f, 0x37, 0x00, 0x60, 0x08, 0x15, 0x9b, 0x0c}}
|
||||
|
||||
extern const nsIID kTableCellFrameCID;
|
||||
|
||||
/**
|
||||
* nsTableCellFrame
|
||||
|
|
|
@ -61,8 +61,6 @@ static const PRBool gsDebugIR = PR_FALSE;
|
|||
NS_DEF_PTR(nsIStyleContext);
|
||||
NS_DEF_PTR(nsIContent);
|
||||
|
||||
const nsIID kTableFrameCID = NS_TABLEFRAME_CID;
|
||||
|
||||
static const PRInt32 kColumnWidthIncrement=100;
|
||||
|
||||
/* ----------- CellData ---------- */
|
||||
|
@ -762,128 +760,6 @@ void nsTableFrame::EnsureColumns(nsIPresContext& aPresContext)
|
|||
}
|
||||
}
|
||||
|
||||
/** 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.
|
||||
*/
|
||||
// XXX should be nsresult, not void
|
||||
void nsTableFrame::EnsureColumnFrameAt(PRInt32 aColIndex,
|
||||
nsIPresContext& aPresContext)
|
||||
{
|
||||
nsresult rv;
|
||||
PRInt32 actualColumns = 0;
|
||||
nsTableColGroupFrame *lastColGroupFrame = nsnull;
|
||||
nsIFrame * firstRowGroupFrame=nsnull;
|
||||
nsIFrame * prevSibFrame=nsnull; // this is the child just before the first row group frame
|
||||
nsIFrame * childFrame=mFirstChild;
|
||||
while (nsnull!=childFrame)
|
||||
{
|
||||
const nsStyleDisplay *childDisplay;
|
||||
childFrame->GetStyleData(eStyleStruct_Display, ((nsStyleStruct *&)childDisplay));
|
||||
if (NS_STYLE_DISPLAY_TABLE_COLUMN_GROUP == childDisplay->mDisplay)
|
||||
{
|
||||
PRInt32 numCols = ((nsTableColGroupFrame*)childFrame)->GetColumnCount();
|
||||
actualColumns += numCols;
|
||||
lastColGroupFrame = (nsTableColGroupFrame *)childFrame;
|
||||
if (actualColumns > aColIndex)
|
||||
break; // we have enough col frames at this point
|
||||
}
|
||||
else if (PR_TRUE==IsRowGroup(childDisplay->mDisplay))
|
||||
{
|
||||
if (nsnull==firstRowGroupFrame)
|
||||
firstRowGroupFrame = childFrame;
|
||||
}
|
||||
if (nsnull==firstRowGroupFrame)
|
||||
prevSibFrame = childFrame;
|
||||
childFrame->GetNextSibling(childFrame);
|
||||
}
|
||||
if (actualColumns <= aColIndex)
|
||||
{
|
||||
nsIHTMLContent *lastColGroup=nsnull;
|
||||
if (nsnull==lastColGroupFrame)
|
||||
{
|
||||
// create an implicit colgroup
|
||||
nsAutoString colGroupTag;
|
||||
nsHTMLAtoms::colgroup->ToString(colGroupTag);
|
||||
rv = NS_CreateHTMLElement(&lastColGroup, colGroupTag); // ADDREF a: lastColGroup++
|
||||
//XXX: make synthetic
|
||||
//XXX mark it as implicit!
|
||||
mContent->AppendChildTo(lastColGroup, PR_FALSE); // add the implicit colgroup to my content
|
||||
// Resolve style for the child
|
||||
nsIStyleContext* colGroupStyleContext =
|
||||
aPresContext.ResolveStyleContextFor(lastColGroup, mStyleContext, PR_TRUE); // kidStyleContext: REFCNT++
|
||||
|
||||
// Create a col group frame
|
||||
nsIFrame* newFrame;
|
||||
NS_NewTableColGroupFrame(lastColGroup, this, newFrame);
|
||||
lastColGroupFrame = (nsTableColGroupFrame*)newFrame;
|
||||
lastColGroupFrame->SetStyleContext(&aPresContext, colGroupStyleContext);
|
||||
NS_RELEASE(colGroupStyleContext); // kidStyleContenxt: REFCNT--
|
||||
|
||||
// hook lastColGroupFrame into child list
|
||||
if (nsnull==firstRowGroupFrame)
|
||||
{ // make lastColGroupFrame the last frame
|
||||
nsIFrame *lastChild = LastFrame(mFirstChild);
|
||||
lastChild->SetNextSibling(lastColGroupFrame);
|
||||
}
|
||||
else
|
||||
{ // insert lastColGroupFrame before the first row group frame
|
||||
if (nsnull!=prevSibFrame)
|
||||
{ // lastColGroupFrame is inserted between prevSibFrame and lastColGroupFrame
|
||||
prevSibFrame->SetNextSibling(lastColGroupFrame);
|
||||
}
|
||||
else
|
||||
{ // lastColGroupFrame is inserted as the first child of this table
|
||||
mFirstChild = lastColGroupFrame;
|
||||
}
|
||||
lastColGroupFrame->SetNextSibling(firstRowGroupFrame);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lastColGroupFrame->GetContent((nsIContent *&)lastColGroup); // ADDREF b: lastColGroup++
|
||||
}
|
||||
|
||||
nsAutoString colTag;
|
||||
nsHTMLAtoms::col->ToString(colTag);
|
||||
PRInt32 excessColumns = aColIndex - actualColumns;
|
||||
nsIFrame* firstNewColFrame = nsnull;
|
||||
nsIFrame* lastNewColFrame = nsnull;
|
||||
nsIStyleContextPtr lastColGroupStyle;
|
||||
lastColGroupFrame->GetStyleContext(lastColGroupStyle.AssignRef());
|
||||
for ( ; excessColumns >= 0; excessColumns--)
|
||||
{
|
||||
nsIHTMLContent *col=nsnull;
|
||||
// create an implicit col
|
||||
rv = NS_CreateHTMLElement(&col, colTag); // ADDREF: col++
|
||||
//XXX: make synthetic
|
||||
lastColGroup->AppendChildTo((nsIContent*)col, PR_FALSE);
|
||||
|
||||
// Create a new col frame
|
||||
nsIFrame* colFrame;
|
||||
NS_NewTableColFrame(col, lastColGroupFrame, colFrame);
|
||||
|
||||
// Set its style context
|
||||
nsIStyleContextPtr colStyleContext =
|
||||
aPresContext.ResolveStyleContextFor(col, lastColGroupStyle, PR_TRUE);
|
||||
colFrame->SetStyleContext(&aPresContext, colStyleContext);
|
||||
|
||||
// XXX Don't release this style context (or we'll end up with a double-free).\
|
||||
// This code is doing what nsTableColGroupFrame::Reflow() does...
|
||||
//NS_RELEASE(colStyleContext);
|
||||
|
||||
// Add it to our list
|
||||
if (nsnull == lastNewColFrame) {
|
||||
firstNewColFrame = colFrame;
|
||||
} else {
|
||||
lastNewColFrame->SetNextSibling(colFrame);
|
||||
}
|
||||
lastNewColFrame = colFrame;
|
||||
NS_RELEASE(col); // ADDREF: col--
|
||||
}
|
||||
NS_RELEASE(lastColGroup); // ADDREF: lastColGroup--
|
||||
}
|
||||
}
|
||||
|
||||
void nsTableFrame::AddColumnFrame (nsTableColFrame *aColFrame)
|
||||
{
|
||||
|
@ -957,7 +833,14 @@ void nsTableFrame::SetMinColSpanForTable()
|
|||
}
|
||||
}
|
||||
if (1<minColSpan)
|
||||
{
|
||||
mCellMap->SetMinColSpan(colIndex, minColSpan);
|
||||
if (gsDebug==PR_TRUE)
|
||||
{
|
||||
printf("minColSpan for col %d set to %d\n", colIndex, minColSpan);
|
||||
DumpCellMap();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1040,8 +923,7 @@ NS_METHOD nsTableFrame::ReBuildCellMap()
|
|||
return rv;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
#ifdef NS_DEBUG
|
||||
void nsTableFrame::DumpCellMap ()
|
||||
{
|
||||
printf("dumping CellMap:\n");
|
||||
|
@ -1113,6 +995,7 @@ void nsTableFrame::DumpCellMap ()
|
|||
else
|
||||
printf ("[nsnull]");
|
||||
}
|
||||
#endif
|
||||
|
||||
void nsTableFrame::BuildCellIntoMap (nsTableCellFrame *aCell, PRInt32 aRowIndex, PRInt32 aColIndex)
|
||||
{
|
||||
|
@ -1203,6 +1086,7 @@ void nsTableFrame::GrowCellMap (PRInt32 aColCount)
|
|||
* around and lists the cell layout data.
|
||||
* This is for debugging purposes only.
|
||||
*/
|
||||
#ifdef NS_DEBUG
|
||||
void nsTableFrame::ListColumnLayoutData(FILE* out, PRInt32 aIndent)
|
||||
{
|
||||
nsTableFrame * firstInFlow = (nsTableFrame *)GetFirstInFlow();
|
||||
|
@ -1258,6 +1142,7 @@ void nsTableFrame::ListColumnLayoutData(FILE* out, PRInt32 aIndent)
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* For the TableCell in CellData, add it to the list
|
||||
|
@ -1809,7 +1694,6 @@ NS_METHOD nsTableFrame::ResizeReflowPass2(nsIPresContext& aPresContext,
|
|||
const nsHTMLReflowState& aReflowState,
|
||||
nsReflowStatus& aStatus)
|
||||
{
|
||||
//DumpCellMap();
|
||||
NS_PRECONDITION(aReflowState.frame == this, "bad reflow state");
|
||||
NS_PRECONDITION(aReflowState.parentReflowState->frame == mGeometricParent,
|
||||
"bad parent reflow state");
|
||||
|
@ -2871,13 +2755,6 @@ void nsTableFrame::SetTableWidth(nsIPresContext& aPresContext)
|
|||
SetRect(tableSize);
|
||||
}
|
||||
|
||||
void nsTableFrame::VerticallyAlignChildren(nsIPresContext& aPresContext,
|
||||
nscoord* aAscents,
|
||||
nscoord aMaxAscent,
|
||||
nscoord aMaxHeight)
|
||||
{
|
||||
}
|
||||
|
||||
void nsTableFrame::AdjustColumnsForCOLSAttribute()
|
||||
{
|
||||
nsCellMap *cellMap = GetCellMap();
|
||||
|
@ -3507,10 +3384,6 @@ nsTableFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
|||
if (NULL == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aIID.Equals(kTableFrameCID)) {
|
||||
*aInstancePtr = (void*) (this);
|
||||
return NS_OK;
|
||||
}
|
||||
return nsContainerFrame::QueryInterface(aIID, aInstancePtr);
|
||||
}
|
||||
|
||||
|
@ -3575,7 +3448,6 @@ NS_METHOD nsTableFrame::GetTableFrame(nsIFrame *aSourceFrame, nsTableFrame *& aT
|
|||
/* helper method for determining if this is a nested table or not */
|
||||
PRBool nsTableFrame::IsNested(const nsHTMLReflowState& aReflowState, nsStylePosition *& aPosition) const
|
||||
{
|
||||
nsresult rv;
|
||||
PRBool result = PR_FALSE;
|
||||
#ifdef NS_DEBUG
|
||||
PRInt32 counter=0;
|
||||
|
@ -3589,12 +3461,12 @@ PRBool nsTableFrame::IsNested(const nsHTMLReflowState& aReflowState, nsStylePosi
|
|||
NS_ASSERTION(counter<100000, "infinite loop in IsNested");
|
||||
break;
|
||||
#endif
|
||||
nsIFrame* parentTable = nsnull;
|
||||
rv = rs->frame->QueryInterface(kTableFrameCID, (void**) &parentTable);
|
||||
if (NS_OK==rv)
|
||||
const nsStyleDisplay *display;
|
||||
rs->frame->GetStyleData(eStyleStruct_Display, (nsStyleStruct *&)display);
|
||||
if (NS_STYLE_DISPLAY_TABLE==display->mDisplay)
|
||||
{
|
||||
result = PR_TRUE;
|
||||
parentTable->GetStyleData(eStyleStruct_Position, ((nsStyleStruct *&)aPosition));
|
||||
rs->frame->GetStyleData(eStyleStruct_Position, ((nsStyleStruct *&)aPosition));
|
||||
break;
|
||||
}
|
||||
rs = rs->parentReflowState;
|
||||
|
@ -3606,7 +3478,7 @@ PRBool nsTableFrame::IsNested(const nsHTMLReflowState& aReflowState, nsStylePosi
|
|||
/* helper method for getting the width of the table's containing block */
|
||||
nscoord nsTableFrame::GetTableContainerWidth(const nsHTMLReflowState& aReflowState)
|
||||
{
|
||||
nsresult rv;
|
||||
const nsStyleDisplay *display;
|
||||
nscoord parentWidth = aReflowState.maxSize.width;
|
||||
|
||||
// Walk up the reflow state chain until we find a block
|
||||
|
@ -3618,9 +3490,8 @@ nscoord nsTableFrame::GetTableContainerWidth(const nsHTMLReflowState& aReflowSta
|
|||
while (nsnull != rs)
|
||||
{
|
||||
// if it's a block, use its max width
|
||||
nsIFrame* block = nsnull;
|
||||
rv = rs->frame->QueryInterface(kBlockFrameCID, (void**) &block);
|
||||
if (NS_OK==rv)
|
||||
rs->frame->GetStyleData(eStyleStruct_Display, (nsStyleStruct *&)display);
|
||||
if (NS_STYLE_DISPLAY_BLOCK==display->mDisplay)
|
||||
{ // we found a block, see if it's really a table cell (which means we're a nested table)
|
||||
PRBool skipThisBlock=PR_FALSE;
|
||||
const nsReflowState* parentRS = rs->parentReflowState;
|
||||
|
@ -3629,11 +3500,10 @@ nscoord nsTableFrame::GetTableContainerWidth(const nsHTMLReflowState& aReflowSta
|
|||
parentRS = parentRS->parentReflowState;
|
||||
if (nsnull!=parentRS)
|
||||
{
|
||||
nsIFrame* cell = nsnull;
|
||||
rv = parentRS->frame->QueryInterface(kTableCellFrameCID, (void**) &cell);
|
||||
if (rv == NS_OK) {
|
||||
parentRS->frame->GetStyleData(eStyleStruct_Display, (nsStyleStruct *&)display);
|
||||
if (NS_STYLE_DISPLAY_TABLE_CELL==display->mDisplay) {
|
||||
if (PR_TRUE==gsDebugNT)
|
||||
printf("%p: found a block pframe %p in a cell, skipping it.\n", aReflowState.frame, block);
|
||||
printf("%p: found a block pframe %p in a cell, skipping it.\n", aReflowState.frame, rs->frame);
|
||||
skipThisBlock = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
@ -3647,7 +3517,7 @@ nscoord nsTableFrame::GetTableContainerWidth(const nsHTMLReflowState& aReflowSta
|
|||
parentWidth = rs->maxSize.width;
|
||||
if (PR_TRUE==gsDebugNT)
|
||||
printf("%p: found a block frame %p, returning width %d\n",
|
||||
aReflowState.frame, block, parentWidth);
|
||||
aReflowState.frame, rs->frame, parentWidth);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -3658,23 +3528,21 @@ nscoord nsTableFrame::GetTableContainerWidth(const nsHTMLReflowState& aReflowSta
|
|||
nsMargin borderPadding;
|
||||
const nsStylePosition* tablePosition;
|
||||
const nsStyleSpacing* spacing;
|
||||
nsIFrame* cell = nsnull;
|
||||
rv = rs->frame->QueryInterface(kTableCellFrameCID, (void**) &cell);
|
||||
// if the cell has a specified width, use it
|
||||
if (NS_OK==rv)
|
||||
{
|
||||
rs->frame->GetStyleData(eStyleStruct_Display, (nsStyleStruct *&)display);
|
||||
if (NS_STYLE_DISPLAY_TABLE_CELL==display->mDisplay)
|
||||
{ // if it's a cell and the cell has a specified width, use it
|
||||
// Compute and subtract out the insets (sum of border and padding) for the table
|
||||
const nsStylePosition* cellPosition;
|
||||
cell->GetStyleData(eStyleStruct_Position, ((nsStyleStruct *&)cellPosition));
|
||||
rs->frame->GetStyleData(eStyleStruct_Position, ((nsStyleStruct *&)cellPosition));
|
||||
if (eStyleUnit_Coord == cellPosition->mWidth.GetUnit())
|
||||
{
|
||||
nsTableFrame *tableParent;
|
||||
rv=GetTableFrame(cell, tableParent);
|
||||
nsresult rv=GetTableFrame(rs->frame, tableParent);
|
||||
if ((NS_OK==rv) && (nsnull!=tableParent) && (nsnull!=tableParent->mColumnWidths))
|
||||
{
|
||||
parentWidth=0;
|
||||
PRInt32 colIndex = ((nsTableCellFrame *)cell)->GetColIndex();
|
||||
PRInt32 colSpan = tableParent->GetEffectiveColSpan(colIndex, (nsTableCellFrame *)cell);
|
||||
PRInt32 colIndex = ((nsTableCellFrame *)rs->frame)->GetColIndex();
|
||||
PRInt32 colSpan = tableParent->GetEffectiveColSpan(colIndex, (nsTableCellFrame *)rs->frame);
|
||||
for (PRInt32 i=0; i<colSpan; i++)
|
||||
parentWidth += tableParent->GetColumnWidth(colIndex);
|
||||
break;
|
||||
|
@ -3685,111 +3553,119 @@ nscoord nsTableFrame::GetTableContainerWidth(const nsHTMLReflowState& aReflowSta
|
|||
{
|
||||
parentWidth = cellPosition->mWidth.GetCoordValue();
|
||||
// subtract out cell border and padding
|
||||
cell->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing);
|
||||
spacing->CalcBorderPaddingFor(cell, borderPadding);
|
||||
rs->frame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing);
|
||||
spacing->CalcBorderPaddingFor(rs->frame, borderPadding);
|
||||
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",
|
||||
aReflowState.frame, cell, cellPosition->mWidth.GetCoordValue(), parentWidth);
|
||||
aReflowState.frame, rs->frame, cellPosition->mWidth.GetCoordValue(), parentWidth);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nsIFrame* table = nsnull;
|
||||
rv = rs->frame->QueryInterface(kTableFrameCID, (void**) &table);
|
||||
if (NS_OK==rv) {
|
||||
/* 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
|
||||
table->GetStyleData(eStyleStruct_Position, (const nsStyleStruct *&)tablePosition);
|
||||
table->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing);
|
||||
if (eStyleUnit_Auto == tablePosition->mWidth.GetUnit())
|
||||
rs->frame->GetStyleData(eStyleStruct_Display, (nsStyleStruct *&)display);
|
||||
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;
|
||||
rs->frame->GetGeometricParent(tableFrameParent);
|
||||
tableFrameParent->GetStyleData(eStyleStruct_Display, (nsStyleStruct *&)display);
|
||||
if (NS_STYLE_DISPLAY_TABLE==display->mDisplay)
|
||||
{
|
||||
parentWidth = NS_UNCONSTRAINEDSIZE;
|
||||
if (nsnull != ((nsTableFrame*)table)->mColumnWidths)
|
||||
/* 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())
|
||||
{
|
||||
parentWidth=0;
|
||||
PRInt32 colIndex = ((nsTableCellFrame *)greatgrandchildFrame)->GetColIndex();
|
||||
PRInt32 colSpan = ((nsTableFrame*)table)->GetEffectiveColSpan(colIndex, ((nsTableCellFrame *)greatgrandchildFrame));
|
||||
for (PRInt32 i = 0; i<colSpan; i++)
|
||||
parentWidth += ((nsTableFrame*)table)->GetColumnWidth(i+colIndex);
|
||||
// subtract out cell border and padding
|
||||
greatgrandchildFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing);
|
||||
spacing->CalcBorderPaddingFor(greatgrandchildFrame, borderPadding);
|
||||
parentWidth -= (borderPadding.right + borderPadding.left);
|
||||
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, table, parentWidth, colIndex, colSpan);
|
||||
}
|
||||
else
|
||||
{
|
||||
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, table, parentWidth);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (nsnull!=((nsTableFrame*)table)->mColumnWidths)
|
||||
{
|
||||
parentWidth=0;
|
||||
PRInt32 colIndex = ((nsTableCellFrame*)greatgrandchildFrame)->GetColIndex();
|
||||
PRInt32 colSpan = ((nsTableFrame*)table)->GetEffectiveColSpan(colIndex, ((nsTableCellFrame *)greatgrandchildFrame));
|
||||
for (PRInt32 i = 0; i<colSpan; i++)
|
||||
parentWidth += ((nsTableFrame*)table)->GetColumnWidth(i+colIndex);
|
||||
if (eStyleUnit_Percent == tablePosition->mWidth.GetUnit())
|
||||
parentWidth = NS_UNCONSTRAINEDSIZE;
|
||||
if (nsnull != ((nsTableFrame*)rs->frame)->mColumnWidths)
|
||||
{
|
||||
float percent = tablePosition->mWidth.GetPercentValue();
|
||||
parentWidth = (nscoord)(percent*((float)parentWidth));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nsSize tableSize;
|
||||
table->GetSize(tableSize);
|
||||
parentWidth = tableSize.width;
|
||||
if (0!=tableSize.width)
|
||||
{ // the table has been sized, so we can compute the available space for the child
|
||||
spacing->CalcBorderPaddingFor(rs->frame, borderPadding);
|
||||
parentWidth -= (borderPadding.right + borderPadding.left);
|
||||
// same for the row group
|
||||
childFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing);
|
||||
spacing->CalcBorderPaddingFor(childFrame, borderPadding);
|
||||
parentWidth -= (borderPadding.right + borderPadding.left);
|
||||
// same for the row
|
||||
grandchildFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing);
|
||||
spacing->CalcBorderPaddingFor(grandchildFrame, borderPadding);
|
||||
parentWidth -= (borderPadding.right + borderPadding.left);
|
||||
// same for the cell
|
||||
parentWidth=0;
|
||||
PRInt32 colIndex = ((nsTableCellFrame *)greatgrandchildFrame)->GetColIndex();
|
||||
PRInt32 colSpan = ((nsTableFrame*)rs->frame)->GetEffectiveColSpan(colIndex, ((nsTableCellFrame *)greatgrandchildFrame));
|
||||
for (PRInt32 i = 0; i<colSpan; i++)
|
||||
parentWidth += ((nsTableFrame*)rs->frame)->GetColumnWidth(i+colIndex);
|
||||
// subtract out cell border and padding
|
||||
greatgrandchildFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing);
|
||||
spacing->CalcBorderPaddingFor(greatgrandchildFrame, borderPadding);
|
||||
parentWidth -= (borderPadding.right + borderPadding.left);
|
||||
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);
|
||||
}
|
||||
else
|
||||
{
|
||||
// the table has not yet been sized, so we need to infer the available space
|
||||
parentWidth = rs->maxSize.width;
|
||||
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
|
||||
{
|
||||
if (nsnull!=((nsTableFrame*)rs->frame)->mColumnWidths)
|
||||
{
|
||||
parentWidth=0;
|
||||
PRInt32 colIndex = ((nsTableCellFrame*)greatgrandchildFrame)->GetColIndex();
|
||||
PRInt32 colSpan = ((nsTableFrame*)rs->frame)->GetEffectiveColSpan(colIndex, ((nsTableCellFrame *)greatgrandchildFrame));
|
||||
for (PRInt32 i = 0; i<colSpan; i++)
|
||||
parentWidth += ((nsTableFrame*)rs->frame)->GetColumnWidth(i+colIndex);
|
||||
if (eStyleUnit_Percent == tablePosition->mWidth.GetUnit())
|
||||
{
|
||||
float percent = tablePosition->mWidth.GetPercentValue();
|
||||
parentWidth = (nscoord)(percent*((float)parentWidth));
|
||||
}
|
||||
}
|
||||
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
|
||||
spacing->CalcBorderPaddingFor(rs->frame, borderPadding);
|
||||
parentWidth -= (borderPadding.right + borderPadding.left);
|
||||
// same for the row group
|
||||
childFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing);
|
||||
spacing->CalcBorderPaddingFor(childFrame, borderPadding);
|
||||
parentWidth -= (borderPadding.right + borderPadding.left);
|
||||
// same for the row
|
||||
grandchildFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing);
|
||||
spacing->CalcBorderPaddingFor(grandchildFrame, borderPadding);
|
||||
parentWidth -= (borderPadding.right + borderPadding.left);
|
||||
// same for the cell
|
||||
greatgrandchildFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing);
|
||||
spacing->CalcBorderPaddingFor(greatgrandchildFrame, borderPadding);
|
||||
parentWidth -= (borderPadding.right + borderPadding.left);
|
||||
}
|
||||
else
|
||||
{
|
||||
// the table has not yet been sized, so we need to infer the available space
|
||||
parentWidth = rs->maxSize.width;
|
||||
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);
|
||||
}
|
||||
if (PR_TRUE==gsDebugNT)
|
||||
printf("%p: found a table frame %p, returning parentWidth %d \n",
|
||||
aReflowState.frame, table, parentWidth);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,12 +39,6 @@ struct InnerTableReflowState;
|
|||
struct nsStylePosition;
|
||||
struct nsStyleSpacing;
|
||||
|
||||
/* ff1d2780-06d6-11d2-8f37-006008159b0c */
|
||||
#define NS_TABLEFRAME_CID \
|
||||
{0xff1d2780, 0x06d6, 0x11d2, {0x8f, 0x37, 0x00, 0x60, 0x08, 0x15, 0x9b, 0x0c}}
|
||||
|
||||
extern const nsIID kTableFrameCID;
|
||||
|
||||
/* ============================================================================ */
|
||||
|
||||
/** nsTableFrame maps the inner portion of a table (everything except captions.)
|
||||
|
@ -227,12 +221,6 @@ public:
|
|||
*/
|
||||
PRInt32 GetEffectiveCOLSAttribute();
|
||||
|
||||
/** verify that there are at least aColIndex column frames created.
|
||||
* if not, create the needed col frames
|
||||
*/
|
||||
virtual void EnsureColumnFrameAt(PRInt32 aColIndex,
|
||||
nsIPresContext& aPresContext);
|
||||
|
||||
/** return the index of the next row that is not yet assigned.
|
||||
* If no row is initialized, 0 is returned.
|
||||
*/
|
||||
|
@ -428,13 +416,6 @@ protected:
|
|||
/** sets the width of the table according to the computed widths of each column. */
|
||||
virtual void SetTableWidth(nsIPresContext& aPresContext);
|
||||
|
||||
/**
|
||||
*/
|
||||
virtual void VerticallyAlignChildren(nsIPresContext& aPresContext,
|
||||
nscoord* aAscents,
|
||||
nscoord aMaxAscent,
|
||||
nscoord aMaxHeight);
|
||||
|
||||
/** given the new parent size, do I really need to do a reflow? */
|
||||
virtual PRBool NeedsReflow(const nsHTMLReflowState& aReflowState,
|
||||
const nsSize& aMaxSize);
|
||||
|
@ -487,6 +468,7 @@ protected:
|
|||
*/
|
||||
virtual nsCellMap *GetCellMap() const;
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
/** for debugging only
|
||||
* prints out information about the cell map
|
||||
*/
|
||||
|
@ -496,6 +478,7 @@ protected:
|
|||
* prints out info about the table layout state, printing columns and their cells
|
||||
*/
|
||||
void ListColumnLayoutData(FILE* out, PRInt32 aIndent);
|
||||
#endif
|
||||
|
||||
/** sum the columns represented by all nsTableColGroup objects.
|
||||
* if the cell map says there are more columns than this,
|
||||
|
|
|
@ -638,7 +638,7 @@ void nsTableRowGroupFrame::ShrinkWrapChildren(nsIPresContext* aPresContext,
|
|||
* 1. optimization, if (PR_TRUE==atLeastOneRowSpanningCell) ... otherwise skip this step entirely
|
||||
*/
|
||||
PRInt32 rowGroupHeight;
|
||||
for (PRInt32 counter; counter<2; counter++)
|
||||
for (PRInt32 counter=0; counter<2; counter++)
|
||||
{
|
||||
rowGroupHeight = 0;
|
||||
rowFrame = mFirstChild;
|
||||
|
|
Загрузка…
Ссылка в новой задаче