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
This commit is contained in:
Emily McDonough 2021-08-12 23:31:19 +00:00
Родитель 8e4871f297
Коммит 21ced21400
1 изменённых файлов: 13 добавлений и 10 удалений

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

@ -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<nsDisplayHeaderFooter>(aBuilder, this);