This commit is contained in:
buster 1998-04-14 21:45:28 +00:00
Родитель 595b938bfe
Коммит 39b10e3604
28 изменённых файлов: 1250 добавлений и 225 удалений

Просмотреть файл

@ -29,31 +29,54 @@ class nsTableFrame;
/** Simple data class that represents in-process reflow information about a cell.
* Each cell is represented by a nsTableCellFrame together with the results
* of the "first pass" layout results (where "first pass" means the cell was told
* to lay itself out with unrestricted height and width.)
* There is one nsCellLayoutData object per nsTableFrame for each cell.
*
* TODO: All methods will be inline.
*/
class nsCellLayoutData
{
public:
/** public constructor. Does not allocate any of its own data.
* @param aCellFrame the frame representing the cell
* @param aDesiredSize the max size of the cell if given infinite height and width
* @param aMaxElementSize the min size of the largest indivisible element within the cell
*/
nsCellLayoutData(nsTableCellFrame *aCellFrame,
nsReflowMetrics * aDesiredSize, nsSize * aMaxElementSize);
/** destructor, not responsible for destroying any of the stored data */
virtual ~nsCellLayoutData();
/** return the frame mapping the cell */
nsTableCellFrame * GetCellFrame();
/** set the frame mapping the cell */
void SetCellFrame(nsTableCellFrame * aCellFrame);
/** return the max size of the cell if given infinite height and width */
nsReflowMetrics * GetDesiredSize();
/** set the max size of the cell if given infinite height and width.
* called after pass 1 of table reflow is complete.
*/
void SetDesiredSize(nsReflowMetrics * aDesiredSize);
/** get the min size of the largest indivisible element within the cell */
nsSize * GetMaxElementSize();
/** set the min size of the largest indivisible element within the cell.
* called after pass 1 of table reflow is complete.
*/
void SetMaxElementSize(nsSize * aMaxElementSize);
/** debug method outputs data about this cell to FILE *out */
void List(FILE* out = stdout, PRInt32 aIndent = 0) const;
/** returns the style molecule associated with this cell */
nsStyleMolecule* GetStyleMolecule();
private:

Просмотреть файл

@ -22,9 +22,17 @@
class CellData;
/**
/** nsCellMap is a support class for nsTablePart.
* It maintains an Rows x Columns grid onto which the cells of the table are mapped.
* This makes processing of rowspan and colspan attributes much easier.
* Each cell is represented by a CellData object.
*
* @see CellData
* @see nsTablePart::BuildCellMap
* @see nsTablePart::GrowCellMap
* @see nsTablePart::BuildCellIntoMap
*
* acts like a 2-dimensional array, so all offsets are 0-indexed
* to the outside world.
TODO: inline methods
*/
class nsCellMap
@ -45,18 +53,25 @@ public:
// NOT VIRTUAL BECAUSE THIS CLASS SHOULD **NEVER** BE SUBCLASSED
~nsCellMap();
/** initialize the CellMap to (aRows x aColumns) */
void Reset(int aRows, int aColumns);
/** return the CellData for the cell at (aRow,aColumn) */
CellData * GetCellAt(int aRow, int aColumn) const;
void SetCellAt(CellData *aCell, int aRow, int aColumn);
/** assign aCellData to the cell at (aRow,aColumn) */
void SetCellAt(CellData *aCellData, int aRow, int aColumn);
/** expand the CellMap to have aColCount columns. The number of rows remains the same */
void GrowTo(int aColCount);
/** return the total number of columns in the table represented by this CellMap */
int GetColCount() const;
/** return the total number of rows in the table represented by this CellMap */
int GetRowCount() const;
/** for debugging, print out this CellMap */
void DumpCellMap() const;
};

Просмотреть файл

@ -29,11 +29,11 @@ class nsTablePart;
{0x8f, 0x2f, 0x00, 0x60, 0x08, 0x15, 0x9b, 0x0c} }
/**
* nsITableContent is a concrete subclass for all content nodes contained directly within a table.
* nsITableContent is a concrete subclass for all content nodes contained directly
* within a table.
*
* @author sclark
* @version $Revision: 3.1 $
* @see
* @see nsTablePart
*/
class nsITableContent : public nsISupports
{
@ -49,33 +49,35 @@ public:
static const int kTableCellType;
protected:
/** protected constructor. Never create an object of type nsITableContent directly.*/
nsITableContent ();
public:
/**
* returns the TablePart that contains this content node.
/** returns the TablePart that contains this content node.
* every table content has one and only one parent,
* and may not be replicated within different hierarchies.
*/
virtual nsTablePart *GetTable ()=0;
/**
*
/** set the parent of this table content object.
* @param aTable the new parent. May be null to disconnect this object from
* the hierarchy it is in. Note that we don't have formalized
* relationship objects, so the caller must also remove this
* from it's prarent's child list.
*/
virtual void SetTable (nsTablePart *aTable)=0;
/**
*
/** returns PR_TRUE if there is an actual input tag corresponding to
* this content object.
*/
virtual PRBool IsImplicit () const =0;
/**
* Don't want to put out implicit tags when saving.
/** returns PR_TRUE if this content object should NOT be written to the output stream.
* for example, we don't generally want to output implicit tags when saving.
*/
virtual PRBool SkipSelfForSaving ()=0;
/**
* return the type of TableContent this object represents.
* implementing interfaces for all these objects seemed like overkill.
*/
/** return the type of TableContent this object represents. */
virtual int GetType()=0;
};

Просмотреть файл

@ -22,8 +22,14 @@
#include "nsTableContent.h"
/**
* nsTableCaption
* data structure to maintain information about a single table caption
* nsTableCaption is the content object that represents table captions
* (HTML tag CAPTION). This class cannot be reused
* outside of an nsTablePart. It assumes that its parent is an nsTablePart, and
* it has a single nsBodyPart child.
*
* @see nsTablePart
* @see nsTableRow
* @see nsBodyPart
*
* @author sclark
*/
@ -31,18 +37,28 @@ class nsTableCaption : public nsTableContent
{
public:
/** constructor
* @param aImplicit PR_TRUE if there is no actual input tag corresponding to
* this caption.
*/
nsTableCaption (PRBool aImplicit);
/** constructor
* @param aTag the HTML tag causing this caption to get constructed.
*/
nsTableCaption (nsIAtom* aTag);
/** destructor, not responsible for any memory destruction itself */
virtual ~nsTableCaption();
// For debugging purposes only
NS_IMETHOD_(nsrefcnt) AddRef();
NS_IMETHOD_(nsrefcnt) Release();
/** returns nsITableContent::kTableCaptionType */
virtual int GetType();
/** @see nsIHTMLContent::CreateFrame */
virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext,
PRInt32 aIndexInParent,
nsIFrame* aParentFrame);

Просмотреть файл

@ -23,8 +23,14 @@
#include "nsTableRow.h"
/**
* nsTableCell
* datastructure to maintain information about a single table column
* nsTableCell is the content object that represents table cells
* (HTML tags TD and TH). This class cannot be reused
* outside of an nsTableRow. It assumes that its parent is an nsTableRow, and
* it has a single nsBodyPart child.
*
* @see nsTablePart
* @see nsTableRow
* @see nsBodyPart
*
* @author sclark
*/
@ -33,18 +39,39 @@ class nsTableCell : public nsTableContent
private:
/** parent pointer */
nsTableRow * mRow;
int mRowSpan, mColSpan;
/** the number of rows spanned by this cell */
int mRowSpan;
/** the number of columns spanned by this cell */
int mColSpan;
/** the starting column for this cell */
int mColIndex;
public:
/** constructor
* @param aImplicit PR_TRUE if there is no actual input tag corresponding to
* this cell.
*/
nsTableCell (PRBool aImplicit);
/** constructor
* @param aTag the HTML tag causing this cell to get constructed.
*/
nsTableCell (nsIAtom* aTag);
/** constructor
* @param aTag the HTML tag causing this caption to get constructed.
* @param aRowSpan the number of rows spanned
* @param aColSpan the number of columns spanned
*/
nsTableCell (nsIAtom* aTag, int aRowSpan, int aColSpan);
/** destructor, not responsible for any memory destruction itself */
virtual ~nsTableCell();
// For debugging purposes only
@ -52,9 +79,10 @@ public:
NS_IMETHOD_(nsrefcnt) Release();
/** returns nsITableContent::kTableCellType */
virtual int GetType();
/** @see nsIHTMLContent::CreateFrame */
virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext,
PRInt32 aIndexInParent,
nsIFrame* aParentFrame);
@ -64,26 +92,33 @@ public:
virtual void MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext);
/** @return the number of rows spanned by this cell. Always >= 1 */
virtual int GetRowSpan ();
/** set the number of rows spanned. Must be >= 1 */
virtual void SetRowSpan (int aRowSpan);
/** @return the number of columns spanned by this cell. Always >= 1 */
virtual int GetColSpan ();
/** set the number of columns spanned. Must be >= 1 */
virtual void SetColSpan (int aColSpan);
/** return a pointer to this cell's parent, the row containing the cell */
virtual nsTableRow * GetRow ();
/**
* Since mRow is the parent of the table cell,
* reference counting should not be done on
* this variable when setting the row.
* see /ns/raptor/doc/MemoryModel.html
**/
/** set this cell's parent.
* Note: Since mRow is the parent of the table cell,
* reference counting should not be done on
* this variable when setting the row.
* see /ns/raptor/doc/MemoryModel.html
*/
virtual void SetRow (nsTableRow * aRow);
/** @return the starting column for this cell. Always >= 1 */
virtual int GetColIndex ();
/** set the starting column for this cell. Always >= 1 */
virtual void SetColIndex (int aColIndex);
virtual void ResetCellMap ();

Просмотреть файл

@ -25,58 +25,81 @@
class nsTablePart;
/**
* nsTableCol
* data structure to maintain information about a single table column
* nsTableCol is the content object that represents table cols
* (HTML tag COL). This class cannot be reused
* outside of an nsTableColGroup. It assumes that its parent is an nsTableColGroup, and
* it has no children.
*
* @see nsTablePart
* @see nsTableColGroup
*
* @author sclark
*/
class nsTableCol : public nsTableContent
{
//NS_DECL_ISUPPORTS
private:
/** parent pointer, the column group to which this column belongs */
nsTableColGroup * mColGroup;
/** the starting index of the column (starting at 0) that this col object represents */
PRInt32 mColIndex;
/** the number of columns that the attributes of this column extend to */
PRInt32 mRepeat;
public:
/** default constructor */
nsTableCol ();
/** constructor
* @param aImplicit PR_TRUE if there is no actual input tag corresponding to
* this col.
*/
nsTableCol (PRBool aImplicit);
/** constructor
* @param aTag the HTML tag causing this col to get constructed.
*/
nsTableCol (nsIAtom* aTag);
/** destructor, not responsible for any memory destruction itself */
virtual ~nsTableCol();
// For debugging purposes only
NS_IMETHOD_(nsrefcnt) AddRef();
NS_IMETHOD_(nsrefcnt) Release();
/** returns nsITableContent::kTableCellType */
virtual int GetType();
/** @see nsIHTMLContent::CreateFrame */
virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext,
PRInt32 aIndexInParent,
nsIFrame* aParentFrame);
/** return the number of columns this content object represents. always >= 1*/
virtual int GetRepeat ();
/** set the number of columns this content object represents. must be >= 1*/
void SetRepeat (int aRepeat);
virtual nsTableColGroup *GetColGroup ();
/**
* Since mColGroup is the parent of the table column,
* reference counting should NOT be done on
* this variable when setting the row.
* see /ns/raptor/doc/MemoryModel.html
**/
/** set the parent col group.<br>
* NOTE: Since mColGroup is the parent of the table column,
* reference counting should NOT be done on
* this variable when setting the row.
* see /ns/raptor/doc/MemoryModel.html
**/
virtual void SetColGroup (nsTableColGroup * aColGroup);
/** return the index of the column this content object represents. always >= 0 */
virtual int GetColumnIndex ();
/** set the index of the column this content object represents. must be >= 0 */
virtual void SetColumnIndex (int aColIndex);
virtual void ResetColumns ();
@ -86,18 +109,19 @@ public:
protected:
/** obsolete */
PRBool SetInternalAttribute (nsString *aName, nsString *aValue);
/** obsolete */
nsString *GetInternalAttribute (nsString *aName);
/** obsolete */
PRBool UnsetInternalAttribute (nsString *aName);
/** obsolete */
int GetInternalAttributeState (nsString *aName);
/** obsolete */
PRBool IsInternalAttribute (nsString *aName);
/** obsolete */
static nsString * kInternalAttributeNames;
/** obsolete */
nsString * GetAllInternalAttributeNames ();

Просмотреть файл

@ -97,7 +97,7 @@ int nsTableColGroup::GetStartColumnIndex ()
void nsTableColGroup::SetStartColumnIndex (int aIndex)
{
if (aIndex != mStartColIndex)
mColCount = 0; // our index is beign changed, trigger reset of col indicies, don't propogate back to table
mColCount = 0; // our index is being changed, trigger reset of col indicies, don't propogate back to table
mStartColIndex = aIndex;
}
@ -116,6 +116,10 @@ void nsTableColGroup::ResetColumns ()
mTable->ResetColumns ();
}
/** returns the number of columns represented by this group.
* if there are col children, count them (taking into account the span of each)
* else, check my own span attribute.
*/
int nsTableColGroup::GetColumnCount ()
{
if (0 == mColCount)

Просмотреть файл

@ -24,8 +24,13 @@
class nsIPresContext;
/**
* nsTableColGroup
* datastructure to maintain information about a single table column
* nsTableColGroup is the content object that represents table col groups
* (HTML tag COLGROUP). This class cannot be reused
* outside of an nsTablePart. It assumes that its parent is an nsTablePart, and
* its children are nsTableCols.
*
* @see nsTablePart
* @see nsTableCol
*
* @author sclark
*/
@ -33,48 +38,104 @@ class nsTableColGroup : public nsTableContent
{
protected:
/** the number of columns this col group represents. Must be >=1.
* Default is 1.
* Must be ignored if the colgroup contains any explicit col content objects.
*/
int mSpan;
/** the starting column index this col group represents. Must be >= 0. */
int mStartColIndex;
/** the number of columns represented by this col group when col content
* objects are contained herein. If no col children, then mSpan is the
* proper place to check.
* @see GetColumnCount
*/
int mColCount;
public:
/** constructor
* @param aImplicit PR_TRUE if there is no actual input tag corresponding to
* this col group.
*/
nsTableColGroup (PRBool aImplicit);
/** constructor
* @param aTag the HTML tag causing this caption to get constructed.
* @param aSpan the number of columns this col group represents
* (unless overridden by col children.)
*/
nsTableColGroup (nsIAtom* aTag, int aSpan);
/** destructor, not responsible for any memory destruction itself */
virtual ~nsTableColGroup();
// For debugging purposes only
NS_IMETHOD_(nsrefcnt) AddRef();
NS_IMETHOD_(nsrefcnt) Release();
/** @see nsIHTMLContent::CreateFrame */
virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext,
PRInt32 aIndexInParent,
nsIFrame* aParentFrame);
/** returns nsITableContent::kTableColGroupType */
virtual int GetType();
/** returns the span attribute, always >= 1. Not necessarily representative
* of the number of columns spanned, since span is overridden by any COL
* children.
* @see GetColumnCount
*/
virtual int GetSpan ();
/** set the span attribute, must be >= 1. */
virtual void SetSpan (int aSpan);
/** get the starting column index, always >= 0. */
virtual int GetStartColumnIndex ();
/** set the starting column index, must be >= 0. */
virtual void SetStartColumnIndex (int aIndex);
/** called whenever the col structure changes.
* Propogates change notification up to the nsTablePart parent
*/
virtual void ResetColumns ();
/** returns the number of columns represented by this group.
* if there are col children, count them (taking into account the span of each)
* else, check my own span attribute.
*/
virtual int GetColumnCount ();
/** helper routine returns PR_TRUE if aContent represents a column */
virtual PRBool IsCol(nsIContent * aContent) const;
/** can only append objects that are columns (implement nsITableContent and are .
* of type nsITableContent::kTableColType.)
* @see nsIContent::AppendChild
*/
virtual PRBool AppendChild (nsIContent * aContent);
/** can only insert objects that are columns (implement nsITableContent and are .
* of type nsITableContent::kTableColType.)
* @see nsIContent::InsertChildAt
*/
virtual PRBool InsertChildAt (nsIContent * aContent, int aIndex);
/** can only replace child objects with objects that are columns
* (implement nsITableContent and are * of type nsITableContent::kTableColType.)
* @param aContent the object to insert, must be a column
* @param aIndex the index of the object to replace. Must be in the range
* 0<=aIndex<ChildCount().
* @see nsIContent::ReplaceChildAt
*/
virtual PRBool ReplaceChildAt (nsIContent * aContent, int aIndex);
/** @see nsIContent::InsertChildAt */
virtual PRBool RemoveChildAt (int aIndex);
protected:

Просмотреть файл

@ -25,10 +25,11 @@
#include "nsIAtom.h"
/**
* TableContent is a concrete subclass for all content nodes contained directly within a table.
* TableContent is a concrete base class for all content nodes contained directly
* within a table.
*
* @author sclark
* @version $Revision: 3.1 $
* @version $Revision: 3.2 $
* @see
*/
class nsTableContent : public nsHTMLContainer, public nsITableContent
@ -36,23 +37,26 @@ class nsTableContent : public nsHTMLContainer, public nsITableContent
public:
//NS_DECL_ISUPPORTS
protected:
/** the table to which this content belongs */
nsTablePart *mTable;
/** PR_TRUE if this content was generated in response to incomplete input,
* meaning there is no actual input tag matching this container.
*/
PRBool mImplicit;
public:
/**
* default constructor
/** constructor
* @param aTag the HTML tag causing this caption to get constructed.
*/
nsTableContent (nsIAtom* aTag);
/**
* constructor
* @param aTag
* @param aImplicit
/** constructor
* @param aTag the HTML tag causing this caption to get constructed.
* @param aImplicit PR_TRUE if there is no actual input tag corresponding to
* this caption.
*/
nsTableContent (nsIAtom* aTag, PRBool aImplicit);
@ -63,30 +67,26 @@ public:
NS_IMETHOD_(nsrefcnt) AddRef();
NS_IMETHOD_(nsrefcnt) Release();
/**
* returns the nsTablePart that contains this content node.
*/
/** @see nsITableContent::GetTable */
nsTablePart* GetTable ();
/**
* Since mColGroup is the parent of the table column,
* reference counting should NOT be done.
* see /ns/raptor/doc/MemoryModel.html
**/
/** @see nsITableContent::SetTable
* Note: Since mColGroup is the parent of the table column,
* reference counting should NOT be done.
* see /ns/raptor/doc/MemoryModel.html
**/
void SetTable (nsTablePart *aTable);
/**
*
*/
/** @see nsITableContent::IsImplicit */
virtual PRBool IsImplicit () const;
/**
* Don't want to put out implicit tags when saving.
*/
/** @see nsITableContent::SkipSelfForSaving */
virtual PRBool SkipSelfForSaving ();
/** @see nsITableContent::GetType */
virtual int GetType()=0;
/** debug method prints out this and all child frames */
void List(FILE* out, PRInt32 aIndent) const;
PRBool InsertChildAt(nsIContent* aKid, PRInt32 aIndex);
@ -97,11 +97,11 @@ public:
private:
/**
*
* If the content is a nsTableContent then call SetTable on
* aContent, otherwise, do nothing.
*
*/
*
* If the content is a nsTableContent then call SetTable on
* aContent, otherwise, do nothing.
*
*/
void SetTableForTableContent(nsIContent* aContent, nsTablePart *aTable);
};

Просмотреть файл

@ -727,7 +727,7 @@ nsIFrame::ReflowStatus nsTableFrame::ResizeReflowPass2(nsIPresContext* aPresCont
}
}
// Did we successfully relow our mapped children?
// Did we successfully reflow our mapped children?
if (PR_TRUE == reflowMappedOK) {
// Any space left?
if ((nsnull != mFirstChild) && (state.availSize.height <= 0)) {
@ -1581,7 +1581,6 @@ if there is space left over
// Step 1 - assign the width of all fixed-width columns,
// and calculate min/max table width
// still needs to take insets into account
PRBool nsTableFrame::AssignFixedColumnWidths(nsIPresContext* aPresContext, PRInt32 maxWidth,
PRInt32 aNumCols, nsStyleMolecule* aTableStyleMol,
PRInt32 &aTotalFixedWidth,

Просмотреть файл

@ -29,36 +29,70 @@ class CellData;
struct nsStyleMolecule;
struct InnerTableReflowState;
/**
/** nsTableFrame maps the inner portion of a table (everything except captions.)
* Used as a pseudo-frame within nsTableOuterFrame,
* it may also be used stand-alone as the top-level frame.
* The meaningful child frames of nsTableFrame map rowgroups.
*
* @author sclark
*
* TODO: make methods virtual so nsTableFrame can be used as a base class in the future.
*/
class nsTableFrame : public nsContainerFrame
{
public:
/** nsTableOuterFrame has intimate knowledge of the inner table frame */
friend class nsTableOuterFrame;
/** instantiate a new instance of nsTableFrame.
* @param aInstancePtrResult the new object is returned in this out-param
* @param aContent the table object to map
* @param aIndexInParent which child is the new frame?
* @param aParent the parent of the new frame
*
* @return NS_OK if the frame was properly allocated, otherwise an error code
*/
static nsresult NewFrame(nsIFrame** aInstancePtrResult,
nsIContent* aContent,
PRInt32 aIndexInParent,
nsIFrame* aParent);
/** @see nsIFrame::Paint */
virtual void Paint(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect);
/** inner tables are reflowed in two steps.
* <pre>
* if mFirstPassValid is false, this is our first time through since content was last changed
* set pass to 1
* do pass 1
* get min/max info for all cells in an infinite space
* do column balancing
* set mFirstPassValid to true
* do pass 2
* use column widths to ResizeReflow cells
* shrinkWrap Cells in each row to tallest, realigning contents within the cell
* </pre>
*
* @see ResizeReflowPass1
* @see ResizeReflowPass2
* @see BalanceColumnWidths
* @see nsIFrame::ResizeReflow
*/
virtual ReflowStatus ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize);
/** @see nsIFrame::IncrementalReflow */
virtual ReflowStatus IncrementalReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsReflowCommand& aReflowCommand);
/**
* @see nsContainerFrame
*/
/** @see nsContainerFrame::CreateContinuingFrame */
virtual nsIFrame* CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent);
@ -94,7 +128,7 @@ public:
*/
virtual nsCellLayoutData * GetCellLayoutData(nsTableCell *aCell);
/**
/** returns PR_TRUE if this table has proportional width
*/
PRBool IsProportionalWidth(nsStyleMolecule* aMol);
@ -104,16 +138,13 @@ public:
* DEBUG METHOD
*
*/
void ListColumnLayoutData(FILE* out = stdout, PRInt32 aIndent = 0) const;
/**
*/
/** return the width of the column at aColIndex */
PRInt32 GetColumnWidth(PRInt32 aColIndex);
/**
*/
/** set the width of the column at aColIndex to aWidth */
void SetColumnWidth(PRInt32 aColIndex, PRInt32 aWidth);
@ -135,17 +166,29 @@ public:
protected:
/** protected constructor.
* @see NewFrame
*/
nsTableFrame(nsIContent* aContent,
PRInt32 aIndexInParent,
nsIFrame* aParentFrame);
/** destructor, responsible for mColumnLayoutData and mColumnWidths */
virtual ~nsTableFrame();
/**
/** helper method to delete contents of mColumnLayoutData
* should be called with care (ie, only by destructor)
*/
virtual void DeleteColumnLayoutData();
/**
/** first pass of ResizeReflow.
* lays out all table content with aMaxSize(NS_UNCONSTRAINEDSIZE,NS_UNCONSTRAINEDSIZE) and
* a non-null aMaxElementSize so we get all the metrics we need to do column balancing.
* Pass 1 only needs to be executed once no matter how many times the table is resized,
* as long as content and style don't change. This is managed in the member variable mFirstPassIsValid.
* The layout information for each cell is cached in mColumLayoutData.
*
* @see ResizeReflow
*/
virtual nsIFrame::ReflowStatus ResizeReflowPass1(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
@ -153,9 +196,16 @@ protected:
nsSize* aMaxElementSize,
nsStyleMolecule* aTableStyle);
/**
* aMinCaptionWidth - the max of all the minimum caption widths. 0 if no captions.
* aMaxCaptionWidth - the max of all the desired caption widths. 0 if no captions.
/** second pass of ResizeReflow.
* lays out all table content with aMaxSize(computed_table_width, given_table_height)
* Pass 2 is executed every time the table needs to resize. An optimization is included
* so that if the table doesn't need to actually be resized, no work is done (see NeedsReflow).
*
* @param aMinCaptionWidth - the max of all the minimum caption widths. 0 if no captions.
* @param aMaxCaptionWidth - the max of all the desired caption widths. 0 if no captions.
*
* @see ResizeReflow
* @see NeedsReflow
*/
virtual nsIFrame::ReflowStatus ResizeReflowPass2(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
@ -177,27 +227,69 @@ protected:
nsSize* aMaxElementSize,
nsSize& aKidMaxElementSize);
/**
* Reflow the frames we've already created
*
* @param aPresContext presentation context to use
* @param aState current inline state
* @return true if we successfully reflowed all the mapped children and false
* otherwise, e.g. we pushed children to the next in flow
*/
PRBool ReflowMappedChildren(nsIPresContext* aPresContext,
InnerTableReflowState& aState,
nsSize* aMaxElementSize);
/**
* Try and pull-up frames from our next-in-flow
*
* @param aPresContext presentation context to use
* @param aState current inline state
* @return true if we successfully pulled-up all the children and false
* otherwise, e.g. child didn't fit
*/
PRBool PullUpChildren(nsIPresContext* aPresContext,
InnerTableReflowState& aState,
nsSize* aMaxElementSize);
/**
* Create new frames for content we haven't yet mapped
*
* @param aPresContext presentation context to use
* @param aState current inline state
* @return frComplete if all content has been mapped and frNotComplete
* if we should be continued
*/
ReflowStatus ReflowUnmappedChildren(nsIPresContext* aPresContext,
InnerTableReflowState& aState,
nsSize* aMaxElementSize);
/**
/** assign widths for each column, taking into account the table content, the effective style,
* the layout constraints, and the compatibility mode. Sets mColumnWidths as a side effect.
* @param aPresContext the presentation context
* @param aTableStyle the resolved style for the table
* @param aMaxSize the height and width constraints
* @param aMaxElementSize the min size of the largest indivisible object
*/
virtual void BalanceColumnWidths(nsIPresContext* aPresContext,
nsStyleMolecule* aTableStyle,
const nsSize& aMaxSize,
nsSize* aMaxElementSize);
/**
/** assign widths for each column that has fixed width.
* Computes the minimum and maximum table widths.
* Sets mColumnWidths as a side effect.
*
* @param aPresContext the presentation context
* @param aMaxWidth the maximum width of the table
* @param aNumCols the total number of columns in the table
* @param aTableStyle the resolved style for the table
* @param aTotalFixedWidth out param, the sum of the fixed width columns
* @param aMinTableWidth out param, the min possible table width
* @param aMaxTableWidth out param, the max table width
*
* @return PR_TRUE if all is well, PR_FALSE if there was an unrecoverable error
*
* TODO: should be renamed to "AssignKnownWidthInformation
*/
virtual PRBool AssignFixedColumnWidths(nsIPresContext* aPresContext,
PRInt32 aMaxWidth,
@ -206,8 +298,22 @@ protected:
PRInt32 & aTotalFixedWidth,
PRInt32 & aMinTableWidth,
PRInt32 & aMaxTableWidth);
/**
*/
/** assign widths for each column that has proportional width inside a table that
* has a fixed width.
* Sets mColumnWidths as a side effect.
*
* @param aPresContext the presentation context
* @param aTableStyle the resolved style for the table
* @param aAvailWidth the remaining amount of horizontal space available
* @param aMaxWidth the total amount of horizontal space available
* @param aMinTableWidth the min possible table width
* @param aMaxTableWidth the max table width
*
* @return PR_TRUE if all is well, PR_FALSE if there was an unrecoverable error
*
* TODO: rename this method to reflect that it is a Nav4 compatibility method
*/
virtual PRBool BalanceProportionalColumnsForSpecifiedWidthTable(nsIPresContext* aPresContext,
nsStyleMolecule* aTableStyleMol,
PRInt32 aAvailWidth,
@ -215,8 +321,21 @@ protected:
PRInt32 aMinTableWidth,
PRInt32 aMaxTableWidth);
/**
*/
/** assign widths for each column that has proportional width inside a table that
* has auto width (width set by the content and available space.)
* Sets mColumnWidths as a side effect.
*
* @param aPresContext the presentation context
* @param aTableStyle the resolved style for the table
* @param aAvailWidth the remaining amount of horizontal space available
* @param aMaxWidth the total amount of horizontal space available
* @param aMinTableWidth the min possible table width
* @param aMaxTableWidth the max table width
*
* @return PR_TRUE if all is well, PR_FALSE if there was an unrecoverable error
*
* TODO: rename this method to reflect that it is a Nav4 compatibility method
*/
virtual PRBool BalanceProportionalColumnsForAutoWidthTable(nsIPresContext* aPresContext,
nsStyleMolecule* aTableStyleMol,
PRInt32 aAvailWidth,
@ -224,12 +343,46 @@ protected:
PRInt32 aMinTableWidth,
PRInt32 aMaxTableWidth);
/** assign the minimum allowed width for each column that has proportional width.
* Typically called when the min table width doesn't fit in the available space.
* Sets mColumnWidths as a side effect.
*
* @param aPresContext the presentation context
*
* @return PR_TRUE if all is well, PR_FALSE if there was an unrecoverable error
*/
virtual PRBool SetColumnsToMinWidth(nsIPresContext* aPresContext);
/** assign the maximum allowed width for each column that has proportional width.
* Typically called when the desired max table width fits in the available space.
* Sets mColumnWidths as a side effect.
*
* @param aPresContext the presentation context
* @param aTableStyle the resolved style for the table
* @param aAvailWidth the remaining amount of horizontal space available
*
* @return PR_TRUE if all is well, PR_FALSE if there was an unrecoverable error
*/
virtual PRBool BalanceColumnsTableFits(nsIPresContext* aPresContext,
nsStyleMolecule* aTableStyleMol,
PRInt32 aAvailWidth);
/** assign widths for each column that has proportional width inside a table that
* has auto width (width set by the content and available space) according to the
* HTML 4 specification.
* Sets mColumnWidths as a side effect.
*
* @param aPresContext the presentation context
* @param aTableStyle the resolved style for the table
* @param aAvailWidth the remaining amount of horizontal space available
* @param aMaxWidth the total amount of horizontal space available
* @param aMinTableWidth the min possible table width
* @param aMaxTableWidth the max table width
*
* @return PR_TRUE if all is well, PR_FALSE if there was an unrecoverable error
*
* TODO: rename this method to reflect that it is a Nav4 compatibility method
*/
virtual PRBool BalanceColumnsHTML4Constrained(nsIPresContext* aPresContext,
nsStyleMolecule* aTableStyleMol,
PRInt32 aAvailWidth,
@ -237,8 +390,7 @@ protected:
PRInt32 aMinTableWidth,
PRInt32 aMaxTableWidth);
/**
*/
/** sets the width of the table according to the computed widths of each column. */
virtual void SetTableWidth(nsIPresContext* aPresContext,
nsStyleMolecule* aTableStyle);
@ -264,10 +416,13 @@ protected:
/** given the new parent size, do I really need to do a reflow? */
virtual PRBool NeedsReflow(const nsSize& aMaxSize);
/** what stage of reflow is currently in process? */
virtual PRInt32 GetReflowPass() const;
/** sets the reflow pass flag. use with caution! */
virtual void SetReflowPass(PRInt32 aReflowPass);
/** returns PR_TRUE if the cached pass 1 data is still valid */
virtual PRBool IsFirstPassValid() const;
private:

Просмотреть файл

@ -28,38 +28,75 @@ class nsTableCaptionFrame;
struct OuterTableReflowState;
/**
* nsTableOuterFrame
* main frame for an nsTable content object.
* main frame for an nsTable content object,
* the nsTableOuterFrame contains 0 or more nsTableCaptionFrames,
* and a single nsTableFrame psuedo-frame.
* and a single nsTableFrame psuedo-frame, often referred to as the "inner frame'.
* <P> Unlike other frames that handle continuing across breaks, nsTableOuterFrame
* has no notion of "unmapped" children. All children (captions and inner table)
* have frames created in Pass 1, so from the layout process' point of view, they
* are always mapped
*
* @author sclark
*/
class nsTableOuterFrame : public nsContainerFrame
{
public:
/** instantiate a new instance of nsTableFrame.
* @param aInstancePtrResult the new object is returned in this out-param
* @param aContent the table object to map
* @param aIndexInParent which child is the new frame?
* @param aParent the parent of the new frame
*
* @return NS_OK if the frame was properly allocated, otherwise an error code
*/
static nsresult NewFrame(nsIFrame** aInstancePtrResult,
nsIContent* aContent,
PRInt32 aIndexInParent,
nsIFrame* aParent);
/** @see nsIFrame::Paint */
virtual void Paint(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect);
/** outer tables are reflowed in two steps.
* Step 1:, we lay out all of the captions and the inner table with
* height and width set to NS_UNCONSTRAINEDSIZE.
* This gives us absolute minimum and maximum widths for each component.
* In the second step, we set all the captions and the inner table to
* the width of the widest component, given the table's style, width constraints
* and compatibility mode.<br>
* Step 2: With the widths now known, we reflow the captions and table.<br>
* NOTE: for breaking across pages, this method has to account for table content
* that is not laid out linearly vis a vis the frames.
* That is, content hierarchy and the frame hierarchy do not match.
*
* @see NeedsReflow
* @see ResizeReflowCaptionsPass1
* @see ResizeReflowTopCaptionsPass2
* @see ResizeReflowBottomCaptionsPass2
* @see PlaceChild
* @see ReflowMappedChildren
* @see PullUpChildren
* @see ReflowChild
* @see nsTableFrame::ResizeReflowPass1
* @see nsTableFrame::ResizeReflowPass2
* @see nsTableFrame::BalanceColumnWidths
* @see nsIFrame::ResizeReflow
*/
ReflowStatus ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize);
/** @see nsIFrame::IncrementalReflow */
ReflowStatus IncrementalReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsReflowCommand& aReflowCommand);
/**
* @see nsContainerFrame
*/
/** @see nsContainerFrame */
virtual nsIFrame* CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent);
/** destructor */
@ -67,14 +104,16 @@ public:
protected:
/** constructor */
/** protected constructor
* @see NewFrame
*/
nsTableOuterFrame(nsIContent* aContent,
PRInt32 aIndexInParent,
nsIFrame* aParentFrame);
/** return PR_TRUE if the table needs to be reflowed.
* the outer table needs to be reflowed if the table content has changed,
* or if the combination of table style attributes and max height/width have
* or if the table style attributes or parent max height/width have
* changed.
*/
virtual PRBool NeedsReflow(const nsSize& aMaxSize);
@ -131,10 +170,26 @@ protected:
nsSize* aMaxElementSize,
nsSize& aKidMaxElementSize);
/**
* Reflow the frames we've already created
*
* @param aPresContext presentation context to use
* @param aState current inline state
* @return true if we successfully reflowed all the mapped children and false
* otherwise, e.g. we pushed children to the next in flow
*/
PRBool ReflowMappedChildren(nsIPresContext* aPresContext,
OuterTableReflowState& aState,
nsSize* aMaxElementSize);
/**
* Try and pull-up frames from our next-in-flow
*
* @param aPresContext presentation context to use
* @param aState current inline state
* @return true if we successfully pulled-up all the children and false
* otherwise, e.g. child didn't fit
*/
PRBool PullUpChildren(nsIPresContext* aPresContext,
OuterTableReflowState& aState,
nsSize* aMaxElementSize);
@ -149,26 +204,20 @@ protected:
nsSize* aMaxElementSize,
OuterTableReflowState& aState);
/**
* Sets the last content offset based on the last child frame. If the last
* child is a pseudo frame then it sets mLastContentIsComplete to be the same
* as the last child's mLastContentIsComplete
*/
//virtual void SetLastContentOffset(const nsIFrame* aLastChild);
/**
* See nsContainerFrame::VerifyTree
/** overridden here to handle special caption-table relationship
* @see nsContainerFrame::VerifyTree
*/
virtual void VerifyTree() const;
/**
* See nsContainerFrame::PrepareContinuingFrame
/** overridden here to handle special caption-table relationship
* @see nsContainerFrame::PrepareContinuingFrame
*/
virtual void PrepareContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsTableOuterFrame* aContFrame);
/**
/** create the inner table frame (nsTableFrame)
* handles initial creation as well as creation of continuing frames
*/
virtual void CreateInnerTableFrame(nsIPresContext* aPresContext);

Просмотреть файл

@ -797,8 +797,6 @@ void nsTablePart::BuildCellMap ()
colIndex++;
}
// SEC: this whole next if block is very suspicious.
if (cellIndex < cellCount)
{
// We didn't use all the cells in this row up. Grow the cell

Просмотреть файл

@ -30,10 +30,15 @@ class nsTableColGroup;
class nsTableCol;
class nsTableCaption;
/**
/** Data stored by nsCellMap to rationalize rowspan and colspan cells.
* if mCell is null then mRealCell will be the rowspan/colspan source
* in addition, if fOverlap is non-null then it will point to the
* other cell that overlaps this position
* @see nsCellMap
* @see nsTablePart::BuildCellMap
* @see nsTablePart::GrowCellMap
* @see nsTablePart::BuildCellIntoMap
*
*/
class CellData
{
@ -49,12 +54,20 @@ public:
/**
* Table Content Model.
* A Table can contain RowGroups, ColumnGroups, and Captions.
* We build a full rationalized content model, so the structure of a table
* will always be regular and predictable.
* A Table can contain RowGroups (THEAD, TBODY, TFOOT), ColumnGroups (COLGROUP),
* and Captions (CAPTION). Any other table content (TH, TD, COL) belongs in
* one of these containers, and if the container doesn't explicitly exist in
* the source, an implicit container will get created.
*
* @author sclark
*/
class nsTablePart : public nsHTMLContainer {
public:
/** known HTML tags */
static const char *nsTablePart::kCaptionTagString;
static const char *nsTablePart::kRowGroupBodyTagString;
static const char *nsTablePart::kRowGroupHeadTagString;
@ -65,22 +78,62 @@ public:
static const char *nsTablePart::kDataCellTagString;
static const char *nsTablePart::kHeaderCellTagString;
/** constructor
* @param aTag the HTML tag that caused this content node to be instantiated
*/
nsTablePart(nsIAtom* aTag);
/** constructor
* @param aTag the HTML tag that caused this content node to be instantiated
* @param aColumnCount the number of columns in this table
*/
nsTablePart(nsIAtom* aTag, int aColumnCount);
// For debugging purposes only
NS_IMETHOD_(nsrefcnt) AddRef();
NS_IMETHOD_(nsrefcnt) Release();
/* public Table methods */
/* public Table methods */
/** ResetCellMap is called when the cell structure of the table is changed.
* Call with caution, only when changing the structure of the table such as
* inserting or removing rows, changing the rowspan or colspan attribute of a cell, etc.
*/
virtual void ResetCellMap ();
/** ResetColumns is called when the column structure of the table is changed.
* Call with caution, only when adding or removing columns, changing
* column attributes, changing the rowspan or colspan attribute of a cell, etc.
*/
virtual void ResetColumns ();
/** 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.
*/
virtual void EnsureColumns ();
/** return the number of columns as specified by the input.
* has 2 side effects:<br>
* calls SetStartColumnIndex on each nsTableColumn<br>
* sets mSpecifiedColCount.<br>
*/
virtual int GetSpecifiedColumnCount ();
/** returns the number of rows in this table.
* if mCellMap has been created, it is asked for the number of rows.<br>
* otherwise, the content is enumerated and the rows are counted.
*/
virtual int GetRowCount();
/** returns the actual number of columns in this table.<br>
* as a side effect, will call BuildCellMap to constuct mCellMap if needed.
*/
virtual int GetMaxColumns();
/* overrides from nsHTMLContainer */
/* overrides from nsHTMLContainer */
virtual PRBool InsertChildAt(nsIContent* aKid, PRInt32 aIndex);
virtual PRBool ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex);
virtual PRBool AppendChild(nsIContent* aKid);
@ -90,21 +143,72 @@ public:
PRInt32 aIndexInParent,
nsIFrame* aParentFrame);
/** called when the input stream knows that the input has been completely consumed.
* this is a hook for future optimizations.
*/
virtual void NotifyContentComplete();
protected:
/** destructor
* deletes mCellMap, if allocated.
*/
virtual ~nsTablePart();
/** return the row span of a cell, taking into account row span magic at the bottom
* of a table.
* @param aRowIndex the first row that contains the cell
* @param aCell the content object representing the cell
* @return the row span, correcting for row spans that extend beyond the bottom
* of the table.
*/
virtual int GetEffectiveRowSpan(int aRowIndex, nsTableCell *aCell);
/** build as much of the CellMap as possible from the info we have so far
*/
virtual void BuildCellMap ();
/** called whenever the number of columns changes, to increase the storage in mCellMap
*/
virtual void GrowCellMap(int aColCount);
/** called every time we discover we have a new cell to add to the table.
* This could be because we got actual cell content, because of rowspan/colspan attributes, etc.
* This method changes mCellMap as necessary to account for the new cell.
*
* @param aCell the content object created for the cell
* @param aRowIndex the row into which the cell is to be inserted
* @param aColIndex the col into which the cell is to be inserted
*/
virtual void BuildCellIntoMap (nsTableCell *aCell, int aRowIndex, int aColIndex);
/** returns the index of the first child after aStartIndex that is a row group
*/
virtual int NextRowGroup (int aStartIndex);
/** obsolete! */
virtual void ReorderChildren();
/** append aContent to my child list
* @return PR_TRUE on success, PR_FALSE if aContent could not be appended
*/
virtual PRBool AppendRowGroup(nsTableRowGroup *aContent);
/** append aContent to my child list
* @return PR_TRUE on success, PR_FALSE if aContent could not be appended
*/
virtual PRBool AppendColGroup(nsTableColGroup *aContent);
/** append aContent to my child list
* @return PR_TRUE on success, PR_FALSE if aContent could not be appended
*/
virtual PRBool AppendColumn(nsTableCol *aContent);
/** append aContent to my child list
* @return PR_TRUE on success, PR_FALSE if aContent could not be appended
*/
virtual PRBool AppendCaption(nsTableCaption *aContent);
public:
virtual void DumpCellMap() const;
virtual nsCellMap* GetCellMap() const;

Просмотреть файл

@ -24,8 +24,14 @@
/**
* nsTableRow
* datastructure to maintain information about a single table row
* nsTableRow is the content object that represents table rows
* (HTML tag TR). This class cannot be reused
* outside of an nsTableRowGroup. It assumes that its parent is an nsTableRowGroup, and
* its children are nsTableCells.
*
* @see nsTablePart
* @see nsTableRowGroup
* @see nsTableCell
*
* @author sclark
*/
@ -33,56 +39,89 @@ class nsTableRow : public nsTableContent
{
private:
/** parent pointer */
nsTableRowGroup * mRowGroup;
/** the index of the row this content object represents */
PRInt32 mRowIndex;
public:
/** constructor
* @param aTag the HTML tag causing this row to get constructed.
*/
nsTableRow (nsIAtom* aTag);
/** constructor
* @param aTag the HTML tag causing this row to get constructed.
* @param aImplicit PR_TRUE if there is no actual input tag corresponding to
* this row.
*/
nsTableRow (nsIAtom* aTag, PRBool aImplicit);
/** destructor, not responsible for any memory destruction itself */
virtual ~nsTableRow();
// For debugging purposes only
NS_IMETHOD_(nsrefcnt) AddRef();
NS_IMETHOD_(nsrefcnt) Release();
/** returns nsITableContent::kTableRowType */
virtual int GetType();
/** @see nsIHTMLContent::CreateFrame */
virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext,
PRInt32 aIndexInParent,
nsIFrame* aParentFrame);
/** return the row group that contains me (my parent) */
virtual nsTableRowGroup *GetRowGroup ();
/**
* Since mRowGroup is the parent of the table row,
* reference counting should not be done on
* this variable when setting the row.
* see /ns/raptor/doc/MemoryModel.html
**/
/** Set my parent row group.<br>
* NOTE: Since mRowGroup is the parent of the table row,
* reference counting should not be done on
* this variable when setting the row.
* see /ns/raptor/doc/MemoryModel.html
**/
virtual void SetRowGroup (nsTableRowGroup * aRowGroup);
/** return this row's starting row index */
virtual PRInt32 GetRowIndex ();
/** set this row's starting row index */
virtual void SetRowIndex (int aRowIndex);
/** return the number of columns represented by the cells in this row */
virtual PRInt32 GetMaxColumns();
/** notify the containing nsTablePart that cell information has changed */
virtual void ResetCellMap ();
/* ----------- nsTableContent overrides ----------- */
/** can only append objects that are cells (implement nsITableContent and are .
* of type nsITableContent::kTableCellType.)
* @see nsIContent::AppendChild
*/
virtual PRBool AppendChild (nsIContent * aContent);
/** can only insert objects that are cells (implement nsITableContent and are .
* of type nsITableContent::kTableCellType.)
* @see nsIContent::InsertChildAt
*/
virtual PRBool InsertChildAt (nsIContent * aContent, int aIndex);
/** can only replace child objects with objects that are cells
* (implement nsITableContent and are * of type nsITableContent::kTableCellType.)
* @param aContent the object to insert, must be a cell
* @param aIndex the index of the object to replace. Must be in the range
* 0<=aIndex<ChildCount().
* @see nsIContent::ReplaceChildAt
*/
virtual PRBool ReplaceChildAt (nsIContent * aContent, int aIndex);
/** @see nsIContent::InsertChildAt */
virtual PRBool RemoveChildAt (int aIndex);

Просмотреть файл

@ -241,6 +241,7 @@ nsTableRowFrame::ResizeReflow(nsIPresContext* aPresContext,
prevKidFrame->SetNextSibling(kidFrame);
} else {
// Our first child (**blush**)
if (gsDebug1) printf ("row frame %p, setting first child to %p\n", this, kidFrame);
mFirstChild = kidFrame;
SetFirstContentOffset(kidFrame);
if (gsDebug1) printf("ROW: set first content offset to %d\n", GetFirstContentOffset()); //@@@
@ -276,6 +277,18 @@ nsTableRowFrame::ResizeReflow(nsIPresContext* aPresContext,
PostReflowCheck(result);
#endif
if (gsDebug1==PR_TRUE)
{
if (nsnull!=aMaxElementSize)
printf("nsTableRowFrame::RR returning: %s with aDesiredSize=%d,%d, aMES=%d,%d\n",
result==frComplete?"Complete":"Not Complete",
aDesiredSize.width, aDesiredSize.height,
aMaxElementSize->width, aMaxElementSize->height);
else
printf("nsTableRowFrame::RR returning: %s with aDesiredSize=%d,%d, aMES=NSNULL\n",
result==frComplete?"Complete":"Not Complete",
aDesiredSize.width, aDesiredSize.height);
}
return result;
}
@ -293,6 +306,7 @@ nsTableRowFrame::IncrementalReflow(nsIPresContext* aPresContext,
nsIFrame* nsTableRowFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent)
{
if (gsDebug1==PR_TRUE) printf("nsTableRowFrame::CreateContinuingFrame\n");
nsTableRowFrame* cf = new nsTableRowFrame(mContent, mIndexInParent, aParent);
PrepareContinuingFrame(aPresContext, aParent, cf);
return cf;

Просмотреть файл

@ -23,47 +23,79 @@
/**
* nsTableRowFrame
* data structure to maintain information about a single table row's geometry
* nsTableRowFrame is the frame that maps table rows
* (HTML tag TR). This class cannot be reused
* outside of an nsTableRowGroupFrame. It assumes that its parent is an nsTableRowGroupFrame,
* and its children are nsTableCellFrames.
*
* @see nsTableFrame
* @see nsTableRowGroupFrame
* @see nsTableCellFrame
*
* @author sclark
*/
/**
*/
class nsTableRowFrame : public nsContainerFrame
{
public:
/** instantiate a new instance of nsTableRowFrame.
* @param aInstancePtrResult the new object is returned in this out-param
* @param aContent the table object to map
* @param aIndexInParent which child is the new frame?
* @param aParent the parent of the new frame
*
* @return NS_OK if the frame was properly allocated, otherwise an error code
*/
static nsresult NewFrame(nsIFrame** aInstancePtrResult,
nsIContent* aContent,
PRInt32 aIndexInParent,
nsIFrame* aParent);
/** @see nsIFrame::Paint */
virtual void Paint(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect);
/** ask all children to paint themselves, without clipping (for cells with rowspan>1)
* @see nsIFrame::Paint
*/
virtual void PaintChildren(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect);
/** calls ResizeReflow for all of its child cells.
* Cells with rowspan=1 are all set to the same height and stacked horizontally.
* <P> Cells are not split unless absolutely necessary.
* <P> Cells are resized in nsTableFrame::BalanceColumnWidths
* and nsTableFrame::ShrinkWrapChildren
*
* @param aDesiredSize width set to width of the sum of the cells, height set to
* height of cells with rowspan=1.
*
* @see nsIFrame::ResizeReflow
* @see nsTableFrame::BalanceColumnWidths
* @see nsTableFrame::ShrinkWrapChildren
*/
ReflowStatus ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize);
/** @see nsIFrame::IncrementalReflow */
ReflowStatus IncrementalReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsReflowCommand& aReflowCommand);
/**
* @see nsContainerFrame
*/
/** @see nsContainerFrame::CreateContinuingFrame */
virtual nsIFrame* CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent);
/** set mTallestCell to 0 in anticipation of recalculating it */
void ResetMaxChildHeight();
/** set mTallestCell to max(mTallestCell, aChildHeight) */
void SetMaxChildHeight(PRInt32 aChildHeight);
/** returns the tallest child in this row (ignoring any cell with rowspans) */
@ -72,10 +104,14 @@ public:
protected:
/** protected constructor.
* @see NewFrame
*/
nsTableRowFrame(nsIContent* aContent,
PRInt32 aIndexInParent,
nsIFrame* aParentFrame);
/** destructor */
virtual ~nsTableRowFrame();
private:

Просмотреть файл

@ -24,57 +24,88 @@
class nsIPresContext;
/**
* TableRowGroup
* nsTableRowGroup is the content object that represents table row groups
* (HTML tags THEAD, TFOOT, and TBODY). This class cannot be reused
* outside of an nsTablePart. It assumes that its parent is an nsTableParte, and
* its children are nsTableRows.
*
* @see nsTablePart
* @see nsTableRow
*
* @author sec 11-20-97 6:12pm
* @version $Revision: 3.1 $
* @see
* @author sclark
* TODO: make getter/setters inline
*/
class nsTableRowGroup : public nsTableContent
{
public:
/** constructor
* @param aTag the HTML tag causing this row group to get constructed.
*/
nsTableRowGroup (nsIAtom* aTag);
/** constructor
* @param aTag the HTML tag causing this row group to get constructed.
* @param aImplicit PR_TRUE if there is no actual input tag corresponding to
* this row group.
*/
nsTableRowGroup (nsIAtom* aTag, PRBool aImplicit);
/** destructor, not responsible for any memory destruction itself */
virtual ~nsTableRowGroup();
/** return the max of the number of columns represented by the contained rows */
virtual PRInt32 GetMaxColumns();
// For debugging purposes only
NS_IMETHOD_(nsrefcnt) AddRef();
NS_IMETHOD_(nsrefcnt) Release();
/** @see nsIHTMLContent::CreateFrame */
virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext,
PRInt32 aIndexInParent,
nsIFrame* aParentFrame);
/** return the number of contained rows */
virtual int GetRowCount ()
{
return ChildCount ();
};
/** returns nsITableContent::kTableRowGroupType */
virtual int GetType()
{
return nsITableContent::kTableRowGroupType;
};
/** notify the containing nsTablePart that cell information has changed */
virtual void ResetCellMap ();
/* ----------- overrides from nsTableContent ---------- */
/** can only append objects that are rows (implement nsITableContent and are .
* of type nsITableContent::kTableRowType.)
* @see nsIContent::AppendChild
*/
virtual PRBool AppendChild (nsIContent * aContent);
/** can only insert objects that are rows (implement nsITableContent and are .
* of type nsITableContent::kTableRowType.)
* @see nsIContent::InsertChildAt
*/
virtual PRBool InsertChildAt (nsIContent * aContent, int aIndex);
/** can only replace child objects with objects that are rows
* (implement nsITableContent and are * of type nsITableContent::kTableRowe.)
* @param aContent the object to insert, must be a row
* @param aIndex the index of the object to replace. Must be in the range
* 0<=aIndex<ChildCount().
* @see nsIContent::ReplaceChildAt
*/
virtual PRBool ReplaceChildAt (nsIContent * aContent, int aIndex);
/**
* Remove a child at the given position. The method is ignored if
* the index is invalid (too small or too large).
*/
/** @see nsIContent::InsertChildAt */
virtual PRBool RemoveChildAt (int aIndex);
protected:

Просмотреть файл

@ -318,6 +318,11 @@ PRBool nsTableRowGroupFrame::ReflowMappedChildren( nsIPresContext* aPresCon
// Update mLastContentIsComplete now that this kid fits
mLastContentIsComplete = PRBool(status == frComplete);
/* Row groups should not create continuing frames for rows
* unless they absolutely have to!
* check to see if this is absolutely necessary (with new params from troy)
* otherwise PushChildren and bail.
*/
// Special handling for incomplete children
if (frNotComplete == status) {
// XXX It's good to assume that we might still have room
@ -512,6 +517,11 @@ PRBool nsTableRowGroupFrame::PullUpChildren(nsIPresContext* aPresContext,
printf("\n");
#endif
/* Row groups should not create continuing frames for rows
* unless they absolutely have to!
* check to see if this is absolutely necessary (with new params from troy)
* otherwise PushChildren and bail, as above.
*/
// Is the child we just pulled up complete?
if (frNotComplete == status) {
// No the child isn't complete.
@ -906,6 +916,19 @@ nsTableRowGroupFrame::ResizeReflow( nsIPresContext* aPresContext,
PostReflowCheck(status);
#endif
if (gsDebug1==PR_TRUE)
{
if (nsnull!=aMaxElementSize)
printf("nsTableRowGroupFrame::RR returning: %s with aDesiredSize=%d,%d, aMES=%d,%d\n",
status==frComplete?"Complete":"Not Complete",
aDesiredSize.width, aDesiredSize.height,
aMaxElementSize->width, aMaxElementSize->height);
else
printf("nsTableRowGroupFrame::RR returning: %s with aDesiredSize=%d,%d, aMES=NSNULL\n",
status==frComplete?"Complete":"Not Complete",
aDesiredSize.width, aDesiredSize.height);
}
return status;
}

Просмотреть файл

@ -25,49 +25,78 @@ struct RowGroupReflowState;
struct nsStyleMolecule;
/**
* nsTableRowGroupFrame
* data structure to maintain information about a single table cell's frame
* nsTableRowGroupFrame is the frame that maps row groups
* (HTML tags THEAD, TFOOT, and TBODY). This class cannot be reused
* outside of an nsTableFrame. It assumes that its parent is an nsTableFrame, and
* its children are nsTableRowFrames.
*
* @see nsTableFrame
* @see nsTableRowFrame
*
* @author sclark
*/
class nsTableRowGroupFrame : public nsContainerFrame
{
public:
/** instantiate a new instance of nsTableRowGroupFrame.
* @param aInstancePtrResult the new object is returned in this out-param
* @param aContent the table object to map
* @param aIndexInParent which child is the new frame?
* @param aParent the parent of the new frame
*
* @return NS_OK if the frame was properly allocated, otherwise an error code
*/
static nsresult NewFrame(nsIFrame** aInstancePtrResult,
nsIContent* aContent,
PRInt32 aIndexInParent,
nsIFrame* aParent);
/** @see nsIFrame::Paint */
virtual void Paint(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect);
/** ask all children to paint themselves, without clipping (for cells with rowspan>1)
* @see nsIFrame::Paint
*/
virtual void PaintChildren(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect);
/** calls ResizeReflow for all of its child rows.
* Rows are all set to the same width and stacked vertically.
* <P> rows are not split unless absolutely necessary.
*
* @param aDesiredSize width set to width of rows, height set to
* sum of height of rows that fit in aMaxSize.height.
*
* @see nsIFrame::ResizeReflow
*/
ReflowStatus ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize);
/** @see nsIFrame::IncrementalReflow */
ReflowStatus IncrementalReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsReflowCommand& aReflowCommand);
/**
* @see nsContainerFrame
*/
/** @see nsContainerFrame::CreateContinuingFrame */
virtual nsIFrame* CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent);
protected:
/** protected constructor.
* @see NewFrame
*/
nsTableRowGroupFrame(nsIContent* aContent,
PRInt32 aIndexInParent,
nsIFrame* aParentFrame);
/** protected destructor */
~nsTableRowGroupFrame();
nscoord GetTopMarginFor(nsIPresContext* aCX,
@ -82,14 +111,38 @@ protected:
nsSize* aMaxElementSize,
nsSize& aKidMaxElementSize);
/**
* Reflow the frames we've already created
*
* @param aPresContext presentation context to use
* @param aState current inline state
* @return true if we successfully reflowed all the mapped children and false
* otherwise, e.g. we pushed children to the next in flow
*/
PRBool ReflowMappedChildren(nsIPresContext* aPresContext,
RowGroupReflowState& aState,
nsSize* aMaxElementSize);
/**
* Try and pull-up frames from our next-in-flow
*
* @param aPresContext presentation context to use
* @param aState current inline state
* @return true if we successfully pulled-up all the children and false
* otherwise, e.g. child didn't fit
*/
PRBool PullUpChildren(nsIPresContext* aPresContext,
RowGroupReflowState& aState,
nsSize* aMaxElementSize);
/**
* Create new frames for content we haven't yet mapped
*
* @param aPresContext presentation context to use
* @param aState current inline state
* @return frComplete if all content has been mapped and frNotComplete
* if we should be continued
*/
ReflowStatus ReflowUnmappedChildren(nsIPresContext* aPresContext,
RowGroupReflowState& aState,
nsSize* aMaxElementSize);

Просмотреть файл

@ -22,9 +22,17 @@
class CellData;
/**
/** nsCellMap is a support class for nsTablePart.
* It maintains an Rows x Columns grid onto which the cells of the table are mapped.
* This makes processing of rowspan and colspan attributes much easier.
* Each cell is represented by a CellData object.
*
* @see CellData
* @see nsTablePart::BuildCellMap
* @see nsTablePart::GrowCellMap
* @see nsTablePart::BuildCellIntoMap
*
* acts like a 2-dimensional array, so all offsets are 0-indexed
* to the outside world.
TODO: inline methods
*/
class nsCellMap
@ -45,18 +53,25 @@ public:
// NOT VIRTUAL BECAUSE THIS CLASS SHOULD **NEVER** BE SUBCLASSED
~nsCellMap();
/** initialize the CellMap to (aRows x aColumns) */
void Reset(int aRows, int aColumns);
/** return the CellData for the cell at (aRow,aColumn) */
CellData * GetCellAt(int aRow, int aColumn) const;
void SetCellAt(CellData *aCell, int aRow, int aColumn);
/** assign aCellData to the cell at (aRow,aColumn) */
void SetCellAt(CellData *aCellData, int aRow, int aColumn);
/** expand the CellMap to have aColCount columns. The number of rows remains the same */
void GrowTo(int aColCount);
/** return the total number of columns in the table represented by this CellMap */
int GetColCount() const;
/** return the total number of rows in the table represented by this CellMap */
int GetRowCount() const;
/** for debugging, print out this CellMap */
void DumpCellMap() const;
};

Просмотреть файл

@ -727,7 +727,7 @@ nsIFrame::ReflowStatus nsTableFrame::ResizeReflowPass2(nsIPresContext* aPresCont
}
}
// Did we successfully relow our mapped children?
// Did we successfully reflow our mapped children?
if (PR_TRUE == reflowMappedOK) {
// Any space left?
if ((nsnull != mFirstChild) && (state.availSize.height <= 0)) {
@ -1581,7 +1581,6 @@ if there is space left over
// Step 1 - assign the width of all fixed-width columns,
// and calculate min/max table width
// still needs to take insets into account
PRBool nsTableFrame::AssignFixedColumnWidths(nsIPresContext* aPresContext, PRInt32 maxWidth,
PRInt32 aNumCols, nsStyleMolecule* aTableStyleMol,
PRInt32 &aTotalFixedWidth,

Просмотреть файл

@ -29,36 +29,70 @@ class CellData;
struct nsStyleMolecule;
struct InnerTableReflowState;
/**
/** nsTableFrame maps the inner portion of a table (everything except captions.)
* Used as a pseudo-frame within nsTableOuterFrame,
* it may also be used stand-alone as the top-level frame.
* The meaningful child frames of nsTableFrame map rowgroups.
*
* @author sclark
*
* TODO: make methods virtual so nsTableFrame can be used as a base class in the future.
*/
class nsTableFrame : public nsContainerFrame
{
public:
/** nsTableOuterFrame has intimate knowledge of the inner table frame */
friend class nsTableOuterFrame;
/** instantiate a new instance of nsTableFrame.
* @param aInstancePtrResult the new object is returned in this out-param
* @param aContent the table object to map
* @param aIndexInParent which child is the new frame?
* @param aParent the parent of the new frame
*
* @return NS_OK if the frame was properly allocated, otherwise an error code
*/
static nsresult NewFrame(nsIFrame** aInstancePtrResult,
nsIContent* aContent,
PRInt32 aIndexInParent,
nsIFrame* aParent);
/** @see nsIFrame::Paint */
virtual void Paint(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect);
/** inner tables are reflowed in two steps.
* <pre>
* if mFirstPassValid is false, this is our first time through since content was last changed
* set pass to 1
* do pass 1
* get min/max info for all cells in an infinite space
* do column balancing
* set mFirstPassValid to true
* do pass 2
* use column widths to ResizeReflow cells
* shrinkWrap Cells in each row to tallest, realigning contents within the cell
* </pre>
*
* @see ResizeReflowPass1
* @see ResizeReflowPass2
* @see BalanceColumnWidths
* @see nsIFrame::ResizeReflow
*/
virtual ReflowStatus ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize);
/** @see nsIFrame::IncrementalReflow */
virtual ReflowStatus IncrementalReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsReflowCommand& aReflowCommand);
/**
* @see nsContainerFrame
*/
/** @see nsContainerFrame::CreateContinuingFrame */
virtual nsIFrame* CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent);
@ -94,7 +128,7 @@ public:
*/
virtual nsCellLayoutData * GetCellLayoutData(nsTableCell *aCell);
/**
/** returns PR_TRUE if this table has proportional width
*/
PRBool IsProportionalWidth(nsStyleMolecule* aMol);
@ -104,16 +138,13 @@ public:
* DEBUG METHOD
*
*/
void ListColumnLayoutData(FILE* out = stdout, PRInt32 aIndent = 0) const;
/**
*/
/** return the width of the column at aColIndex */
PRInt32 GetColumnWidth(PRInt32 aColIndex);
/**
*/
/** set the width of the column at aColIndex to aWidth */
void SetColumnWidth(PRInt32 aColIndex, PRInt32 aWidth);
@ -135,17 +166,29 @@ public:
protected:
/** protected constructor.
* @see NewFrame
*/
nsTableFrame(nsIContent* aContent,
PRInt32 aIndexInParent,
nsIFrame* aParentFrame);
/** destructor, responsible for mColumnLayoutData and mColumnWidths */
virtual ~nsTableFrame();
/**
/** helper method to delete contents of mColumnLayoutData
* should be called with care (ie, only by destructor)
*/
virtual void DeleteColumnLayoutData();
/**
/** first pass of ResizeReflow.
* lays out all table content with aMaxSize(NS_UNCONSTRAINEDSIZE,NS_UNCONSTRAINEDSIZE) and
* a non-null aMaxElementSize so we get all the metrics we need to do column balancing.
* Pass 1 only needs to be executed once no matter how many times the table is resized,
* as long as content and style don't change. This is managed in the member variable mFirstPassIsValid.
* The layout information for each cell is cached in mColumLayoutData.
*
* @see ResizeReflow
*/
virtual nsIFrame::ReflowStatus ResizeReflowPass1(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
@ -153,9 +196,16 @@ protected:
nsSize* aMaxElementSize,
nsStyleMolecule* aTableStyle);
/**
* aMinCaptionWidth - the max of all the minimum caption widths. 0 if no captions.
* aMaxCaptionWidth - the max of all the desired caption widths. 0 if no captions.
/** second pass of ResizeReflow.
* lays out all table content with aMaxSize(computed_table_width, given_table_height)
* Pass 2 is executed every time the table needs to resize. An optimization is included
* so that if the table doesn't need to actually be resized, no work is done (see NeedsReflow).
*
* @param aMinCaptionWidth - the max of all the minimum caption widths. 0 if no captions.
* @param aMaxCaptionWidth - the max of all the desired caption widths. 0 if no captions.
*
* @see ResizeReflow
* @see NeedsReflow
*/
virtual nsIFrame::ReflowStatus ResizeReflowPass2(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
@ -177,27 +227,69 @@ protected:
nsSize* aMaxElementSize,
nsSize& aKidMaxElementSize);
/**
* Reflow the frames we've already created
*
* @param aPresContext presentation context to use
* @param aState current inline state
* @return true if we successfully reflowed all the mapped children and false
* otherwise, e.g. we pushed children to the next in flow
*/
PRBool ReflowMappedChildren(nsIPresContext* aPresContext,
InnerTableReflowState& aState,
nsSize* aMaxElementSize);
/**
* Try and pull-up frames from our next-in-flow
*
* @param aPresContext presentation context to use
* @param aState current inline state
* @return true if we successfully pulled-up all the children and false
* otherwise, e.g. child didn't fit
*/
PRBool PullUpChildren(nsIPresContext* aPresContext,
InnerTableReflowState& aState,
nsSize* aMaxElementSize);
/**
* Create new frames for content we haven't yet mapped
*
* @param aPresContext presentation context to use
* @param aState current inline state
* @return frComplete if all content has been mapped and frNotComplete
* if we should be continued
*/
ReflowStatus ReflowUnmappedChildren(nsIPresContext* aPresContext,
InnerTableReflowState& aState,
nsSize* aMaxElementSize);
/**
/** assign widths for each column, taking into account the table content, the effective style,
* the layout constraints, and the compatibility mode. Sets mColumnWidths as a side effect.
* @param aPresContext the presentation context
* @param aTableStyle the resolved style for the table
* @param aMaxSize the height and width constraints
* @param aMaxElementSize the min size of the largest indivisible object
*/
virtual void BalanceColumnWidths(nsIPresContext* aPresContext,
nsStyleMolecule* aTableStyle,
const nsSize& aMaxSize,
nsSize* aMaxElementSize);
/**
/** assign widths for each column that has fixed width.
* Computes the minimum and maximum table widths.
* Sets mColumnWidths as a side effect.
*
* @param aPresContext the presentation context
* @param aMaxWidth the maximum width of the table
* @param aNumCols the total number of columns in the table
* @param aTableStyle the resolved style for the table
* @param aTotalFixedWidth out param, the sum of the fixed width columns
* @param aMinTableWidth out param, the min possible table width
* @param aMaxTableWidth out param, the max table width
*
* @return PR_TRUE if all is well, PR_FALSE if there was an unrecoverable error
*
* TODO: should be renamed to "AssignKnownWidthInformation
*/
virtual PRBool AssignFixedColumnWidths(nsIPresContext* aPresContext,
PRInt32 aMaxWidth,
@ -206,8 +298,22 @@ protected:
PRInt32 & aTotalFixedWidth,
PRInt32 & aMinTableWidth,
PRInt32 & aMaxTableWidth);
/**
*/
/** assign widths for each column that has proportional width inside a table that
* has a fixed width.
* Sets mColumnWidths as a side effect.
*
* @param aPresContext the presentation context
* @param aTableStyle the resolved style for the table
* @param aAvailWidth the remaining amount of horizontal space available
* @param aMaxWidth the total amount of horizontal space available
* @param aMinTableWidth the min possible table width
* @param aMaxTableWidth the max table width
*
* @return PR_TRUE if all is well, PR_FALSE if there was an unrecoverable error
*
* TODO: rename this method to reflect that it is a Nav4 compatibility method
*/
virtual PRBool BalanceProportionalColumnsForSpecifiedWidthTable(nsIPresContext* aPresContext,
nsStyleMolecule* aTableStyleMol,
PRInt32 aAvailWidth,
@ -215,8 +321,21 @@ protected:
PRInt32 aMinTableWidth,
PRInt32 aMaxTableWidth);
/**
*/
/** assign widths for each column that has proportional width inside a table that
* has auto width (width set by the content and available space.)
* Sets mColumnWidths as a side effect.
*
* @param aPresContext the presentation context
* @param aTableStyle the resolved style for the table
* @param aAvailWidth the remaining amount of horizontal space available
* @param aMaxWidth the total amount of horizontal space available
* @param aMinTableWidth the min possible table width
* @param aMaxTableWidth the max table width
*
* @return PR_TRUE if all is well, PR_FALSE if there was an unrecoverable error
*
* TODO: rename this method to reflect that it is a Nav4 compatibility method
*/
virtual PRBool BalanceProportionalColumnsForAutoWidthTable(nsIPresContext* aPresContext,
nsStyleMolecule* aTableStyleMol,
PRInt32 aAvailWidth,
@ -224,12 +343,46 @@ protected:
PRInt32 aMinTableWidth,
PRInt32 aMaxTableWidth);
/** assign the minimum allowed width for each column that has proportional width.
* Typically called when the min table width doesn't fit in the available space.
* Sets mColumnWidths as a side effect.
*
* @param aPresContext the presentation context
*
* @return PR_TRUE if all is well, PR_FALSE if there was an unrecoverable error
*/
virtual PRBool SetColumnsToMinWidth(nsIPresContext* aPresContext);
/** assign the maximum allowed width for each column that has proportional width.
* Typically called when the desired max table width fits in the available space.
* Sets mColumnWidths as a side effect.
*
* @param aPresContext the presentation context
* @param aTableStyle the resolved style for the table
* @param aAvailWidth the remaining amount of horizontal space available
*
* @return PR_TRUE if all is well, PR_FALSE if there was an unrecoverable error
*/
virtual PRBool BalanceColumnsTableFits(nsIPresContext* aPresContext,
nsStyleMolecule* aTableStyleMol,
PRInt32 aAvailWidth);
/** assign widths for each column that has proportional width inside a table that
* has auto width (width set by the content and available space) according to the
* HTML 4 specification.
* Sets mColumnWidths as a side effect.
*
* @param aPresContext the presentation context
* @param aTableStyle the resolved style for the table
* @param aAvailWidth the remaining amount of horizontal space available
* @param aMaxWidth the total amount of horizontal space available
* @param aMinTableWidth the min possible table width
* @param aMaxTableWidth the max table width
*
* @return PR_TRUE if all is well, PR_FALSE if there was an unrecoverable error
*
* TODO: rename this method to reflect that it is a Nav4 compatibility method
*/
virtual PRBool BalanceColumnsHTML4Constrained(nsIPresContext* aPresContext,
nsStyleMolecule* aTableStyleMol,
PRInt32 aAvailWidth,
@ -237,8 +390,7 @@ protected:
PRInt32 aMinTableWidth,
PRInt32 aMaxTableWidth);
/**
*/
/** sets the width of the table according to the computed widths of each column. */
virtual void SetTableWidth(nsIPresContext* aPresContext,
nsStyleMolecule* aTableStyle);
@ -264,10 +416,13 @@ protected:
/** given the new parent size, do I really need to do a reflow? */
virtual PRBool NeedsReflow(const nsSize& aMaxSize);
/** what stage of reflow is currently in process? */
virtual PRInt32 GetReflowPass() const;
/** sets the reflow pass flag. use with caution! */
virtual void SetReflowPass(PRInt32 aReflowPass);
/** returns PR_TRUE if the cached pass 1 data is still valid */
virtual PRBool IsFirstPassValid() const;
private:

Просмотреть файл

@ -28,38 +28,75 @@ class nsTableCaptionFrame;
struct OuterTableReflowState;
/**
* nsTableOuterFrame
* main frame for an nsTable content object.
* main frame for an nsTable content object,
* the nsTableOuterFrame contains 0 or more nsTableCaptionFrames,
* and a single nsTableFrame psuedo-frame.
* and a single nsTableFrame psuedo-frame, often referred to as the "inner frame'.
* <P> Unlike other frames that handle continuing across breaks, nsTableOuterFrame
* has no notion of "unmapped" children. All children (captions and inner table)
* have frames created in Pass 1, so from the layout process' point of view, they
* are always mapped
*
* @author sclark
*/
class nsTableOuterFrame : public nsContainerFrame
{
public:
/** instantiate a new instance of nsTableFrame.
* @param aInstancePtrResult the new object is returned in this out-param
* @param aContent the table object to map
* @param aIndexInParent which child is the new frame?
* @param aParent the parent of the new frame
*
* @return NS_OK if the frame was properly allocated, otherwise an error code
*/
static nsresult NewFrame(nsIFrame** aInstancePtrResult,
nsIContent* aContent,
PRInt32 aIndexInParent,
nsIFrame* aParent);
/** @see nsIFrame::Paint */
virtual void Paint(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect);
/** outer tables are reflowed in two steps.
* Step 1:, we lay out all of the captions and the inner table with
* height and width set to NS_UNCONSTRAINEDSIZE.
* This gives us absolute minimum and maximum widths for each component.
* In the second step, we set all the captions and the inner table to
* the width of the widest component, given the table's style, width constraints
* and compatibility mode.<br>
* Step 2: With the widths now known, we reflow the captions and table.<br>
* NOTE: for breaking across pages, this method has to account for table content
* that is not laid out linearly vis a vis the frames.
* That is, content hierarchy and the frame hierarchy do not match.
*
* @see NeedsReflow
* @see ResizeReflowCaptionsPass1
* @see ResizeReflowTopCaptionsPass2
* @see ResizeReflowBottomCaptionsPass2
* @see PlaceChild
* @see ReflowMappedChildren
* @see PullUpChildren
* @see ReflowChild
* @see nsTableFrame::ResizeReflowPass1
* @see nsTableFrame::ResizeReflowPass2
* @see nsTableFrame::BalanceColumnWidths
* @see nsIFrame::ResizeReflow
*/
ReflowStatus ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize);
/** @see nsIFrame::IncrementalReflow */
ReflowStatus IncrementalReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsReflowCommand& aReflowCommand);
/**
* @see nsContainerFrame
*/
/** @see nsContainerFrame */
virtual nsIFrame* CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent);
/** destructor */
@ -67,14 +104,16 @@ public:
protected:
/** constructor */
/** protected constructor
* @see NewFrame
*/
nsTableOuterFrame(nsIContent* aContent,
PRInt32 aIndexInParent,
nsIFrame* aParentFrame);
/** return PR_TRUE if the table needs to be reflowed.
* the outer table needs to be reflowed if the table content has changed,
* or if the combination of table style attributes and max height/width have
* or if the table style attributes or parent max height/width have
* changed.
*/
virtual PRBool NeedsReflow(const nsSize& aMaxSize);
@ -131,10 +170,26 @@ protected:
nsSize* aMaxElementSize,
nsSize& aKidMaxElementSize);
/**
* Reflow the frames we've already created
*
* @param aPresContext presentation context to use
* @param aState current inline state
* @return true if we successfully reflowed all the mapped children and false
* otherwise, e.g. we pushed children to the next in flow
*/
PRBool ReflowMappedChildren(nsIPresContext* aPresContext,
OuterTableReflowState& aState,
nsSize* aMaxElementSize);
/**
* Try and pull-up frames from our next-in-flow
*
* @param aPresContext presentation context to use
* @param aState current inline state
* @return true if we successfully pulled-up all the children and false
* otherwise, e.g. child didn't fit
*/
PRBool PullUpChildren(nsIPresContext* aPresContext,
OuterTableReflowState& aState,
nsSize* aMaxElementSize);
@ -149,26 +204,20 @@ protected:
nsSize* aMaxElementSize,
OuterTableReflowState& aState);
/**
* Sets the last content offset based on the last child frame. If the last
* child is a pseudo frame then it sets mLastContentIsComplete to be the same
* as the last child's mLastContentIsComplete
*/
//virtual void SetLastContentOffset(const nsIFrame* aLastChild);
/**
* See nsContainerFrame::VerifyTree
/** overridden here to handle special caption-table relationship
* @see nsContainerFrame::VerifyTree
*/
virtual void VerifyTree() const;
/**
* See nsContainerFrame::PrepareContinuingFrame
/** overridden here to handle special caption-table relationship
* @see nsContainerFrame::PrepareContinuingFrame
*/
virtual void PrepareContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsTableOuterFrame* aContFrame);
/**
/** create the inner table frame (nsTableFrame)
* handles initial creation as well as creation of continuing frames
*/
virtual void CreateInnerTableFrame(nsIPresContext* aPresContext);

Просмотреть файл

@ -241,6 +241,7 @@ nsTableRowFrame::ResizeReflow(nsIPresContext* aPresContext,
prevKidFrame->SetNextSibling(kidFrame);
} else {
// Our first child (**blush**)
if (gsDebug1) printf ("row frame %p, setting first child to %p\n", this, kidFrame);
mFirstChild = kidFrame;
SetFirstContentOffset(kidFrame);
if (gsDebug1) printf("ROW: set first content offset to %d\n", GetFirstContentOffset()); //@@@
@ -276,6 +277,18 @@ nsTableRowFrame::ResizeReflow(nsIPresContext* aPresContext,
PostReflowCheck(result);
#endif
if (gsDebug1==PR_TRUE)
{
if (nsnull!=aMaxElementSize)
printf("nsTableRowFrame::RR returning: %s with aDesiredSize=%d,%d, aMES=%d,%d\n",
result==frComplete?"Complete":"Not Complete",
aDesiredSize.width, aDesiredSize.height,
aMaxElementSize->width, aMaxElementSize->height);
else
printf("nsTableRowFrame::RR returning: %s with aDesiredSize=%d,%d, aMES=NSNULL\n",
result==frComplete?"Complete":"Not Complete",
aDesiredSize.width, aDesiredSize.height);
}
return result;
}
@ -293,6 +306,7 @@ nsTableRowFrame::IncrementalReflow(nsIPresContext* aPresContext,
nsIFrame* nsTableRowFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent)
{
if (gsDebug1==PR_TRUE) printf("nsTableRowFrame::CreateContinuingFrame\n");
nsTableRowFrame* cf = new nsTableRowFrame(mContent, mIndexInParent, aParent);
PrepareContinuingFrame(aPresContext, aParent, cf);
return cf;

Просмотреть файл

@ -23,47 +23,79 @@
/**
* nsTableRowFrame
* data structure to maintain information about a single table row's geometry
* nsTableRowFrame is the frame that maps table rows
* (HTML tag TR). This class cannot be reused
* outside of an nsTableRowGroupFrame. It assumes that its parent is an nsTableRowGroupFrame,
* and its children are nsTableCellFrames.
*
* @see nsTableFrame
* @see nsTableRowGroupFrame
* @see nsTableCellFrame
*
* @author sclark
*/
/**
*/
class nsTableRowFrame : public nsContainerFrame
{
public:
/** instantiate a new instance of nsTableRowFrame.
* @param aInstancePtrResult the new object is returned in this out-param
* @param aContent the table object to map
* @param aIndexInParent which child is the new frame?
* @param aParent the parent of the new frame
*
* @return NS_OK if the frame was properly allocated, otherwise an error code
*/
static nsresult NewFrame(nsIFrame** aInstancePtrResult,
nsIContent* aContent,
PRInt32 aIndexInParent,
nsIFrame* aParent);
/** @see nsIFrame::Paint */
virtual void Paint(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect);
/** ask all children to paint themselves, without clipping (for cells with rowspan>1)
* @see nsIFrame::Paint
*/
virtual void PaintChildren(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect);
/** calls ResizeReflow for all of its child cells.
* Cells with rowspan=1 are all set to the same height and stacked horizontally.
* <P> Cells are not split unless absolutely necessary.
* <P> Cells are resized in nsTableFrame::BalanceColumnWidths
* and nsTableFrame::ShrinkWrapChildren
*
* @param aDesiredSize width set to width of the sum of the cells, height set to
* height of cells with rowspan=1.
*
* @see nsIFrame::ResizeReflow
* @see nsTableFrame::BalanceColumnWidths
* @see nsTableFrame::ShrinkWrapChildren
*/
ReflowStatus ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize);
/** @see nsIFrame::IncrementalReflow */
ReflowStatus IncrementalReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsReflowCommand& aReflowCommand);
/**
* @see nsContainerFrame
*/
/** @see nsContainerFrame::CreateContinuingFrame */
virtual nsIFrame* CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent);
/** set mTallestCell to 0 in anticipation of recalculating it */
void ResetMaxChildHeight();
/** set mTallestCell to max(mTallestCell, aChildHeight) */
void SetMaxChildHeight(PRInt32 aChildHeight);
/** returns the tallest child in this row (ignoring any cell with rowspans) */
@ -72,10 +104,14 @@ public:
protected:
/** protected constructor.
* @see NewFrame
*/
nsTableRowFrame(nsIContent* aContent,
PRInt32 aIndexInParent,
nsIFrame* aParentFrame);
/** destructor */
virtual ~nsTableRowFrame();
private:

Просмотреть файл

@ -318,6 +318,11 @@ PRBool nsTableRowGroupFrame::ReflowMappedChildren( nsIPresContext* aPresCon
// Update mLastContentIsComplete now that this kid fits
mLastContentIsComplete = PRBool(status == frComplete);
/* Row groups should not create continuing frames for rows
* unless they absolutely have to!
* check to see if this is absolutely necessary (with new params from troy)
* otherwise PushChildren and bail.
*/
// Special handling for incomplete children
if (frNotComplete == status) {
// XXX It's good to assume that we might still have room
@ -512,6 +517,11 @@ PRBool nsTableRowGroupFrame::PullUpChildren(nsIPresContext* aPresContext,
printf("\n");
#endif
/* Row groups should not create continuing frames for rows
* unless they absolutely have to!
* check to see if this is absolutely necessary (with new params from troy)
* otherwise PushChildren and bail, as above.
*/
// Is the child we just pulled up complete?
if (frNotComplete == status) {
// No the child isn't complete.
@ -906,6 +916,19 @@ nsTableRowGroupFrame::ResizeReflow( nsIPresContext* aPresContext,
PostReflowCheck(status);
#endif
if (gsDebug1==PR_TRUE)
{
if (nsnull!=aMaxElementSize)
printf("nsTableRowGroupFrame::RR returning: %s with aDesiredSize=%d,%d, aMES=%d,%d\n",
status==frComplete?"Complete":"Not Complete",
aDesiredSize.width, aDesiredSize.height,
aMaxElementSize->width, aMaxElementSize->height);
else
printf("nsTableRowGroupFrame::RR returning: %s with aDesiredSize=%d,%d, aMES=NSNULL\n",
status==frComplete?"Complete":"Not Complete",
aDesiredSize.width, aDesiredSize.height);
}
return status;
}

Просмотреть файл

@ -25,49 +25,78 @@ struct RowGroupReflowState;
struct nsStyleMolecule;
/**
* nsTableRowGroupFrame
* data structure to maintain information about a single table cell's frame
* nsTableRowGroupFrame is the frame that maps row groups
* (HTML tags THEAD, TFOOT, and TBODY). This class cannot be reused
* outside of an nsTableFrame. It assumes that its parent is an nsTableFrame, and
* its children are nsTableRowFrames.
*
* @see nsTableFrame
* @see nsTableRowFrame
*
* @author sclark
*/
class nsTableRowGroupFrame : public nsContainerFrame
{
public:
/** instantiate a new instance of nsTableRowGroupFrame.
* @param aInstancePtrResult the new object is returned in this out-param
* @param aContent the table object to map
* @param aIndexInParent which child is the new frame?
* @param aParent the parent of the new frame
*
* @return NS_OK if the frame was properly allocated, otherwise an error code
*/
static nsresult NewFrame(nsIFrame** aInstancePtrResult,
nsIContent* aContent,
PRInt32 aIndexInParent,
nsIFrame* aParent);
/** @see nsIFrame::Paint */
virtual void Paint(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect);
/** ask all children to paint themselves, without clipping (for cells with rowspan>1)
* @see nsIFrame::Paint
*/
virtual void PaintChildren(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect);
/** calls ResizeReflow for all of its child rows.
* Rows are all set to the same width and stacked vertically.
* <P> rows are not split unless absolutely necessary.
*
* @param aDesiredSize width set to width of rows, height set to
* sum of height of rows that fit in aMaxSize.height.
*
* @see nsIFrame::ResizeReflow
*/
ReflowStatus ResizeReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsSize* aMaxElementSize);
/** @see nsIFrame::IncrementalReflow */
ReflowStatus IncrementalReflow(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredSize,
const nsSize& aMaxSize,
nsReflowCommand& aReflowCommand);
/**
* @see nsContainerFrame
*/
/** @see nsContainerFrame::CreateContinuingFrame */
virtual nsIFrame* CreateContinuingFrame(nsIPresContext* aPresContext,
nsIFrame* aParent);
protected:
/** protected constructor.
* @see NewFrame
*/
nsTableRowGroupFrame(nsIContent* aContent,
PRInt32 aIndexInParent,
nsIFrame* aParentFrame);
/** protected destructor */
~nsTableRowGroupFrame();
nscoord GetTopMarginFor(nsIPresContext* aCX,
@ -82,14 +111,38 @@ protected:
nsSize* aMaxElementSize,
nsSize& aKidMaxElementSize);
/**
* Reflow the frames we've already created
*
* @param aPresContext presentation context to use
* @param aState current inline state
* @return true if we successfully reflowed all the mapped children and false
* otherwise, e.g. we pushed children to the next in flow
*/
PRBool ReflowMappedChildren(nsIPresContext* aPresContext,
RowGroupReflowState& aState,
nsSize* aMaxElementSize);
/**
* Try and pull-up frames from our next-in-flow
*
* @param aPresContext presentation context to use
* @param aState current inline state
* @return true if we successfully pulled-up all the children and false
* otherwise, e.g. child didn't fit
*/
PRBool PullUpChildren(nsIPresContext* aPresContext,
RowGroupReflowState& aState,
nsSize* aMaxElementSize);
/**
* Create new frames for content we haven't yet mapped
*
* @param aPresContext presentation context to use
* @param aState current inline state
* @return frComplete if all content has been mapped and frNotComplete
* if we should be continued
*/
ReflowStatus ReflowUnmappedChildren(nsIPresContext* aPresContext,
RowGroupReflowState& aState,
nsSize* aMaxElementSize);