Bug 1770047 [wpt PR 34117] - Update wpt metadata, a=testonly
[gecko.git] / widget / nsIDeviceContextSpec.h
blob4edccfefb16a1f284f57baadc59c3521badf7a43
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 #ifndef nsIDeviceContextSpec_h___
7 #define nsIDeviceContextSpec_h___
9 #include "gfxPoint.h"
10 #include "nsISupports.h"
11 #include "mozilla/StaticPrefs_print.h"
13 class nsIWidget;
14 class nsIPrintSettings;
16 namespace mozilla {
17 namespace gfx {
18 class DrawEventRecorder;
19 class PrintTarget;
20 } // namespace gfx
21 } // namespace mozilla
23 #define NS_IDEVICE_CONTEXT_SPEC_IID \
24 { \
25 0xf407cfba, 0xbe28, 0x46c9, { \
26 0x8a, 0xba, 0x04, 0x2d, 0xae, 0xbb, 0x4f, 0x23 \
27 } \
30 class nsIDeviceContextSpec : public nsISupports {
31 public:
32 typedef mozilla::gfx::PrintTarget PrintTarget;
34 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDEVICE_CONTEXT_SPEC_IID)
36 /**
37 * Initialize the device context spec.
38 * @param aWidget A widget a dialog can be hosted in
39 * @param aPrintSettings Print settings for the print operation
40 * @param aIsPrintPreview True if creating Spec for PrintPreview
41 * @return NS_OK or a suitable error code.
43 NS_IMETHOD Init(nsIPrintSettings* aPrintSettings, bool aIsPrintPreview) = 0;
45 virtual already_AddRefed<PrintTarget> MakePrintTarget() = 0;
47 /**
48 * If required override to return a recorder to record the print.
50 * @param aDrawEventRecorder out param for the recorder to use
51 * @return NS_OK or a suitable error code
53 NS_IMETHOD GetDrawEventRecorder(
54 mozilla::gfx::DrawEventRecorder** aDrawEventRecorder) {
55 MOZ_ASSERT(aDrawEventRecorder);
56 *aDrawEventRecorder = nullptr;
57 return NS_OK;
60 /**
61 * @return DPI for printing.
63 float GetDPI() { return mozilla::StaticPrefs::print_default_dpi(); }
65 /**
66 * @return the printing scale to be applied to the context for printing.
68 float GetPrintingScale();
70 /**
71 * @return the point to translate the context to for printing.
73 gfxPoint GetPrintingTranslate();
75 NS_IMETHOD BeginDocument(const nsAString& aTitle,
76 const nsAString& aPrintToFileName,
77 int32_t aStartPage, int32_t aEndPage) = 0;
79 NS_IMETHOD EndDocument() = 0;
80 NS_IMETHOD AbortDocument() { return EndDocument(); }
81 NS_IMETHOD BeginPage() = 0;
82 NS_IMETHOD EndPage() = 0;
84 protected:
85 nsCOMPtr<nsIPrintSettings> mPrintSettings;
87 #ifdef MOZ_ENABLE_SKIA_PDF
88 // This variable is independant of nsIPrintSettings::kOutputFormatPDF (i.e.
89 // save-to-PDF). If set to true, then even when we print to a printer we
90 // output and send it PDF.
91 bool mPrintViaSkPDF = false;
92 #endif
95 NS_DEFINE_STATIC_IID_ACCESSOR(nsIDeviceContextSpec, NS_IDEVICE_CONTEXT_SPEC_IID)
96 #endif