зеркало из https://github.com/mozilla/pjs.git
bug 57467 - print a new row on the current page if it will waste too much space otherwise. sr=attinasi.
This commit is contained in:
Родитель
b0e435e189
Коммит
46aa2d1bf9
|
@ -125,7 +125,7 @@ struct nsTableReflowState {
|
|||
|
||||
availSize.height = aAvailHeight;
|
||||
if (NS_UNCONSTRAINEDSIZE != availSize.height) {
|
||||
availSize.height -= borderPadding.top + borderPadding.bottom;
|
||||
availSize.height -= borderPadding.top + borderPadding.bottom + (2 * table->GetCellSpacingY());
|
||||
}
|
||||
|
||||
footerFrame = nsnull;
|
||||
|
@ -1828,6 +1828,7 @@ NS_METHOD nsTableFrame::Reflow(nsIPresContext* aPresContext,
|
|||
haveReflowedColGroups = HaveReflowedColGroups();
|
||||
}
|
||||
// Constrain our reflow width to the computed table width (of the 1st in flow).
|
||||
// and our reflow height to our avail height minus border, padding, cellspacing
|
||||
aDesiredSize.width = GetDesiredWidth();
|
||||
nsTableReflowState reflowState(aReflowState, *this, nextReason,
|
||||
aDesiredSize.width, aReflowState.availableHeight);
|
||||
|
|
|
@ -778,6 +778,8 @@ nsTableRowFrame::ReflowChildren(nsIPresContext* aPresContext,
|
|||
if (!tableFrame) return NS_ERROR_NULL_POINTER;
|
||||
nsIFrame* tablePrevInFlow;
|
||||
tableFrame->GetPrevInFlow(&tablePrevInFlow);
|
||||
PRBool isPaginated;
|
||||
aPresContext->IsPaginated(&isPaginated);
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
|
@ -837,13 +839,12 @@ nsTableRowFrame::ReflowChildren(nsIPresContext* aPresContext,
|
|||
|
||||
// If the available width is the same as last time we reflowed the cell,then
|
||||
// use the previous desired size and max element size (else clause). We can't
|
||||
// do this if our height is constrained or the cell frame has a next-in-flow
|
||||
// do this in paganated mode or for a style change reflow.
|
||||
nsIFrame* kidNextInFlow;
|
||||
kidFrame->GetNextInFlow(&kidNextInFlow);
|
||||
if ((aReflowState.availableHeight != NS_UNCONSTRAINEDSIZE) ||
|
||||
(availWidth != cellFrame->GetPriorAvailWidth()) ||
|
||||
if ((availWidth != cellFrame->GetPriorAvailWidth()) ||
|
||||
(eReflowReason_StyleChange == aReflowState.reason) ||
|
||||
kidNextInFlow) {
|
||||
isPaginated) {
|
||||
// Reflow the cell to fit the available width, height
|
||||
nsSize kidAvailSize(availWidth, aReflowState.availableHeight);
|
||||
nsReflowReason reason = eReflowReason_Resize;
|
||||
|
@ -1228,7 +1229,7 @@ nsTableRowFrame::Reflow(nsIPresContext* aPresContext,
|
|||
|
||||
switch (aReflowState.reason) {
|
||||
case eReflowReason_Initial:
|
||||
rv = ReflowChildren(aPresContext, aDesiredSize, aReflowState, *tableFrame, aStatus, PR_TRUE);
|
||||
rv = ReflowChildren(aPresContext, aDesiredSize, aReflowState, *tableFrame, aStatus, PR_FALSE);
|
||||
#ifdef WHY
|
||||
if (!tableFrame->IsAutoLayout()) {
|
||||
// this resize reflow is necessary to place the cells correctly in the case of rowspans and colspans.
|
||||
|
|
|
@ -808,19 +808,27 @@ nsTableRowGroupFrame::SplitRowGroup(nsIPresContext* aPresContext,
|
|||
{
|
||||
nsIFrame* prevRowFrame = nsnull;
|
||||
nsresult rv = NS_OK;
|
||||
float p2t;
|
||||
aPresContext->GetPixelsToTwips(&p2t);
|
||||
|
||||
nscoord heightTaken = 0;
|
||||
nscoord availWidth = nsTableFrame::RoundToPixel(aReflowState.availableWidth, p2t);
|
||||
nscoord availHeight = nsTableFrame::RoundToPixel(aReflowState.availableHeight, p2t);
|
||||
|
||||
// Walk each of the row frames looking for the first row frame that
|
||||
// doesn't fit in the available space
|
||||
for (nsIFrame* rowFrame = GetFirstFrame(); rowFrame; GetNextFrame(rowFrame, &rowFrame)) {
|
||||
PRBool rowIsOnCurrentPage = PR_TRUE;
|
||||
nsRect bounds;
|
||||
|
||||
rowFrame->GetRect(bounds);
|
||||
if (bounds.YMost() > aReflowState.availableHeight) {
|
||||
// If this is the first row frame then we need to split it
|
||||
if (!prevRowFrame) {
|
||||
if (bounds.YMost() > availHeight) {
|
||||
nscoord pageHeight;
|
||||
aPresContext->GetPageHeight(&pageHeight);
|
||||
// reflow the row in the availabe space and have it split if it is the 1st
|
||||
// row or there is at least 20% of the current page available
|
||||
if (!prevRowFrame || (availHeight - heightTaken > pageHeight / 5)) {
|
||||
// Reflow the row in the available space and have it split
|
||||
nsSize availSize(aReflowState.availableWidth,
|
||||
aReflowState.availableHeight - bounds.y);
|
||||
nsSize availSize(availWidth, availHeight - bounds.y);
|
||||
nsHTMLReflowState rowReflowState(aPresContext, aReflowState, rowFrame,
|
||||
availSize, eReflowReason_Resize);
|
||||
nsHTMLReflowMetrics desiredSize(nsnull);
|
||||
|
@ -830,7 +838,7 @@ nsTableRowGroupFrame::SplitRowGroup(nsIPresContext* aPresContext,
|
|||
rowFrame->SizeTo(aPresContext, desiredSize.width, desiredSize.height);
|
||||
rowFrame->DidReflow(aPresContext, NS_FRAME_REFLOW_FINISHED);
|
||||
((nsTableRowFrame *)rowFrame)->DidResize(aPresContext, aReflowState);
|
||||
aDesiredSize.height = desiredSize.height;
|
||||
aDesiredSize.height = availHeight;
|
||||
|
||||
if (NS_FRAME_IS_NOT_COMPLETE(aStatus)) {
|
||||
#ifdef NS_DEBUG
|
||||
|
@ -866,6 +874,11 @@ nsTableRowGroupFrame::SplitRowGroup(nsIPresContext* aPresContext,
|
|||
} else {
|
||||
// The row frame is complete. It may be the case that it's minimum
|
||||
// height was greater than the available height we gave it
|
||||
if (prevRowFrame) {
|
||||
// put the row on the next page since it needs more height than it was given
|
||||
rowIsOnCurrentPage = PR_FALSE;
|
||||
}
|
||||
else {
|
||||
nsIFrame* nextRowFrame;
|
||||
|
||||
// Push the frame that follows
|
||||
|
@ -875,9 +888,13 @@ nsTableRowGroupFrame::SplitRowGroup(nsIPresContext* aPresContext,
|
|||
PushChildren(aPresContext, nextRowFrame, rowFrame);
|
||||
}
|
||||
aStatus = nextRowFrame ? NS_FRAME_NOT_COMPLETE : NS_FRAME_COMPLETE;
|
||||
aDesiredSize.height = bounds.YMost();
|
||||
}
|
||||
}
|
||||
}
|
||||
else rowIsOnCurrentPage = PR_FALSE;
|
||||
|
||||
} else {
|
||||
if (!rowIsOnCurrentPage) {
|
||||
// See whether the row frame has cells that span into it
|
||||
const nsStyleDisplay *display;
|
||||
rowFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)display));
|
||||
|
@ -940,12 +957,12 @@ nsTableRowGroupFrame::SplitRowGroup(nsIPresContext* aPresContext,
|
|||
// Push this row frame and those that follow to the next-in-flow
|
||||
PushChildren(aPresContext, rowFrame, prevRowFrame);
|
||||
aStatus = NS_FRAME_NOT_COMPLETE;
|
||||
aDesiredSize.height = bounds.y;
|
||||
aDesiredSize.height = bounds.y - aTableFrame->GetCellSpacingY();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
heightTaken = bounds.YMost();
|
||||
prevRowFrame = rowFrame;
|
||||
}
|
||||
|
||||
|
@ -1000,15 +1017,10 @@ nsTableRowGroupFrame::Reflow(nsIPresContext* aPresContext,
|
|||
PRBool isPaginated;
|
||||
aPresContext->IsPaginated(&isPaginated);
|
||||
if (isPaginated) {
|
||||
PRBool repeatable = PR_FALSE;
|
||||
nsCOMPtr<nsIDeviceContext> dc;
|
||||
rv = aPresContext->GetDeviceContext(getter_AddRefs(dc));
|
||||
if (NS_SUCCEEDED(rv) && dc) {
|
||||
PRInt32 pageWidth, pageHeight;
|
||||
dc->GetDeviceSurfaceDimensions(pageWidth, pageHeight);
|
||||
nscoord pageHeight;
|
||||
aPresContext->GetPageHeight(&pageHeight);
|
||||
// don't repeat the thead or tfoot unless it is < 25% of the page height
|
||||
repeatable = (aDesiredSize.height < (pageHeight / 4));
|
||||
}
|
||||
PRBool repeatable = (aDesiredSize.height < (pageHeight / 4));
|
||||
SetRepeatable(repeatable);
|
||||
}
|
||||
// shrink wrap rows to height of tallest cell in that row
|
||||
|
@ -1020,7 +1032,9 @@ nsTableRowGroupFrame::Reflow(nsIPresContext* aPresContext,
|
|||
// reflow, then we need to do this because the table will skip the pass 2 reflow,
|
||||
// but we need to correctly calculate the row group height and we can't if there
|
||||
// are row spans unless we do this step
|
||||
if ((eReflowReason_Initial != aReflowState.reason) || isTableUnconstrainedReflow) {
|
||||
if ((eReflowReason_Initial != aReflowState.reason) ||
|
||||
isTableUnconstrainedReflow ||
|
||||
isPaginated) {
|
||||
CalculateRowHeights(aPresContext, aDesiredSize, aReflowState);
|
||||
haveDesiredHeight = PR_TRUE;
|
||||
}
|
||||
|
|
|
@ -125,7 +125,7 @@ struct nsTableReflowState {
|
|||
|
||||
availSize.height = aAvailHeight;
|
||||
if (NS_UNCONSTRAINEDSIZE != availSize.height) {
|
||||
availSize.height -= borderPadding.top + borderPadding.bottom;
|
||||
availSize.height -= borderPadding.top + borderPadding.bottom + (2 * table->GetCellSpacingY());
|
||||
}
|
||||
|
||||
footerFrame = nsnull;
|
||||
|
@ -1828,6 +1828,7 @@ NS_METHOD nsTableFrame::Reflow(nsIPresContext* aPresContext,
|
|||
haveReflowedColGroups = HaveReflowedColGroups();
|
||||
}
|
||||
// Constrain our reflow width to the computed table width (of the 1st in flow).
|
||||
// and our reflow height to our avail height minus border, padding, cellspacing
|
||||
aDesiredSize.width = GetDesiredWidth();
|
||||
nsTableReflowState reflowState(aReflowState, *this, nextReason,
|
||||
aDesiredSize.width, aReflowState.availableHeight);
|
||||
|
|
|
@ -778,6 +778,8 @@ nsTableRowFrame::ReflowChildren(nsIPresContext* aPresContext,
|
|||
if (!tableFrame) return NS_ERROR_NULL_POINTER;
|
||||
nsIFrame* tablePrevInFlow;
|
||||
tableFrame->GetPrevInFlow(&tablePrevInFlow);
|
||||
PRBool isPaginated;
|
||||
aPresContext->IsPaginated(&isPaginated);
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
|
@ -837,13 +839,12 @@ nsTableRowFrame::ReflowChildren(nsIPresContext* aPresContext,
|
|||
|
||||
// If the available width is the same as last time we reflowed the cell,then
|
||||
// use the previous desired size and max element size (else clause). We can't
|
||||
// do this if our height is constrained or the cell frame has a next-in-flow
|
||||
// do this in paganated mode or for a style change reflow.
|
||||
nsIFrame* kidNextInFlow;
|
||||
kidFrame->GetNextInFlow(&kidNextInFlow);
|
||||
if ((aReflowState.availableHeight != NS_UNCONSTRAINEDSIZE) ||
|
||||
(availWidth != cellFrame->GetPriorAvailWidth()) ||
|
||||
if ((availWidth != cellFrame->GetPriorAvailWidth()) ||
|
||||
(eReflowReason_StyleChange == aReflowState.reason) ||
|
||||
kidNextInFlow) {
|
||||
isPaginated) {
|
||||
// Reflow the cell to fit the available width, height
|
||||
nsSize kidAvailSize(availWidth, aReflowState.availableHeight);
|
||||
nsReflowReason reason = eReflowReason_Resize;
|
||||
|
@ -1228,7 +1229,7 @@ nsTableRowFrame::Reflow(nsIPresContext* aPresContext,
|
|||
|
||||
switch (aReflowState.reason) {
|
||||
case eReflowReason_Initial:
|
||||
rv = ReflowChildren(aPresContext, aDesiredSize, aReflowState, *tableFrame, aStatus, PR_TRUE);
|
||||
rv = ReflowChildren(aPresContext, aDesiredSize, aReflowState, *tableFrame, aStatus, PR_FALSE);
|
||||
#ifdef WHY
|
||||
if (!tableFrame->IsAutoLayout()) {
|
||||
// this resize reflow is necessary to place the cells correctly in the case of rowspans and colspans.
|
||||
|
|
|
@ -808,19 +808,27 @@ nsTableRowGroupFrame::SplitRowGroup(nsIPresContext* aPresContext,
|
|||
{
|
||||
nsIFrame* prevRowFrame = nsnull;
|
||||
nsresult rv = NS_OK;
|
||||
float p2t;
|
||||
aPresContext->GetPixelsToTwips(&p2t);
|
||||
|
||||
nscoord heightTaken = 0;
|
||||
nscoord availWidth = nsTableFrame::RoundToPixel(aReflowState.availableWidth, p2t);
|
||||
nscoord availHeight = nsTableFrame::RoundToPixel(aReflowState.availableHeight, p2t);
|
||||
|
||||
// Walk each of the row frames looking for the first row frame that
|
||||
// doesn't fit in the available space
|
||||
for (nsIFrame* rowFrame = GetFirstFrame(); rowFrame; GetNextFrame(rowFrame, &rowFrame)) {
|
||||
PRBool rowIsOnCurrentPage = PR_TRUE;
|
||||
nsRect bounds;
|
||||
|
||||
rowFrame->GetRect(bounds);
|
||||
if (bounds.YMost() > aReflowState.availableHeight) {
|
||||
// If this is the first row frame then we need to split it
|
||||
if (!prevRowFrame) {
|
||||
if (bounds.YMost() > availHeight) {
|
||||
nscoord pageHeight;
|
||||
aPresContext->GetPageHeight(&pageHeight);
|
||||
// reflow the row in the availabe space and have it split if it is the 1st
|
||||
// row or there is at least 20% of the current page available
|
||||
if (!prevRowFrame || (availHeight - heightTaken > pageHeight / 5)) {
|
||||
// Reflow the row in the available space and have it split
|
||||
nsSize availSize(aReflowState.availableWidth,
|
||||
aReflowState.availableHeight - bounds.y);
|
||||
nsSize availSize(availWidth, availHeight - bounds.y);
|
||||
nsHTMLReflowState rowReflowState(aPresContext, aReflowState, rowFrame,
|
||||
availSize, eReflowReason_Resize);
|
||||
nsHTMLReflowMetrics desiredSize(nsnull);
|
||||
|
@ -830,7 +838,7 @@ nsTableRowGroupFrame::SplitRowGroup(nsIPresContext* aPresContext,
|
|||
rowFrame->SizeTo(aPresContext, desiredSize.width, desiredSize.height);
|
||||
rowFrame->DidReflow(aPresContext, NS_FRAME_REFLOW_FINISHED);
|
||||
((nsTableRowFrame *)rowFrame)->DidResize(aPresContext, aReflowState);
|
||||
aDesiredSize.height = desiredSize.height;
|
||||
aDesiredSize.height = availHeight;
|
||||
|
||||
if (NS_FRAME_IS_NOT_COMPLETE(aStatus)) {
|
||||
#ifdef NS_DEBUG
|
||||
|
@ -866,6 +874,11 @@ nsTableRowGroupFrame::SplitRowGroup(nsIPresContext* aPresContext,
|
|||
} else {
|
||||
// The row frame is complete. It may be the case that it's minimum
|
||||
// height was greater than the available height we gave it
|
||||
if (prevRowFrame) {
|
||||
// put the row on the next page since it needs more height than it was given
|
||||
rowIsOnCurrentPage = PR_FALSE;
|
||||
}
|
||||
else {
|
||||
nsIFrame* nextRowFrame;
|
||||
|
||||
// Push the frame that follows
|
||||
|
@ -875,9 +888,13 @@ nsTableRowGroupFrame::SplitRowGroup(nsIPresContext* aPresContext,
|
|||
PushChildren(aPresContext, nextRowFrame, rowFrame);
|
||||
}
|
||||
aStatus = nextRowFrame ? NS_FRAME_NOT_COMPLETE : NS_FRAME_COMPLETE;
|
||||
aDesiredSize.height = bounds.YMost();
|
||||
}
|
||||
}
|
||||
}
|
||||
else rowIsOnCurrentPage = PR_FALSE;
|
||||
|
||||
} else {
|
||||
if (!rowIsOnCurrentPage) {
|
||||
// See whether the row frame has cells that span into it
|
||||
const nsStyleDisplay *display;
|
||||
rowFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)display));
|
||||
|
@ -940,12 +957,12 @@ nsTableRowGroupFrame::SplitRowGroup(nsIPresContext* aPresContext,
|
|||
// Push this row frame and those that follow to the next-in-flow
|
||||
PushChildren(aPresContext, rowFrame, prevRowFrame);
|
||||
aStatus = NS_FRAME_NOT_COMPLETE;
|
||||
aDesiredSize.height = bounds.y;
|
||||
aDesiredSize.height = bounds.y - aTableFrame->GetCellSpacingY();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
heightTaken = bounds.YMost();
|
||||
prevRowFrame = rowFrame;
|
||||
}
|
||||
|
||||
|
@ -1000,15 +1017,10 @@ nsTableRowGroupFrame::Reflow(nsIPresContext* aPresContext,
|
|||
PRBool isPaginated;
|
||||
aPresContext->IsPaginated(&isPaginated);
|
||||
if (isPaginated) {
|
||||
PRBool repeatable = PR_FALSE;
|
||||
nsCOMPtr<nsIDeviceContext> dc;
|
||||
rv = aPresContext->GetDeviceContext(getter_AddRefs(dc));
|
||||
if (NS_SUCCEEDED(rv) && dc) {
|
||||
PRInt32 pageWidth, pageHeight;
|
||||
dc->GetDeviceSurfaceDimensions(pageWidth, pageHeight);
|
||||
nscoord pageHeight;
|
||||
aPresContext->GetPageHeight(&pageHeight);
|
||||
// don't repeat the thead or tfoot unless it is < 25% of the page height
|
||||
repeatable = (aDesiredSize.height < (pageHeight / 4));
|
||||
}
|
||||
PRBool repeatable = (aDesiredSize.height < (pageHeight / 4));
|
||||
SetRepeatable(repeatable);
|
||||
}
|
||||
// shrink wrap rows to height of tallest cell in that row
|
||||
|
@ -1020,7 +1032,9 @@ nsTableRowGroupFrame::Reflow(nsIPresContext* aPresContext,
|
|||
// reflow, then we need to do this because the table will skip the pass 2 reflow,
|
||||
// but we need to correctly calculate the row group height and we can't if there
|
||||
// are row spans unless we do this step
|
||||
if ((eReflowReason_Initial != aReflowState.reason) || isTableUnconstrainedReflow) {
|
||||
if ((eReflowReason_Initial != aReflowState.reason) ||
|
||||
isTableUnconstrainedReflow ||
|
||||
isPaginated) {
|
||||
CalculateRowHeights(aPresContext, aDesiredSize, aReflowState);
|
||||
haveDesiredHeight = PR_TRUE;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче