зеркало из https://github.com/mozilla/pjs.git
bug 57378 (table portion) - don't repeat a thead or tfoot that is larger than 25% of the page. a=buster, r=attinasi.
This commit is contained in:
Родитель
a4b1f04c3b
Коммит
7021f8c112
|
@ -10832,32 +10832,33 @@ nsCSSFrameConstructor::CreateContinuingTableFrame(nsIPresShell* aPresShell,
|
|||
|
||||
if ((NS_STYLE_DISPLAY_TABLE_HEADER_GROUP == display->mDisplay) ||
|
||||
(NS_STYLE_DISPLAY_TABLE_FOOTER_GROUP == display->mDisplay)) {
|
||||
|
||||
// Replicate the header/footer frame
|
||||
nsIFrame* headerFooterFrame;
|
||||
nsFrameItems childItems;
|
||||
nsIContent* headerFooter;
|
||||
nsFrameConstructorState state(aPresContext, mFixedContainingBlock,
|
||||
GetAbsoluteContainingBlock(aPresContext, newFrame),
|
||||
nsnull, nsnull);
|
||||
// Replicate the header/footer frame if it is not too tall
|
||||
if (((nsTableRowGroupFrame*)rowGroupFrame)->IsRepeatable()) {
|
||||
nsIFrame* headerFooterFrame;
|
||||
nsFrameItems childItems;
|
||||
nsIContent* headerFooter;
|
||||
nsFrameConstructorState state(aPresContext, mFixedContainingBlock,
|
||||
GetAbsoluteContainingBlock(aPresContext, newFrame),
|
||||
nsnull, nsnull);
|
||||
|
||||
NS_NewTableRowGroupFrame(aPresShell, &headerFooterFrame);
|
||||
rowGroupFrame->GetContent(&headerFooter);
|
||||
headerFooterFrame->Init(aPresContext, headerFooter, newFrame,
|
||||
rowGroupStyle, nsnull);
|
||||
nsTableCreator tableCreator(aPresShell);
|
||||
ProcessChildren(aPresShell, aPresContext, state, headerFooter, headerFooterFrame,
|
||||
PR_FALSE, childItems, PR_FALSE, &tableCreator);
|
||||
NS_ASSERTION(!state.mFloatedItems.childList, "unexpected floated element");
|
||||
NS_RELEASE(headerFooter);
|
||||
headerFooterFrame->SetInitialChildList(aPresContext, nsnull, childItems.childList);
|
||||
NS_NewTableRowGroupFrame(aPresShell, &headerFooterFrame);
|
||||
rowGroupFrame->GetContent(&headerFooter);
|
||||
headerFooterFrame->Init(aPresContext, headerFooter, newFrame,
|
||||
rowGroupStyle, nsnull);
|
||||
nsTableCreator tableCreator(aPresShell);
|
||||
ProcessChildren(aPresShell, aPresContext, state, headerFooter, headerFooterFrame,
|
||||
PR_FALSE, childItems, PR_FALSE, &tableCreator);
|
||||
NS_ASSERTION(!state.mFloatedItems.childList, "unexpected floated element");
|
||||
NS_RELEASE(headerFooter);
|
||||
headerFooterFrame->SetInitialChildList(aPresContext, nsnull, childItems.childList);
|
||||
|
||||
// Table specific initialization
|
||||
((nsTableRowGroupFrame*)headerFooterFrame)->InitRepeatedFrame
|
||||
(aPresContext, (nsTableRowGroupFrame*)rowGroupFrame);
|
||||
// Table specific initialization
|
||||
((nsTableRowGroupFrame*)headerFooterFrame)->InitRepeatedFrame
|
||||
(aPresContext, (nsTableRowGroupFrame*)rowGroupFrame);
|
||||
|
||||
// XXX Deal with absolute and fixed frames...
|
||||
childFrames.AddChild(headerFooterFrame);
|
||||
// XXX Deal with absolute and fixed frames...
|
||||
childFrames.AddChild(headerFooterFrame);
|
||||
}
|
||||
}
|
||||
|
||||
NS_RELEASE(rowGroupStyle);
|
||||
|
|
|
@ -10832,32 +10832,33 @@ nsCSSFrameConstructor::CreateContinuingTableFrame(nsIPresShell* aPresShell,
|
|||
|
||||
if ((NS_STYLE_DISPLAY_TABLE_HEADER_GROUP == display->mDisplay) ||
|
||||
(NS_STYLE_DISPLAY_TABLE_FOOTER_GROUP == display->mDisplay)) {
|
||||
|
||||
// Replicate the header/footer frame
|
||||
nsIFrame* headerFooterFrame;
|
||||
nsFrameItems childItems;
|
||||
nsIContent* headerFooter;
|
||||
nsFrameConstructorState state(aPresContext, mFixedContainingBlock,
|
||||
GetAbsoluteContainingBlock(aPresContext, newFrame),
|
||||
nsnull, nsnull);
|
||||
// Replicate the header/footer frame if it is not too tall
|
||||
if (((nsTableRowGroupFrame*)rowGroupFrame)->IsRepeatable()) {
|
||||
nsIFrame* headerFooterFrame;
|
||||
nsFrameItems childItems;
|
||||
nsIContent* headerFooter;
|
||||
nsFrameConstructorState state(aPresContext, mFixedContainingBlock,
|
||||
GetAbsoluteContainingBlock(aPresContext, newFrame),
|
||||
nsnull, nsnull);
|
||||
|
||||
NS_NewTableRowGroupFrame(aPresShell, &headerFooterFrame);
|
||||
rowGroupFrame->GetContent(&headerFooter);
|
||||
headerFooterFrame->Init(aPresContext, headerFooter, newFrame,
|
||||
rowGroupStyle, nsnull);
|
||||
nsTableCreator tableCreator(aPresShell);
|
||||
ProcessChildren(aPresShell, aPresContext, state, headerFooter, headerFooterFrame,
|
||||
PR_FALSE, childItems, PR_FALSE, &tableCreator);
|
||||
NS_ASSERTION(!state.mFloatedItems.childList, "unexpected floated element");
|
||||
NS_RELEASE(headerFooter);
|
||||
headerFooterFrame->SetInitialChildList(aPresContext, nsnull, childItems.childList);
|
||||
NS_NewTableRowGroupFrame(aPresShell, &headerFooterFrame);
|
||||
rowGroupFrame->GetContent(&headerFooter);
|
||||
headerFooterFrame->Init(aPresContext, headerFooter, newFrame,
|
||||
rowGroupStyle, nsnull);
|
||||
nsTableCreator tableCreator(aPresShell);
|
||||
ProcessChildren(aPresShell, aPresContext, state, headerFooter, headerFooterFrame,
|
||||
PR_FALSE, childItems, PR_FALSE, &tableCreator);
|
||||
NS_ASSERTION(!state.mFloatedItems.childList, "unexpected floated element");
|
||||
NS_RELEASE(headerFooter);
|
||||
headerFooterFrame->SetInitialChildList(aPresContext, nsnull, childItems.childList);
|
||||
|
||||
// Table specific initialization
|
||||
((nsTableRowGroupFrame*)headerFooterFrame)->InitRepeatedFrame
|
||||
(aPresContext, (nsTableRowGroupFrame*)rowGroupFrame);
|
||||
// Table specific initialization
|
||||
((nsTableRowGroupFrame*)headerFooterFrame)->InitRepeatedFrame
|
||||
(aPresContext, (nsTableRowGroupFrame*)rowGroupFrame);
|
||||
|
||||
// XXX Deal with absolute and fixed frames...
|
||||
childFrames.AddChild(headerFooterFrame);
|
||||
// XXX Deal with absolute and fixed frames...
|
||||
childFrames.AddChild(headerFooterFrame);
|
||||
}
|
||||
}
|
||||
|
||||
NS_RELEASE(rowGroupStyle);
|
||||
|
|
|
@ -1094,6 +1094,21 @@ nsTableRowGroupFrame::Reflow(nsIPresContext* aPresContext,
|
|||
aDesiredSize.width = aReflowState.availableWidth;
|
||||
aDesiredSize.height = state.y;
|
||||
|
||||
// determine if the row group is repeatable in paginated mode
|
||||
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);
|
||||
// don't repeat the thead or tfoot unless it is < 25% of the page height
|
||||
repeatable = (aDesiredSize.height < (pageHeight / 4));
|
||||
}
|
||||
SetRepeatable(repeatable);
|
||||
}
|
||||
// account for scroll bars. XXX needs optimization/caching
|
||||
if (nsnull != aDesiredSize.maxElementSize) {
|
||||
nsIAtom* pseudoTag;
|
||||
|
|
|
@ -74,6 +74,9 @@ struct RowGroupReflowState {
|
|||
{ 0xe940e7bc, 0xb534, 0x11d2, \
|
||||
{ 0x95, 0xa2, 0x0, 0x60, 0xb0, 0xc3, 0x44, 0x14 } }
|
||||
|
||||
// use a bit from nsFrame's frame state bits to determine whether a
|
||||
// thead or tfoot should be repeated on every printed page
|
||||
#define NS_ROWGROUP_REPEATABLE 0x80000000
|
||||
/**
|
||||
* nsTableRowGroupFrame is the frame that maps row groups
|
||||
* (HTML tags THEAD, TFOOT, and TBODY). This class cannot be reused
|
||||
|
@ -332,6 +335,8 @@ public:
|
|||
virtual void GetNextFrame(nsIFrame* aFrame, nsIFrame** aResult) { aFrame->GetNextSibling(aResult); };
|
||||
virtual PRBool RowsDesireExcessSpace() { return PR_TRUE; };
|
||||
virtual PRBool RowGroupDesiresExcessSpace() { return PR_TRUE; };
|
||||
PRBool IsRepeatable();
|
||||
void SetRepeatable(PRBool aRepeatable);
|
||||
|
||||
private:
|
||||
nsSize mMaxElementSize;
|
||||
|
@ -343,5 +348,18 @@ inline void nsTableRowGroupFrame::GetMaxElementSize(nsSize& aMaxElementSize) con
|
|||
aMaxElementSize = mMaxElementSize;
|
||||
}
|
||||
|
||||
inline PRBool nsTableRowGroupFrame::IsRepeatable()
|
||||
{
|
||||
return (mState & NS_ROWGROUP_REPEATABLE) == NS_ROWGROUP_REPEATABLE;
|
||||
}
|
||||
|
||||
inline void nsTableRowGroupFrame::SetRepeatable(PRBool aRepeatable)
|
||||
{
|
||||
if (aRepeatable) {
|
||||
mState |= NS_ROWGROUP_REPEATABLE;
|
||||
} else {
|
||||
mState &= ~NS_ROWGROUP_REPEATABLE;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
<table border=1>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>inside thead
|
||||
</thead>
|
||||
<tr>
|
||||
<td>inside tbody</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
|
@ -40,7 +40,8 @@ file:///s|/mozilla/layout/html/tests/table/bugs/bug53690-1.html
|
|||
file:///s|/mozilla/layout/html/tests/table/bugs/bug53690-2.html
|
||||
file:///s|/mozilla/layout/html/tests/table/bugs/bug5797.html
|
||||
file:///s|/mozilla/layout/html/tests/table/bugs/bug5538.html
|
||||
file:///s|/mozilla/layout/html/tests/table/bugs/bug5798.html
|
||||
file:///s|/mozilla/layout/html/tests/table/bugs/bug5538.html
|
||||
file:///s|/mozilla/layout/html/tests/table/bugs/bug57378.html
|
||||
file:///s|/mozilla/layout/html/tests/table/bugs/bug5799.html
|
||||
file:///s|/mozilla/layout/html/tests/table/bugs/bug5835.html
|
||||
file:///s|/mozilla/layout/html/tests/table/bugs/bug5838.html
|
||||
|
|
|
@ -1094,6 +1094,21 @@ nsTableRowGroupFrame::Reflow(nsIPresContext* aPresContext,
|
|||
aDesiredSize.width = aReflowState.availableWidth;
|
||||
aDesiredSize.height = state.y;
|
||||
|
||||
// determine if the row group is repeatable in paginated mode
|
||||
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);
|
||||
// don't repeat the thead or tfoot unless it is < 25% of the page height
|
||||
repeatable = (aDesiredSize.height < (pageHeight / 4));
|
||||
}
|
||||
SetRepeatable(repeatable);
|
||||
}
|
||||
// account for scroll bars. XXX needs optimization/caching
|
||||
if (nsnull != aDesiredSize.maxElementSize) {
|
||||
nsIAtom* pseudoTag;
|
||||
|
|
|
@ -74,6 +74,9 @@ struct RowGroupReflowState {
|
|||
{ 0xe940e7bc, 0xb534, 0x11d2, \
|
||||
{ 0x95, 0xa2, 0x0, 0x60, 0xb0, 0xc3, 0x44, 0x14 } }
|
||||
|
||||
// use a bit from nsFrame's frame state bits to determine whether a
|
||||
// thead or tfoot should be repeated on every printed page
|
||||
#define NS_ROWGROUP_REPEATABLE 0x80000000
|
||||
/**
|
||||
* nsTableRowGroupFrame is the frame that maps row groups
|
||||
* (HTML tags THEAD, TFOOT, and TBODY). This class cannot be reused
|
||||
|
@ -332,6 +335,8 @@ public:
|
|||
virtual void GetNextFrame(nsIFrame* aFrame, nsIFrame** aResult) { aFrame->GetNextSibling(aResult); };
|
||||
virtual PRBool RowsDesireExcessSpace() { return PR_TRUE; };
|
||||
virtual PRBool RowGroupDesiresExcessSpace() { return PR_TRUE; };
|
||||
PRBool IsRepeatable();
|
||||
void SetRepeatable(PRBool aRepeatable);
|
||||
|
||||
private:
|
||||
nsSize mMaxElementSize;
|
||||
|
@ -343,5 +348,18 @@ inline void nsTableRowGroupFrame::GetMaxElementSize(nsSize& aMaxElementSize) con
|
|||
aMaxElementSize = mMaxElementSize;
|
||||
}
|
||||
|
||||
inline PRBool nsTableRowGroupFrame::IsRepeatable()
|
||||
{
|
||||
return (mState & NS_ROWGROUP_REPEATABLE) == NS_ROWGROUP_REPEATABLE;
|
||||
}
|
||||
|
||||
inline void nsTableRowGroupFrame::SetRepeatable(PRBool aRepeatable)
|
||||
{
|
||||
if (aRepeatable) {
|
||||
mState |= NS_ROWGROUP_REPEATABLE;
|
||||
} else {
|
||||
mState &= ~NS_ROWGROUP_REPEATABLE;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Загрузка…
Ссылка в новой задаче