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___
8 
9 #include "mozilla/Attributes.h"
10 #include "mozilla/UniquePtr.h"
11 
12 // Interfaces
13 #include "nsCOMPtr.h"
14 #include "nsViewManager.h"
15 #include "nsIDocShell.h"
16 #include "nsIDocShellTreeOwner.h"
17 
18 class nsIContent;
19 class nsPresContext;
20 
21 namespace mozilla {
22 class PresShell;
23 }  // namespace mozilla
24 
25 // nsPrintObject Document Type
26 enum PrintObjectType { eDoc = 0, eFrame = 1, eIFrame = 2, eFrameSet = 3 };
27 
28 //---------------------------------------------------
29 //-- nsPrintObject Class
30 //---------------------------------------------------
31 class nsPrintObject {
32  public:
33   nsPrintObject();
34   ~nsPrintObject();  // non-virtual
35 
36   nsresult InitAsRootObject(nsIDocShell* aDocShell,
37                             mozilla::dom::Document* aDoc,
38                             bool aForPrintPreview);
39   nsresult InitAsNestedObject(nsIDocShell* aDocShell,
40                               mozilla::dom::Document* aDoc,
41                               nsPrintObject* aParent);
42 
IsPrintable()43   bool IsPrintable() { return !mDontPrint; }
44   void DestroyPresentation();
45 
46   /**
47    * Recursively sets the PO items to be printed "As Is"
48    * from the given item down into the treei
49    */
50   void SetPrintAsIs(bool aAsIs);
51 
52   /**
53    * Recursively sets all the PO items to be printed
54    * from the given item down into the tree
55    */
56   void EnablePrinting(bool aEnable);
57 
58   // Data Members
59   nsCOMPtr<nsIDocShell> mDocShell;
60   nsCOMPtr<nsIDocShellTreeOwner> mTreeOwner;
61   RefPtr<mozilla::dom::Document> mDocument;
62 
63   RefPtr<nsPresContext> mPresContext;
64   RefPtr<mozilla::PresShell> mPresShell;
65   RefPtr<nsViewManager> mViewManager;
66 
67   nsCOMPtr<nsIContent> mContent;
68   PrintObjectType mFrameType;
69 
70   nsTArray<mozilla::UniquePtr<nsPrintObject>> mKids;
71   nsPrintObject* mParent;  // This is a non-owning pointer.
72   bool mHasBeenPrinted;
73   bool mDontPrint;
74   bool mPrintAsIs;
75   bool mInvisible;  // Indicates PO is set to not visible by CSS
76   bool mDidCreateDocShell;
77   float mShrinkRatio;
78   float mZoomRatio;
79 
80  private:
81   nsPrintObject& operator=(const nsPrintObject& aOther) = delete;
82 };
83 
84 #endif /* nsPrintObject_h___ */
85