/src/mozilla-central/layout/generic/nsSimplePageSequenceFrame.h
Line | Count | Source (jump to first uncovered line) |
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 nsSimplePageSequenceFrame_h___ |
7 | | #define nsSimplePageSequenceFrame_h___ |
8 | | |
9 | | #include "mozilla/Attributes.h" |
10 | | #include "nsIPageSequenceFrame.h" |
11 | | #include "nsContainerFrame.h" |
12 | | #include "nsIPrintSettings.h" |
13 | | |
14 | | namespace mozilla { |
15 | | namespace dom { |
16 | | |
17 | | class HTMLCanvasElement; |
18 | | |
19 | | } // namespace dom |
20 | | } // namespace mozilla |
21 | | |
22 | | //----------------------------------------------- |
23 | | // This class maintains all the data that |
24 | | // is used by all the page frame |
25 | | // It lives while the nsSimplePageSequenceFrame lives |
26 | | class nsSharedPageData { |
27 | | public: |
28 | | // This object a shared by all the nsPageFrames |
29 | | // parented to a SimplePageSequenceFrame |
30 | 0 | nsSharedPageData() : mShrinkToFitRatio(1.0f) {} |
31 | | |
32 | | nsString mDateTimeStr; |
33 | | nsString mPageNumFormat; |
34 | | nsString mPageNumAndTotalsFormat; |
35 | | nsString mDocTitle; |
36 | | nsString mDocURL; |
37 | | nsFont mHeadFootFont; |
38 | | |
39 | | nsSize mReflowSize; |
40 | | nsMargin mReflowMargin; |
41 | | // Margin for headers and footers; it defaults to 4/100 of an inch on UNIX |
42 | | // and 0 elsewhere; I think it has to do with some inconsistency in page size |
43 | | // computations |
44 | | nsMargin mEdgePaperMargin; |
45 | | |
46 | | nsCOMPtr<nsIPrintSettings> mPrintSettings; |
47 | | |
48 | | // The scaling ratio we need to apply to make all pages fit horizontally. It's |
49 | | // the minimum "ComputedWidth / OverflowWidth" ratio of all page content frames |
50 | | // that overflowed. It's 1.0 if none overflowed horizontally. |
51 | | float mShrinkToFitRatio; |
52 | | }; |
53 | | |
54 | | // Simple page sequence frame class. Used when we're in paginated mode |
55 | | class nsSimplePageSequenceFrame final |
56 | | : public nsContainerFrame |
57 | | , public nsIPageSequenceFrame |
58 | | { |
59 | | public: |
60 | | friend nsSimplePageSequenceFrame* NS_NewSimplePageSequenceFrame(nsIPresShell* aPresShell, |
61 | | ComputedStyle* aStyle); |
62 | | |
63 | | NS_DECL_QUERYFRAME |
64 | | NS_DECL_FRAMEARENA_HELPERS(nsSimplePageSequenceFrame) |
65 | | |
66 | | // nsIFrame |
67 | | void Reflow(nsPresContext* aPresContext, |
68 | | ReflowOutput& aDesiredSize, |
69 | | const ReflowInput& aReflowInput, |
70 | | nsReflowStatus& aStatus) override; |
71 | | |
72 | | void BuildDisplayList(nsDisplayListBuilder* aBuilder, |
73 | | const nsDisplayListSet& aLists) override; |
74 | | |
75 | | // For Shrink To Fit |
76 | | NS_IMETHOD GetSTFPercent(float& aSTFPercent) override; |
77 | | |
78 | | // Async Printing |
79 | | NS_IMETHOD StartPrint(nsPresContext* aPresContext, |
80 | | nsIPrintSettings* aPrintSettings, |
81 | | const nsAString& aDocTitle, |
82 | | const nsAString& aDocURL) override; |
83 | | NS_IMETHOD PrePrintNextPage(nsITimerCallback* aCallback, bool* aDone) override; |
84 | | NS_IMETHOD PrintNextPage() override; |
85 | | NS_IMETHOD ResetPrintCanvasList() override; |
86 | | NS_IMETHOD GetCurrentPageNum(int32_t* aPageNum) override; |
87 | | NS_IMETHOD GetNumPages(int32_t* aNumPages) override; |
88 | | NS_IMETHOD IsDoingPrintRange(bool* aDoing) override; |
89 | | NS_IMETHOD GetPrintRange(int32_t* aFromPage, int32_t* aToPage) override; |
90 | | NS_IMETHOD DoPageEnd() override; |
91 | | |
92 | | // We must allow Print Preview UI to have a background, no matter what the |
93 | | // user's settings |
94 | 0 | bool HonorPrintBackgroundSettings() override { return false; } |
95 | | |
96 | 0 | bool HasTransformGetter() const override { return true; } |
97 | | |
98 | | /** |
99 | | * Return our first page frame. |
100 | | */ |
101 | | void AppendDirectlyOwnedAnonBoxes(nsTArray<OwnedAnonBox>& aResult) override; |
102 | | |
103 | | #ifdef DEBUG_FRAME_DUMP |
104 | | nsresult GetFrameName(nsAString& aResult) const override; |
105 | | #endif |
106 | | |
107 | | protected: |
108 | | explicit nsSimplePageSequenceFrame(ComputedStyle* aStyle); |
109 | | virtual ~nsSimplePageSequenceFrame(); |
110 | | |
111 | | void SetPageNumberFormat(const char* aPropName, const char* aDefPropVal, bool aPageNumOnly); |
112 | | |
113 | | // SharedPageData Helper methods |
114 | | void SetDateTimeStr(const nsAString& aDateTimeStr); |
115 | | void SetPageNumberFormat(const nsAString& aFormatStr, bool aForPageNumOnly); |
116 | | |
117 | | // Sets the frame desired size to the size of the viewport, or the given |
118 | | // nscoords, whichever is larger. Print scaling is applied in this function. |
119 | | void SetDesiredSize(ReflowOutput& aDesiredSize, |
120 | | const ReflowInput& aReflowInput, |
121 | | nscoord aWidth, nscoord aHeight); |
122 | | |
123 | | // Helper function to compute the offset needed to center a child |
124 | | // page-frame's margin-box inside our content-box. |
125 | | nscoord ComputeCenteringMargin(nscoord aContainerContentBoxWidth, |
126 | | nscoord aChildPaddingBoxWidth, |
127 | | const nsMargin& aChildPhysicalMargin); |
128 | | |
129 | | |
130 | | void DetermineWhetherToPrintPage(); |
131 | | nsIFrame* GetCurrentPageFrame(); |
132 | | |
133 | | nsMargin mMargin; |
134 | | |
135 | | nsSize mSize; |
136 | | nsSharedPageData* mPageData; // data shared by all the nsPageFrames |
137 | | |
138 | | // Asynch Printing |
139 | | int32_t mPageNum; |
140 | | int32_t mTotalPages; |
141 | | int32_t mPrintRangeType; |
142 | | int32_t mFromPageNum; |
143 | | int32_t mToPageNum; |
144 | | nsTArray<int32_t> mPageRanges; |
145 | | nsTArray<RefPtr<mozilla::dom::HTMLCanvasElement> > mCurrentCanvasList; |
146 | | |
147 | | // Asynch Printing |
148 | | bool mPrintThisPage; |
149 | | bool mDoingPageRange; |
150 | | |
151 | | bool mCalledBeginPage; |
152 | | |
153 | | bool mCurrentCanvasListSetup; |
154 | | }; |
155 | | |
156 | | #endif /* nsSimplePageSequenceFrame_h___ */ |
157 | | |