Bug 1640197 - Part 4: Create more pages for vertical overflow r=dholbert,mats

Depends on D90425

Differential Revision: https://phabricator.services.mozilla.com/D90426
This commit is contained in:
Miko Mynttinen 2020-10-28 18:33:52 +00:00
parent 8f780ba14a
commit 96bcc0ad72
3 changed files with 36 additions and 1 deletions

View File

@ -156,8 +156,15 @@ void nsAbsoluteContainingBlock::Reflow(nsContainerFrame* aDelegatingFrame,
const nsRect& aContainingBlock,
AbsPosReflowFlags aFlags,
nsOverflowAreas* aOverflowAreas) {
nsReflowStatus reflowStatus;
// PageContentFrame replicates fixed pos children so we really don't want
// them contributing to overflow areas because that means we'll create new
// pages ad infinitum if one of them overflows the page.
if (aDelegatingFrame->IsPageContentFrame()) {
MOZ_ASSERT(mChildListID == nsAtomicContainerFrame::kFixedList);
aOverflowAreas = nullptr;
}
nsReflowStatus reflowStatus;
const bool reflowAll = aReflowInput.ShouldReflowAllKids();
const bool isGrid = !!(aFlags & AbsPosReflowFlags::IsGridContainerCB);
nsIFrame* kidFrame;

View File

@ -6,6 +6,7 @@
#include "nsPageContentFrame.h"
#include "mozilla/PresShell.h"
#include "mozilla/StaticPrefs_layout.h"
#include "nsCSSFrameConstructor.h"
#include "nsPresContext.h"
@ -114,6 +115,29 @@ void nsPageContentFrame::Reflow(nsPresContext* aPresContext,
}
FinishAndStoreOverflow(&aReflowOutput);
if (StaticPrefs::layout_display_list_improve_fragmentation() &&
mFrames.NotEmpty()) {
auto* previous = static_cast<nsPageContentFrame*>(GetPrevContinuation());
const nscoord previousPageOverflow =
previous ? previous->mRemainingOverflow : 0;
const nscoord overflowHeight = InkOverflowRect().YMost();
const nscoord pageHeight = GetRect().Height();
const nscoord currentPageOverflow = overflowHeight - pageHeight;
nscoord remainingOverflow =
std::max(currentPageOverflow, previousPageOverflow - pageHeight);
if (aStatus.IsFullyComplete() && remainingOverflow > 0) {
// If we have InkOverflow off the end of our page, then we report
// ourselves as overflow-incomplete in order to produce an additional
// content-less page, which we expect to draw our InkOverflow on our
// behalf.
aStatus.SetOverflowIncomplete();
}
mRemainingOverflow = std::max(remainingOverflow, 0);
}
NS_FRAME_SET_TRUNCATION(aStatus, aReflowInput, aReflowOutput);
}

View File

@ -57,6 +57,10 @@ class nsPageContentFrame final : public mozilla::ViewportFrame {
// Note: this will be set before reflow, and it's strongly owned by our
// nsPageSequenceFrame, which outlives us.
nsSharedPageData* mPD = nullptr;
// The combined InkOverflow from the previous and current page that does not
// yet have space allocated for it.
nscoord mRemainingOverflow = 0;
};
#endif /* nsPageContentFrame_h___ */