зеркало из https://github.com/mozilla/gecko-dev.git
Moved code that resized the table row cells from the row group frame
to the row frame. It's now handled as part of the DidReflow() post- processing code
This commit is contained in:
Родитель
981c82fe21
Коммит
d138bc14e1
|
@ -398,6 +398,11 @@ PRInt32 nsTableFrame::GetRowCount ()
|
|||
// return the rows spanned by aCell starting at aRowIndex
|
||||
// note that this is different from just the rowspan of aCell
|
||||
// (that would be GetEffectiveRowSpan (indexOfRowThatContains_aCell, aCell)
|
||||
//
|
||||
// XXX This code should be in the table row group frame instead, and it
|
||||
// should clip rows spans so they don't extend past a row group rather than
|
||||
// clip to the table itself. Before that can happen the code that builds the
|
||||
// cell map needs to take row groups into account
|
||||
PRInt32 nsTableFrame::GetEffectiveRowSpan (PRInt32 aRowIndex, nsTableCellFrame *aCell)
|
||||
{
|
||||
NS_PRECONDITION (nsnull!=aCell, "bad cell arg");
|
||||
|
|
|
@ -105,6 +105,42 @@ nsTableRowFrame::~nsTableRowFrame()
|
|||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Post-reflow hook. This is where the table row does its post-processing
|
||||
*/
|
||||
NS_METHOD
|
||||
nsTableRowFrame::DidReflow(nsIPresContext& aPresContext,
|
||||
nsDidReflowStatus aStatus)
|
||||
{
|
||||
if (NS_FRAME_REFLOW_FINISHED == aStatus) {
|
||||
// Resize and re-align the cell frames based on our row height
|
||||
nscoord cellHeight = mRect.height - mCellMaxTopMargin - mCellMaxBottomMargin;
|
||||
nsTableCellFrame *cellFrame = (nsTableCellFrame*)mFirstChild;
|
||||
nsTableFrame* tableFrame;
|
||||
mContentParent->GetContentParent((nsIFrame*&)tableFrame);
|
||||
while (nsnull != cellFrame)
|
||||
{
|
||||
PRInt32 rowSpan = tableFrame->GetEffectiveRowSpan(mRowIndex, cellFrame);
|
||||
if (1==rowSpan)
|
||||
{
|
||||
// resize the cell's height
|
||||
nsSize cellFrameSize;
|
||||
cellFrame->GetSize(cellFrameSize);
|
||||
cellFrame->SizeTo(cellFrameSize.width, cellHeight);
|
||||
|
||||
// realign cell content based on the new height
|
||||
cellFrame->VerticallyAlignChild(&aPresContext);
|
||||
}
|
||||
|
||||
// Get the next cell
|
||||
cellFrame->GetNextSibling((nsIFrame*&)cellFrame);
|
||||
}
|
||||
}
|
||||
|
||||
// Let our base class do the usual work
|
||||
return nsContainerFrame::DidReflow(aPresContext, aStatus);
|
||||
}
|
||||
|
||||
void nsTableRowFrame::ResetMaxChildHeight()
|
||||
{
|
||||
mTallestCell=0;
|
||||
|
|
|
@ -94,6 +94,9 @@ public:
|
|||
const nsReflowState& aReflowState,
|
||||
nsReflowStatus& aStatus);
|
||||
|
||||
NS_IMETHOD DidReflow(nsIPresContext& aPresContext,
|
||||
nsDidReflowStatus aStatus);
|
||||
|
||||
/** @see nsContainerFrame::CreateContinuingFrame */
|
||||
NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext,
|
||||
nsIFrame* aParent,
|
||||
|
|
|
@ -827,55 +827,6 @@ nsTableRowGroupFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by ShrinkWrapChildren() to set the height of a table row. Resizes
|
||||
* the table row, each of the row's table cells, and then realigns the cell
|
||||
* content based on the new height
|
||||
*/
|
||||
void nsTableRowGroupFrame::SetRowHeight(nsIPresContext* aPresContext,
|
||||
nsIFrame* aRowFrame,
|
||||
PRInt32 aRowIndex,
|
||||
nscoord aRowHeight,
|
||||
nscoord aMaxCellHeight,
|
||||
PRBool& aHasRowSpanningCell)
|
||||
{
|
||||
// initialize out parameter
|
||||
aHasRowSpanningCell = PR_FALSE;
|
||||
|
||||
// set the row's height
|
||||
nsSize rowFrameSize;
|
||||
aRowFrame->GetSize(rowFrameSize);
|
||||
aRowFrame->SizeTo(rowFrameSize.width, aRowHeight);
|
||||
|
||||
// resize all the cells based on the max cell height
|
||||
// XXX It would be better to just inform the row of the new size and have
|
||||
// it resize and re-align its cells...
|
||||
nsTableCellFrame *cellFrame;
|
||||
aRowFrame->FirstChild((nsIFrame*&)cellFrame);
|
||||
while (nsnull != cellFrame)
|
||||
{
|
||||
PRInt32 rowSpan = ((nsTableFrame*)mGeometricParent)->GetEffectiveRowSpan(aRowIndex,
|
||||
cellFrame);
|
||||
if (1==rowSpan)
|
||||
{
|
||||
// resize the cell's height
|
||||
nsSize cellFrameSize;
|
||||
cellFrame->GetSize(cellFrameSize);
|
||||
cellFrame->SizeTo(cellFrameSize.width, aMaxCellHeight);
|
||||
|
||||
// realign cell content based on the new height
|
||||
cellFrame->VerticallyAlignChild(aPresContext);
|
||||
}
|
||||
else
|
||||
{
|
||||
aHasRowSpanningCell = PR_TRUE;
|
||||
}
|
||||
|
||||
// Get the next cell
|
||||
cellFrame->GetNextSibling((nsIFrame*&)cellFrame);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
void nsTableRowGroupFrame::ShrinkWrapChildren(nsIPresContext* aPresContext,
|
||||
|
@ -909,12 +860,9 @@ void nsTableRowGroupFrame::ShrinkWrapChildren(nsIPresContext* aPresContext,
|
|||
rowHeights[rowIndex] = maxRowHeight;
|
||||
|
||||
// resize the row
|
||||
PRBool hasRowSpanningCell;
|
||||
SetRowHeight(aPresContext, rowFrame, rowIndex, maxRowHeight, maxCellHeight,
|
||||
hasRowSpanningCell);
|
||||
if (hasRowSpanningCell) {
|
||||
atLeastOneRowSpanningCell = PR_TRUE;
|
||||
}
|
||||
nsSize rowFrameSize;
|
||||
rowFrame->GetSize(rowFrameSize);
|
||||
rowFrame->SizeTo(rowFrameSize.width, maxRowHeight);
|
||||
|
||||
// Update the running row group height
|
||||
rowGroupHeight += maxRowHeight;
|
||||
|
|
|
@ -123,13 +123,6 @@ protected:
|
|||
nsReflowMetrics& aDesiredSize,
|
||||
nsSize* aMaxElementSize);
|
||||
|
||||
void SetRowHeight(nsIPresContext* aPresContext,
|
||||
nsIFrame* aRowFrame,
|
||||
PRInt32 aRowIndex,
|
||||
nscoord aRowHeight,
|
||||
nscoord aMaxCellHeight,
|
||||
PRBool& aHasRowSpanningCell);
|
||||
|
||||
/**
|
||||
* Reflow the frames we've already created
|
||||
*
|
||||
|
|
|
@ -398,6 +398,11 @@ PRInt32 nsTableFrame::GetRowCount ()
|
|||
// return the rows spanned by aCell starting at aRowIndex
|
||||
// note that this is different from just the rowspan of aCell
|
||||
// (that would be GetEffectiveRowSpan (indexOfRowThatContains_aCell, aCell)
|
||||
//
|
||||
// XXX This code should be in the table row group frame instead, and it
|
||||
// should clip rows spans so they don't extend past a row group rather than
|
||||
// clip to the table itself. Before that can happen the code that builds the
|
||||
// cell map needs to take row groups into account
|
||||
PRInt32 nsTableFrame::GetEffectiveRowSpan (PRInt32 aRowIndex, nsTableCellFrame *aCell)
|
||||
{
|
||||
NS_PRECONDITION (nsnull!=aCell, "bad cell arg");
|
||||
|
|
|
@ -105,6 +105,42 @@ nsTableRowFrame::~nsTableRowFrame()
|
|||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Post-reflow hook. This is where the table row does its post-processing
|
||||
*/
|
||||
NS_METHOD
|
||||
nsTableRowFrame::DidReflow(nsIPresContext& aPresContext,
|
||||
nsDidReflowStatus aStatus)
|
||||
{
|
||||
if (NS_FRAME_REFLOW_FINISHED == aStatus) {
|
||||
// Resize and re-align the cell frames based on our row height
|
||||
nscoord cellHeight = mRect.height - mCellMaxTopMargin - mCellMaxBottomMargin;
|
||||
nsTableCellFrame *cellFrame = (nsTableCellFrame*)mFirstChild;
|
||||
nsTableFrame* tableFrame;
|
||||
mContentParent->GetContentParent((nsIFrame*&)tableFrame);
|
||||
while (nsnull != cellFrame)
|
||||
{
|
||||
PRInt32 rowSpan = tableFrame->GetEffectiveRowSpan(mRowIndex, cellFrame);
|
||||
if (1==rowSpan)
|
||||
{
|
||||
// resize the cell's height
|
||||
nsSize cellFrameSize;
|
||||
cellFrame->GetSize(cellFrameSize);
|
||||
cellFrame->SizeTo(cellFrameSize.width, cellHeight);
|
||||
|
||||
// realign cell content based on the new height
|
||||
cellFrame->VerticallyAlignChild(&aPresContext);
|
||||
}
|
||||
|
||||
// Get the next cell
|
||||
cellFrame->GetNextSibling((nsIFrame*&)cellFrame);
|
||||
}
|
||||
}
|
||||
|
||||
// Let our base class do the usual work
|
||||
return nsContainerFrame::DidReflow(aPresContext, aStatus);
|
||||
}
|
||||
|
||||
void nsTableRowFrame::ResetMaxChildHeight()
|
||||
{
|
||||
mTallestCell=0;
|
||||
|
|
|
@ -94,6 +94,9 @@ public:
|
|||
const nsReflowState& aReflowState,
|
||||
nsReflowStatus& aStatus);
|
||||
|
||||
NS_IMETHOD DidReflow(nsIPresContext& aPresContext,
|
||||
nsDidReflowStatus aStatus);
|
||||
|
||||
/** @see nsContainerFrame::CreateContinuingFrame */
|
||||
NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext,
|
||||
nsIFrame* aParent,
|
||||
|
|
|
@ -827,55 +827,6 @@ nsTableRowGroupFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by ShrinkWrapChildren() to set the height of a table row. Resizes
|
||||
* the table row, each of the row's table cells, and then realigns the cell
|
||||
* content based on the new height
|
||||
*/
|
||||
void nsTableRowGroupFrame::SetRowHeight(nsIPresContext* aPresContext,
|
||||
nsIFrame* aRowFrame,
|
||||
PRInt32 aRowIndex,
|
||||
nscoord aRowHeight,
|
||||
nscoord aMaxCellHeight,
|
||||
PRBool& aHasRowSpanningCell)
|
||||
{
|
||||
// initialize out parameter
|
||||
aHasRowSpanningCell = PR_FALSE;
|
||||
|
||||
// set the row's height
|
||||
nsSize rowFrameSize;
|
||||
aRowFrame->GetSize(rowFrameSize);
|
||||
aRowFrame->SizeTo(rowFrameSize.width, aRowHeight);
|
||||
|
||||
// resize all the cells based on the max cell height
|
||||
// XXX It would be better to just inform the row of the new size and have
|
||||
// it resize and re-align its cells...
|
||||
nsTableCellFrame *cellFrame;
|
||||
aRowFrame->FirstChild((nsIFrame*&)cellFrame);
|
||||
while (nsnull != cellFrame)
|
||||
{
|
||||
PRInt32 rowSpan = ((nsTableFrame*)mGeometricParent)->GetEffectiveRowSpan(aRowIndex,
|
||||
cellFrame);
|
||||
if (1==rowSpan)
|
||||
{
|
||||
// resize the cell's height
|
||||
nsSize cellFrameSize;
|
||||
cellFrame->GetSize(cellFrameSize);
|
||||
cellFrame->SizeTo(cellFrameSize.width, aMaxCellHeight);
|
||||
|
||||
// realign cell content based on the new height
|
||||
cellFrame->VerticallyAlignChild(aPresContext);
|
||||
}
|
||||
else
|
||||
{
|
||||
aHasRowSpanningCell = PR_TRUE;
|
||||
}
|
||||
|
||||
// Get the next cell
|
||||
cellFrame->GetNextSibling((nsIFrame*&)cellFrame);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
void nsTableRowGroupFrame::ShrinkWrapChildren(nsIPresContext* aPresContext,
|
||||
|
@ -909,12 +860,9 @@ void nsTableRowGroupFrame::ShrinkWrapChildren(nsIPresContext* aPresContext,
|
|||
rowHeights[rowIndex] = maxRowHeight;
|
||||
|
||||
// resize the row
|
||||
PRBool hasRowSpanningCell;
|
||||
SetRowHeight(aPresContext, rowFrame, rowIndex, maxRowHeight, maxCellHeight,
|
||||
hasRowSpanningCell);
|
||||
if (hasRowSpanningCell) {
|
||||
atLeastOneRowSpanningCell = PR_TRUE;
|
||||
}
|
||||
nsSize rowFrameSize;
|
||||
rowFrame->GetSize(rowFrameSize);
|
||||
rowFrame->SizeTo(rowFrameSize.width, maxRowHeight);
|
||||
|
||||
// Update the running row group height
|
||||
rowGroupHeight += maxRowHeight;
|
||||
|
|
|
@ -123,13 +123,6 @@ protected:
|
|||
nsReflowMetrics& aDesiredSize,
|
||||
nsSize* aMaxElementSize);
|
||||
|
||||
void SetRowHeight(nsIPresContext* aPresContext,
|
||||
nsIFrame* aRowFrame,
|
||||
PRInt32 aRowIndex,
|
||||
nscoord aRowHeight,
|
||||
nscoord aMaxCellHeight,
|
||||
PRBool& aHasRowSpanningCell);
|
||||
|
||||
/**
|
||||
* Reflow the frames we've already created
|
||||
*
|
||||
|
|
Загрузка…
Ссылка в новой задаче