From 42b00957181cc0a62c824f9a8940d85b5ad8f5ff Mon Sep 17 00:00:00 2001 From: Matt Woodrow Date: Thu, 20 Sep 2012 11:26:35 +1200 Subject: [PATCH] Bug 792314 - Build full display lists for nsSimplePageSequence. r=roc --- layout/generic/nsSimplePageSequence.cpp | 52 ++++++---------------- layout/generic/nsSimplePageSequence.h | 4 -- layout/reftests/printing/745025-1-ref.html | 2 +- 3 files changed, 15 insertions(+), 43 deletions(-) diff --git a/layout/generic/nsSimplePageSequence.cpp b/layout/generic/nsSimplePageSequence.cpp index 01121fcbcf4d..05490b928464 100644 --- a/layout/generic/nsSimplePageSequence.cpp +++ b/layout/generic/nsSimplePageSequence.cpp @@ -815,42 +815,11 @@ nsSimplePageSequenceFrame::DoPageEnd() return rv; } -static void PaintPageSequence(nsIFrame* aFrame, nsRenderingContext* aCtx, - const nsRect& aDirtyRect, nsPoint aPt) +static gfx3DMatrix +ComputePageSequenceTransform(nsIFrame* aFrame, float aAppUnitsPerPixel) { - static_cast(aFrame)->PaintPageSequence(*aCtx, aDirtyRect, aPt); -} - -//------------------------------------------------------------------------------ -void -nsSimplePageSequenceFrame::PaintPageSequence(nsRenderingContext& aRenderingContext, - const nsRect& aDirtyRect, - nsPoint aPt) { - nsRect rect = aDirtyRect; - float scale = PresContext()->GetPrintPreviewScale(); - aRenderingContext.PushState(); - nsPoint framePos = aPt; - aRenderingContext.Translate(framePos); - rect -= framePos; - aRenderingContext.Scale(scale, scale); - rect.ScaleRoundOut(1.0f / scale); - - // Now the rect and the rendering coordinates are are relative to this frame. - // Loop over the pages and paint them. - nsIFrame* child = GetFirstPrincipalChild(); - while (child) { - nsPoint pt = child->GetPosition(); - // The rendering context has to be translated before each call to PaintFrame - aRenderingContext.PushState(); - aRenderingContext.Translate(pt); - nsLayoutUtils::PaintFrame(&aRenderingContext, child, - nsRegion(rect - pt), NS_RGBA(0,0,0,0), - nsLayoutUtils::PAINT_SYNC_DECODE_IMAGES); - aRenderingContext.PopState(); - child = child->GetNextSibling(); - } - - aRenderingContext.PopState(); + float scale = aFrame->PresContext()->GetPrintPreviewScale(); + return gfx3DMatrix::ScalingMatrix(scale, scale, 1); } NS_IMETHODIMP @@ -861,11 +830,18 @@ nsSimplePageSequenceFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, nsresult rv = DisplayBorderBackgroundOutline(aBuilder, aLists); NS_ENSURE_SUCCESS(rv, rv); - rv = aLists.Content()->AppendNewToTop(new (aBuilder) - nsDisplayGeneric(aBuilder, this, ::PaintPageSequence, "PageSequence", - nsDisplayItem::TYPE_PAGE_SEQUENCE)); + nsDisplayList content; + nsIFrame* child = GetFirstPrincipalChild(); + while (child) { + rv = child->BuildDisplayListForStackingContext(aBuilder, aDirtyRect - child->GetOffsetTo(this), &content); + NS_ENSURE_SUCCESS(rv, rv); + child = child->GetNextSibling(); + } + + rv = content.AppendNewToTop(new (aBuilder) nsDisplayTransform(aBuilder, this, &content, ::ComputePageSequenceTransform)); NS_ENSURE_SUCCESS(rv, rv); + aLists.Content()->AppendToTop(&content); return NS_OK; } diff --git a/layout/generic/nsSimplePageSequence.h b/layout/generic/nsSimplePageSequence.h index e5a8ff73ec57..c4474b981351 100644 --- a/layout/generic/nsSimplePageSequence.h +++ b/layout/generic/nsSimplePageSequence.h @@ -106,10 +106,6 @@ public: NS_IMETHOD GetFrameName(nsAString& aResult) const; #endif - void PaintPageSequence(nsRenderingContext& aRenderingContext, - const nsRect& aDirtyRect, - nsPoint aPt); - protected: nsSimplePageSequenceFrame(nsStyleContext* aContext); virtual ~nsSimplePageSequenceFrame(); diff --git a/layout/reftests/printing/745025-1-ref.html b/layout/reftests/printing/745025-1-ref.html index 34b106a966ba..44f0b10dabdf 100644 --- a/layout/reftests/printing/745025-1-ref.html +++ b/layout/reftests/printing/745025-1-ref.html @@ -4,6 +4,6 @@ - +