1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef nsPrintObject_h___
7 #define nsPrintObject_h___
9 #include "mozilla/Attributes.h"
10 #include "mozilla/UniquePtr.h"
14 #include "nsViewManager.h"
15 #include "nsIDocShell.h"
16 #include "nsIDocShellTreeOwner.h"
23 } // namespace mozilla
25 //---------------------------------------------------
26 //-- nsPrintObject Class
27 //---------------------------------------------------
28 class nsPrintObject final
{
31 * If aParent is nullptr (default), then this instance will be initialized as
32 * a "root" nsPrintObject. Otherwise, this will be a "nested" nsPrintObject.
34 nsPrintObject(nsIDocShell
& aDocShell
, mozilla::dom::Document
& aDoc
,
35 nsPrintObject
* aParent
= nullptr);
38 void DestroyPresentation();
41 * Recursively sets all the PO items to be printed
42 * from the given item down into the tree
44 void EnablePrinting(bool aEnable
);
47 * Recursively sets all the PO items to be printed if they have a selection.
49 void EnablePrintingSelectionOnly();
51 bool PrintingIsEnabled() const { return mPrintingIsEnabled
; }
53 bool HasSelection() const;
56 nsCOMPtr
<nsIDocShell
> mDocShell
;
57 nsCOMPtr
<nsIDocShellTreeOwner
> mTreeOwner
;
58 RefPtr
<mozilla::dom::Document
> mDocument
;
60 RefPtr
<nsPresContext
> mPresContext
;
61 RefPtr
<mozilla::PresShell
> mPresShell
;
62 RefPtr
<nsViewManager
> mViewManager
;
64 nsCOMPtr
<nsIContent
> mContent
;
66 nsTArray
<mozilla::UniquePtr
<nsPrintObject
>> mKids
;
67 const nsPrintObject
* mParent
; // This is a non-owning pointer.
68 bool mHasBeenPrinted
= false;
69 bool mInvisible
= false; // Indicates PO is set to not visible by CSS
71 // The scale factor that sheets should be scaled by. This is either the
72 // explicit scale chosen by the user or else the shrink-to-fit scale factor
73 // if the user selects shrink-to-fit. Only set on the top-level nsPrintObject
74 // since this is only used by nsPageFrame (via nsPresContext::GetPageScale()).
75 float mZoomRatio
= 1.0;
77 // If the user selects the shrink-to-fit option, the shrink-to-fit scale
78 // factor is calculated and stored here. Only set on the top-level
80 float mShrinkRatio
= 1.0;
83 nsPrintObject
& operator=(const nsPrintObject
& aOther
) = delete;
85 bool mPrintingIsEnabled
= false;
88 #endif /* nsPrintObject_h___ */