Line data Source code
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/. */
5 : #ifndef nsPageFrame_h___
6 : #define nsPageFrame_h___
7 :
8 : #include "mozilla/Attributes.h"
9 : #include "nsContainerFrame.h"
10 : #include "nsLeafFrame.h"
11 :
12 : class nsFontMetrics;
13 : class nsSharedPageData;
14 :
15 : // Page frame class used by the simple page sequence frame
16 : class nsPageFrame final : public nsContainerFrame {
17 :
18 : public:
19 : NS_DECL_QUERYFRAME
20 0 : NS_DECL_FRAMEARENA_HELPERS(nsPageFrame)
21 :
22 : friend nsPageFrame* NS_NewPageFrame(nsIPresShell* aPresShell,
23 : nsStyleContext* aContext);
24 :
25 : virtual void Reflow(nsPresContext* aPresContext,
26 : ReflowOutput& aDesiredSize,
27 : const ReflowInput& aMaxSize,
28 : nsReflowStatus& aStatus) override;
29 :
30 : virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
31 : const nsRect& aDirtyRect,
32 : const nsDisplayListSet& aLists) override;
33 :
34 : #ifdef DEBUG_FRAME_DUMP
35 : virtual nsresult GetFrameName(nsAString& aResult) const override;
36 : #endif
37 :
38 : //////////////////
39 : // For Printing
40 : //////////////////
41 :
42 : // Tell the page which page number it is out of how many
43 : virtual void SetPageNumInfo(int32_t aPageNumber, int32_t aTotalPages);
44 :
45 : virtual void SetSharedPageData(nsSharedPageData* aPD);
46 :
47 : // We must allow Print Preview UI to have a background, no matter what the
48 : // user's settings
49 0 : virtual bool HonorPrintBackgroundSettings() override { return false; }
50 :
51 : void PaintHeaderFooter(gfxContext& aRenderingContext,
52 : nsPoint aPt, bool aSubpixelAA);
53 :
54 : /**
55 : * Return our page content frame.
56 : */
57 : void AppendDirectlyOwnedAnonBoxes(nsTArray<OwnedAnonBox>& aResult) override;
58 :
59 : protected:
60 : explicit nsPageFrame(nsStyleContext* aContext);
61 : virtual ~nsPageFrame();
62 :
63 : typedef enum {
64 : eHeader,
65 : eFooter
66 : } nsHeaderFooterEnum;
67 :
68 : nscoord GetXPosition(gfxContext& aRenderingContext,
69 : nsFontMetrics& aFontMetrics,
70 : const nsRect& aRect,
71 : int32_t aJust,
72 : const nsString& aStr);
73 :
74 : void DrawHeaderFooter(gfxContext& aRenderingContext,
75 : nsFontMetrics& aFontMetrics,
76 : nsHeaderFooterEnum aHeaderFooter,
77 : int32_t aJust,
78 : const nsString& sStr,
79 : const nsRect& aRect,
80 : nscoord aHeight,
81 : nscoord aAscent,
82 : nscoord aWidth);
83 :
84 : void DrawHeaderFooter(gfxContext& aRenderingContext,
85 : nsFontMetrics& aFontMetrics,
86 : nsHeaderFooterEnum aHeaderFooter,
87 : const nsString& aStrLeft,
88 : const nsString& aStrRight,
89 : const nsString& aStrCenter,
90 : const nsRect& aRect,
91 : nscoord aAscent,
92 : nscoord aHeight);
93 :
94 : void ProcessSpecialCodes(const nsString& aStr, nsString& aNewStr);
95 :
96 : int32_t mPageNum;
97 : int32_t mTotNumPages;
98 :
99 : nsSharedPageData* mPD;
100 : nsMargin mPageContentMargin;
101 : };
102 :
103 :
104 : class nsPageBreakFrame : public nsLeafFrame
105 : {
106 0 : NS_DECL_FRAMEARENA_HELPERS(nsPageBreakFrame)
107 :
108 : explicit nsPageBreakFrame(nsStyleContext* aContext);
109 : ~nsPageBreakFrame();
110 :
111 : virtual void Reflow(nsPresContext* aPresContext,
112 : ReflowOutput& aDesiredSize,
113 : const ReflowInput& aReflowInput,
114 : nsReflowStatus& aStatus) override;
115 :
116 : #ifdef DEBUG_FRAME_DUMP
117 : virtual nsresult GetFrameName(nsAString& aResult) const override;
118 : #endif
119 :
120 : protected:
121 :
122 : virtual nscoord GetIntrinsicISize() override;
123 : virtual nscoord GetIntrinsicBSize() override;
124 :
125 : bool mHaveReflowed;
126 :
127 : friend nsIFrame* NS_NewPageBreakFrame(nsIPresShell* aPresShell,
128 : nsStyleContext* aContext);
129 : };
130 :
131 : #endif /* nsPageFrame_h___ */
132 :
|