Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
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___
8 #include "mozilla/Attributes.h"
9 #include "nsContainerFrame.h"
10 #include "nsLeafFrame.h"
12 class nsSharedPageData;
14 // Page frame class used by the simple page sequence frame
15 class nsPageFrame : public nsContainerFrame {
17 public:
18 NS_DECL_FRAMEARENA_HELPERS
20 friend nsIFrame* NS_NewPageFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
22 virtual nsresult Reflow(nsPresContext* aPresContext,
23 nsHTMLReflowMetrics& aDesiredSize,
24 const nsHTMLReflowState& aMaxSize,
25 nsReflowStatus& aStatus) MOZ_OVERRIDE;
27 virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
28 const nsRect& aDirtyRect,
29 const nsDisplayListSet& aLists) MOZ_OVERRIDE;
31 /**
32 * Get the "type" of the frame
33 *
34 * @see nsGkAtoms::pageFrame
35 */
36 virtual nsIAtom* GetType() const MOZ_OVERRIDE;
38 #ifdef DEBUG_FRAME_DUMP
39 virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE;
40 #endif
42 //////////////////
43 // For Printing
44 //////////////////
46 // Tell the page which page number it is out of how many
47 virtual void SetPageNumInfo(int32_t aPageNumber, int32_t aTotalPages);
49 virtual void SetSharedPageData(nsSharedPageData* aPD);
51 // We must allow Print Preview UI to have a background, no matter what the
52 // user's settings
53 virtual bool HonorPrintBackgroundSettings() MOZ_OVERRIDE { return false; }
55 void PaintHeaderFooter(nsRenderingContext& aRenderingContext,
56 nsPoint aPt);
58 protected:
59 nsPageFrame(nsStyleContext* aContext);
60 virtual ~nsPageFrame();
62 typedef enum {
63 eHeader,
64 eFooter
65 } nsHeaderFooterEnum;
67 nscoord GetXPosition(nsRenderingContext& aRenderingContext,
68 const nsRect& aRect,
69 int32_t aJust,
70 const nsString& aStr);
72 void DrawHeaderFooter(nsRenderingContext& aRenderingContext,
73 nsHeaderFooterEnum aHeaderFooter,
74 int32_t aJust,
75 const nsString& sStr,
76 const nsRect& aRect,
77 nscoord aHeight,
78 nscoord aAscent,
79 nscoord aWidth);
81 void DrawHeaderFooter(nsRenderingContext& aRenderingContext,
82 nsHeaderFooterEnum aHeaderFooter,
83 const nsString& aStrLeft,
84 const nsString& aStrRight,
85 const nsString& aStrCenter,
86 const nsRect& aRect,
87 nscoord aAscent,
88 nscoord aHeight);
90 void ProcessSpecialCodes(const nsString& aStr, nsString& aNewStr);
92 int32_t mPageNum;
93 int32_t mTotNumPages;
95 nsSharedPageData* mPD;
96 };
99 class nsPageBreakFrame : public nsLeafFrame
100 {
101 NS_DECL_FRAMEARENA_HELPERS
103 nsPageBreakFrame(nsStyleContext* aContext);
104 ~nsPageBreakFrame();
106 virtual nsresult Reflow(nsPresContext* aPresContext,
107 nsHTMLReflowMetrics& aDesiredSize,
108 const nsHTMLReflowState& aReflowState,
109 nsReflowStatus& aStatus) MOZ_OVERRIDE;
111 virtual nsIAtom* GetType() const MOZ_OVERRIDE;
113 #ifdef DEBUG_FRAME_DUMP
114 virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE;
115 #endif
117 protected:
119 virtual nscoord GetIntrinsicWidth() MOZ_OVERRIDE;
120 virtual nscoord GetIntrinsicHeight() MOZ_OVERRIDE;
122 bool mHaveReflowed;
124 friend nsIFrame* NS_NewPageBreakFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
125 };
127 #endif /* nsPageFrame_h___ */