Don't page-break before or after a repeated frame. b=278983 r+sr=bzbarsky

This commit is contained in:
mats.palmgren%bredband.net 2005-02-05 04:23:52 +00:00
Родитель 3965eb1eb3
Коммит 92858c988e
4 изменённых файлов: 20 добавлений и 6 удалений

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

@ -365,21 +365,29 @@ nsTableFrame::RePositionViews(nsIFrame* aFrame)
nsContainerFrame::PositionChildViews(aFrame);
}
static PRBool
IsRepeatedFrame(nsIFrame* kidFrame)
{
return (kidFrame->GetType() == nsLayoutAtoms::tableRowFrame ||
kidFrame->GetType() == nsLayoutAtoms::tableRowGroupFrame) &&
(kidFrame->GetStateBits() & NS_REPEATED_ROW_OR_ROWGROUP);
}
PRBool
nsTableFrame::PageBreakAfter(nsIFrame& aSourceFrame,
nsIFrame* aNextFrame)
{
const nsStyleDisplay* display = aSourceFrame.GetStyleDisplay();
// don't allow a page break after a repeated header
if (display->mBreakAfter && (NS_STYLE_DISPLAY_TABLE_HEADER_GROUP != display->mDisplay)) {
return PR_TRUE;
// don't allow a page break after a repeated element ...
if (display->mBreakAfter && !IsRepeatedFrame(&aSourceFrame)) {
return !(aNextFrame && IsRepeatedFrame(aNextFrame)); // or before
}
if (aNextFrame) {
display = aNextFrame->GetStyleDisplay();
// don't allow a page break before a repeated footer
if (display->mBreakBefore && (NS_STYLE_DISPLAY_TABLE_FOOTER_GROUP != display->mDisplay)) {
return PR_TRUE;
// don't allow a page break before a repeated element ...
if (display->mBreakBefore && !IsRepeatedFrame(aNextFrame)) {
return !IsRepeatedFrame(&aSourceFrame); // or after
}
}
return PR_FALSE;

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

@ -51,6 +51,8 @@ class nsReflowTimer;
#define NS_ROW_NEED_SPECIAL_REFLOW 0x20000000
#define NS_TABLE_ROW_HAS_UNPAGINATED_HEIGHT 0x40000000
// This is also used on rows, from nsTableRowGroupFrame.h
// #define NS_REPEATED_ROW_OR_ROWGROUP 0x10000000
/**
* nsTableRowFrame is the frame that maps table rows

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

@ -158,7 +158,9 @@ nsTableRowGroupFrame::InitRepeatedFrame(nsPresContext* aPresContext,
{
nsTableRowFrame* copyRowFrame = GetFirstRow();
nsTableRowFrame* originalRowFrame = aHeaderFooterFrame->GetFirstRow();
AddStateBits(NS_REPEATED_ROW_OR_ROWGROUP);
while (copyRowFrame && originalRowFrame) {
copyRowFrame->AddStateBits(NS_REPEATED_ROW_OR_ROWGROUP);
int rowIndex = originalRowFrame->GetRowIndex();
copyRowFrame->SetRowIndex(rowIndex);

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

@ -87,6 +87,8 @@ struct nsRowGroupReflowState {
#define NS_ROWGROUP_HAS_STYLE_HEIGHT 0x40000000
// we need a 3rd pass reflow to deal with pct height nested tables
#define NS_ROWGROUP_NEED_SPECIAL_REFLOW 0x20000000
// the next is also used on rows (see nsTableRowGroupFrame::InitRepeatedFrame)
#define NS_REPEATED_ROW_OR_ROWGROUP 0x10000000
/**
* nsTableRowGroupFrame is the frame that maps row groups
* (HTML tags THEAD, TFOOT, and TBODY). This class cannot be reused