From dbc26c185f0edb5f3a4dbeb1f4c0e386e055c280 Mon Sep 17 00:00:00 2001 From: Emily McDonough Date: Thu, 17 Aug 2023 17:05:15 +0000 Subject: [PATCH] Bug 1848407 - Ensure that zero-height block frame lines will be placed on the next page when break-after: page is set. r=dholbert Differential Revision: https://phabricator.services.mozilla.com/D186061 --- layout/generic/nsBlockFrame.cpp | 12 +++++++ .../abspos-overflow-hidden-001-print-ref.html | 25 +++++++++++++++ .../abspos-overflow-hidden-001-print.html | 31 +++++++++++++++++++ .../zero-height-page-break-001-print-ref.html | 9 ++++++ .../zero-height-page-break-001-print.html | 14 +++++++++ 5 files changed, 91 insertions(+) create mode 100644 testing/web-platform/tests/css/css-break/abspos-overflow-hidden-001-print-ref.html create mode 100644 testing/web-platform/tests/css/css-break/abspos-overflow-hidden-001-print.html create mode 100644 testing/web-platform/tests/css/css-break/zero-height-page-break-001-print-ref.html create mode 100644 testing/web-platform/tests/css/css-break/zero-height-page-break-001-print.html diff --git a/layout/generic/nsBlockFrame.cpp b/layout/generic/nsBlockFrame.cpp index 12a4327559ce..252d91d50a29 100644 --- a/layout/generic/nsBlockFrame.cpp +++ b/layout/generic/nsBlockFrame.cpp @@ -3761,6 +3761,18 @@ void nsBlockFrame::ReflowBlockFrame(BlockReflowState& aState, return; } + // If the previous frame was a page-break-frame, then preemptively push this + // frame to the next page. + // This is primarily important for the placeholders for abspos frames, which + // measure as zero height and then would be placed on this page. + if (aState.ContentBSize() != NS_UNCONSTRAINEDSIZE) { + const nsIFrame* const prev = frame->GetPrevSibling(); + if (prev && prev->IsPageBreakFrame()) { + PushTruncatedLine(aState, aLine, aKeepReflowGoing); + return; + } + } + // Prepare the block reflow engine nsBlockReflowContext brc(aState.mPresContext, aState.mReflowInput); diff --git a/testing/web-platform/tests/css/css-break/abspos-overflow-hidden-001-print-ref.html b/testing/web-platform/tests/css/css-break/abspos-overflow-hidden-001-print-ref.html new file mode 100644 index 000000000000..08f69ef6a1e8 --- /dev/null +++ b/testing/web-platform/tests/css/css-break/abspos-overflow-hidden-001-print-ref.html @@ -0,0 +1,25 @@ + + + Absolute position frame inside 'overflow: hidden' immediately after a forced page break + + + +
+
111
+
+
+
222
+
+ + diff --git a/testing/web-platform/tests/css/css-break/abspos-overflow-hidden-001-print.html b/testing/web-platform/tests/css/css-break/abspos-overflow-hidden-001-print.html new file mode 100644 index 000000000000..12d8a679ad73 --- /dev/null +++ b/testing/web-platform/tests/css/css-break/abspos-overflow-hidden-001-print.html @@ -0,0 +1,31 @@ + + + Absolute position frame inside 'overflow: hidden' immediately after a forced page break + + + + + + +
+
111
+
+
+
222
+
+ + diff --git a/testing/web-platform/tests/css/css-break/zero-height-page-break-001-print-ref.html b/testing/web-platform/tests/css/css-break/zero-height-page-break-001-print-ref.html new file mode 100644 index 000000000000..d56687c9e525 --- /dev/null +++ b/testing/web-platform/tests/css/css-break/zero-height-page-break-001-print-ref.html @@ -0,0 +1,9 @@ + + + Zero height box immediately after a forced page-break + + +
Page 1
+
+ + diff --git a/testing/web-platform/tests/css/css-break/zero-height-page-break-001-print.html b/testing/web-platform/tests/css/css-break/zero-height-page-break-001-print.html new file mode 100644 index 000000000000..3e3fb82628a1 --- /dev/null +++ b/testing/web-platform/tests/css/css-break/zero-height-page-break-001-print.html @@ -0,0 +1,14 @@ + + + Zero height box immediately after a forced page-break + + + + + + + +
Page 1
+
+ +