Bug 792314 - Build full display lists for nsSimplePageSequence. r=roc

This commit is contained in:
Matt Woodrow 2012-09-20 11:26:35 +12:00
parent ef42a8465e
commit 42b0095718
3 changed files with 15 additions and 43 deletions

View File

@ -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<nsSimplePageSequenceFrame*>(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;
}

View File

@ -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();

View File

@ -4,6 +4,6 @@
</head>
<body>
<!-- A 10x10 red image --><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAFElEQVQYlWP4z8DwnxjMMKqQvgoBksPHOVp9kXEAAAAASUVORK5CYII=">
<!-- A 10x10 red image --><img style="-moz-transform: perspective(1px)" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAFElEQVQYlWP4z8DwnxjMMKqQvgoBksPHOVp9kXEAAAAASUVORK5CYII=">
</body>
</html>