nsPageFrame.h 4.3 KB

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