From 57a0ff75ad7318299d70d79842ebce5005381983 Mon Sep 17 00:00:00 2001 From: Timothy Nikkel Date: Mon, 6 Dec 2021 01:08:55 +0000 Subject: [PATCH] Bug 1743533. Handle the visible rect of oop iframes that span multiple pages in print documents. r=botond Differential Revision: https://phabricator.services.mozilla.com/D132789 --- layout/painting/nsDisplayList.cpp | 22 ++++++++++++++++++++++ layout/painting/nsDisplayList.h | 5 ++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/layout/painting/nsDisplayList.cpp b/layout/painting/nsDisplayList.cpp index 498c81e22f88..5d485dde9e6e 100644 --- a/layout/painting/nsDisplayList.cpp +++ b/layout/painting/nsDisplayList.cpp @@ -742,6 +742,28 @@ void nsDisplayListBuilder::BeginFrame() { } } +void nsDisplayListBuilder::AddEffectUpdate(dom::RemoteBrowser* aBrowser, + const dom::EffectsInfo& aUpdate) { + dom::EffectsInfo update = aUpdate; + // For printing we create one display item for each page that an iframe + // appears on, the proper visible rect is the union of all the visible rects + // we get from each display item. + nsPresContext* pc = + mReferenceFrame ? mReferenceFrame->PresContext() : nullptr; + if (pc && (pc->Type() != nsPresContext::eContext_Galley)) { + Maybe existing = mEffectsUpdates.MaybeGet(aBrowser); + if (existing.isSome()) { + // Only the visible rect should differ, the scales should match. + MOZ_ASSERT(existing->mScaleX == aUpdate.mScaleX && + existing->mScaleY == aUpdate.mScaleY && + existing->mTransformToAncestorScale == + aUpdate.mTransformToAncestorScale); + update.mVisibleRect = update.mVisibleRect.Union(existing->mVisibleRect); + } + } + mEffectsUpdates.InsertOrUpdate(aBrowser, update); +} + void nsDisplayListBuilder::EndFrame() { NS_ASSERTION(!mInInvalidSubtree, "Someone forgot to cleanup mInInvalidSubtree!"); diff --git a/layout/painting/nsDisplayList.h b/layout/painting/nsDisplayList.h index 03949363b05e..a9a31664903d 100644 --- a/layout/painting/nsDisplayList.h +++ b/layout/painting/nsDisplayList.h @@ -875,9 +875,8 @@ class nsDisplayListBuilder { return mEffectsUpdates; } - void AddEffectUpdate(dom::RemoteBrowser* aBrowser, dom::EffectsInfo aUpdate) { - mEffectsUpdates.InsertOrUpdate(aBrowser, aUpdate); - } + void AddEffectUpdate(dom::RemoteBrowser* aBrowser, + const dom::EffectsInfo& aUpdate); /** * Allocate memory in our arena. It will only be freed when this display list