1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "nsIDeviceContextSpec.h"
9 #include "nsIPrintSettings.h"
11 // We have some platform specific code here rather than in the appropriate
12 // nsIDeviceContextSpec subclass. We structure the code this way so that
13 // nsIDeviceContextSpecProxy gets the correct behavior without us having to
14 // instantiate a platform specific nsIDeviceContextSpec subclass in content
15 // processes. That is necessary for sandboxing.
17 float nsIDeviceContextSpec::GetPrintingScale() {
19 if (mPrintSettings
->GetOutputFormat() != nsIPrintSettings::kOutputFormatPDF
20 # ifdef MOZ_ENABLE_SKIA_PDF
24 // The print settings will have the resolution stored from the real device.
26 mPrintSettings
->GetResolution(&resolution
);
27 return float(resolution
) / GetDPI();
31 return 72.0f
/ GetDPI();
34 gfxPoint
nsIDeviceContextSpec::GetPrintingTranslate() {
36 // The underlying surface on windows is the size of the printable region. When
37 // the region is smaller than the actual paper size the (0, 0) coordinate
38 // refers top-left of that unwritable region. To instead have (0, 0) become
39 // the top-left of the actual paper, translate it's coordinate system by the
40 // unprintable region's width.
41 double marginTop
, marginLeft
;
42 mPrintSettings
->GetUnwriteableMarginTop(&marginTop
);
43 mPrintSettings
->GetUnwriteableMarginLeft(&marginLeft
);
45 mPrintSettings
->GetResolution(&resolution
);
46 return gfxPoint(-marginLeft
* resolution
, -marginTop
* resolution
);
48 return gfxPoint(0, 0);