mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
document the lineiterator interface and all its current flaws. Make :GetNextSiblingOnLine more efficient. bug 388700 r/sr=roc a=mtschrep
This commit is contained in:
parent
d242f98c36
commit
1797043034
@ -1781,58 +1781,7 @@ nsTableRowGroupFrame::GetNextSiblingOnLine(nsIFrame*& aFrame,
|
||||
PRInt32 aLineNumber)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aFrame);
|
||||
|
||||
nsITableCellLayout* cellFrame;
|
||||
nsresult result = CallQueryInterface(aFrame, &cellFrame);
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
|
||||
nsTableFrame* parentFrame = nsTableFrame::GetTableFrame(this);
|
||||
if (!parentFrame)
|
||||
return NS_ERROR_FAILURE;
|
||||
nsTableCellMap* cellMap = parentFrame->GetCellMap();
|
||||
if (!cellMap)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
||||
PRInt32 colIndex;
|
||||
PRInt32& colIndexRef = colIndex;
|
||||
cellFrame->GetColIndex(colIndexRef);
|
||||
|
||||
CellData* cellData = cellMap->GetDataAt(aLineNumber, colIndex + 1);
|
||||
|
||||
if (!cellData)// if this isn't a valid cell, drop down and check the next line
|
||||
{
|
||||
cellData = cellMap->GetDataAt(aLineNumber + 1, 0);
|
||||
if (!cellData)
|
||||
{
|
||||
//*aFrame = nsnull;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
aFrame = (nsIFrame*)cellData->GetCellFrame();
|
||||
if (!aFrame)
|
||||
{
|
||||
//PRInt32 numCellsInRow = cellMap->GetNumCellsOriginatingInRow(aLineNumber) - 1;
|
||||
PRInt32 tempCol = colIndex + 1;
|
||||
PRInt32 tempRow = aLineNumber;
|
||||
while ((tempCol > 0) && (!aFrame))
|
||||
{
|
||||
tempCol--;
|
||||
cellData = cellMap->GetDataAt(aLineNumber, tempCol);
|
||||
aFrame = (nsIFrame*)cellData->GetCellFrame();
|
||||
if (!aFrame && (tempCol==0))
|
||||
{
|
||||
while ((tempRow > 0) && (!aFrame))
|
||||
{
|
||||
tempRow--;
|
||||
cellData = cellMap->GetDataAt(tempRow, 0);
|
||||
aFrame = (nsIFrame*)cellData->GetCellFrame();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
aFrame = aFrame->GetNextSibling();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -222,18 +222,81 @@ public:
|
||||
|
||||
// nsILineIterator methods
|
||||
public:
|
||||
// The table row is the equivalent to a line in block layout.
|
||||
// The nsILineIterator assumes that a line resides in a block, this role is
|
||||
// fullfilled by the row group. Rows in table are counted relative to the
|
||||
// table. The row index of row corresponds to the cellmap coordinates. The
|
||||
// number of lines in a table might be greater than the number of rows in a
|
||||
// single row group, as there might be multiple row groups.
|
||||
|
||||
/** Get the number of rows in a table
|
||||
* @param aResult - pointer that holds the number of lines in a table
|
||||
* XXX this currently returns the number of rows in a
|
||||
* rowgroup rather than that of the table.
|
||||
*/
|
||||
NS_IMETHOD GetNumLines(PRInt32* aResult);
|
||||
|
||||
/** @see nsILineIterator.h GetDirection
|
||||
* @param aIsRightToLeft - true if the table is rtl
|
||||
* XXX returns always false
|
||||
*/
|
||||
NS_IMETHOD GetDirection(PRBool* aIsRightToLeft);
|
||||
|
||||
/** Return structural information about a line.
|
||||
* @param aLineNumber - the index of the row relative to the table
|
||||
* If the line-number is invalid then
|
||||
* aFirstFrameOnLine will be nsnull and
|
||||
* aNumFramesOnLine will be zero.
|
||||
* XXX this is what nsLineIterator::GetLine does
|
||||
* the code here currently returns
|
||||
* NS_ERROR_FAILURE without setting the params
|
||||
* as required.
|
||||
* @param aFirstFrameOnLine - the first cell frame that originates in row
|
||||
* with a rowindex that matches a line number
|
||||
* XXX now this goes up to the row with cell
|
||||
* that spans into this row.
|
||||
* @param aNumFramesOnLine - return the numbers of cells originating in
|
||||
* this row
|
||||
* @param aLineBounds - rect of the row
|
||||
* XXX currently not implemented, nothing
|
||||
* is written to aLineBounds
|
||||
* @param aLineFlags - unused set to 0
|
||||
*/
|
||||
NS_IMETHOD GetLine(PRInt32 aLineNumber,
|
||||
nsIFrame** aFirstFrameOnLine,
|
||||
PRInt32* aNumFramesOnLine,
|
||||
nsRect& aLineBounds,
|
||||
PRUint32* aLineFlags);
|
||||
|
||||
/** Given a frame that's a child of the rowgroup, find which line its on.
|
||||
* @param aFrame - frame, should be a row
|
||||
* @param aIndexResult - row index if this a row frame. aIndexResult will be
|
||||
* set to -1 if the frame cannot be found.
|
||||
* XXX currently aIndexResult is set to 0 if aFrame is
|
||||
* not a row and a error code is returned to the caller
|
||||
* instead.
|
||||
*/
|
||||
NS_IMETHOD FindLineContaining(nsIFrame* aFrame, PRInt32* aLineNumberResult);
|
||||
NS_IMETHOD FindLineAt(nscoord aY, PRInt32* aLineNumberResult);
|
||||
|
||||
/** not implemented
|
||||
* the function is also not called in our tree
|
||||
*/
|
||||
NS_IMETHOD FindLineAt(nscoord aY, PRInt32* aLineNumberResult);
|
||||
|
||||
/** Find the orginating cell frame on a row that is the nearest to the
|
||||
* coordinate X.
|
||||
* XXX the design is completely broken if aX points to a point between
|
||||
* cells or in a cell that spans from rows above, the function will return
|
||||
* NS_ERROR_FAILURE in this case.
|
||||
* @param aLineNumber - the index of the row relative to the table
|
||||
* @param aX - X coordinate in twips relative to the
|
||||
* originof the rowgroup
|
||||
* @param aFrameFound - pointer to the cellframe
|
||||
* @param aXIsBeforeFirstFrame - the point is before the first originating
|
||||
* cellframe
|
||||
* @param aXIsAfterLastFrame - the point is after the last originating
|
||||
* cellframe
|
||||
*/
|
||||
NS_IMETHOD FindFrameAt(PRInt32 aLineNumber,
|
||||
nscoord aX,
|
||||
nsIFrame** aFrameFound,
|
||||
@ -241,11 +304,25 @@ public:
|
||||
PRBool* aXIsAfterLastFrame);
|
||||
|
||||
#ifdef IBMBIDI
|
||||
/** Check whether visual and logical order of cell frames within a line are
|
||||
* identical. As the layout will reorder them this is always the case
|
||||
* @param aLine - the index of the row relative to the table
|
||||
* @param aIsReordered - returns false
|
||||
* @param aFirstVisual - if the table is rtl first originating cell frame
|
||||
* @param aLastVisual - if the table is rtl last originating cell frame
|
||||
*/
|
||||
|
||||
NS_IMETHOD CheckLineOrder(PRInt32 aLine,
|
||||
PRBool *aIsReordered,
|
||||
nsIFrame **aFirstVisual,
|
||||
nsIFrame **aLastVisual);
|
||||
#endif
|
||||
|
||||
/** Find the next originating cell frame that originates in the row.
|
||||
* @param aFrame - cell frame to start with, will return the next cell
|
||||
* originating in a row
|
||||
* @param aLineNumber - the index of the row relative to the table
|
||||
*/
|
||||
NS_IMETHOD GetNextSiblingOnLine(nsIFrame*& aFrame, PRInt32 aLineNumber);
|
||||
|
||||
// row cursor methods to speed up searching for the row(s)
|
||||
|
Loading…
Reference in New Issue
Block a user