diff --git a/mozilla/layout/base/nsIPresShell.h b/mozilla/layout/base/nsIPresShell.h index 72011ea894d..dc7e1468d73 100644 --- a/mozilla/layout/base/nsIPresShell.h +++ b/mozilla/layout/base/nsIPresShell.h @@ -694,7 +694,7 @@ public: * @param aRect is the region to capture into the offscreen buffer, in the * root frame's coordinate system (if aIgnoreViewportScrolling is false) * or in the root scrolled frame's coordinate system - * (if aIgnoreViewportScrolling is true) + * (if aIgnoreViewportScrolling is true). The coordinates are in appunits. * @param aUntrusted set to PR_TRUE if the contents may be passed to malicious * agents. E.g. we might choose not to paint the contents of sensitive widgets * such as the file name in a file upload widget, and we might choose not @@ -702,7 +702,9 @@ public: * @param aIgnoreViewportScrolling ignore clipping/scrolling/scrollbar painting * due to scrolling in the viewport * @param aBackgroundColor a background color to render onto - * @param aRenderedContext the gfxContext to render to + * @param aRenderedContext the gfxContext to render to. We render so that + * one CSS pixel in the source document is rendered to one unit in the current + * transform. */ NS_IMETHOD RenderDocument(const nsRect& aRect, PRBool aUntrusted, PRBool aIgnoreViewportScrolling, diff --git a/mozilla/layout/base/nsPresShell.cpp b/mozilla/layout/base/nsPresShell.cpp index 191b2edfbb6..66ef465c9ad 100644 --- a/mozilla/layout/base/nsPresShell.cpp +++ b/mozilla/layout/base/nsPresShell.cpp @@ -4799,6 +4799,12 @@ PresShell::RenderDocument(const nsRect& aRect, PRBool aUntrusted, { NS_ENSURE_TRUE(!aUntrusted, NS_ERROR_NOT_IMPLEMENTED); + gfxRect r(0, 0, + nsPresContext::AppUnitsToFloatCSSPixels(aRect.width), + nsPresContext::AppUnitsToFloatCSSPixels(aRect.height)); + aThebesContext->Save(); + aThebesContext->Clip(r); + aThebesContext->PushGroup(NS_GET_A(aBackgroundColor) == 0xff ? gfxASurface::CONTENT_COLOR : gfxASurface::CONTENT_COLOR_ALPHA); @@ -4839,10 +4845,13 @@ PresShell::RenderDocument(const nsRect& aRect, PRBool aUntrusted, if (NS_SUCCEEDED(rv)) { // Ensure that r.x,r.y gets drawn at (0,0) aThebesContext->Save(); - aThebesContext->Translate(gfxPoint(-mPresContext->AppUnitsToGfxUnits(rect.x), - -mPresContext->AppUnitsToGfxUnits(rect.y))); + aThebesContext->Translate(gfxPoint(-nsPresContext::AppUnitsToFloatCSSPixels(rect.x), + -nsPresContext::AppUnitsToFloatCSSPixels(rect.y))); nsIDeviceContext* devCtx = mPresContext->DeviceContext(); + gfxFloat scale = gfxFloat(devCtx->AppUnitsPerDevPixel())/nsPresContext::AppUnitsPerCSSPixel(); + aThebesContext->Scale(scale, scale); + nsCOMPtr rc; devCtx->CreateRenderingContextInstance(*getter_AddRefs(rc)); rc->Init(devCtx, aThebesContext); @@ -4861,6 +4870,8 @@ PresShell::RenderDocument(const nsRect& aRect, PRBool aUntrusted, aThebesContext->PopGroupToSource(); aThebesContext->Paint(); + aThebesContext->Restore(); + return NS_OK; }