From 21ced2140051bf6329b310f510d14adfd00b9839 Mon Sep 17 00:00:00 2001 From: Emily McDonough Date: Thu, 12 Aug 2021 23:31:19 +0000 Subject: [PATCH] Bug 1722890 Part 1 - Apply page scaling to the clipping rect for page content frames r=dholbert Differential Revision: https://phabricator.services.mozilla.com/D122291 --- layout/generic/nsPageFrame.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/layout/generic/nsPageFrame.cpp b/layout/generic/nsPageFrame.cpp index d3d9357c56dc..d08ccc360c3c 100644 --- a/layout/generic/nsPageFrame.cpp +++ b/layout/generic/nsPageFrame.cpp @@ -592,20 +592,23 @@ void nsPageFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, 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()); + // We need to extend the building rect to include the specified page size + // (scaled by the print scaling factor), 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. + nsPresContext* const pc = PresContext(); + const float scale = pc->GetPageScale(); + const nsSize pageSize = ComputePageSize(); + const nsRect scaledPageRect{0, 0, NSToCoordCeil(pageSize.width / scale), + NSToCoordCeil(pageSize.height / scale)}; nsDisplayListBuilder::AutoBuildingDisplayList buildingForPageContentFrame( - aBuilder, this, pageContentRect, pageContentRect); + aBuilder, this, scaledPageRect, scaledPageRect); nsContainerFrame::BuildDisplayList(aBuilder, set); - nsPresContext* const pc = PresContext(); if (pc->IsRootPaginatedDocument()) { content.AppendNewToTop(aBuilder, this);