Bug 427017: Disable page-break-before/after for fixed- & absolutely-positioned elements. Also, fix assertion during an iterator-comparison by handling case where lineBox is in overflow-lines. r=fantasai sr=roc a1.9=beltzner

This commit is contained in:
dholbert@cs.stanford.edu 2008-04-11 22:32:49 -07:00
Родитель dceef468ff
Коммит fa2eeaf551
8 изменённых файлов: 45 добавлений и 4 удалений

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

@ -7489,6 +7489,13 @@ nsCSSFrameConstructor::ConstructSVGFrame(nsFrameConstructorState& aState,
}
#endif // MOZ_SVG
// If page-break-before is set, this function constructs a page break frame,
// EXCEPT for on these types of elements:
// * row groups, rows, cells (these are handled internally by tables)
// * fixed- and absolutely-positioned elements (currently, our positioning
// code doesn't expect positioned frames to have nsPageBreakFrame siblings)
//
// Returns true iff we should construct a page break frame after this element.
PRBool
nsCSSFrameConstructor::PageBreakBefore(nsFrameConstructorState& aState,
nsIContent* aContent,
@ -7498,9 +7505,9 @@ nsCSSFrameConstructor::PageBreakBefore(nsFrameConstructorState& aState,
{
const nsStyleDisplay* display = aStyleContext->GetStyleDisplay();
// See if page-break-before is set for all elements except row groups, rows, cells
// (these are handled internally by tables) and construct a page break frame if so.
if (NS_STYLE_DISPLAY_NONE != display->mDisplay &&
NS_STYLE_POSITION_FIXED != display->mPosition &&
NS_STYLE_POSITION_ABSOLUTE != display->mPosition &&
(NS_STYLE_DISPLAY_TABLE == display->mDisplay ||
!IsTableRelated(display->mDisplay, PR_TRUE))) {
if (display->mBreakBefore) {

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

@ -5160,10 +5160,16 @@ nsBlockInFlowLineIterator::nsBlockInFlowLineIterator(nsBlockFrame* aFrame,
} while (Next());
}
nsBlockFrame::line_iterator
nsBlockInFlowLineIterator::End()
{
return mInOverflowLines ? mInOverflowLines->end() : mFrame->end_lines();
}
PRBool
nsBlockInFlowLineIterator::IsLastLineInList()
{
line_iterator end = mInOverflowLines ? mInOverflowLines->end() : mFrame->end_lines();
line_iterator end = End();
return mLine != end && mLine.next() == end;
}

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

@ -706,6 +706,13 @@ public:
PRBool IsLastLineInList();
nsBlockFrame* GetContainer() { return mFrame; }
PRBool GetInOverflow() { return mInOverflowLines != nsnull; }
/**
* Returns the end-iterator of whatever line list we're in.
*/
line_iterator End();
/**
* Returns false if there are no more lines. After this has returned false,
* don't call any methods on this object again.

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

@ -950,7 +950,7 @@ nsHTMLReflowState::CalculateHypotheticalBox(nsPresContext* aPresContext,
// this line.
// XXXbz the line box is not fully reflown yet if our containing block is
// relatively positioned...
if (lineBox != blockFrame->end_lines()) {
if (lineBox != iter.End()) {
nsIFrame * firstFrame = lineBox->mFirstChild;
PRBool found = PR_FALSE;
PRBool allEmpty = PR_TRUE;

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

@ -601,6 +601,12 @@ nsPageBreakFrame::GetIntrinsicWidth()
return nsPresContext::CSSPixelsToAppUnits(1);
}
nscoord
nsPageBreakFrame::GetIntrinsicHeight()
{
return 0;
}
nsresult
nsPageBreakFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,

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

@ -143,6 +143,7 @@ class nsPageBreakFrame : public nsLeafFrame {
protected:
virtual nscoord GetIntrinsicWidth();
virtual nscoord GetIntrinsicHeight();
PRBool mHaveReflowed;

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

@ -0,0 +1,13 @@
<html xmlns="http://www.w3.org/1999/xhtml" class="reftest-print">
<body>
<div style="position: absolute; border: 5px solid black;">
<div style="position: fixed; page-break-before: left;"/>
<div style="display: table-header-group; page-break-after: right;">
<div style="position: absolute;">
<div style="position: fixed;"/>
</div>
</div>
<div style="display: table-footer-group;"/>
</div>
</body>
</html>

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

@ -797,3 +797,4 @@ fails-if(MOZ_WIDGET_TOOLKIT=="gtk2") == 424074-1-ref2.xul 424074-1-ref3.xul
== 425972-1.html 425972-1-ref.html
== 425972-2.html 425972-2-ref.html
!= 425972-1.html 425972-2.html
!= 427017-1.xhtml about:blank # crash test (needs reftest-print)