michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: #ifndef nsSimplePageSequenceFrame_h___ michael@0: #define nsSimplePageSequenceFrame_h___ michael@0: michael@0: #include "mozilla/Attributes.h" michael@0: #include "nsIPageSequenceFrame.h" michael@0: #include "nsContainerFrame.h" michael@0: #include "nsIPrintSettings.h" michael@0: #include "nsIPrintOptions.h" michael@0: michael@0: class nsIDateTimeFormat; michael@0: michael@0: namespace mozilla { michael@0: namespace dom { michael@0: michael@0: class HTMLCanvasElement; michael@0: michael@0: } michael@0: } michael@0: michael@0: //----------------------------------------------- michael@0: // This class maintains all the data that michael@0: // is used by all the page frame michael@0: // It lives while the nsSimplePageSequenceFrame lives michael@0: class nsSharedPageData { michael@0: public: michael@0: // This object a shared by all the nsPageFrames michael@0: // parented to a SimplePageSequenceFrame michael@0: nsSharedPageData() : mShrinkToFitRatio(1.0f) {} michael@0: michael@0: nsString mDateTimeStr; michael@0: nsString mPageNumFormat; michael@0: nsString mPageNumAndTotalsFormat; michael@0: nsString mDocTitle; michael@0: nsString mDocURL; michael@0: nsFont mHeadFootFont; michael@0: michael@0: nsSize mReflowSize; michael@0: nsMargin mReflowMargin; michael@0: // Margin for headers and footers; it defaults to 4/100 of an inch on UNIX michael@0: // and 0 elsewhere; I think it has to do with some inconsistency in page size michael@0: // computations michael@0: nsMargin mEdgePaperMargin; michael@0: michael@0: nsCOMPtr mPrintSettings; michael@0: nsCOMPtr mPrintOptions; michael@0: michael@0: // The scaling ratio we need to apply to make all pages fit horizontally. It's michael@0: // the minimum "ComputedWidth / OverflowWidth" ratio of all page content frames michael@0: // that overflowed. It's 1.0 if none overflowed horizontally. michael@0: float mShrinkToFitRatio; michael@0: }; michael@0: michael@0: // Simple page sequence frame class. Used when we're in paginated mode michael@0: class nsSimplePageSequenceFrame : public nsContainerFrame, michael@0: public nsIPageSequenceFrame { michael@0: public: michael@0: friend nsIFrame* NS_NewSimplePageSequenceFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); michael@0: michael@0: NS_DECL_QUERYFRAME michael@0: NS_DECL_FRAMEARENA_HELPERS michael@0: michael@0: // nsIFrame michael@0: virtual nsresult Reflow(nsPresContext* aPresContext, michael@0: nsHTMLReflowMetrics& aDesiredSize, michael@0: const nsHTMLReflowState& aMaxSize, michael@0: nsReflowStatus& aStatus) MOZ_OVERRIDE; michael@0: michael@0: virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder, michael@0: const nsRect& aDirtyRect, michael@0: const nsDisplayListSet& aLists) MOZ_OVERRIDE; michael@0: michael@0: // nsIPageSequenceFrame michael@0: NS_IMETHOD SetPageNo(int32_t aPageNo) { return NS_OK;} michael@0: NS_IMETHOD SetSelectionHeight(nscoord aYOffset, nscoord aHeight) MOZ_OVERRIDE { mYSelOffset = aYOffset; mSelectionHeight = aHeight; return NS_OK; } michael@0: NS_IMETHOD SetTotalNumPages(int32_t aTotal) MOZ_OVERRIDE { mTotalPages = aTotal; return NS_OK; } michael@0: michael@0: // For Shrink To Fit michael@0: NS_IMETHOD GetSTFPercent(float& aSTFPercent) MOZ_OVERRIDE; michael@0: michael@0: // Async Printing michael@0: NS_IMETHOD StartPrint(nsPresContext* aPresContext, michael@0: nsIPrintSettings* aPrintSettings, michael@0: const nsAString& aDocTitle, michael@0: const nsAString& aDocURL) MOZ_OVERRIDE; michael@0: NS_IMETHOD PrePrintNextPage(nsITimerCallback* aCallback, bool* aDone) MOZ_OVERRIDE; michael@0: NS_IMETHOD PrintNextPage() MOZ_OVERRIDE; michael@0: NS_IMETHOD ResetPrintCanvasList() MOZ_OVERRIDE; michael@0: NS_IMETHOD GetCurrentPageNum(int32_t* aPageNum) MOZ_OVERRIDE; michael@0: NS_IMETHOD GetNumPages(int32_t* aNumPages) MOZ_OVERRIDE; michael@0: NS_IMETHOD IsDoingPrintRange(bool* aDoing) MOZ_OVERRIDE; michael@0: NS_IMETHOD GetPrintRange(int32_t* aFromPage, int32_t* aToPage) MOZ_OVERRIDE; michael@0: NS_IMETHOD DoPageEnd() MOZ_OVERRIDE; michael@0: michael@0: // We must allow Print Preview UI to have a background, no matter what the michael@0: // user's settings michael@0: virtual bool HonorPrintBackgroundSettings() MOZ_OVERRIDE { return false; } michael@0: michael@0: virtual bool HasTransformGetter() const MOZ_OVERRIDE { return true; } michael@0: michael@0: /** michael@0: * Get the "type" of the frame michael@0: * michael@0: * @see nsGkAtoms::sequenceFrame michael@0: */ michael@0: virtual nsIAtom* GetType() const MOZ_OVERRIDE; michael@0: michael@0: #ifdef DEBUG_FRAME_DUMP michael@0: virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE; michael@0: #endif michael@0: michael@0: protected: michael@0: nsSimplePageSequenceFrame(nsStyleContext* aContext); michael@0: virtual ~nsSimplePageSequenceFrame(); michael@0: michael@0: void SetPageNumberFormat(const char* aPropName, const char* aDefPropVal, bool aPageNumOnly); michael@0: michael@0: // SharedPageData Helper methods michael@0: void SetDateTimeStr(const nsAString& aDateTimeStr); michael@0: void SetPageNumberFormat(const nsAString& aFormatStr, bool aForPageNumOnly); michael@0: michael@0: // Sets the frame desired size to the size of the viewport, or the given michael@0: // nscoords, whichever is larger. Print scaling is applied in this function. michael@0: void SetDesiredSize(nsHTMLReflowMetrics& aDesiredSize, michael@0: const nsHTMLReflowState& aReflowState, michael@0: nscoord aWidth, nscoord aHeight); michael@0: michael@0: void DetermineWhetherToPrintPage(); michael@0: nsIFrame* GetCurrentPageFrame(); michael@0: michael@0: nsMargin mMargin; michael@0: michael@0: // I18N date formatter service which we'll want to cache locally. michael@0: nsCOMPtr mDateFormatter; michael@0: michael@0: nsSize mSize; michael@0: nsSharedPageData* mPageData; // data shared by all the nsPageFrames michael@0: michael@0: // Asynch Printing michael@0: int32_t mPageNum; michael@0: int32_t mTotalPages; michael@0: int32_t mPrintRangeType; michael@0: int32_t mFromPageNum; michael@0: int32_t mToPageNum; michael@0: nsTArray mPageRanges; michael@0: nsTArray > mCurrentCanvasList; michael@0: michael@0: // Selection Printing Info michael@0: nscoord mSelectionHeight; michael@0: nscoord mYSelOffset; michael@0: michael@0: // Asynch Printing michael@0: bool mPrintThisPage; michael@0: bool mDoingPageRange; michael@0: michael@0: bool mIsPrintingSelection; michael@0: michael@0: bool mCalledBeginPage; michael@0: michael@0: bool mCurrentCanvasListSetup; michael@0: }; michael@0: michael@0: #endif /* nsSimplePageSequenceFrame_h___ */ michael@0: