add colframe documentation, fix a colframe renumbering problem, bug 238999 r/sr=bzbarsky

This commit is contained in:
bmlk%gmx.de 2004-05-03 18:31:34 +00:00
Родитель 26b1503f71
Коммит 743b37f228
8 изменённых файлов: 252 добавлений и 438 удалений

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

@ -96,7 +96,7 @@ void nsTableColGroupFrame::ResetColIndices(nsIFrame* aFirstColGroup,
}
NS_IMETHODIMP
nsresult
nsTableColGroupFrame::AddColsToTable(nsIPresContext& aPresContext,
PRInt32 aFirstColIndex,
PRBool aResetSubsequentColIndices,
@ -126,7 +126,10 @@ nsTableColGroupFrame::AddColsToTable(nsIPresContext& aPresContext,
}
kidFrame = kidFrame->GetNextSibling();
}
// We have already set the colindex for all the colframes in this
// colgroup that come after the first inserted colframe, but there could
// be other colgroups following this one and their colframes need
// correct colindices too.
if (aResetSubsequentColIndices && GetNextSibling()) {
ResetColIndices(GetNextSibling(), colIndex);
}
@ -134,53 +137,6 @@ nsTableColGroupFrame::AddColsToTable(nsIPresContext& aPresContext,
return rv;
}
// this is called when a col frame doesn't have an explicit col group parent.
nsTableColGroupFrame*
nsTableColGroupFrame::FindParentForAppendedCol(nsTableFrame* aTableFrame,
nsTableColType aColType)
{
nsVoidArray& cols = aTableFrame->GetColCache();
PRInt32 numCols = cols.Count();
if (numCols == 0) return nsnull; // no columns so no colgroups
nsIFrame* lastCol = (nsIFrame*)cols.ElementAt(numCols - 1);
NS_ASSERTION(lastCol,"null entry in column array");
nsIFrame* lastColGroup = lastCol->GetParent();
if (!lastColGroup) return nsnull; // shouldn't happen
nsTableColGroupFrame* relevantColGroup =
NS_STATIC_CAST(nsTableColGroupFrame *, lastColGroup);
nsTableColGroupType relevantColGroupType = relevantColGroup->GetColType();
if (eColGroupAnonymousCell == relevantColGroupType) {
if (eColAnonymousCell == aColType) {
return relevantColGroup;
}
else {
// find the next to last col group
for (PRInt32 colX = numCols - 2; colX >= 0; colX--) {
nsTableColFrame* colFrame = (nsTableColFrame*)cols.ElementAt(colX);
nsTableColGroupFrame* colGroupFrame =
NS_STATIC_CAST(nsTableColGroupFrame*, colFrame->GetParent());
nsTableColGroupType cgType = colGroupFrame->GetColType();
if (cgType != relevantColGroupType) {
relevantColGroup = colGroupFrame;
relevantColGroupType = cgType;
break;
}
else if (0 == colX) {
return nsnull;
}
}
}
}
if (eColGroupAnonymousCol == relevantColGroupType) {
if ((eColContent == aColType) || (eColAnonymousCol == aColType)) {
return relevantColGroup;
}
}
return nsnull;
}
PRBool
nsTableColGroupFrame::GetLastRealColGroup(nsTableFrame* aTableFrame,
@ -294,18 +250,25 @@ nsTableColGroupFrame::InsertColsReflow(nsIPresContext& aPresContext,
void
nsTableColGroupFrame::RemoveChild(nsIPresContext& aPresContext,
nsTableColFrame& aChild,
PRBool aResetColIndices)
PRBool aResetSubsequentColIndices)
{
PRInt32 colIndex = 0;
nsIFrame* nextChild = nsnull;
if (aResetColIndices) {
if (aResetSubsequentColIndices) {
colIndex = aChild.GetColIndex();
nextChild = aChild.GetNextSibling();
}
if (mFrames.DestroyFrame(&aPresContext, (nsIFrame*)&aChild)) {
mColCount--;
if (aResetColIndices) {
ResetColIndices(this, colIndex, nextChild);
if (aResetSubsequentColIndices) {
if (nextChild) { // reset inside this and all following colgroups
ResetColIndices(this, colIndex, nextChild);
}
else {
nsIFrame* nextGroup = GetNextSibling();
if (nextGroup) // reset next and all following colgroups
ResetColIndices(nextGroup, colIndex);
}
}
}
nsTableFrame* tableFrame;
@ -318,35 +281,6 @@ nsTableColGroupFrame::RemoveChild(nsIPresContext& aPresContext,
nsTableFrame::AppendDirtyReflowCommand(aPresContext.PresShell(), tableFrame);
}
// this removes children form the last col group (eColGroupAnonymousCell) in the
// table only,so there is no need to reset col indices for subsequent col groups.
void
nsTableColGroupFrame::RemoveChildrenAtEnd(nsIPresContext& aPresContext,
PRInt32 aNumChildrenToRemove)
{
PRInt32 numToRemove = aNumChildrenToRemove;
if (numToRemove > mColCount) {
NS_ASSERTION(PR_FALSE, "invalid arg to RemoveChildrenAtEnd");
numToRemove = mColCount;
}
PRInt32 offsetOfFirstRemoval = mColCount - numToRemove;
PRInt32 offsetX = 0;
nsIFrame* kidFrame = mFrames.FirstChild();
while(kidFrame) {
if (nsLayoutAtoms::tableColFrame == kidFrame->GetType()) {
offsetX++;
if (offsetX > offsetOfFirstRemoval) {
nsIFrame* byebye = kidFrame;
kidFrame = kidFrame->GetNextSibling();
mFrames.DestroyFrame(&aPresContext, byebye);
continue;
}
}
kidFrame = kidFrame->GetNextSibling();
}
}
NS_IMETHODIMP
nsTableColGroupFrame::RemoveFrame(nsIPresContext* aPresContext,
nsIPresShell& aPresShell,
@ -592,28 +526,6 @@ nsTableColFrame * nsTableColGroupFrame::GetNextColumn(nsIFrame *aChildFrame)
return result;
}
nsTableColFrame * nsTableColGroupFrame::GetColumnAt (PRInt32 aColIndex)
{
nsTableColFrame *result = nsnull;
PRInt32 count = 0;
nsIFrame *childFrame = mFrames.FirstChild();
while (nsnull!=childFrame) {
if (NS_STYLE_DISPLAY_TABLE_COLUMN ==
childFrame->GetStyleDisplay()->mDisplay) {
nsTableColFrame *col = (nsTableColFrame *)childFrame;
count++;
if (aColIndex<=count) {
result = col;
}
}
childFrame = childFrame->GetNextSibling();
}
return result;
}
PRInt32 nsTableColGroupFrame::GetSpan()
{
PRInt32 span = 1;
@ -635,26 +547,6 @@ PRInt32 nsTableColGroupFrame::GetSpan()
return span;
}
/** returns colcount because it is frequently used in the context of
* shuffling relative colgroup order, and it's convenient to not have to
* call GetColumnCount redundantly.
*/
PRInt32 nsTableColGroupFrame::SetStartColumnIndex (int aIndex)
{
PRInt32 result = mColCount;
if (aIndex != mStartColIndex) {
mStartColIndex = aIndex;
result = GetColCount();
}
return result;
}
void nsTableColGroupFrame::DeleteColFrame(nsIPresContext* aPresContext, nsTableColFrame* aColFrame)
{
mFrames.DestroyFrame(aPresContext, aColFrame);
}
void nsTableColGroupFrame::SetContinuousBCBorderWidth(PRUint8 aForSide,
BCPixelSize aPixelValue)
{

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

@ -70,26 +70,51 @@ public:
friend nsresult
NS_NewTableColGroupFrame(nsIPresShell* aPresShell, nsIFrame** aResult);
/** sets defaults for the colgroup.
* @see nsIFrame::Init
*/
NS_IMETHOD Init(nsIPresContext* aPresContext,
nsIContent* aContent,
nsIFrame* aParent,
nsStyleContext* aContext,
nsIFrame* aPrevInFlow);
/** Initialize the colgroup frame with a set of children.
* @see nsIFrame::SetInitialChildList
*/
NS_IMETHOD SetInitialChildList(nsIPresContext* aPresContext,
nsIAtom* aListName,
nsIFrame* aChildList);
/** A colgroup can be caused by three things:
* 1) An element with table-column-group display
* 2) An element with a table-column display without a
* table-column-group parent
* 3) Cells that are not in a column (and hence get an anonymous
* column and colgroup).
* @return colgroup type
*/
nsTableColGroupType GetColType() const;
/** Set the colgroup type based on the creation cause
* @param aType - the reason why this colgroup is needed
*/
void SetColType(nsTableColGroupType aType);
/** Real in this context are colgroups that come from an element
* with table-column-group display or wrap around columns that
* come from an element with table-column display. Colgroups
* that are the result of wrapping cells in an anonymous
* column and colgroup are not considered real here.
* @param aTableFrame - the table parent of the colgroups
* @param aLastColgroup - the last real colgroup
* @return is false if there is a non real colgroup at the end
*/
static PRBool GetLastRealColGroup(nsTableFrame* aTableFrame,
nsIFrame** aLastColGroup);
static nsTableColGroupFrame* FindParentForAppendedCol(nsTableFrame* aTableFrame,
nsTableColType aColType);
/** @see nsIFrame::AppendFrames, InsertFrames, RemoveFrame
*/
NS_IMETHOD AppendFrames(nsIPresContext* aPresContext,
nsIPresShell& aPresShell,
nsIAtom* aListName,
@ -104,13 +129,21 @@ public:
nsIAtom* aListName,
nsIFrame* aOldFrame);
void RemoveChild(nsIPresContext& aPresContext,
nsTableColFrame& aLastChild,
PRBool aResetColIndices);
void RemoveChildrenAtEnd(nsIPresContext& aPresContext,
PRInt32 aNumChildrenToRemove);
/** remove the column aChild from the column group, if requested renumber
* the subsequent columns in this column group and all following column
* groups. see also ResetColIndices for this
* @param aPresContext - the presentation context
* @param aChild - the column frame that needs to be removed
* @param aResetSubsequentColIndices - if true the columns that follow
* after aChild will be reenumerated
*/
void RemoveChild(nsIPresContext& aPresContext,
nsTableColFrame& aChild,
PRBool aResetSubsequentColIndices);
/** @see nsIFrame::Paint
* all the table painting is done in nsTablePainter.cpp
*/
NS_IMETHOD Paint(nsIPresContext* aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
@ -120,6 +153,8 @@ public:
// column groups don't paint their own background -- the cells do
virtual PRBool CanPaintBackground() { return PR_FALSE; }
/** @see nsIFrame::GetFrameForPoint
*/
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
@ -142,12 +177,28 @@ public:
* @see nsLayoutAtoms::tableColGroupFrame
*/
virtual nsIAtom* GetType() const;
NS_IMETHOD AddColsToTable(nsIPresContext& aPresContext,
PRInt32 aFirstColIndex,
PRBool aResetSubsequentColIndices,
nsIFrame* aFirstFrame,
nsIFrame* aLastFrame = nsnull);
/** Add column frames to the table storages: colframe cache and cellmap
* this doesn't change the mFrames of the colgroup frame.
* @param aPresContext - the presentation context
* @param aFirstColIndex - the index at which aFirstFrame should be inserted
* into the colframe cache.
* @param aResetSubsequentColIndices - the indices of the col frames
* after the insertion might need
* an update
* @param aFirstFrame - first frame that needs to be added to the table,
* the frame should have a correctly set sibling
* @param aLastFrame - last frame that needs to be added. It can be either
* null or should be in the sibling chain of
* aFirstFrame
* @result - if there is no table frame or the table frame is not
* the first in flow it will return an error
*/
nsresult AddColsToTable(nsIPresContext& aPresContext,
PRInt32 aFirstColIndex,
PRBool aResetSubsequentColIndices,
nsIFrame* aFirstFrame,
nsIFrame* aLastFrame = nsnull);
#ifdef DEBUG
NS_IMETHOD GetFrameName(nsAString& aResult) const;
@ -159,27 +210,38 @@ public:
*/
virtual PRInt32 GetColCount() const;
virtual nsTableColFrame * GetFirstColumn();
virtual nsTableColFrame * GetNextColumn(nsIFrame *aChildFrame);
virtual nsTableColFrame * GetColumnAt(PRInt32 aColIndex);
virtual PRInt32 GetStartColumnIndex();
/** sets mStartColIndex to aIndex.
* @return the col count
* has the side effect of setting all child COL indexes
/** first column on the child list */
nsTableColFrame * GetFirstColumn();
/** next sibling to aChildFrame that is a column frame, first column frame
* in the column group if aChildFrame is null
*/
virtual PRInt32 SetStartColumnIndex(PRInt32 aIndex);
nsTableColFrame * GetNextColumn(nsIFrame *aChildFrame);
/** @return - the position of the first column in this colgroup in the table
* colframe cache.
*/
PRInt32 GetStartColumnIndex();
/** set the position of the first column in this colgroup in the table
* colframe cache.
*/
void SetStartColumnIndex(PRInt32 aIndex);
/** helper method to get the span attribute for this colgroup */
PRInt32 GetSpan();
void DeleteColFrame(nsIPresContext* aPresContext, nsTableColFrame* aColFrame);
/** provide access to the mFrames list
*/
nsFrameList& GetChildList();
/** set the column index for all frames starting at aStartColFrame, it
* will also reset the column indices in all subsequent colgroups
* @param aFirstColGroup - start the reset operation inside this colgroup
* @param aFirstColIndex - first column that is reset should get this index
* @param aStartColFrame - if specified the reset starts with this column
* inside the colgroup; if not specified, the reset
* starts with the first column
*/
static void ResetColIndices(nsIFrame* aFirstColGroup,
PRInt32 aFirstColIndex,
nsIFrame* aStartColFrame = nsnull);
@ -253,6 +315,11 @@ inline PRInt32 nsTableColGroupFrame::GetStartColumnIndex()
return mStartColIndex;
}
inline void nsTableColGroupFrame::SetStartColumnIndex (PRInt32 aIndex)
{
mStartColIndex = aIndex;
}
inline PRInt32 nsTableColGroupFrame::GetColCount() const
{
return mColCount;

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

@ -491,18 +491,6 @@ void nsTableFrame::AttributeChangedFor(nsIPresContext* aPresContext,
/* ****** CellMap methods ******* */
/* counts columns in column groups */
PRInt32 nsTableFrame::GetSpecifiedColumnCount ()
{
PRInt32 colCount = 0;
nsIFrame * childFrame = mColGroups.FirstChild();
while (nsnull!=childFrame) {
colCount += ((nsTableColGroupFrame *)childFrame)->GetColCount();
childFrame = childFrame->GetNextSibling();
}
return colCount;
}
PRInt32 nsTableFrame::GetRowCount () const
{
PRInt32 rowCount = 0;
@ -553,7 +541,8 @@ PRInt32 nsTableFrame::GetIndexOfLastRealCol()
return -1;
}
nsTableColFrame* nsTableFrame::GetColFrame(PRInt32 aColIndex)
nsTableColFrame*
nsTableFrame::GetColFrame(PRInt32 aColIndex) const
{
NS_ASSERTION(!mPrevInFlow, "GetColFrame called on next in flow");
PRInt32 numCols = mColFrames.Count();
@ -701,7 +690,7 @@ void nsTableFrame::InsertColGroups(nsIPresContext& aPresContext,
}
if (firstColGroupToReset) {
nsTableColGroupFrame::ResetColIndices(firstColGroupToReset, aStartColIndex);
nsTableColGroupFrame::ResetColIndices(firstColGroupToReset, colIndex);
}
}
@ -2468,35 +2457,6 @@ NS_METHOD nsTableFrame::AdjustForCollapsingCols(nsIPresContext* aPresContext,
return NS_OK;
}
// Sets the starting column index for aColGroupFrame and the siblings frames that
// follow
void
nsTableFrame::SetStartingColumnIndexFor(nsTableColGroupFrame* aColGroupFrame,
PRInt32 aIndex)
{
while (aColGroupFrame) {
aIndex += aColGroupFrame->SetStartColumnIndex(aIndex);
aColGroupFrame =
NS_STATIC_CAST(nsTableColGroupFrame*, aColGroupFrame->GetNextSibling());
}
}
// Calculate the starting column index to use for the specified col group frame
PRInt32
nsTableFrame::CalculateStartingColumnIndexFor(nsTableColGroupFrame* aColGroupFrame)
{
PRInt32 index = 0;
for (nsTableColGroupFrame* colGroupFrame = (nsTableColGroupFrame*)mColGroups.FirstChild();
colGroupFrame && (colGroupFrame != aColGroupFrame);
colGroupFrame =
NS_STATIC_CAST(nsTableColGroupFrame*, colGroupFrame->GetNextSibling()))
{
index += colGroupFrame->GetColCount();
}
return index;
}
NS_IMETHODIMP
nsTableFrame::AppendFrames(nsIPresContext* aPresContext,
nsIPresShell& aPresShell,
@ -2617,8 +2577,6 @@ nsTableFrame::RemoveFrame(nsIPresContext* aPresContext,
nsTableColGroupFrame* colGroup = (nsTableColGroupFrame*)aOldFrame;
PRInt32 firstColIndex = colGroup->GetStartColumnIndex();
PRInt32 lastColIndex = firstColIndex + colGroup->GetColCount() - 1;
// remove the col frames, the colGroup frame and reset col indices
colGroup->RemoveChildrenAtEnd(*aPresContext, colGroup->GetColCount());
mColGroups.DestroyFrame(aPresContext, aOldFrame);
nsTableColGroupFrame::ResetColIndices(nextColGroupFrame, firstColIndex);
// remove the cols from the table

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

@ -460,9 +460,18 @@ public:
*/
PRInt32 GetEffectiveCOLSAttribute();
/** return the column frame associated with aColIndex */
/** return the column frame associated with aColIndex
* returns nsnull if the col frame has not yet been allocated, or if
* aColIndex is out of range
*/
nsTableColFrame* GetColFrame(PRInt32 aColIndex) const;
/** Insert a col frame reference into the colframe cache and adapt the cellmap
* @param aPresContext - the presentation context
* @param aColFrame - the column frame
* @param aColIndex - index where the column should be inserted into the
* colframe cache
*/
void InsertCol(nsIPresContext& aPresContext,
nsTableColFrame& aColFrame,
PRInt32 aColIndex);
@ -584,14 +593,6 @@ protected:
virtual PRBool ParentDisablesSelection() const; //override default behavior
// Sets the starting column index for aColGroupFrame and the siblings frames that
// follow
void SetStartingColumnIndexFor(nsTableColGroupFrame* aColGroupFrame,
PRInt32 aIndex);
// Calculate the starting column index to use for the specified col group frame
PRInt32 CalculateStartingColumnIndexFor(nsTableColGroupFrame* aColGroupFrame);
public:
/** first pass of ResizeReflow.
* lays out all table content with aMaxSize(NS_UNCONSTRAINEDSIZE,NS_UNCONSTRAINEDSIZE) and
@ -830,13 +831,6 @@ protected:
void SetColumnDimensions(nscoord aHeight,
const nsMargin& aReflowState);
/** 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 PRInt32 GetSpecifiedColumnCount ();
PRInt32 CollectRows(nsIFrame* aFrame,
nsVoidArray& aCollection);
@ -855,10 +849,6 @@ public: /* ----- Cell Map public methods ----- */
virtual PRInt32 GetEffectiveColCount() const;
virtual PRInt32 GetColCount() const;
/** return the column frame at colIndex.
* returns nsnull if the col frame has not yet been allocated, or if aColIndex is out of range
*/
nsTableColFrame * GetColFrame(PRInt32 aColIndex);
// return the last col index which isn't of type eColAnonymousCell
PRInt32 GetIndexOfLastRealCol();

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

@ -96,7 +96,7 @@ void nsTableColGroupFrame::ResetColIndices(nsIFrame* aFirstColGroup,
}
NS_IMETHODIMP
nsresult
nsTableColGroupFrame::AddColsToTable(nsIPresContext& aPresContext,
PRInt32 aFirstColIndex,
PRBool aResetSubsequentColIndices,
@ -126,7 +126,10 @@ nsTableColGroupFrame::AddColsToTable(nsIPresContext& aPresContext,
}
kidFrame = kidFrame->GetNextSibling();
}
// We have already set the colindex for all the colframes in this
// colgroup that come after the first inserted colframe, but there could
// be other colgroups following this one and their colframes need
// correct colindices too.
if (aResetSubsequentColIndices && GetNextSibling()) {
ResetColIndices(GetNextSibling(), colIndex);
}
@ -134,53 +137,6 @@ nsTableColGroupFrame::AddColsToTable(nsIPresContext& aPresContext,
return rv;
}
// this is called when a col frame doesn't have an explicit col group parent.
nsTableColGroupFrame*
nsTableColGroupFrame::FindParentForAppendedCol(nsTableFrame* aTableFrame,
nsTableColType aColType)
{
nsVoidArray& cols = aTableFrame->GetColCache();
PRInt32 numCols = cols.Count();
if (numCols == 0) return nsnull; // no columns so no colgroups
nsIFrame* lastCol = (nsIFrame*)cols.ElementAt(numCols - 1);
NS_ASSERTION(lastCol,"null entry in column array");
nsIFrame* lastColGroup = lastCol->GetParent();
if (!lastColGroup) return nsnull; // shouldn't happen
nsTableColGroupFrame* relevantColGroup =
NS_STATIC_CAST(nsTableColGroupFrame *, lastColGroup);
nsTableColGroupType relevantColGroupType = relevantColGroup->GetColType();
if (eColGroupAnonymousCell == relevantColGroupType) {
if (eColAnonymousCell == aColType) {
return relevantColGroup;
}
else {
// find the next to last col group
for (PRInt32 colX = numCols - 2; colX >= 0; colX--) {
nsTableColFrame* colFrame = (nsTableColFrame*)cols.ElementAt(colX);
nsTableColGroupFrame* colGroupFrame =
NS_STATIC_CAST(nsTableColGroupFrame*, colFrame->GetParent());
nsTableColGroupType cgType = colGroupFrame->GetColType();
if (cgType != relevantColGroupType) {
relevantColGroup = colGroupFrame;
relevantColGroupType = cgType;
break;
}
else if (0 == colX) {
return nsnull;
}
}
}
}
if (eColGroupAnonymousCol == relevantColGroupType) {
if ((eColContent == aColType) || (eColAnonymousCol == aColType)) {
return relevantColGroup;
}
}
return nsnull;
}
PRBool
nsTableColGroupFrame::GetLastRealColGroup(nsTableFrame* aTableFrame,
@ -294,18 +250,25 @@ nsTableColGroupFrame::InsertColsReflow(nsIPresContext& aPresContext,
void
nsTableColGroupFrame::RemoveChild(nsIPresContext& aPresContext,
nsTableColFrame& aChild,
PRBool aResetColIndices)
PRBool aResetSubsequentColIndices)
{
PRInt32 colIndex = 0;
nsIFrame* nextChild = nsnull;
if (aResetColIndices) {
if (aResetSubsequentColIndices) {
colIndex = aChild.GetColIndex();
nextChild = aChild.GetNextSibling();
}
if (mFrames.DestroyFrame(&aPresContext, (nsIFrame*)&aChild)) {
mColCount--;
if (aResetColIndices) {
ResetColIndices(this, colIndex, nextChild);
if (aResetSubsequentColIndices) {
if (nextChild) { // reset inside this and all following colgroups
ResetColIndices(this, colIndex, nextChild);
}
else {
nsIFrame* nextGroup = GetNextSibling();
if (nextGroup) // reset next and all following colgroups
ResetColIndices(nextGroup, colIndex);
}
}
}
nsTableFrame* tableFrame;
@ -318,35 +281,6 @@ nsTableColGroupFrame::RemoveChild(nsIPresContext& aPresContext,
nsTableFrame::AppendDirtyReflowCommand(aPresContext.PresShell(), tableFrame);
}
// this removes children form the last col group (eColGroupAnonymousCell) in the
// table only,so there is no need to reset col indices for subsequent col groups.
void
nsTableColGroupFrame::RemoveChildrenAtEnd(nsIPresContext& aPresContext,
PRInt32 aNumChildrenToRemove)
{
PRInt32 numToRemove = aNumChildrenToRemove;
if (numToRemove > mColCount) {
NS_ASSERTION(PR_FALSE, "invalid arg to RemoveChildrenAtEnd");
numToRemove = mColCount;
}
PRInt32 offsetOfFirstRemoval = mColCount - numToRemove;
PRInt32 offsetX = 0;
nsIFrame* kidFrame = mFrames.FirstChild();
while(kidFrame) {
if (nsLayoutAtoms::tableColFrame == kidFrame->GetType()) {
offsetX++;
if (offsetX > offsetOfFirstRemoval) {
nsIFrame* byebye = kidFrame;
kidFrame = kidFrame->GetNextSibling();
mFrames.DestroyFrame(&aPresContext, byebye);
continue;
}
}
kidFrame = kidFrame->GetNextSibling();
}
}
NS_IMETHODIMP
nsTableColGroupFrame::RemoveFrame(nsIPresContext* aPresContext,
nsIPresShell& aPresShell,
@ -592,28 +526,6 @@ nsTableColFrame * nsTableColGroupFrame::GetNextColumn(nsIFrame *aChildFrame)
return result;
}
nsTableColFrame * nsTableColGroupFrame::GetColumnAt (PRInt32 aColIndex)
{
nsTableColFrame *result = nsnull;
PRInt32 count = 0;
nsIFrame *childFrame = mFrames.FirstChild();
while (nsnull!=childFrame) {
if (NS_STYLE_DISPLAY_TABLE_COLUMN ==
childFrame->GetStyleDisplay()->mDisplay) {
nsTableColFrame *col = (nsTableColFrame *)childFrame;
count++;
if (aColIndex<=count) {
result = col;
}
}
childFrame = childFrame->GetNextSibling();
}
return result;
}
PRInt32 nsTableColGroupFrame::GetSpan()
{
PRInt32 span = 1;
@ -635,26 +547,6 @@ PRInt32 nsTableColGroupFrame::GetSpan()
return span;
}
/** returns colcount because it is frequently used in the context of
* shuffling relative colgroup order, and it's convenient to not have to
* call GetColumnCount redundantly.
*/
PRInt32 nsTableColGroupFrame::SetStartColumnIndex (int aIndex)
{
PRInt32 result = mColCount;
if (aIndex != mStartColIndex) {
mStartColIndex = aIndex;
result = GetColCount();
}
return result;
}
void nsTableColGroupFrame::DeleteColFrame(nsIPresContext* aPresContext, nsTableColFrame* aColFrame)
{
mFrames.DestroyFrame(aPresContext, aColFrame);
}
void nsTableColGroupFrame::SetContinuousBCBorderWidth(PRUint8 aForSide,
BCPixelSize aPixelValue)
{

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

@ -70,26 +70,51 @@ public:
friend nsresult
NS_NewTableColGroupFrame(nsIPresShell* aPresShell, nsIFrame** aResult);
/** sets defaults for the colgroup.
* @see nsIFrame::Init
*/
NS_IMETHOD Init(nsIPresContext* aPresContext,
nsIContent* aContent,
nsIFrame* aParent,
nsStyleContext* aContext,
nsIFrame* aPrevInFlow);
/** Initialize the colgroup frame with a set of children.
* @see nsIFrame::SetInitialChildList
*/
NS_IMETHOD SetInitialChildList(nsIPresContext* aPresContext,
nsIAtom* aListName,
nsIFrame* aChildList);
/** A colgroup can be caused by three things:
* 1) An element with table-column-group display
* 2) An element with a table-column display without a
* table-column-group parent
* 3) Cells that are not in a column (and hence get an anonymous
* column and colgroup).
* @return colgroup type
*/
nsTableColGroupType GetColType() const;
/** Set the colgroup type based on the creation cause
* @param aType - the reason why this colgroup is needed
*/
void SetColType(nsTableColGroupType aType);
/** Real in this context are colgroups that come from an element
* with table-column-group display or wrap around columns that
* come from an element with table-column display. Colgroups
* that are the result of wrapping cells in an anonymous
* column and colgroup are not considered real here.
* @param aTableFrame - the table parent of the colgroups
* @param aLastColgroup - the last real colgroup
* @return is false if there is a non real colgroup at the end
*/
static PRBool GetLastRealColGroup(nsTableFrame* aTableFrame,
nsIFrame** aLastColGroup);
static nsTableColGroupFrame* FindParentForAppendedCol(nsTableFrame* aTableFrame,
nsTableColType aColType);
/** @see nsIFrame::AppendFrames, InsertFrames, RemoveFrame
*/
NS_IMETHOD AppendFrames(nsIPresContext* aPresContext,
nsIPresShell& aPresShell,
nsIAtom* aListName,
@ -104,13 +129,21 @@ public:
nsIAtom* aListName,
nsIFrame* aOldFrame);
void RemoveChild(nsIPresContext& aPresContext,
nsTableColFrame& aLastChild,
PRBool aResetColIndices);
void RemoveChildrenAtEnd(nsIPresContext& aPresContext,
PRInt32 aNumChildrenToRemove);
/** remove the column aChild from the column group, if requested renumber
* the subsequent columns in this column group and all following column
* groups. see also ResetColIndices for this
* @param aPresContext - the presentation context
* @param aChild - the column frame that needs to be removed
* @param aResetSubsequentColIndices - if true the columns that follow
* after aChild will be reenumerated
*/
void RemoveChild(nsIPresContext& aPresContext,
nsTableColFrame& aChild,
PRBool aResetSubsequentColIndices);
/** @see nsIFrame::Paint
* all the table painting is done in nsTablePainter.cpp
*/
NS_IMETHOD Paint(nsIPresContext* aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
@ -120,6 +153,8 @@ public:
// column groups don't paint their own background -- the cells do
virtual PRBool CanPaintBackground() { return PR_FALSE; }
/** @see nsIFrame::GetFrameForPoint
*/
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsFramePaintLayer aWhichLayer,
@ -142,12 +177,28 @@ public:
* @see nsLayoutAtoms::tableColGroupFrame
*/
virtual nsIAtom* GetType() const;
NS_IMETHOD AddColsToTable(nsIPresContext& aPresContext,
PRInt32 aFirstColIndex,
PRBool aResetSubsequentColIndices,
nsIFrame* aFirstFrame,
nsIFrame* aLastFrame = nsnull);
/** Add column frames to the table storages: colframe cache and cellmap
* this doesn't change the mFrames of the colgroup frame.
* @param aPresContext - the presentation context
* @param aFirstColIndex - the index at which aFirstFrame should be inserted
* into the colframe cache.
* @param aResetSubsequentColIndices - the indices of the col frames
* after the insertion might need
* an update
* @param aFirstFrame - first frame that needs to be added to the table,
* the frame should have a correctly set sibling
* @param aLastFrame - last frame that needs to be added. It can be either
* null or should be in the sibling chain of
* aFirstFrame
* @result - if there is no table frame or the table frame is not
* the first in flow it will return an error
*/
nsresult AddColsToTable(nsIPresContext& aPresContext,
PRInt32 aFirstColIndex,
PRBool aResetSubsequentColIndices,
nsIFrame* aFirstFrame,
nsIFrame* aLastFrame = nsnull);
#ifdef DEBUG
NS_IMETHOD GetFrameName(nsAString& aResult) const;
@ -159,27 +210,38 @@ public:
*/
virtual PRInt32 GetColCount() const;
virtual nsTableColFrame * GetFirstColumn();
virtual nsTableColFrame * GetNextColumn(nsIFrame *aChildFrame);
virtual nsTableColFrame * GetColumnAt(PRInt32 aColIndex);
virtual PRInt32 GetStartColumnIndex();
/** sets mStartColIndex to aIndex.
* @return the col count
* has the side effect of setting all child COL indexes
/** first column on the child list */
nsTableColFrame * GetFirstColumn();
/** next sibling to aChildFrame that is a column frame, first column frame
* in the column group if aChildFrame is null
*/
virtual PRInt32 SetStartColumnIndex(PRInt32 aIndex);
nsTableColFrame * GetNextColumn(nsIFrame *aChildFrame);
/** @return - the position of the first column in this colgroup in the table
* colframe cache.
*/
PRInt32 GetStartColumnIndex();
/** set the position of the first column in this colgroup in the table
* colframe cache.
*/
void SetStartColumnIndex(PRInt32 aIndex);
/** helper method to get the span attribute for this colgroup */
PRInt32 GetSpan();
void DeleteColFrame(nsIPresContext* aPresContext, nsTableColFrame* aColFrame);
/** provide access to the mFrames list
*/
nsFrameList& GetChildList();
/** set the column index for all frames starting at aStartColFrame, it
* will also reset the column indices in all subsequent colgroups
* @param aFirstColGroup - start the reset operation inside this colgroup
* @param aFirstColIndex - first column that is reset should get this index
* @param aStartColFrame - if specified the reset starts with this column
* inside the colgroup; if not specified, the reset
* starts with the first column
*/
static void ResetColIndices(nsIFrame* aFirstColGroup,
PRInt32 aFirstColIndex,
nsIFrame* aStartColFrame = nsnull);
@ -253,6 +315,11 @@ inline PRInt32 nsTableColGroupFrame::GetStartColumnIndex()
return mStartColIndex;
}
inline void nsTableColGroupFrame::SetStartColumnIndex (PRInt32 aIndex)
{
mStartColIndex = aIndex;
}
inline PRInt32 nsTableColGroupFrame::GetColCount() const
{
return mColCount;

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

@ -491,18 +491,6 @@ void nsTableFrame::AttributeChangedFor(nsIPresContext* aPresContext,
/* ****** CellMap methods ******* */
/* counts columns in column groups */
PRInt32 nsTableFrame::GetSpecifiedColumnCount ()
{
PRInt32 colCount = 0;
nsIFrame * childFrame = mColGroups.FirstChild();
while (nsnull!=childFrame) {
colCount += ((nsTableColGroupFrame *)childFrame)->GetColCount();
childFrame = childFrame->GetNextSibling();
}
return colCount;
}
PRInt32 nsTableFrame::GetRowCount () const
{
PRInt32 rowCount = 0;
@ -553,7 +541,8 @@ PRInt32 nsTableFrame::GetIndexOfLastRealCol()
return -1;
}
nsTableColFrame* nsTableFrame::GetColFrame(PRInt32 aColIndex)
nsTableColFrame*
nsTableFrame::GetColFrame(PRInt32 aColIndex) const
{
NS_ASSERTION(!mPrevInFlow, "GetColFrame called on next in flow");
PRInt32 numCols = mColFrames.Count();
@ -701,7 +690,7 @@ void nsTableFrame::InsertColGroups(nsIPresContext& aPresContext,
}
if (firstColGroupToReset) {
nsTableColGroupFrame::ResetColIndices(firstColGroupToReset, aStartColIndex);
nsTableColGroupFrame::ResetColIndices(firstColGroupToReset, colIndex);
}
}
@ -2468,35 +2457,6 @@ NS_METHOD nsTableFrame::AdjustForCollapsingCols(nsIPresContext* aPresContext,
return NS_OK;
}
// Sets the starting column index for aColGroupFrame and the siblings frames that
// follow
void
nsTableFrame::SetStartingColumnIndexFor(nsTableColGroupFrame* aColGroupFrame,
PRInt32 aIndex)
{
while (aColGroupFrame) {
aIndex += aColGroupFrame->SetStartColumnIndex(aIndex);
aColGroupFrame =
NS_STATIC_CAST(nsTableColGroupFrame*, aColGroupFrame->GetNextSibling());
}
}
// Calculate the starting column index to use for the specified col group frame
PRInt32
nsTableFrame::CalculateStartingColumnIndexFor(nsTableColGroupFrame* aColGroupFrame)
{
PRInt32 index = 0;
for (nsTableColGroupFrame* colGroupFrame = (nsTableColGroupFrame*)mColGroups.FirstChild();
colGroupFrame && (colGroupFrame != aColGroupFrame);
colGroupFrame =
NS_STATIC_CAST(nsTableColGroupFrame*, colGroupFrame->GetNextSibling()))
{
index += colGroupFrame->GetColCount();
}
return index;
}
NS_IMETHODIMP
nsTableFrame::AppendFrames(nsIPresContext* aPresContext,
nsIPresShell& aPresShell,
@ -2617,8 +2577,6 @@ nsTableFrame::RemoveFrame(nsIPresContext* aPresContext,
nsTableColGroupFrame* colGroup = (nsTableColGroupFrame*)aOldFrame;
PRInt32 firstColIndex = colGroup->GetStartColumnIndex();
PRInt32 lastColIndex = firstColIndex + colGroup->GetColCount() - 1;
// remove the col frames, the colGroup frame and reset col indices
colGroup->RemoveChildrenAtEnd(*aPresContext, colGroup->GetColCount());
mColGroups.DestroyFrame(aPresContext, aOldFrame);
nsTableColGroupFrame::ResetColIndices(nextColGroupFrame, firstColIndex);
// remove the cols from the table

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

@ -460,9 +460,18 @@ public:
*/
PRInt32 GetEffectiveCOLSAttribute();
/** return the column frame associated with aColIndex */
/** return the column frame associated with aColIndex
* returns nsnull if the col frame has not yet been allocated, or if
* aColIndex is out of range
*/
nsTableColFrame* GetColFrame(PRInt32 aColIndex) const;
/** Insert a col frame reference into the colframe cache and adapt the cellmap
* @param aPresContext - the presentation context
* @param aColFrame - the column frame
* @param aColIndex - index where the column should be inserted into the
* colframe cache
*/
void InsertCol(nsIPresContext& aPresContext,
nsTableColFrame& aColFrame,
PRInt32 aColIndex);
@ -584,14 +593,6 @@ protected:
virtual PRBool ParentDisablesSelection() const; //override default behavior
// Sets the starting column index for aColGroupFrame and the siblings frames that
// follow
void SetStartingColumnIndexFor(nsTableColGroupFrame* aColGroupFrame,
PRInt32 aIndex);
// Calculate the starting column index to use for the specified col group frame
PRInt32 CalculateStartingColumnIndexFor(nsTableColGroupFrame* aColGroupFrame);
public:
/** first pass of ResizeReflow.
* lays out all table content with aMaxSize(NS_UNCONSTRAINEDSIZE,NS_UNCONSTRAINEDSIZE) and
@ -830,13 +831,6 @@ protected:
void SetColumnDimensions(nscoord aHeight,
const nsMargin& aReflowState);
/** 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 PRInt32 GetSpecifiedColumnCount ();
PRInt32 CollectRows(nsIFrame* aFrame,
nsVoidArray& aCollection);
@ -855,10 +849,6 @@ public: /* ----- Cell Map public methods ----- */
virtual PRInt32 GetEffectiveColCount() const;
virtual PRInt32 GetColCount() const;
/** return the column frame at colIndex.
* returns nsnull if the col frame has not yet been allocated, or if aColIndex is out of range
*/
nsTableColFrame * GetColFrame(PRInt32 aColIndex);
// return the last col index which isn't of type eColAnonymousCell
PRInt32 GetIndexOfLastRealCol();