Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Protected Member Functions | Protected Attributes | Friends
nsTableCellMap Class Reference

#include <nsCellMap.h>

Collaboration diagram for nsTableCellMap:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsTableCellMap (nsTableFrame &aTableFrame, PRBool aBorderCollapse)
 ~nsTableCellMap ()
 destructor NOT VIRTUAL BECAUSE THIS CLASS SHOULD NEVER BE SUBCLASSED
void RemoveGroupCellMap (nsTableRowGroupFrame *aRowGroup)
void InsertGroupCellMap (nsTableRowGroupFrame &aNewRowGroup, nsTableRowGroupFrame *&aPrevRowGroup)
nsCellMapGetMapFor (nsTableRowGroupFrame &aRowGroup)
void Synchronize (nsTableFrame *aTableFrame)
 synchronize the cellmaps with the rowgroups again
nsTableCellFrameGetCellFrame (PRInt32 aRowIndex, PRInt32 aColIndex, CellData &aData, PRBool aUseRowIfOverlap) const
CellDataGetDataAt (PRInt32 aRowIndex, PRInt32 aColIndex, PRBool aUpdateZeroSpan=PR_TRUE)
 return the CellData for the cell at (aTableRowIndex, aTableColIndex)
nsColInfoGetColInfoAt (PRInt32 aColIndex)
CellDataAppendCell (nsTableCellFrame &aCellFrame, PRInt32 aRowIndex, PRBool aRebuildIfNecessary, nsRect &aDamageArea)
 append the cellFrame at the end of the row at aRowIndex and return the col index
void InsertCells (nsVoidArray &aCellFrames, PRInt32 aRowIndex, PRInt32 aColIndexBefore, nsRect &aDamageArea)
void RemoveCell (nsTableCellFrame *aCellFrame, PRInt32 aRowIndex, nsRect &aDamageArea)
void ClearCols ()
 Remove the previously gathered column information.
void InsertRows (nsTableRowGroupFrame &aRowGroup, nsVoidArray &aRows, PRInt32 aFirstRowIndex, PRBool aConsiderSpans, nsRect &aDamageArea)
void RemoveRows (PRInt32 aFirstRowIndex, PRInt32 aNumRowsToRemove, PRBool aConsiderSpans, nsRect &aDamageArea)
PRInt32 GetNumCellsOriginatingInRow (PRInt32 aRowIndex)
PRInt32 GetNumCellsOriginatingInCol (PRInt32 aColIndex) const
PRBool HasMoreThanOneCell (PRInt32 aRowIndex)
 indicate whether the row has more than one cell that either originates or is spanned from the rows above
PRInt32 GetEffectiveRowSpan (PRInt32 aRowIndex, PRInt32 aColIndex)
PRInt32 GetEffectiveColSpan (PRInt32 aRowIndex, PRInt32 aColIndex)
PRInt32 GetColCount () const
 return the total number of columns in the table represented by this CellMap
PRInt32 GetRowCount () const
 return the actual number of rows in the table represented by this CellMap
nsTableCellFrameGetCellInfoAt (PRInt32 aRowX, PRInt32 aColX, PRBool *aOriginates=nsnull, PRInt32 *aColSpan=nsnull)
void AddColsAtEnd (PRUint32 aNumCols)
void RemoveColsAtEnd ()
PRBool RowIsSpannedInto (PRInt32 aRowIndex)
PRBool RowHasSpanningCells (PRInt32 aRowIndex)
void RebuildConsideringCells (nsCellMap *aCellMap, nsVoidArray *aCellFrames, PRInt32 aRowIndex, PRInt32 aColIndex, PRBool aInsert, nsRect &aDamageArea)
void RebuildConsideringRows (nsCellMap *aCellMap, PRInt32 aStartRowIndex, nsVoidArray *aRowsToInsert, PRBool aNumRowsToRemove, nsRect &aDamageArea)
PRBool ColIsSpannedInto (PRInt32 aColIndex)
PRBool ColHasSpanningCells (PRInt32 aColIndex)
BCDataGetBCData (PRUint8 aSide, nsCellMap &aCellMap, PRUint32 aYPos, PRUint32 aXPos, PRBool aIsLowerRight=PR_FALSE)
void SetBCBorderEdge (PRUint8 aEdge, nsCellMap &aCellMap, PRUint32 aCellMapStart, PRUint32 aYPos, PRUint32 aXPos, PRUint32 aLength, BCBorderOwner aOwner, nscoord aSize, PRBool aChanged)
void SetBCBorderCorner (Corner aCorner, nsCellMap &aCellMap, PRUint32 aCellMapStart, PRUint32 aYPos, PRUint32 aXPos, PRUint8 aOwner, nscoord aSubSize, PRBool aBevel, PRBool aIsBottomRight=PR_FALSE)

Protected Member Functions

BCDataGetRightMostBorder (PRInt32 aRowIndex)
 dump a representation of the cell map to stdout for debugging
BCDataGetBottomMostBorder (PRInt32 aColIndex)
void InsertGroupCellMap (nsCellMap *aPrevMap, nsCellMap &aNewMap)
 Insert a row group cellmap after aPrevMap, if aPrefMap is null insert it at the beginning, the ordering of the cellmap corresponds to the ordering of rowgroups once OrderRowGroups has been called.
void DeleteRightBottomBorders ()

Protected Attributes

nsTableFramemTableFrame
nsAutoVoidArray mCols
nsCellMapmFirstMap
BCInfomBCInfo

Friends

class nsCellMap
class BCMapCellIterator
class BCMapBorderIterator

Detailed Description

Definition at line 79 of file nsCellMap.h.


Constructor & Destructor Documentation

nsTableCellMap::nsTableCellMap ( nsTableFrame aTableFrame,
PRBool  aBorderCollapse 
)

Definition at line 79 of file nsCellMap.cpp.

:mTableFrame(aTableFrame), mFirstMap(nsnull), mBCInfo(nsnull)
{
  MOZ_COUNT_CTOR(nsTableCellMap);

  nsAutoVoidArray orderedRowGroups;
  PRUint32 numRowGroups;
  aTableFrame.OrderRowGroups(orderedRowGroups, numRowGroups);

  for (PRUint32 rgX = 0; rgX < numRowGroups; rgX++) {
    nsTableRowGroupFrame* rgFrame =
      nsTableFrame::GetRowGroupFrame((nsIFrame*)orderedRowGroups.ElementAt(rgX));
    if (rgFrame) {
      nsTableRowGroupFrame* prior = (0 == rgX)
        ? nsnull : nsTableFrame::GetRowGroupFrame((nsIFrame*)orderedRowGroups.ElementAt(rgX - 1));
      InsertGroupCellMap(*rgFrame, prior);
    }
  }
  if (aBorderCollapse) {
    mBCInfo = new BCInfo();
  }
}

Here is the call graph for this function:

destructor NOT VIRTUAL BECAUSE THIS CLASS SHOULD NEVER BE SUBCLASSED

Definition at line 103 of file nsCellMap.cpp.

{
  MOZ_COUNT_DTOR(nsTableCellMap);

  nsCellMap* cellMap = mFirstMap;
  while (cellMap) {
    nsCellMap* next = cellMap->GetNextSibling();
    delete cellMap;
    cellMap = next;
  }

  PRInt32 colCount = mCols.Count();
  for (PRInt32 colX = 0; colX < colCount; colX++) {
    nsColInfo* colInfo = (nsColInfo *)mCols.ElementAt(colX);
    if (colInfo) {
      delete colInfo;
    }
  }
  if (mBCInfo) {
    DeleteRightBottomBorders();
    delete mBCInfo;
  }
}

Here is the call graph for this function:


Member Function Documentation

Definition at line 450 of file nsCellMap.cpp.

{
  PRBool added;
  // XXX We really should have a way to say "make this voidarray at least
  // N entries long" to avoid reallocating N times.  On the other hand, the
  // number of likely allocations here isn't TOO gigantic, and we may not
  // know about many of them at a time.
  for (PRUint32 numX = 1; numX <= aNumCols; numX++) {
    nsColInfo* colInfo = new nsColInfo();
    if (colInfo) {
      added = mCols.AppendElement(colInfo);
      if (!added) {
        delete colInfo;
        NS_WARNING("Could not AppendElement");
      }
    }
    if (mBCInfo) {
      BCData* bcData = new BCData();
      if (bcData) {
        added = mBCInfo->mBottomBorders.AppendElement(bcData);
        if (!added) {
          delete bcData;
          NS_WARNING("Could not AppendElement");
        }
      }
    }
  }
}

Here is the caller graph for this function:

CellData * nsTableCellMap::AppendCell ( nsTableCellFrame aCellFrame,
PRInt32  aRowIndex,
PRBool  aRebuildIfNecessary,
nsRect aDamageArea 
)

append the cellFrame at the end of the row at aRowIndex and return the col index

Definition at line 636 of file nsCellMap.cpp.

{
  NS_ASSERTION(&aCellFrame == aCellFrame.GetFirstInFlow(), "invalid call on continuing frame");
  nsIFrame* rgFrame = aCellFrame.GetParent(); // get the row
  if (!rgFrame) return 0;
  rgFrame = rgFrame->GetParent();   // get the row group
  if (!rgFrame) return 0;

  CellData* result = nsnull;
  PRInt32 rowIndex = aRowIndex;
  nsCellMap* cellMap = mFirstMap;
  while (cellMap) {
    if (cellMap->GetRowGroup() == rgFrame) {
      result = cellMap->AppendCell(*this, &aCellFrame, rowIndex, aRebuildIfNecessary, aDamageArea);
      nsTableRowGroupFrame* rg = cellMap->GetRowGroup();
      aDamageArea.y += (rg) ? rg->GetStartRowIndex() : 0;
      break;
    }
    rowIndex -= cellMap->GetRowCount();
    cellMap = cellMap->GetNextSibling();
  }
#ifdef DEBUG_TABLE_CELLMAP
  Dump("after AppendCell");
#endif
  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Remove the previously gathered column information.

Definition at line 515 of file nsCellMap.cpp.

{
  PRInt32 numCols = GetColCount();
  for (PRInt32 colX = numCols - 1; (colX >= 0);colX--) {
    nsColInfo* colInfo = (nsColInfo*)mCols.ElementAt(colX);  
    delete colInfo;
    mCols.RemoveElementAt(colX);
    if (mBCInfo) { 
      PRInt32 count = mBCInfo->mBottomBorders.Count();
      if (colX < count) {
        BCData* bcData = (BCData*)mBCInfo->mBottomBorders.ElementAt(colX);
        if (bcData) {
              delete bcData;
        }
        mBCInfo->mBottomBorders.RemoveElementAt(colX);
      }
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 930 of file nsCellMap.cpp.

{
  nsCellMap* cellMap = mFirstMap;
  while (cellMap) {
    if (cellMap->ColHasSpanningCells(*this, aColIndex)) {
      return PR_TRUE;
    }
    cellMap = cellMap->GetNextSibling();
  }
  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 919 of file nsCellMap.cpp.

{
  PRBool result = PR_FALSE;

  PRInt32 colCount = mCols.Count();
  if ((aColIndex >= 0) && (aColIndex < colCount)) {
    result = (PRBool) ((nsColInfo *)mCols.ElementAt(aColIndex))->mNumCellsSpan;
  }
  return result;
}

Here is the caller graph for this function:

Definition at line 175 of file nsCellMap.cpp.

{
  if (mBCInfo) {
    PRInt32 numCols = mBCInfo->mBottomBorders.Count();
    if (numCols > 0) {
      for (PRInt32 colX = numCols - 1; colX >= 0; colX--) {
        BCData* bcData = (BCData*)mBCInfo->mBottomBorders.ElementAt(colX);
        if (bcData) {
          delete bcData;
        }
        mBCInfo->mBottomBorders.RemoveElementAt(colX);
      }
    }
    PRUint32 numRows = mBCInfo->mRightBorders.Count();
    if (numRows > 0) {
      for (PRInt32 rowX = numRows - 1; rowX >= 0; rowX--) {
        BCData* bcData = (BCData*)mBCInfo->mRightBorders.ElementAt(rowX);
        if (bcData) {
          delete bcData;
        }
        mBCInfo->mRightBorders.RemoveElementAt(rowX);
      }
    }
  }
}

Here is the caller graph for this function:

BCData * nsTableCellMap::GetBCData ( PRUint8  aSide,
nsCellMap aCellMap,
PRUint32  aYPos,
PRUint32  aXPos,
PRBool  aIsLowerRight = PR_FALSE 
)

Definition at line 943 of file nsCellMap.cpp.

{
  if (!mBCInfo || aIsLowerRight) ABORT1(nsnull);

  BCCellData* cellData;
  BCData* bcData = nsnull;

  switch(aSide) {
  case NS_SIDE_BOTTOM:
    aRowIndex++;
  case NS_SIDE_TOP:
    cellData = (BCCellData*)aCellMap.GetDataAt(*this, aRowIndex, aColIndex, PR_FALSE);
    if (cellData) {
      bcData = &cellData->mData;
    }
    else {
      NS_ASSERTION(aSide == NS_SIDE_BOTTOM, "program error");
      // try the next row group
      nsCellMap* cellMap = aCellMap.GetNextSibling();
      if (cellMap) {
        cellData = (BCCellData*)cellMap->GetDataAt(*this, 0, aColIndex, PR_FALSE);
        if (cellData) {
          bcData = &cellData->mData;
        }
        else {
          bcData = GetBottomMostBorder(aColIndex);
        }
      }
    }
    break;
  case NS_SIDE_RIGHT:
    aColIndex++;
  case NS_SIDE_LEFT:
    cellData = (BCCellData*)aCellMap.GetDataAt(*this, aRowIndex, aColIndex, PR_FALSE);
    if (cellData) {
      bcData = &cellData->mData;
    }
    else {
      NS_ASSERTION(aSide == NS_SIDE_RIGHT, "program error");
      bcData = GetRightMostBorder(aRowIndex);
    }
    break;
  }
  return bcData;
}

Here is the call graph for this function:

Here is the caller graph for this function:

BCData * nsTableCellMap::GetBottomMostBorder ( PRInt32  aColIndex) [protected]

Definition at line 152 of file nsCellMap.cpp.

{
  if (!mBCInfo) ABORT1(nsnull);

  PRInt32 numCols = mBCInfo->mBottomBorders.Count();
  if (aColIndex < numCols) {
    return (BCData*)mBCInfo->mBottomBorders.ElementAt(aColIndex);
  }

  BCData* bcData;
  PRInt32 colX = numCols;

  do {
    bcData = new BCData();
    if (!bcData) ABORT1(nsnull);
    mBCInfo->mBottomBorders.AppendElement(bcData);
  } while (++colX <= aColIndex);

  return bcData;
}

Here is the caller graph for this function:

nsTableCellFrame * nsTableCellMap::GetCellFrame ( PRInt32  aRowIndex,
PRInt32  aColIndex,
CellData aData,
PRBool  aUseRowIfOverlap 
) const

Definition at line 393 of file nsCellMap.cpp.

{
  PRInt32 rowIndex = aRowIndex;
  nsCellMap* map = mFirstMap;
  while (map) {
    if (map->GetRowCount() > rowIndex) {
      return map->GetCellFrame(rowIndex, aColIndex, aData, aUseRowIfOverlap);
    }
    rowIndex -= map->GetRowCount();
    map = map->GetNextSibling();
  }
  return nsnull;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsTableCellFrame * nsTableCellMap::GetCellInfoAt ( PRInt32  aRowX,
PRInt32  aColX,
PRBool aOriginates = nsnull,
PRInt32 aColSpan = nsnull 
)

Definition at line 873 of file nsCellMap.cpp.

{
  PRInt32 rowIndex = aRowIndex;
  nsCellMap* cellMap = mFirstMap;
  while (cellMap) {
    if (cellMap->GetRowCount() > rowIndex) {
      return cellMap->GetCellInfoAt(*this, rowIndex, aColIndex, aOriginates, aColSpan);
    }
    rowIndex -= cellMap->GetRowCount();
    cellMap = cellMap->GetNextSibling();
  }
  return nsnull;
}

Here is the call graph for this function:

Here is the caller graph for this function:

return the total number of columns in the table represented by this CellMap

Definition at line 490 of file nsCellMap.h.

{
  return mCols.Count();
}

Here is the caller graph for this function:

Definition at line 411 of file nsCellMap.cpp.

{
  PRInt32 numColsToAdd = aColIndex + 1 - mCols.Count();
  if (numColsToAdd > 0) {
    AddColsAtEnd(numColsToAdd);  // XXX this could fail to add cols in theory
  }
  return (nsColInfo*)mCols.ElementAt(aColIndex);
}

Here is the call graph for this function:

Here is the caller graph for this function:

CellData * nsTableCellMap::GetDataAt ( PRInt32  aRowIndex,
PRInt32  aColIndex,
PRBool  aUpdateZeroSpan = PR_TRUE 
)

return the CellData for the cell at (aTableRowIndex, aTableColIndex)

Definition at line 433 of file nsCellMap.cpp.

{
  PRInt32 rowIndex = aRowIndex;
  nsCellMap* map = mFirstMap;
  while (map) {
    if (map->GetRowCount() > rowIndex) {
      return map->GetDataAt(*this, rowIndex, aColIndex, aUpdateZeroSpan);
    }
    rowIndex -= map->GetRowCount();
    map = map->GetNextSibling();
  }
  return nsnull;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 376 of file nsCellMap.cpp.

{
  PRInt32 rowIndex = aRowIndex;
  nsCellMap* map = mFirstMap;
  while (map) {
    if (map->GetRowCount() > rowIndex) {
      PRBool zeroColSpan;
      return map->GetEffectiveColSpan(*this, rowIndex, aColIndex, zeroColSpan);
    }
    rowIndex -= map->GetRowCount();
    map = map->GetNextSibling();
  }
  return nsnull;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 359 of file nsCellMap.cpp.

{
  PRInt32 rowIndex = aRowIndex;
  nsCellMap* map = mFirstMap;
  while (map) {
    if (map->GetRowCount() > rowIndex) {
      PRBool zeroRowSpan;
      return map->GetRowSpan(*this, rowIndex, aColIndex, PR_TRUE, zeroRowSpan);
    }
    rowIndex -= map->GetRowCount();
    map = map->GetNextSibling();
  }
  return nsnull;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 270 of file nsCellMap.cpp.

{
  NS_ASSERTION(!aRowGroup.GetPrevInFlow(), "GetMapFor called with continuation");
  for (nsCellMap* map = mFirstMap; map; map = map->GetNextSibling()) {
    if (&aRowGroup == map->GetRowGroup()) {
      return map;
    }
  }
  // if aRowGroup is a repeated header or footer find the header or footer it was repeated from
  if (aRowGroup.IsRepeatable()) {
    nsTableFrame* fifTable = NS_STATIC_CAST(nsTableFrame*, mTableFrame.GetFirstInFlow());

    nsAutoVoidArray rowGroups;
    PRUint32 numRowGroups;
    nsTableRowGroupFrame *thead, *tfoot;
    nsIFrame *ignore;
    // find the original header/footer 
    fifTable->OrderRowGroups(rowGroups, numRowGroups, &ignore, &thead, &tfoot);

    const nsStyleDisplay* display = aRowGroup.GetStyleDisplay();
    nsTableRowGroupFrame* rgOrig = 
      (NS_STYLE_DISPLAY_TABLE_HEADER_GROUP == display->mDisplay) ? thead : tfoot; 
    // find the row group cell map using the original header/footer
    if (rgOrig) {
      for (nsCellMap* map = mFirstMap; map; map = map->GetNextSibling()) {
        if (rgOrig == map->GetRowGroup()) {
          return map;
        }
      }
    }
  }

  return nsnull;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 789 of file nsCellMap.cpp.

{
  PRInt32 colCount = mCols.Count();
  if ((aColIndex >= 0) && (aColIndex < colCount)) {
    return ((nsColInfo *)mCols.ElementAt(aColIndex))->mNumCellsOrig;
  }
  else {
    NS_ASSERTION(PR_FALSE, "nsCellMap::GetNumCellsOriginatingInCol - bad col index");
    return 0;
  }
}

Here is the caller graph for this function:

Definition at line 618 of file nsCellMap.cpp.

{
  PRInt32 originCount = 0;

  CellData* cellData;
  PRInt32   colIndex = 0;

  do {
         cellData = GetDataAt(aRowIndex, colIndex);
         if (cellData && cellData->GetCellFrame())
                originCount++;
    colIndex++;
  } while(cellData);

  return originCount;
}

Here is the call graph for this function:

Here is the caller graph for this function:

BCData * nsTableCellMap::GetRightMostBorder ( PRInt32  aRowIndex) [protected]

dump a representation of the cell map to stdout for debugging

Definition at line 129 of file nsCellMap.cpp.

{
  if (!mBCInfo) ABORT1(nsnull);

  PRInt32 numRows = mBCInfo->mRightBorders.Count();
  if (aRowIndex < numRows) {
    return (BCData*)mBCInfo->mRightBorders.ElementAt(aRowIndex);
  }

  BCData* bcData;
  PRInt32 rowX = numRows;

  do {
    bcData = new BCData();
    if (!bcData) ABORT1(nsnull);
    mBCInfo->mRightBorders.AppendElement(bcData);
  } while (++rowX <= aRowIndex);

  return bcData;
}

Here is the caller graph for this function:

return the actual number of rows in the table represented by this CellMap

Definition at line 421 of file nsCellMap.cpp.

{
  PRInt32 numRows = 0;
  nsCellMap* map = mFirstMap;
  while (map) {
    numRows += map->GetRowCount();
    map = map->GetNextSibling();
  }
  return numRows;
}

Here is the call graph for this function:

Here is the caller graph for this function:

indicate whether the row has more than one cell that either originates or is spanned from the rows above

Definition at line 344 of file nsCellMap.cpp.

{
  PRInt32 rowIndex = aRowIndex;
  nsCellMap* map = mFirstMap;
  while (map) {
    if (map->GetRowCount() > rowIndex) {
      return map->HasMoreThanOneCell(*this, rowIndex);
    }
    rowIndex -= map->GetRowCount();
    map = map->GetNextSibling();
  }
  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsTableCellMap::InsertCells ( nsVoidArray aCellFrames,
PRInt32  aRowIndex,
PRInt32  aColIndexBefore,
nsRect aDamageArea 
)

Definition at line 668 of file nsCellMap.cpp.

{
  PRInt32 rowIndex = aRowIndex;
  nsCellMap* cellMap = mFirstMap;
  while (cellMap) {
    if (cellMap->GetRowCount() > rowIndex) {
      cellMap->InsertCells(*this, aCellFrames, rowIndex, aColIndexBefore, aDamageArea);
      nsTableRowGroupFrame* rg = cellMap->GetRowGroup();
      aDamageArea.y += (rg) ? rg->GetStartRowIndex() : 0;
      aDamageArea.width = PR_MAX(0, GetColCount() - aColIndexBefore - 1);
      break;
    }
    rowIndex -= cellMap->GetRowCount();
    cellMap = cellMap->GetNextSibling();
  }
#ifdef DEBUG_TABLE_CELLMAP
  Dump("after InsertCells");
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 217 of file nsCellMap.cpp.

{
  nsCellMap* newMap = new nsCellMap(aNewGroup);
  if (newMap) {
    nsCellMap* prevMap = nsnull;
    nsCellMap* lastMap = mFirstMap;
    if (aPrevGroup) {
      nsCellMap* map = mFirstMap;
      while (map) {
        lastMap = map;
        if (map->GetRowGroup() == aPrevGroup) {
          prevMap = map;
          break;
        }
        map = map->GetNextSibling();
      }
    }
    if (!prevMap) {
      if (aPrevGroup) {
        prevMap = lastMap;
        aPrevGroup = (prevMap) ? prevMap->GetRowGroup() : nsnull;
      }
      else {
        aPrevGroup = nsnull;
      }
    }
    InsertGroupCellMap(prevMap, *newMap);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsTableCellMap::InsertGroupCellMap ( nsCellMap aPrevMap,
nsCellMap aNewMap 
) [protected]

Insert a row group cellmap after aPrevMap, if aPrefMap is null insert it at the beginning, the ordering of the cellmap corresponds to the ordering of rowgroups once OrderRowGroups has been called.

Definition at line 202 of file nsCellMap.cpp.

{
  nsCellMap* next;
  if (aPrevMap) {
    next = aPrevMap->GetNextSibling();
    aPrevMap->SetNextSibling(&aNewMap);
  }
  else {
    next = mFirstMap;
    mFirstMap = &aNewMap;
  }
  aNewMap.SetNextSibling(next);
}

Here is the call graph for this function:

void nsTableCellMap::InsertRows ( nsTableRowGroupFrame aRowGroup,
nsVoidArray aRows,
PRInt32  aFirstRowIndex,
PRBool  aConsiderSpans,
nsRect aDamageArea 
)

Definition at line 535 of file nsCellMap.cpp.

{
  PRInt32 numNewRows = aRows.Count();
  if ((numNewRows <= 0) || (aFirstRowIndex < 0)) ABORT0(); 

  PRInt32 rowIndex = aFirstRowIndex;
  nsCellMap* cellMap = mFirstMap;
  while (cellMap) {
    nsTableRowGroupFrame* rg = cellMap->GetRowGroup();
    if (rg == &aParent) {
      cellMap->InsertRows(*this, aRows, rowIndex, aConsiderSpans, aDamageArea);
      aDamageArea.y = aFirstRowIndex;
      aDamageArea.height = PR_MAX(0, GetRowCount() - aFirstRowIndex);
#ifdef DEBUG_TABLE_CELLMAP 
      Dump("after InsertRows");
#endif
      if (mBCInfo) {
        BCData* bcData;
        PRInt32 count = mBCInfo->mRightBorders.Count();
        if (aFirstRowIndex < count) {
          for (PRInt32 rowX = aFirstRowIndex; rowX < aFirstRowIndex + numNewRows; rowX++) {
            bcData = new BCData(); if (!bcData) ABORT0();
            mBCInfo->mRightBorders.InsertElementAt(bcData, rowX);
          }
        }
        else {
          GetRightMostBorder(aFirstRowIndex); // this will create missing entries
          for (PRInt32 rowX = aFirstRowIndex + 1; rowX < aFirstRowIndex + numNewRows; rowX++) {
            bcData = new BCData(); if (!bcData) ABORT0();
            mBCInfo->mRightBorders.AppendElement(bcData);
          }
        }
      }
      return;
    }
    rowIndex -= cellMap->GetRowCount();
    cellMap = cellMap->GetNextSibling();
  }

  NS_ASSERTION(PR_FALSE, "Attempt to insert row into wrong map.");
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsTableCellMap::RebuildConsideringCells ( nsCellMap aCellMap,
nsVoidArray aCellFrames,
PRInt32  aRowIndex,
PRInt32  aColIndex,
PRBool  aInsert,
nsRect aDamageArea 
)

Definition at line 739 of file nsCellMap.cpp.

{
  PRInt32 numOrigCols = GetColCount();
  ClearCols();
  nsCellMap* cellMap = mFirstMap;
  PRInt32 rowCount = 0;
  while (cellMap) {
    if (cellMap == aCellMap) {
      cellMap->RebuildConsideringCells(*this, numOrigCols, aCellFrames, aRowIndex, aColIndex, aInsert, aDamageArea);
      
    }
    else {
      cellMap->RebuildConsideringCells(*this, numOrigCols, nsnull, -1, 0, PR_FALSE, aDamageArea);
    }
    rowCount += cellMap->GetRowCount();
    cellMap = cellMap->GetNextSibling();
  }
  SetDamageArea(0, 0, GetColCount(), rowCount, aDamageArea);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsTableCellMap::RebuildConsideringRows ( nsCellMap aCellMap,
PRInt32  aStartRowIndex,
nsVoidArray aRowsToInsert,
PRBool  aNumRowsToRemove,
nsRect aDamageArea 
)

Definition at line 765 of file nsCellMap.cpp.

{
  PRInt32 numOrigCols = GetColCount();
  ClearCols();
  nsCellMap* cellMap = mFirstMap;
  PRInt32 rowCount = 0;
  while (cellMap) {
    if (cellMap == aCellMap) {
      cellMap->RebuildConsideringRows(*this, aStartRowIndex, aRowsToInsert, aNumRowsToRemove, aDamageArea);
    }
    else {
      cellMap->RebuildConsideringCells(*this, numOrigCols, nsnull, -1, 0, PR_FALSE, aDamageArea);
    }
    rowCount += cellMap->GetRowCount();
    cellMap = cellMap->GetNextSibling();
  }
  SetDamageArea(0, 0, GetColCount(), rowCount, aDamageArea);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsTableCellMap::RemoveCell ( nsTableCellFrame aCellFrame,
PRInt32  aRowIndex,
nsRect aDamageArea 
)

Definition at line 693 of file nsCellMap.cpp.

{
  if (!aCellFrame) ABORT0();
  NS_ASSERTION(aCellFrame == (nsTableCellFrame *)aCellFrame->GetFirstInFlow(),
               "invalid call on continuing frame");
  PRInt32 rowIndex = aRowIndex;
  nsCellMap* cellMap = mFirstMap;
  while (cellMap) {
    if (cellMap->GetRowCount() > rowIndex) {
      cellMap->RemoveCell(*this, aCellFrame, rowIndex, aDamageArea);
      nsTableRowGroupFrame* rg = cellMap->GetRowGroup();
      aDamageArea.y += (rg) ? rg->GetStartRowIndex() : 0;
      PRInt32 colIndex;
      aCellFrame->GetColIndex(colIndex);
      aDamageArea.width = PR_MAX(0, GetColCount() - colIndex - 1);
#ifdef DEBUG_TABLE_CELLMAP
      Dump("after RemoveCell");
#endif
      return;
    }
    rowIndex -= cellMap->GetRowCount();
    cellMap = cellMap->GetNextSibling();
  }
  // if we reach this point - the cell did not get removed, the caller of this routine 
  // will delete the cell and the cellmap will probably hold a reference to 
  // the deleted cell which will cause a subsequent crash when this cell is 
  // referenced later
  NS_ERROR("nsTableCellMap::RemoveCell - could not remove cell");
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 480 of file nsCellMap.cpp.

{
  // Remove the cols at the end which don't have originating cells or cells spanning 
  // into them. Only do this if the col was created as eColAnonymousCell  
  PRInt32 numCols = GetColCount();
  PRInt32 lastGoodColIndex = mTableFrame.GetIndexOfLastRealCol();
  for (PRInt32 colX = numCols - 1; (colX >= 0) && (colX > lastGoodColIndex); colX--) {
    nsColInfo* colInfo = (nsColInfo*)mCols.ElementAt(colX);
    if (colInfo) {
      if ((colInfo->mNumCellsOrig <= 0) && (colInfo->mNumCellsSpan <= 0))  {

        delete colInfo;
        mCols.RemoveElementAt(colX);

        if (mBCInfo) { 
          PRInt32 count = mBCInfo->mBottomBorders.Count();
          if (colX < count) {
            BCData* bcData = (BCData*)mBCInfo->mBottomBorders.ElementAt(colX);
            if (bcData) {
              delete bcData;
            }
            mBCInfo->mBottomBorders.RemoveElementAt(colX);
          }
        }
      }
      else break; // only remove until we encounter the 1st valid one
    }
    else {
      NS_ASSERTION(0, "null entry in column info array");
      mCols.RemoveElementAt(colX);
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 248 of file nsCellMap.cpp.

{
  nsCellMap* map = mFirstMap;
  nsCellMap* prior = nsnull;
  while (map) {
    if (map->GetRowGroup() == aGroup) {
      nsCellMap* next = map->GetNextSibling();
      if (mFirstMap == map) {
        mFirstMap = next;
      }
      else {
        prior->SetNextSibling(next);
      }
      delete map;
      break;
    }
    prior = map;
    map = map->GetNextSibling();
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsTableCellMap::RemoveRows ( PRInt32  aFirstRowIndex,
PRInt32  aNumRowsToRemove,
PRBool  aConsiderSpans,
nsRect aDamageArea 
)

Definition at line 582 of file nsCellMap.cpp.

{
  PRInt32 rowIndex = aFirstRowIndex;
  nsCellMap* cellMap = mFirstMap;
  while (cellMap) {
    if (cellMap->GetRowCount() > rowIndex) {
      cellMap->RemoveRows(*this, rowIndex, aNumRowsToRemove, aConsiderSpans, aDamageArea);
      nsTableRowGroupFrame* rg = cellMap->GetRowGroup();
      aDamageArea.y += (rg) ? rg->GetStartRowIndex() : 0;
      aDamageArea.height = PR_MAX(0, GetRowCount() - aFirstRowIndex);
      if (mBCInfo) {
        BCData* bcData;
        for (PRInt32 rowX = aFirstRowIndex + aNumRowsToRemove - 1; rowX >= aFirstRowIndex; rowX--) {
          if (rowX < mBCInfo->mRightBorders.Count()) {
            bcData = (BCData*)mBCInfo->mRightBorders.ElementAt(rowX);
            if (bcData) {
              delete bcData;
            }
            mBCInfo->mRightBorders.RemoveElementAt(rowX);
          }
        }
      }
      break;
    }
    rowIndex -= cellMap->GetRowCount();
    cellMap = cellMap->GetNextSibling();
  }
#ifdef DEBUG_TABLE_CELLMAP
  Dump("after RemoveRows");
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 905 of file nsCellMap.cpp.

{
  PRInt32 rowIndex = aRowIndex;
  nsCellMap* cellMap = mFirstMap;
  while (cellMap) {
    if (cellMap->GetRowCount() > rowIndex) {
      return cellMap->RowHasSpanningCells(*this, rowIndex);
    }
    rowIndex -= cellMap->GetRowCount();
    cellMap = cellMap->GetNextSibling();
  }
  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 891 of file nsCellMap.cpp.

{
  PRInt32 rowIndex = aRowIndex;
  nsCellMap* cellMap = mFirstMap;
  while (cellMap) {
    if (cellMap->GetRowCount() > rowIndex) {
      return cellMap->RowIsSpannedInto(*this, rowIndex);
    }
    rowIndex -= cellMap->GetRowCount();
    cellMap = cellMap->GetNextSibling();
  }
  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsTableCellMap::SetBCBorderCorner ( Corner  aCorner,
nsCellMap aCellMap,
PRUint32  aCellMapStart,
PRUint32  aYPos,
PRUint32  aXPos,
PRUint8  aOwner,
nscoord  aSubSize,
PRBool  aBevel,
PRBool  aIsBottomRight = PR_FALSE 
)

Definition at line 1092 of file nsCellMap.cpp.

{
  if (!mBCInfo) ABORT0();

  if (aIsBottomRight) { 
    mBCInfo->mLowerRightCorner.SetCorner(aSubSize, aOwner, aBevel);
    return;
  }

  PRInt32 xPos = aColIndex;
  PRInt32 yPos = aRowIndex;
  PRInt32 rgYPos = aRowIndex - aCellMapStart;

  if (eTopRight == aCorner) {
    xPos++;
  }
  else if (eBottomRight == aCorner) {
    xPos++;
    rgYPos++;
    yPos++;
  }
  else if (eBottomLeft == aCorner) {
    rgYPos++;
    yPos++;
  }

  BCCellData* cellData = nsnull;
  BCData*     bcData   = nsnull;
  if (GetColCount() <= xPos) {
    NS_ASSERTION(xPos == GetColCount(), "program error");
    // at the right edge of the table as we checked the corner before
    bcData = GetRightMostBorder(yPos);
  }
  else {
    cellData = (BCCellData*)aCellMap.GetDataAt(*this, rgYPos, xPos, PR_FALSE);
    if (!cellData) {
      PRInt32 numRgRows = aCellMap.GetRowCount();
      if (yPos < numRgRows) { // add a dead cell data
        nsRect damageArea;
        cellData = (BCCellData*)aCellMap.AppendCell(*this, nsnull, rgYPos, PR_FALSE, damageArea); 
      }
      else {
        // try the next non empty row group
        nsCellMap* cellMap = aCellMap.GetNextSibling();
        while (cellMap && (0 == cellMap->GetRowCount())) {
          cellMap = cellMap->GetNextSibling();
        }
        if (cellMap) {
          cellData = (BCCellData*)cellMap->GetDataAt(*this, 0, xPos, PR_FALSE);
          if (!cellData) { // add a dead cell
            nsRect damageArea;
            cellData = (BCCellData*)cellMap->AppendCell(*this, nsnull, 0, PR_FALSE, damageArea); 
          }
        }
        else { // must be a the bottom of the table
          bcData = GetBottomMostBorder(xPos);
        }
      }
    }
  }
  if (!bcData && cellData) {
    bcData = &cellData->mData;
  }
  if (bcData) {
    bcData->SetCorner(aSubSize, aOwner, aBevel);
  }
  else NS_ASSERTION(PR_FALSE, "program error");
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsTableCellMap::SetBCBorderEdge ( PRUint8  aEdge,
nsCellMap aCellMap,
PRUint32  aCellMapStart,
PRUint32  aYPos,
PRUint32  aXPos,
PRUint32  aLength,
BCBorderOwner  aOwner,
nscoord  aSize,
PRBool  aChanged 
)

Definition at line 998 of file nsCellMap.cpp.

{
  if (!mBCInfo) ABORT0();
  //if (aRowIndex >= 80) {
  //  NS_ASSERTION(PR_FALSE, "hello");
  //}

  BCCellData* cellData;
  PRInt32 lastIndex, xIndex, yIndex;
  PRInt32 xPos = aColIndex;
  PRInt32 yPos = aRowIndex;
  PRInt32 rgYPos = aRowIndex - aCellMapStart;
  PRBool changed;

  switch(aSide) {
  case NS_SIDE_BOTTOM:
    rgYPos++;
    yPos++;
  case NS_SIDE_TOP:
    lastIndex = xPos + aLength - 1;
    for (xIndex = xPos; xIndex <= lastIndex; xIndex++) {
      changed = aChanged && (xIndex == xPos);
      BCData* bcData = nsnull;
      cellData = (BCCellData*)aCellMap.GetDataAt(*this, rgYPos, xIndex, PR_FALSE);
      if (!cellData) {
        PRInt32 numRgRows = aCellMap.GetRowCount();
        if (yPos < numRgRows) { // add a dead cell data
          nsRect damageArea;
          cellData = (BCCellData*)aCellMap.AppendCell(*this, nsnull, rgYPos, PR_FALSE, damageArea); if (!cellData) ABORT0();
        }
        else {
          NS_ASSERTION(aSide == NS_SIDE_BOTTOM, "program error");
          // try the next non empty row group
          nsCellMap* cellMap = aCellMap.GetNextSibling();
          while (cellMap && (0 == cellMap->GetRowCount())) {
            cellMap = cellMap->GetNextSibling();
          }
          if (cellMap) {
            cellData = (BCCellData*)cellMap->GetDataAt(*this, 0, xIndex, PR_FALSE);
            if (!cellData) { // add a dead cell
              nsRect damageArea;
              cellData = (BCCellData*)cellMap->AppendCell(*this, nsnull, 0, PR_FALSE, damageArea); 
            }
          }
          else { // must be at the end of the table
            bcData = GetBottomMostBorder(xIndex);
          }
        }
      }
      if (!bcData && cellData) {
        bcData = &cellData->mData;
      }
      if (bcData) {
        bcData->SetTopEdge(aOwner, aSize, changed);
      }
      else NS_ASSERTION(PR_FALSE, "program error");
    }
    break;
  case NS_SIDE_RIGHT:
    xPos++;
  case NS_SIDE_LEFT:
    // since top, bottom borders were set, there should already be a cellData entry
    lastIndex = rgYPos + aLength - 1;
    for (yIndex = rgYPos; yIndex <= lastIndex; yIndex++) {
      changed = aChanged && (yIndex == rgYPos);
      cellData = (BCCellData*)aCellMap.GetDataAt(*this, yIndex, xPos, PR_FALSE);
      if (cellData) {
        cellData->mData.SetLeftEdge(aOwner, aSize, changed);
      }
      else {
        NS_ASSERTION(aSide == NS_SIDE_RIGHT, "program error");
        BCData* bcData = GetRightMostBorder(yIndex + aCellMapStart);
        if (bcData) {
          bcData->SetLeftEdge(aOwner, aSize, changed);
        }
        else NS_ASSERTION(PR_FALSE, "program error");
      }
    }
    break;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

synchronize the cellmaps with the rowgroups again

Definition at line 306 of file nsCellMap.cpp.

{
  nsAutoVoidArray orderedRowGroups;
  nsAutoVoidArray maps;
  PRUint32 numRowGroups;
  PRInt32 mapIndex;

  maps.Clear();
  aTableFrame->OrderRowGroups(orderedRowGroups, numRowGroups);
  if (!numRowGroups) {
    return;
  }

  for (PRUint32 rgX = 0; rgX < numRowGroups; rgX++) {
    nsTableRowGroupFrame* rgFrame =
      nsTableFrame::GetRowGroupFrame((nsIFrame*)orderedRowGroups.ElementAt(rgX));
    if (rgFrame) {
      nsCellMap* map = GetMapFor(*(nsTableRowGroupFrame*)(rgFrame->GetFirstInFlow()));
      if (map) {
        if (!maps.AppendElement(map)) {
          delete map;
          NS_WARNING("Could not AppendElement");
        }
      }
    }
  }
  mapIndex = maps.Count() - 1;
  nsCellMap* nextMap = (nsCellMap*) maps.ElementAt(mapIndex);
  nextMap->SetNextSibling(nsnull);
  for (mapIndex-- ; mapIndex >= 0; mapIndex--) {
    nsCellMap* map = (nsCellMap*) maps.ElementAt(mapIndex);
    map->SetNextSibling(nextMap);
    nextMap = map;
  }
  mFirstMap = nextMap;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Friends And Related Function Documentation

friend class BCMapBorderIterator [friend]

Definition at line 220 of file nsCellMap.h.

friend class BCMapCellIterator [friend]

Definition at line 219 of file nsCellMap.h.

friend class nsCellMap [friend]

Definition at line 218 of file nsCellMap.h.


Member Data Documentation

Definition at line 233 of file nsCellMap.h.

nsAutoVoidArray nsTableCellMap::mCols [protected]

Definition at line 230 of file nsCellMap.h.

Definition at line 231 of file nsCellMap.h.

Definition at line 229 of file nsCellMap.h.


The documentation for this class was generated from the following files: