Bug 1717703 Part 1 - Set display list clipping rect for nsPageFrame children to use the content size. r=emilio,mattwoodrow
authorEmily McDonough <emcdonough@mozilla.com>
Fri, 16 Jul 2021 19:47:48 +0000
changeset 585767 1a2bbe2775867a382f6c155c4a50e831e7cd039e
parent 585766 0d307662db0f5204ea6286e95e885d8ab12c57e8
child 585768 f46839a3cf869168e295850f9fea9f854f2122c8
push id146444
push useremcdonough@mozilla.com
push dateFri, 16 Jul 2021 19:50:21 +0000
treeherderautoland@f46839a3cf86 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio, mattwoodrow
bugs1717703
milestone92.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1717703 Part 1 - Set display list clipping rect for nsPageFrame children to use the content size. r=emilio,mattwoodrow Without explicitly setting the clipping rect to the specified page size, the building rect of the display lists will be kept to the size of the nsPageFrame. This means that any content in the nsPageContentFrame which is larger than the physical paper size will be clipped. The actual content frames are scaled down when this is too large, so no overdraw will occur. Differential Revision: https://phabricator.services.mozilla.com/D119459
layout/generic/nsPageFrame.cpp
--- a/layout/generic/nsPageFrame.cpp
+++ b/layout/generic/nsPageFrame.cpp
@@ -580,25 +580,37 @@ nsSize nsPageFrame::ComputePageSize() co
   } else {
     MOZ_ASSERT(pageSize.IsAuto(), "Impossible page-size value?");
   }
   return size;
 }
 
 void nsPageFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
                                    const nsDisplayListSet& aLists) {
-  nsPresContext* pc = PresContext();
   nsDisplayList content;
   nsDisplayListSet set(&content, &content, &content, &content, &content,
                        &content);
   {
     DisplayListClipState::AutoSaveRestore clipState(aBuilder);
     clipState.Clear();
 
+    // We need to extend the building rect to include the specified page size,
+    // in case it is larger than the physical page size. In that case the
+    // nsPageFrame will be the size of the physical page, but the child
+    // nsPageContentFrame will be the larger specified page size.
+    // The more correct way to do this would be to fully reverse the result of
+    // ComputePagesPerSheetAndPageSizeTransform to handle this scaling, but
+    // this should have the same result and is easier.
+    const nsRect pageContentRect({0, 0}, ComputePageSize());
+    nsDisplayListBuilder::AutoBuildingDisplayList buildingForPageContentFrame(
+        aBuilder, this, pageContentRect, pageContentRect);
+
     nsContainerFrame::BuildDisplayList(aBuilder, set);
+
+    nsPresContext* const pc = PresContext();
     if (pc->IsRootPaginatedDocument()) {
       content.AppendNewToTop<nsDisplayHeaderFooter>(aBuilder, this);
 
       // For print-preview, show margin guides if requested in the settings.
       if (pc->Type() == nsPresContext::eContext_PrintPreview &&
           mPD->mPrintSettings->GetShowMarginGuides()) {
         content.AppendNewToTop<nsDisplayGeneric>(
             aBuilder, this, PaintMarginGuides, "MarginGuides",