File mozilla-landscape_printing.patch of Package MozillaFirefox.2166
# HG changeset patch
# Parent 548ea0216c0d35b5eac28815df6cdf41353b9806
Handle printing in landscape orientation properly.
Modified from bmo#1120490 - mozilla-central changeset 036e241fd1b4
Also see bsc#908275
diff --git a/gfx/src/nsDeviceContext.cpp b/gfx/src/nsDeviceContext.cpp
--- a/gfx/src/nsDeviceContext.cpp
+++ b/gfx/src/nsDeviceContext.cpp
@@ -411,17 +411,30 @@ nsDeviceContext::CreateRenderingContext(
gfx::IntSize(mWidth, mHeight));
#ifdef XP_MACOSX
dt->AddUserData(&gfxContext::sDontUseAsSourceKey, dt, nullptr);
#endif
dt->AddUserData(&sDisablePixelSnapping, (void*)0x1, nullptr);
nsRefPtr<gfxContext> pContext = new gfxContext(dt);
- pContext->SetMatrix(gfxMatrix::Scaling(mPrintingScale, mPrintingScale));
+
+ gfxMatrix transform;
+ if (printingSurface->GetRotateForLandscape()) {
+ // Rotate page 90 degrees CW aroung the origin and move the result by its
+ // height to draw landscape page on portrait paper
+ // (the Y axis grows downwards, hence the opposite sign for rotation)
+ gfxMatrix rotate( 0, 1,
+ -1, 0,
+ printingSurface->GetSize().height, 0);
+ transform *= rotate;
+ }
+ transform.Scale(mPrintingScale, mPrintingScale);
+
+ pContext->SetMatrix(transform);
return pContext.forget();
}
nsresult
nsDeviceContext::GetDepth(uint32_t& aDepth)
{
if (mDepth == 0 && mScreenManager) {
nsCOMPtr<nsIScreen> primaryScreen;