diff --git a/mozilla/content/base/src/nsStyleContext.cpp b/mozilla/content/base/src/nsStyleContext.cpp index 73cdb506221..ab298c598ac 100644 --- a/mozilla/content/base/src/nsStyleContext.cpp +++ b/mozilla/content/base/src/nsStyleContext.cpp @@ -537,6 +537,7 @@ struct StyleTableImpl: public nsStyleTable { StyleTableImpl::StyleTableImpl() { + mLayoutStrategy = NS_STYLE_TABLE_LAYOUT_AUTO; ResetFrom(nsnull, nsnull); } @@ -549,6 +550,9 @@ void StyleTableImpl::ResetFrom(const nsStyleTable* aParent, nsIPresContext* aPre mCellPadding.Reset(); mCellSpacing.Reset(); mSpan=0; + // values inherited + if (nsnull!=aParent) + mLayoutStrategy = aParent->mLayoutStrategy; } diff --git a/mozilla/content/html/content/src/nsHTMLAtoms.cpp b/mozilla/content/html/content/src/nsHTMLAtoms.cpp index c31e1918ea5..1ccdcb22b62 100644 --- a/mozilla/content/html/content/src/nsHTMLAtoms.cpp +++ b/mozilla/content/html/content/src/nsHTMLAtoms.cpp @@ -114,6 +114,7 @@ nsIAtom* nsHTMLAtoms::input; nsIAtom* nsHTMLAtoms::ismap; nsIAtom* nsHTMLAtoms::label; nsIAtom* nsHTMLAtoms::lang; +nsIAtom* nsHTMLAtoms::layout; nsIAtom* nsHTMLAtoms::li; nsIAtom* nsHTMLAtoms::link; nsIAtom* nsHTMLAtoms::left; @@ -321,6 +322,7 @@ void nsHTMLAtoms::AddrefAtoms() ismap = NS_NewAtom("ISMAP"); label = NS_NewAtom("LABEL"); lang = NS_NewAtom("LANG"); + layout = NS_NewAtom("LAYOUT"); li = NS_NewAtom("LI"); link = NS_NewAtom("LINK"); left = NS_NewAtom("LEFT"); @@ -521,6 +523,7 @@ void nsHTMLAtoms::ReleaseAtoms() NS_RELEASE(ismap); NS_RELEASE(label); NS_RELEASE(lang); + NS_RELEASE(layout); NS_RELEASE(li); NS_RELEASE(link); NS_RELEASE(left); diff --git a/mozilla/content/html/content/src/nsHTMLAtoms.h b/mozilla/content/html/content/src/nsHTMLAtoms.h index cec83e499d1..46cc95da323 100644 --- a/mozilla/content/html/content/src/nsHTMLAtoms.h +++ b/mozilla/content/html/content/src/nsHTMLAtoms.h @@ -142,6 +142,7 @@ public: static nsIAtom* label; static nsIAtom* lang; + static nsIAtom* layout; static nsIAtom* li; static nsIAtom* link; static nsIAtom* left; diff --git a/mozilla/content/html/content/src/nsHTMLTableElement.cpp b/mozilla/content/html/content/src/nsHTMLTableElement.cpp index 29d5d9e8e8b..ac0b9d190e5 100644 --- a/mozilla/content/html/content/src/nsHTMLTableElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLTableElement.cpp @@ -309,6 +309,12 @@ static nsGenericHTMLElement::EnumTable kRulesTable[] = { { 0 } }; +static nsGenericHTMLElement::EnumTable kLayoutTable[] = { + { "auto", NS_STYLE_TABLE_LAYOUT_AUTO }, + { "fixed", NS_STYLE_TABLE_LAYOUT_FIXED }, + { 0 } +}; + NS_IMETHODIMP nsHTMLTableElement::StringToAttribute(nsIAtom* aAttribute, @@ -385,6 +391,10 @@ nsHTMLTableElement::StringToAttribute(nsIAtom* aAttribute, nsGenericHTMLElement::ParseEnumValue(aValue, kFrameTable, aResult); return NS_CONTENT_ATTR_HAS_VALUE; } + else if (aAttribute == nsHTMLAtoms::layout) { + nsGenericHTMLElement::ParseEnumValue(aValue, kLayoutTable, aResult); + return NS_CONTENT_ATTR_HAS_VALUE; + } else if (aAttribute == nsHTMLAtoms::rules) { nsGenericHTMLElement::ParseEnumValue(aValue, kRulesTable, aResult); return NS_CONTENT_ATTR_HAS_VALUE; @@ -412,6 +422,11 @@ nsHTMLTableElement::AttributeToString(nsIAtom* aAttribute, return NS_CONTENT_ATTR_HAS_VALUE; } } + else if (aAttribute == nsHTMLAtoms::layout) { + if (nsGenericHTMLElement::EnumValueToString(aValue, kLayoutTable, aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } + } else if (aAttribute == nsHTMLAtoms::rules) { if (nsGenericHTMLElement::EnumValueToString(aValue, kRulesTable, aResult)) { return NS_CONTENT_ATTR_HAS_VALUE; @@ -519,11 +534,19 @@ MapAttributesInto(nsIHTMLAttributes* aAttributes, } } - // cellpadding + // layout nsStyleTable* tableStyle=nsnull; + aAttributes->GetAttribute(nsHTMLAtoms::layout, value); + if (value.GetUnit() == eHTMLUnit_Enumerated) { // it may be another type if illegal + tableStyle = (nsStyleTable*)aContext->GetMutableStyleData(eStyleStruct_Table); + tableStyle->mLayoutStrategy = value.GetIntValue(); + } + + // cellpadding aAttributes->GetAttribute(nsHTMLAtoms::cellpadding, value); if (value.GetUnit() == eHTMLUnit_Pixel) { - tableStyle = (nsStyleTable*)aContext->GetMutableStyleData(eStyleStruct_Table); + if (nsnull==tableStyle) + tableStyle = (nsStyleTable*)aContext->GetMutableStyleData(eStyleStruct_Table); tableStyle->mCellPadding.SetCoordValue(NSIntPixelsToTwips(value.GetPixelValue(), p2t)); } diff --git a/mozilla/content/shared/public/nsHTMLAtoms.h b/mozilla/content/shared/public/nsHTMLAtoms.h index cec83e499d1..46cc95da323 100644 --- a/mozilla/content/shared/public/nsHTMLAtoms.h +++ b/mozilla/content/shared/public/nsHTMLAtoms.h @@ -142,6 +142,7 @@ public: static nsIAtom* label; static nsIAtom* lang; + static nsIAtom* layout; static nsIAtom* li; static nsIAtom* link; static nsIAtom* left; diff --git a/mozilla/content/shared/src/nsHTMLAtoms.cpp b/mozilla/content/shared/src/nsHTMLAtoms.cpp index c31e1918ea5..1ccdcb22b62 100644 --- a/mozilla/content/shared/src/nsHTMLAtoms.cpp +++ b/mozilla/content/shared/src/nsHTMLAtoms.cpp @@ -114,6 +114,7 @@ nsIAtom* nsHTMLAtoms::input; nsIAtom* nsHTMLAtoms::ismap; nsIAtom* nsHTMLAtoms::label; nsIAtom* nsHTMLAtoms::lang; +nsIAtom* nsHTMLAtoms::layout; nsIAtom* nsHTMLAtoms::li; nsIAtom* nsHTMLAtoms::link; nsIAtom* nsHTMLAtoms::left; @@ -321,6 +322,7 @@ void nsHTMLAtoms::AddrefAtoms() ismap = NS_NewAtom("ISMAP"); label = NS_NewAtom("LABEL"); lang = NS_NewAtom("LANG"); + layout = NS_NewAtom("LAYOUT"); li = NS_NewAtom("LI"); link = NS_NewAtom("LINK"); left = NS_NewAtom("LEFT"); @@ -521,6 +523,7 @@ void nsHTMLAtoms::ReleaseAtoms() NS_RELEASE(ismap); NS_RELEASE(label); NS_RELEASE(lang); + NS_RELEASE(layout); NS_RELEASE(li); NS_RELEASE(link); NS_RELEASE(left); diff --git a/mozilla/layout/base/public/nsIStyleContext.h b/mozilla/layout/base/public/nsIStyleContext.h index 595b0d5a304..33a2f2b879e 100644 --- a/mozilla/layout/base/public/nsIStyleContext.h +++ b/mozilla/layout/base/public/nsIStyleContext.h @@ -154,6 +154,7 @@ protected: }; struct nsStyleTable: public nsStyleStruct { + PRUint8 mLayoutStrategy;// [inherited] see nsStyleConsts.h NS_STYLE_TABLE_LAYOUT_* PRUint8 mFrame; // [reset] see nsStyleConsts.h NS_STYLE_TABLE_FRAME_* PRUint8 mRules; // [reset] see nsStyleConsts.h NS_STYLE_TABLE_RULES_* nsStyleCoord mCellPadding; // [reset] diff --git a/mozilla/layout/base/src/nsStyleConsts.h b/mozilla/layout/base/src/nsStyleConsts.h index e1985590506..9fe220526c4 100644 --- a/mozilla/layout/base/src/nsStyleConsts.h +++ b/mozilla/layout/base/src/nsStyleConsts.h @@ -266,6 +266,9 @@ #define NS_STYLE_TABLE_COLS_NONE (-1) #define NS_STYLE_TABLE_COLS_ALL PRInt32(1 << 30) +#define NS_STYLE_TABLE_LAYOUT_AUTO 0 +#define NS_STYLE_TABLE_LAYOUT_FIXED 1 + // constants for cell "scope" attribute #define NS_STYLE_CELL_SCOPE_ROW 0 #define NS_STYLE_CELL_SCOPE_COL 1 diff --git a/mozilla/layout/base/src/nsStyleContext.cpp b/mozilla/layout/base/src/nsStyleContext.cpp index 73cdb506221..ab298c598ac 100644 --- a/mozilla/layout/base/src/nsStyleContext.cpp +++ b/mozilla/layout/base/src/nsStyleContext.cpp @@ -537,6 +537,7 @@ struct StyleTableImpl: public nsStyleTable { StyleTableImpl::StyleTableImpl() { + mLayoutStrategy = NS_STYLE_TABLE_LAYOUT_AUTO; ResetFrom(nsnull, nsnull); } @@ -549,6 +550,9 @@ void StyleTableImpl::ResetFrom(const nsStyleTable* aParent, nsIPresContext* aPre mCellPadding.Reset(); mCellSpacing.Reset(); mSpan=0; + // values inherited + if (nsnull!=aParent) + mLayoutStrategy = aParent->mLayoutStrategy; } diff --git a/mozilla/layout/html/base/src/nsHTMLAtoms.cpp b/mozilla/layout/html/base/src/nsHTMLAtoms.cpp index c31e1918ea5..1ccdcb22b62 100644 --- a/mozilla/layout/html/base/src/nsHTMLAtoms.cpp +++ b/mozilla/layout/html/base/src/nsHTMLAtoms.cpp @@ -114,6 +114,7 @@ nsIAtom* nsHTMLAtoms::input; nsIAtom* nsHTMLAtoms::ismap; nsIAtom* nsHTMLAtoms::label; nsIAtom* nsHTMLAtoms::lang; +nsIAtom* nsHTMLAtoms::layout; nsIAtom* nsHTMLAtoms::li; nsIAtom* nsHTMLAtoms::link; nsIAtom* nsHTMLAtoms::left; @@ -321,6 +322,7 @@ void nsHTMLAtoms::AddrefAtoms() ismap = NS_NewAtom("ISMAP"); label = NS_NewAtom("LABEL"); lang = NS_NewAtom("LANG"); + layout = NS_NewAtom("LAYOUT"); li = NS_NewAtom("LI"); link = NS_NewAtom("LINK"); left = NS_NewAtom("LEFT"); @@ -521,6 +523,7 @@ void nsHTMLAtoms::ReleaseAtoms() NS_RELEASE(ismap); NS_RELEASE(label); NS_RELEASE(lang); + NS_RELEASE(layout); NS_RELEASE(li); NS_RELEASE(link); NS_RELEASE(left); diff --git a/mozilla/layout/html/base/src/nsHTMLAtoms.h b/mozilla/layout/html/base/src/nsHTMLAtoms.h index cec83e499d1..46cc95da323 100644 --- a/mozilla/layout/html/base/src/nsHTMLAtoms.h +++ b/mozilla/layout/html/base/src/nsHTMLAtoms.h @@ -142,6 +142,7 @@ public: static nsIAtom* label; static nsIAtom* lang; + static nsIAtom* layout; static nsIAtom* li; static nsIAtom* link; static nsIAtom* left; diff --git a/mozilla/layout/html/content/src/nsHTMLTableElement.cpp b/mozilla/layout/html/content/src/nsHTMLTableElement.cpp index 29d5d9e8e8b..ac0b9d190e5 100644 --- a/mozilla/layout/html/content/src/nsHTMLTableElement.cpp +++ b/mozilla/layout/html/content/src/nsHTMLTableElement.cpp @@ -309,6 +309,12 @@ static nsGenericHTMLElement::EnumTable kRulesTable[] = { { 0 } }; +static nsGenericHTMLElement::EnumTable kLayoutTable[] = { + { "auto", NS_STYLE_TABLE_LAYOUT_AUTO }, + { "fixed", NS_STYLE_TABLE_LAYOUT_FIXED }, + { 0 } +}; + NS_IMETHODIMP nsHTMLTableElement::StringToAttribute(nsIAtom* aAttribute, @@ -385,6 +391,10 @@ nsHTMLTableElement::StringToAttribute(nsIAtom* aAttribute, nsGenericHTMLElement::ParseEnumValue(aValue, kFrameTable, aResult); return NS_CONTENT_ATTR_HAS_VALUE; } + else if (aAttribute == nsHTMLAtoms::layout) { + nsGenericHTMLElement::ParseEnumValue(aValue, kLayoutTable, aResult); + return NS_CONTENT_ATTR_HAS_VALUE; + } else if (aAttribute == nsHTMLAtoms::rules) { nsGenericHTMLElement::ParseEnumValue(aValue, kRulesTable, aResult); return NS_CONTENT_ATTR_HAS_VALUE; @@ -412,6 +422,11 @@ nsHTMLTableElement::AttributeToString(nsIAtom* aAttribute, return NS_CONTENT_ATTR_HAS_VALUE; } } + else if (aAttribute == nsHTMLAtoms::layout) { + if (nsGenericHTMLElement::EnumValueToString(aValue, kLayoutTable, aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } + } else if (aAttribute == nsHTMLAtoms::rules) { if (nsGenericHTMLElement::EnumValueToString(aValue, kRulesTable, aResult)) { return NS_CONTENT_ATTR_HAS_VALUE; @@ -519,11 +534,19 @@ MapAttributesInto(nsIHTMLAttributes* aAttributes, } } - // cellpadding + // layout nsStyleTable* tableStyle=nsnull; + aAttributes->GetAttribute(nsHTMLAtoms::layout, value); + if (value.GetUnit() == eHTMLUnit_Enumerated) { // it may be another type if illegal + tableStyle = (nsStyleTable*)aContext->GetMutableStyleData(eStyleStruct_Table); + tableStyle->mLayoutStrategy = value.GetIntValue(); + } + + // cellpadding aAttributes->GetAttribute(nsHTMLAtoms::cellpadding, value); if (value.GetUnit() == eHTMLUnit_Pixel) { - tableStyle = (nsStyleTable*)aContext->GetMutableStyleData(eStyleStruct_Table); + if (nsnull==tableStyle) + tableStyle = (nsStyleTable*)aContext->GetMutableStyleData(eStyleStruct_Table); tableStyle->mCellPadding.SetCoordValue(NSIntPixelsToTwips(value.GetPixelValue(), p2t)); } diff --git a/mozilla/layout/html/document/src/ua.css b/mozilla/layout/html/document/src/ua.css index f184fd66e55..1715f8063c5 100644 --- a/mozilla/layout/html/document/src/ua.css +++ b/mozilla/layout/html/document/src/ua.css @@ -102,6 +102,7 @@ MULTICOL { TABLE { display: table; + table-layout: auto; border-style: outset; border-color: #C0C0C0; cell-spacing: 2px; diff --git a/mozilla/layout/html/table/src/BasicTableLayoutStrategy.cpp b/mozilla/layout/html/table/src/BasicTableLayoutStrategy.cpp index 6ca032e720d..fd7e734563b 100644 --- a/mozilla/layout/html/table/src/BasicTableLayoutStrategy.cpp +++ b/mozilla/layout/html/table/src/BasicTableLayoutStrategy.cpp @@ -123,7 +123,7 @@ BasicTableLayoutStrategy::~BasicTableLayoutStrategy() PRBool BasicTableLayoutStrategy::Initialize(nsSize* aMaxElementSize) { -#ifdef DEBUG +#ifdef NS_DEBUG nsIFrame *tablePIF=nsnull; mTableFrame->GetPrevInFlow(tablePIF); NS_ASSERTION(nsnull==tablePIF, "never ever call me on a continuing frame!"); @@ -146,12 +146,8 @@ PRBool BasicTableLayoutStrategy::Initialize(nsSize* aMaxElementSize) nsMargin borderPadding; const nsStylePosition* tablePosition; const nsStyleSpacing* tableSpacing; - // begin REMOVE_ME_WHEN_TABLE_STYLE_IS_RESOLVED! - nsIFrame * parent = nsnull; - mTableFrame->GetGeometricParent(parent); - parent->GetStyleData(eStyleStruct_Position, ((nsStyleStruct *&)tablePosition)); - parent->GetStyleData(eStyleStruct_Spacing , ((nsStyleStruct *&)tableSpacing)); - // end REMOVE_ME_WHEN_TABLE_STYLE_IS_RESOLVED! + mTableFrame->GetStyleData(eStyleStruct_Position, ((nsStyleStruct *&)tablePosition)); + mTableFrame->GetStyleData(eStyleStruct_Spacing , ((nsStyleStruct *&)tableSpacing)); tableSpacing->CalcBorderPaddingFor(mTableFrame, borderPadding); if (tablePosition->mWidth.GetUnit()==eStyleUnit_Coord) { @@ -177,7 +173,7 @@ PRBool BasicTableLayoutStrategy::BalanceColumnWidths(nsIStyleContext *aTableStyl const nsReflowState& aReflowState, nscoord aMaxWidth) { -#ifdef DEBUG +#ifdef NS_DEBUG nsIFrame *tablePIF=nsnull; mTableFrame->GetPrevInFlow(tablePIF); NS_ASSERTION(nsnull==tablePIF, "never ever call me on a continuing frame!"); @@ -1640,7 +1636,7 @@ PRBool BasicTableLayoutStrategy::BalanceColumnsConstrained( const nsReflowState& nscoord aMaxWidth, PRBool aTableIsAutoWidth) { -#ifdef DEBUG +#ifdef NS_DEBUG nsIFrame *tablePIF=nsnull; mTableFrame->GetPrevInFlow(tablePIF); NS_ASSERTION(nsnull==tablePIF, "never ever call me on a continuing frame!"); diff --git a/mozilla/layout/html/table/src/Makefile b/mozilla/layout/html/table/src/Makefile index fa0b0920f9f..61456d1bcef 100644 --- a/mozilla/layout/html/table/src/Makefile +++ b/mozilla/layout/html/table/src/Makefile @@ -24,6 +24,7 @@ LIBRARY_NAME = raptorhtmltable_s # Note the sophisticated alphabetical ordering :-| CPPSRCS = \ BasicTableLayoutStrategy.cpp \ + FixedTableLayoutStrategy.cpp \ nsCellMap.cpp \ nsTableCellFrame.cpp \ nsTableColFrame.cpp \ diff --git a/mozilla/layout/html/table/src/makefile.win b/mozilla/layout/html/table/src/makefile.win index 97fa3824694..25793d9785c 100644 --- a/mozilla/layout/html/table/src/makefile.win +++ b/mozilla/layout/html/table/src/makefile.win @@ -31,7 +31,8 @@ CPPSRCS= nsCellMap.cpp \ nsTableOuterFrame.cpp \ nsTableRowFrame.cpp \ nsTableRowGroupFrame.cpp \ - BasicTableLayoutStrategy.cpp + BasicTableLayoutStrategy.cpp \ + FixedTableLayoutStrategy.cpp CPP_OBJS= .\$(OBJDIR)\nsCellMap.obj \ .\$(OBJDIR)\nsTableCellFrame.obj .\$(OBJDIR)\nsTableColFrame.obj \ @@ -40,7 +41,8 @@ CPP_OBJS= .\$(OBJDIR)\nsCellMap.obj \ .\$(OBJDIR)\nsTableOuterFrame.obj \ .\$(OBJDIR)\nsTableRowFrame.obj \ .\$(OBJDIR)\nsTableRowGroupFrame.obj \ - .\$(OBJDIR)\BasicTableLayoutStrategy.obj + .\$(OBJDIR)\BasicTableLayoutStrategy.obj \ + .\$(OBJDIR)\FixedTableLayoutStrategy.obj LINCS=-I$(XPDIST)\public\xpcom -I$(XPDIST)\public\raptor \ -I..\..\base\src -I..\..\style\src -I..\..\content\src \ diff --git a/mozilla/layout/html/table/src/nsTableFrame.cpp b/mozilla/layout/html/table/src/nsTableFrame.cpp index 335563324ca..a9aceb647ea 100644 --- a/mozilla/layout/html/table/src/nsTableFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableFrame.cpp @@ -29,6 +29,7 @@ #include "nsIHTMLContent.h" #include "BasicTableLayoutStrategy.h" +#include "FixedTableLayoutStrategy.h" #include "nsIPresContext.h" #include "nsCSSRendering.h" @@ -545,7 +546,8 @@ PRInt32 nsTableFrame::GetEffectiveColSpan (PRInt32 aColIndex, nsTableCellFrame * NS_PRECONDITION (nsnull!=aCell, "bad cell arg"); nsCellMap *cellMap = GetCellMap(); NS_PRECONDITION (nsnull!=cellMap, "bad call, cellMap not yet allocated."); - NS_PRECONDITION (0<=aColIndex && aColIndexGetColSpan(); - PRInt32 colCount = GetColCount(); if (colCount < (aColIndex + colSpan)) result = colCount - aColIndex; else @@ -608,12 +609,14 @@ void nsTableFrame::ResetCellMap () * if the cell map says there are more columns than this, * add extra implicit columns to the content tree. */ + +// XXX this and ENsureColumnsAt should be 1 method, with -1 for aColIndex meaning "do them all" void nsTableFrame::EnsureColumns(nsIPresContext* aPresContext, nsReflowMetrics& aDesiredSize, const nsReflowState& aReflowState, nsReflowStatus& aStatus) { -#ifdef XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX + nsresult rv; // XXX sec should only be called on firstInFlow SetMinColSpanForTable(); if (nsnull==mCellMap) @@ -649,27 +652,30 @@ void nsTableFrame::EnsureColumns(nsIPresContext* aPresContext, } if (actualColumns < GetColCount()) { - nsTableColGroup *lastColGroup=nsnull; + nsIHTMLContent *lastColGroup=nsnull; if (nsnull==lastColGroupFrame) { - lastColGroup = new nsTableColGroup (PR_TRUE); // create an implicit colgroup - // XXX: instead of Append, maybe this should be insertAt(0)? + // create an implicit colgroup + nsAutoString colGroupTag; + nsHTMLAtoms::colgroup->ToString(colGroupTag); + rv = NS_CreateHTMLElement(&lastColGroup, colGroupTag); // ADDREF a: lastColGroup++ + //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, this, PR_TRUE); // kidStyleContext: REFCNT++ - nsIContentDelegate* kidDel = nsnull; - kidDel = lastColGroup->GetDelegate(aPresContext); // kidDel: REFCNT++ - nsresult rv = kidDel->CreateFrame(aPresContext, lastColGroup, this, - colGroupStyleContext, (nsIFrame *&)lastColGroupFrame); - NS_RELEASE(kidDel); // kidDel: 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=nsnull; - LastChild(lastChild); + nsIFrame *lastChild = LastFrame(mFirstChild); lastChild->SetNextSibling(lastColGroupFrame); } else @@ -690,17 +696,58 @@ void nsTableFrame::EnsureColumns(nsIPresContext* aPresContext, lastColGroupFrame->GetContent((nsIContent *&)lastColGroup); // ADDREF b: lastColGroup++ } + // XXX It would be better to do this in the style code while constructing + // the table's frames + nsAutoString colTag; + nsHTMLAtoms::col->ToString(colTag); PRInt32 excessColumns = GetColCount() - actualColumns; + nsIFrame* firstNewColFrame = nsnull; + nsIFrame* lastNewColFrame = nsnull; for ( ; excessColumns > 0; excessColumns--) - { //QQQ - // need to find the generic way to stamp out this content, and ::AppendChildTo it - nsTableCol *col = new nsTableCol(PR_TRUE); - lastColGroup->AppendChildTo (col, PR_FALSE); + { + nsIHTMLContent *col=nsnull; + // create an implicit col + rv = NS_CreateHTMLElement(&col, colTag); // ADDREF: col++ + //XXX mark the col implicit + 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, lastColGroupFrame, 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-- - lastColGroupFrame->Reflow(*aPresContext, aDesiredSize, aReflowState, aStatus); + + // Generate an appended reflow command + // XXX This is really yucky... + nsIReflowCommand* reflowCmd; + + NS_NewHTMLReflowCommand(&reflowCmd, lastColGroupFrame, nsIReflowCommand::FrameAppended, + firstNewColFrame); + nsReflowState incrReflowState(lastColGroupFrame, aReflowState, aReflowState.maxSize); + incrReflowState.reflowCommand = reflowCmd; + incrReflowState.reason = eReflowReason_Incremental; + + // Reflow the frames + lastColGroupFrame->Reflow(*aPresContext, aDesiredSize, incrReflowState, aStatus); } -#endif } /** sum the columns represented by all nsTableColGroup objects @@ -1636,39 +1683,44 @@ nsReflowStatus nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresContext, nscoord leftInset = borderPadding.left; nsReflowReason reflowReason = aReflowState.reason; - for (nsIFrame* kidFrame = mFirstChild; nsnull != kidFrame; kidFrame->GetNextSibling(kidFrame)) { - nsSize maxKidElementSize(0,0); - nsReflowState kidReflowState(kidFrame, aReflowState, availSize); + nsStyleTable* tableStyle; + GetStyleData(eStyleStruct_Table, (nsStyleStruct *&)tableStyle); + if (1||NS_STYLE_TABLE_LAYOUT_FIXED!=tableStyle->mLayoutStrategy) + { + for (nsIFrame* kidFrame = mFirstChild; nsnull != kidFrame; kidFrame->GetNextSibling(kidFrame)) { + nsSize maxKidElementSize(0,0); + nsReflowState kidReflowState(kidFrame, aReflowState, availSize); - PRInt32 yCoord = y; - if (NS_UNCONSTRAINEDSIZE!=yCoord) - yCoord+= topInset; - kidFrame->WillReflow(*aPresContext); - kidFrame->MoveTo(leftInset, yCoord); - result = ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState); + PRInt32 yCoord = y; + if (NS_UNCONSTRAINEDSIZE!=yCoord) + yCoord+= topInset; + kidFrame->WillReflow(*aPresContext); + kidFrame->MoveTo(leftInset, yCoord); + result = ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState); - // 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); - } - kidFrame->SetRect(nsRect(leftInset, yCoord, - kidSize.width, kidSize.height)); - 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; - } + // 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); + } + kidFrame->SetRect(nsRect(leftInset, yCoord, + kidSize.width, kidSize.height)); + 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; + } - if (NS_FRAME_IS_NOT_COMPLETE(result)) { - // 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; + if (NS_FRAME_IS_NOT_COMPLETE(result)) { + // 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; + } } } @@ -2243,8 +2295,13 @@ void nsTableFrame::BalanceColumnWidths(nsIPresContext* aPresContext, // based on the compatibility mode, create a table layout strategy if (nsnull==mTableLayoutStrategy) - { // TODO: build a different strategy based on the compatibility mode - mTableLayoutStrategy = new BasicTableLayoutStrategy(this, numCols); + { + nsStyleTable* tableStyle; + GetStyleData(eStyleStruct_Table, (nsStyleStruct *&)tableStyle); + if (NS_STYLE_TABLE_LAYOUT_FIXED==tableStyle->mLayoutStrategy) + mTableLayoutStrategy = new FixedTableLayoutStrategy(this, numCols); + else + mTableLayoutStrategy = new BasicTableLayoutStrategy(this, numCols); mTableLayoutStrategy->Initialize(aMaxElementSize); } mTableLayoutStrategy->BalanceColumnWidths(mStyleContext, aReflowState, maxWidth); @@ -2453,6 +2510,8 @@ void nsTableFrame::BuildColumnCache( nsIPresContext* aPresContext, { // probably want this assertion : NS_ASSERTION(nsnull==mPrevInFlow, "never ever call me on a continuing frame!"); NS_ASSERTION(nsnull!=mCellMap, "never ever call me until the cell map is built!"); + nsStyleTable* tableStyle; + GetStyleData(eStyleStruct_Table, (nsStyleStruct *&)tableStyle); EnsureColumns(aPresContext, aDesiredSize, aReflowState, aStatus); if (nsnull==mColCache) { @@ -2477,22 +2536,25 @@ void nsTableFrame::BuildColumnCache( nsIPresContext* aPresContext, NS_STYLE_DISPLAY_TABLE_HEADER_GROUP == childDisplay->mDisplay || NS_STYLE_DISPLAY_TABLE_FOOTER_GROUP == childDisplay->mDisplay ) { // if it's a row group, get the cells and set the column style if appropriate - nsIFrame *rowFrame; - childFrame->FirstChild(rowFrame); - while (nsnull!=rowFrame) + if (NS_STYLE_TABLE_LAYOUT_FIXED!=tableStyle->mLayoutStrategy) { - nsIFrame *cellFrame; - rowFrame->FirstChild(cellFrame); - while (nsnull!=cellFrame) + nsIFrame *rowFrame; + childFrame->FirstChild(rowFrame); + while (nsnull!=rowFrame) { - /* 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) - */ - SetColumnStyleFromCell(aPresContext, (nsTableCellFrame *)cellFrame, (nsTableRowFrame *)rowFrame); - cellFrame->GetNextSibling(cellFrame); + nsIFrame *cellFrame; + rowFrame->FirstChild(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) + */ + SetColumnStyleFromCell(aPresContext, (nsTableCellFrame *)cellFrame, (nsTableRowFrame *)rowFrame); + cellFrame->GetNextSibling(cellFrame); + } + rowFrame->GetNextSibling(rowFrame); } - rowFrame->GetNextSibling(rowFrame); } } childFrame->GetNextSibling(childFrame); diff --git a/mozilla/layout/html/table/src/nsTableRowFrame.cpp b/mozilla/layout/html/table/src/nsTableRowFrame.cpp index 8791b62415e..66a112d7ce4 100644 --- a/mozilla/layout/html/table/src/nsTableRowFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableRowFrame.cpp @@ -535,9 +535,6 @@ nsTableRowFrame::InitialReflow(nsIPresContext& aPresContext, RowReflowState& aState, nsReflowMetrics& aDesiredSize) { - // For our initial reflow we expect to be given an unconstrained width - NS_PRECONDITION(NS_UNCONSTRAINEDSIZE == aState.availSize.width, "bad size"); - // Place our children, one at a time, until we are out of children nsSize kidMaxElementSize; PRInt32 kidIndex = 0; diff --git a/mozilla/layout/style/nsStyleContext.cpp b/mozilla/layout/style/nsStyleContext.cpp index 73cdb506221..ab298c598ac 100644 --- a/mozilla/layout/style/nsStyleContext.cpp +++ b/mozilla/layout/style/nsStyleContext.cpp @@ -537,6 +537,7 @@ struct StyleTableImpl: public nsStyleTable { StyleTableImpl::StyleTableImpl() { + mLayoutStrategy = NS_STYLE_TABLE_LAYOUT_AUTO; ResetFrom(nsnull, nsnull); } @@ -549,6 +550,9 @@ void StyleTableImpl::ResetFrom(const nsStyleTable* aParent, nsIPresContext* aPre mCellPadding.Reset(); mCellSpacing.Reset(); mSpan=0; + // values inherited + if (nsnull!=aParent) + mLayoutStrategy = aParent->mLayoutStrategy; } diff --git a/mozilla/layout/style/ua.css b/mozilla/layout/style/ua.css index f184fd66e55..1715f8063c5 100644 --- a/mozilla/layout/style/ua.css +++ b/mozilla/layout/style/ua.css @@ -102,6 +102,7 @@ MULTICOL { TABLE { display: table; + table-layout: auto; border-style: outset; border-color: #C0C0C0; cell-spacing: 2px; diff --git a/mozilla/layout/tables/BasicTableLayoutStrategy.cpp b/mozilla/layout/tables/BasicTableLayoutStrategy.cpp index 6ca032e720d..fd7e734563b 100644 --- a/mozilla/layout/tables/BasicTableLayoutStrategy.cpp +++ b/mozilla/layout/tables/BasicTableLayoutStrategy.cpp @@ -123,7 +123,7 @@ BasicTableLayoutStrategy::~BasicTableLayoutStrategy() PRBool BasicTableLayoutStrategy::Initialize(nsSize* aMaxElementSize) { -#ifdef DEBUG +#ifdef NS_DEBUG nsIFrame *tablePIF=nsnull; mTableFrame->GetPrevInFlow(tablePIF); NS_ASSERTION(nsnull==tablePIF, "never ever call me on a continuing frame!"); @@ -146,12 +146,8 @@ PRBool BasicTableLayoutStrategy::Initialize(nsSize* aMaxElementSize) nsMargin borderPadding; const nsStylePosition* tablePosition; const nsStyleSpacing* tableSpacing; - // begin REMOVE_ME_WHEN_TABLE_STYLE_IS_RESOLVED! - nsIFrame * parent = nsnull; - mTableFrame->GetGeometricParent(parent); - parent->GetStyleData(eStyleStruct_Position, ((nsStyleStruct *&)tablePosition)); - parent->GetStyleData(eStyleStruct_Spacing , ((nsStyleStruct *&)tableSpacing)); - // end REMOVE_ME_WHEN_TABLE_STYLE_IS_RESOLVED! + mTableFrame->GetStyleData(eStyleStruct_Position, ((nsStyleStruct *&)tablePosition)); + mTableFrame->GetStyleData(eStyleStruct_Spacing , ((nsStyleStruct *&)tableSpacing)); tableSpacing->CalcBorderPaddingFor(mTableFrame, borderPadding); if (tablePosition->mWidth.GetUnit()==eStyleUnit_Coord) { @@ -177,7 +173,7 @@ PRBool BasicTableLayoutStrategy::BalanceColumnWidths(nsIStyleContext *aTableStyl const nsReflowState& aReflowState, nscoord aMaxWidth) { -#ifdef DEBUG +#ifdef NS_DEBUG nsIFrame *tablePIF=nsnull; mTableFrame->GetPrevInFlow(tablePIF); NS_ASSERTION(nsnull==tablePIF, "never ever call me on a continuing frame!"); @@ -1640,7 +1636,7 @@ PRBool BasicTableLayoutStrategy::BalanceColumnsConstrained( const nsReflowState& nscoord aMaxWidth, PRBool aTableIsAutoWidth) { -#ifdef DEBUG +#ifdef NS_DEBUG nsIFrame *tablePIF=nsnull; mTableFrame->GetPrevInFlow(tablePIF); NS_ASSERTION(nsnull==tablePIF, "never ever call me on a continuing frame!"); diff --git a/mozilla/layout/tables/nsTableFrame.cpp b/mozilla/layout/tables/nsTableFrame.cpp index 335563324ca..a9aceb647ea 100644 --- a/mozilla/layout/tables/nsTableFrame.cpp +++ b/mozilla/layout/tables/nsTableFrame.cpp @@ -29,6 +29,7 @@ #include "nsIHTMLContent.h" #include "BasicTableLayoutStrategy.h" +#include "FixedTableLayoutStrategy.h" #include "nsIPresContext.h" #include "nsCSSRendering.h" @@ -545,7 +546,8 @@ PRInt32 nsTableFrame::GetEffectiveColSpan (PRInt32 aColIndex, nsTableCellFrame * NS_PRECONDITION (nsnull!=aCell, "bad cell arg"); nsCellMap *cellMap = GetCellMap(); NS_PRECONDITION (nsnull!=cellMap, "bad call, cellMap not yet allocated."); - NS_PRECONDITION (0<=aColIndex && aColIndexGetColSpan(); - PRInt32 colCount = GetColCount(); if (colCount < (aColIndex + colSpan)) result = colCount - aColIndex; else @@ -608,12 +609,14 @@ void nsTableFrame::ResetCellMap () * if the cell map says there are more columns than this, * add extra implicit columns to the content tree. */ + +// XXX this and ENsureColumnsAt should be 1 method, with -1 for aColIndex meaning "do them all" void nsTableFrame::EnsureColumns(nsIPresContext* aPresContext, nsReflowMetrics& aDesiredSize, const nsReflowState& aReflowState, nsReflowStatus& aStatus) { -#ifdef XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX + nsresult rv; // XXX sec should only be called on firstInFlow SetMinColSpanForTable(); if (nsnull==mCellMap) @@ -649,27 +652,30 @@ void nsTableFrame::EnsureColumns(nsIPresContext* aPresContext, } if (actualColumns < GetColCount()) { - nsTableColGroup *lastColGroup=nsnull; + nsIHTMLContent *lastColGroup=nsnull; if (nsnull==lastColGroupFrame) { - lastColGroup = new nsTableColGroup (PR_TRUE); // create an implicit colgroup - // XXX: instead of Append, maybe this should be insertAt(0)? + // create an implicit colgroup + nsAutoString colGroupTag; + nsHTMLAtoms::colgroup->ToString(colGroupTag); + rv = NS_CreateHTMLElement(&lastColGroup, colGroupTag); // ADDREF a: lastColGroup++ + //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, this, PR_TRUE); // kidStyleContext: REFCNT++ - nsIContentDelegate* kidDel = nsnull; - kidDel = lastColGroup->GetDelegate(aPresContext); // kidDel: REFCNT++ - nsresult rv = kidDel->CreateFrame(aPresContext, lastColGroup, this, - colGroupStyleContext, (nsIFrame *&)lastColGroupFrame); - NS_RELEASE(kidDel); // kidDel: 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=nsnull; - LastChild(lastChild); + nsIFrame *lastChild = LastFrame(mFirstChild); lastChild->SetNextSibling(lastColGroupFrame); } else @@ -690,17 +696,58 @@ void nsTableFrame::EnsureColumns(nsIPresContext* aPresContext, lastColGroupFrame->GetContent((nsIContent *&)lastColGroup); // ADDREF b: lastColGroup++ } + // XXX It would be better to do this in the style code while constructing + // the table's frames + nsAutoString colTag; + nsHTMLAtoms::col->ToString(colTag); PRInt32 excessColumns = GetColCount() - actualColumns; + nsIFrame* firstNewColFrame = nsnull; + nsIFrame* lastNewColFrame = nsnull; for ( ; excessColumns > 0; excessColumns--) - { //QQQ - // need to find the generic way to stamp out this content, and ::AppendChildTo it - nsTableCol *col = new nsTableCol(PR_TRUE); - lastColGroup->AppendChildTo (col, PR_FALSE); + { + nsIHTMLContent *col=nsnull; + // create an implicit col + rv = NS_CreateHTMLElement(&col, colTag); // ADDREF: col++ + //XXX mark the col implicit + 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, lastColGroupFrame, 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-- - lastColGroupFrame->Reflow(*aPresContext, aDesiredSize, aReflowState, aStatus); + + // Generate an appended reflow command + // XXX This is really yucky... + nsIReflowCommand* reflowCmd; + + NS_NewHTMLReflowCommand(&reflowCmd, lastColGroupFrame, nsIReflowCommand::FrameAppended, + firstNewColFrame); + nsReflowState incrReflowState(lastColGroupFrame, aReflowState, aReflowState.maxSize); + incrReflowState.reflowCommand = reflowCmd; + incrReflowState.reason = eReflowReason_Incremental; + + // Reflow the frames + lastColGroupFrame->Reflow(*aPresContext, aDesiredSize, incrReflowState, aStatus); } -#endif } /** sum the columns represented by all nsTableColGroup objects @@ -1636,39 +1683,44 @@ nsReflowStatus nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresContext, nscoord leftInset = borderPadding.left; nsReflowReason reflowReason = aReflowState.reason; - for (nsIFrame* kidFrame = mFirstChild; nsnull != kidFrame; kidFrame->GetNextSibling(kidFrame)) { - nsSize maxKidElementSize(0,0); - nsReflowState kidReflowState(kidFrame, aReflowState, availSize); + nsStyleTable* tableStyle; + GetStyleData(eStyleStruct_Table, (nsStyleStruct *&)tableStyle); + if (1||NS_STYLE_TABLE_LAYOUT_FIXED!=tableStyle->mLayoutStrategy) + { + for (nsIFrame* kidFrame = mFirstChild; nsnull != kidFrame; kidFrame->GetNextSibling(kidFrame)) { + nsSize maxKidElementSize(0,0); + nsReflowState kidReflowState(kidFrame, aReflowState, availSize); - PRInt32 yCoord = y; - if (NS_UNCONSTRAINEDSIZE!=yCoord) - yCoord+= topInset; - kidFrame->WillReflow(*aPresContext); - kidFrame->MoveTo(leftInset, yCoord); - result = ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState); + PRInt32 yCoord = y; + if (NS_UNCONSTRAINEDSIZE!=yCoord) + yCoord+= topInset; + kidFrame->WillReflow(*aPresContext); + kidFrame->MoveTo(leftInset, yCoord); + result = ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState); - // 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); - } - kidFrame->SetRect(nsRect(leftInset, yCoord, - kidSize.width, kidSize.height)); - 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; - } + // 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); + } + kidFrame->SetRect(nsRect(leftInset, yCoord, + kidSize.width, kidSize.height)); + 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; + } - if (NS_FRAME_IS_NOT_COMPLETE(result)) { - // 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; + if (NS_FRAME_IS_NOT_COMPLETE(result)) { + // 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; + } } } @@ -2243,8 +2295,13 @@ void nsTableFrame::BalanceColumnWidths(nsIPresContext* aPresContext, // based on the compatibility mode, create a table layout strategy if (nsnull==mTableLayoutStrategy) - { // TODO: build a different strategy based on the compatibility mode - mTableLayoutStrategy = new BasicTableLayoutStrategy(this, numCols); + { + nsStyleTable* tableStyle; + GetStyleData(eStyleStruct_Table, (nsStyleStruct *&)tableStyle); + if (NS_STYLE_TABLE_LAYOUT_FIXED==tableStyle->mLayoutStrategy) + mTableLayoutStrategy = new FixedTableLayoutStrategy(this, numCols); + else + mTableLayoutStrategy = new BasicTableLayoutStrategy(this, numCols); mTableLayoutStrategy->Initialize(aMaxElementSize); } mTableLayoutStrategy->BalanceColumnWidths(mStyleContext, aReflowState, maxWidth); @@ -2453,6 +2510,8 @@ void nsTableFrame::BuildColumnCache( nsIPresContext* aPresContext, { // probably want this assertion : NS_ASSERTION(nsnull==mPrevInFlow, "never ever call me on a continuing frame!"); NS_ASSERTION(nsnull!=mCellMap, "never ever call me until the cell map is built!"); + nsStyleTable* tableStyle; + GetStyleData(eStyleStruct_Table, (nsStyleStruct *&)tableStyle); EnsureColumns(aPresContext, aDesiredSize, aReflowState, aStatus); if (nsnull==mColCache) { @@ -2477,22 +2536,25 @@ void nsTableFrame::BuildColumnCache( nsIPresContext* aPresContext, NS_STYLE_DISPLAY_TABLE_HEADER_GROUP == childDisplay->mDisplay || NS_STYLE_DISPLAY_TABLE_FOOTER_GROUP == childDisplay->mDisplay ) { // if it's a row group, get the cells and set the column style if appropriate - nsIFrame *rowFrame; - childFrame->FirstChild(rowFrame); - while (nsnull!=rowFrame) + if (NS_STYLE_TABLE_LAYOUT_FIXED!=tableStyle->mLayoutStrategy) { - nsIFrame *cellFrame; - rowFrame->FirstChild(cellFrame); - while (nsnull!=cellFrame) + nsIFrame *rowFrame; + childFrame->FirstChild(rowFrame); + while (nsnull!=rowFrame) { - /* 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) - */ - SetColumnStyleFromCell(aPresContext, (nsTableCellFrame *)cellFrame, (nsTableRowFrame *)rowFrame); - cellFrame->GetNextSibling(cellFrame); + nsIFrame *cellFrame; + rowFrame->FirstChild(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) + */ + SetColumnStyleFromCell(aPresContext, (nsTableCellFrame *)cellFrame, (nsTableRowFrame *)rowFrame); + cellFrame->GetNextSibling(cellFrame); + } + rowFrame->GetNextSibling(rowFrame); } - rowFrame->GetNextSibling(rowFrame); } } childFrame->GetNextSibling(childFrame); diff --git a/mozilla/layout/tables/nsTableRowFrame.cpp b/mozilla/layout/tables/nsTableRowFrame.cpp index 8791b62415e..66a112d7ce4 100644 --- a/mozilla/layout/tables/nsTableRowFrame.cpp +++ b/mozilla/layout/tables/nsTableRowFrame.cpp @@ -535,9 +535,6 @@ nsTableRowFrame::InitialReflow(nsIPresContext& aPresContext, RowReflowState& aState, nsReflowMetrics& aDesiredSize) { - // For our initial reflow we expect to be given an unconstrained width - NS_PRECONDITION(NS_UNCONSTRAINEDSIZE == aState.availSize.width, "bad size"); - // Place our children, one at a time, until we are out of children nsSize kidMaxElementSize; PRInt32 kidIndex = 0;