Bug 539356. Make PruneDisplayListForExtraPage prune print preview properly. r=mattwoodrow

PruneDisplayListForExtraPage wasn't pruning properly in print preview. It
was pruning to the RootReferenceFrame, which is per-page when printing normally,
but is the ancestor of all pages in print preview, so it wasn't doing anything in
print preview.
So, pass in the nsPageFrame we want to prune to. This prevents bogus
entirely-clipped-out display items appearing in the display list for the page.
This commit is contained in:
Robert O'Callahan 2012-09-28 23:19:39 +12:00
Родитель d2d71eb564
Коммит 6c9ec69e94
1 изменённых файлов: 12 добавлений и 10 удалений

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

@ -363,6 +363,7 @@ nsPageFrame::DrawHeaderFooter(nsRenderingContext& aRenderingContext,
* Remove all leaf display items that are not for descendants of
* aBuilder->GetReferenceFrame() from aList, and move all nsDisplayClip
* wrappers to their correct locations.
* @param aPage the page we're constructing the display list for
* @param aExtraPage the page we constructed aList for
* @param aY the Y-coordinate where aPage would be positioned relative
* to the main page (aBuilder->GetReferenceFrame()), considering only
@ -371,11 +372,10 @@ nsPageFrame::DrawHeaderFooter(nsRenderingContext& aRenderingContext,
*/
static void
PruneDisplayListForExtraPage(nsDisplayListBuilder* aBuilder,
nsIFrame* aExtraPage, nscoord aY, nsDisplayList* aList)
nsPageFrame* aPage, nsIFrame* aExtraPage,
nscoord aY, nsDisplayList* aList)
{
nsDisplayList newList;
// The page which we're really constructing a display list for
nsIFrame* mainPage = aBuilder->RootReferenceFrame();
while (true) {
nsDisplayItem* i = aList->RemoveBottom();
@ -383,7 +383,7 @@ PruneDisplayListForExtraPage(nsDisplayListBuilder* aBuilder,
break;
nsDisplayList* subList = i->GetList();
if (subList) {
PruneDisplayListForExtraPage(aBuilder, aExtraPage, aY, subList);
PruneDisplayListForExtraPage(aBuilder, aPage, aExtraPage, aY, subList);
nsDisplayItem::Type type = i->GetType();
if (type == nsDisplayItem::TYPE_CLIP ||
type == nsDisplayItem::TYPE_CLIP_ROUNDED_RECT) {
@ -400,12 +400,12 @@ PruneDisplayListForExtraPage(nsDisplayListBuilder* aBuilder,
// (bug 426909).
nsDisplayClip* clip = static_cast<nsDisplayClip*>(i);
clip->SetClipRect(clip->GetClipRect() + nsPoint(0, aY) -
aExtraPage->GetOffsetTo(mainPage));
aExtraPage->GetOffsetTo(aBuilder->FindReferenceFrameFor(aPage)));
}
newList.AppendToTop(i);
} else {
nsIFrame* f = i->GetUnderlyingFrame();
if (f && nsLayoutUtils::IsProperAncestorFrameCrossDoc(mainPage, f)) {
if (f && nsLayoutUtils::IsProperAncestorFrameCrossDoc(aPage, f)) {
// This one is in the page we care about, keep it
newList.AppendToTop(i);
} else {
@ -421,7 +421,8 @@ PruneDisplayListForExtraPage(nsDisplayListBuilder* aBuilder,
static nsresult
BuildDisplayListForExtraPage(nsDisplayListBuilder* aBuilder,
nsIFrame* aPage, nscoord aY, nsDisplayList* aList)
nsPageFrame* aPage, nsIFrame* aExtraPage,
nscoord aY, nsDisplayList* aList)
{
nsDisplayList list;
// Pass an empty dirty rect since we're only interested in finding
@ -430,10 +431,11 @@ BuildDisplayListForExtraPage(nsDisplayListBuilder* aBuilder,
// have already been marked as NS_FRAME_FORCE_DISPLAY_LIST_DESCEND_INTO.
// Note that we should still do a prune step since we don't want to
// rely on dirty-rect checking for correctness.
nsresult rv = aPage->BuildDisplayListForStackingContext(aBuilder, nsRect(), &list);
nsresult rv =
aExtraPage->BuildDisplayListForStackingContext(aBuilder, nsRect(), &list);
if (NS_FAILED(rv))
return rv;
PruneDisplayListForExtraPage(aBuilder, aPage, aY, &list);
PruneDisplayListForExtraPage(aBuilder, aPage, aExtraPage, aY, &list);
aList->AppendToTop(&list);
return NS_OK;
}
@ -498,7 +500,7 @@ nsPageFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
nsIFrame* page = child;
nscoord y = child->GetSize().height;
while ((page = GetNextPage(page)) != nullptr) {
rv = BuildDisplayListForExtraPage(aBuilder, page, y, &content);
rv = BuildDisplayListForExtraPage(aBuilder, this, page, y, &content);
if (NS_FAILED(rv))
break;
y += page->GetSize().height;