Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | #ifndef nsSimplePageSequenceFrame_h___ |
michael@0 | 6 | #define nsSimplePageSequenceFrame_h___ |
michael@0 | 7 | |
michael@0 | 8 | #include "mozilla/Attributes.h" |
michael@0 | 9 | #include "nsIPageSequenceFrame.h" |
michael@0 | 10 | #include "nsContainerFrame.h" |
michael@0 | 11 | #include "nsIPrintSettings.h" |
michael@0 | 12 | #include "nsIPrintOptions.h" |
michael@0 | 13 | |
michael@0 | 14 | class nsIDateTimeFormat; |
michael@0 | 15 | |
michael@0 | 16 | namespace mozilla { |
michael@0 | 17 | namespace dom { |
michael@0 | 18 | |
michael@0 | 19 | class HTMLCanvasElement; |
michael@0 | 20 | |
michael@0 | 21 | } |
michael@0 | 22 | } |
michael@0 | 23 | |
michael@0 | 24 | //----------------------------------------------- |
michael@0 | 25 | // This class maintains all the data that |
michael@0 | 26 | // is used by all the page frame |
michael@0 | 27 | // It lives while the nsSimplePageSequenceFrame lives |
michael@0 | 28 | class nsSharedPageData { |
michael@0 | 29 | public: |
michael@0 | 30 | // This object a shared by all the nsPageFrames |
michael@0 | 31 | // parented to a SimplePageSequenceFrame |
michael@0 | 32 | nsSharedPageData() : mShrinkToFitRatio(1.0f) {} |
michael@0 | 33 | |
michael@0 | 34 | nsString mDateTimeStr; |
michael@0 | 35 | nsString mPageNumFormat; |
michael@0 | 36 | nsString mPageNumAndTotalsFormat; |
michael@0 | 37 | nsString mDocTitle; |
michael@0 | 38 | nsString mDocURL; |
michael@0 | 39 | nsFont mHeadFootFont; |
michael@0 | 40 | |
michael@0 | 41 | nsSize mReflowSize; |
michael@0 | 42 | nsMargin mReflowMargin; |
michael@0 | 43 | // Margin for headers and footers; it defaults to 4/100 of an inch on UNIX |
michael@0 | 44 | // and 0 elsewhere; I think it has to do with some inconsistency in page size |
michael@0 | 45 | // computations |
michael@0 | 46 | nsMargin mEdgePaperMargin; |
michael@0 | 47 | |
michael@0 | 48 | nsCOMPtr<nsIPrintSettings> mPrintSettings; |
michael@0 | 49 | nsCOMPtr<nsIPrintOptions> mPrintOptions; |
michael@0 | 50 | |
michael@0 | 51 | // The scaling ratio we need to apply to make all pages fit horizontally. It's |
michael@0 | 52 | // the minimum "ComputedWidth / OverflowWidth" ratio of all page content frames |
michael@0 | 53 | // that overflowed. It's 1.0 if none overflowed horizontally. |
michael@0 | 54 | float mShrinkToFitRatio; |
michael@0 | 55 | }; |
michael@0 | 56 | |
michael@0 | 57 | // Simple page sequence frame class. Used when we're in paginated mode |
michael@0 | 58 | class nsSimplePageSequenceFrame : public nsContainerFrame, |
michael@0 | 59 | public nsIPageSequenceFrame { |
michael@0 | 60 | public: |
michael@0 | 61 | friend nsIFrame* NS_NewSimplePageSequenceFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); |
michael@0 | 62 | |
michael@0 | 63 | NS_DECL_QUERYFRAME |
michael@0 | 64 | NS_DECL_FRAMEARENA_HELPERS |
michael@0 | 65 | |
michael@0 | 66 | // nsIFrame |
michael@0 | 67 | virtual nsresult Reflow(nsPresContext* aPresContext, |
michael@0 | 68 | nsHTMLReflowMetrics& aDesiredSize, |
michael@0 | 69 | const nsHTMLReflowState& aMaxSize, |
michael@0 | 70 | nsReflowStatus& aStatus) MOZ_OVERRIDE; |
michael@0 | 71 | |
michael@0 | 72 | virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder, |
michael@0 | 73 | const nsRect& aDirtyRect, |
michael@0 | 74 | const nsDisplayListSet& aLists) MOZ_OVERRIDE; |
michael@0 | 75 | |
michael@0 | 76 | // nsIPageSequenceFrame |
michael@0 | 77 | NS_IMETHOD SetPageNo(int32_t aPageNo) { return NS_OK;} |
michael@0 | 78 | NS_IMETHOD SetSelectionHeight(nscoord aYOffset, nscoord aHeight) MOZ_OVERRIDE { mYSelOffset = aYOffset; mSelectionHeight = aHeight; return NS_OK; } |
michael@0 | 79 | NS_IMETHOD SetTotalNumPages(int32_t aTotal) MOZ_OVERRIDE { mTotalPages = aTotal; return NS_OK; } |
michael@0 | 80 | |
michael@0 | 81 | // For Shrink To Fit |
michael@0 | 82 | NS_IMETHOD GetSTFPercent(float& aSTFPercent) MOZ_OVERRIDE; |
michael@0 | 83 | |
michael@0 | 84 | // Async Printing |
michael@0 | 85 | NS_IMETHOD StartPrint(nsPresContext* aPresContext, |
michael@0 | 86 | nsIPrintSettings* aPrintSettings, |
michael@0 | 87 | const nsAString& aDocTitle, |
michael@0 | 88 | const nsAString& aDocURL) MOZ_OVERRIDE; |
michael@0 | 89 | NS_IMETHOD PrePrintNextPage(nsITimerCallback* aCallback, bool* aDone) MOZ_OVERRIDE; |
michael@0 | 90 | NS_IMETHOD PrintNextPage() MOZ_OVERRIDE; |
michael@0 | 91 | NS_IMETHOD ResetPrintCanvasList() MOZ_OVERRIDE; |
michael@0 | 92 | NS_IMETHOD GetCurrentPageNum(int32_t* aPageNum) MOZ_OVERRIDE; |
michael@0 | 93 | NS_IMETHOD GetNumPages(int32_t* aNumPages) MOZ_OVERRIDE; |
michael@0 | 94 | NS_IMETHOD IsDoingPrintRange(bool* aDoing) MOZ_OVERRIDE; |
michael@0 | 95 | NS_IMETHOD GetPrintRange(int32_t* aFromPage, int32_t* aToPage) MOZ_OVERRIDE; |
michael@0 | 96 | NS_IMETHOD DoPageEnd() MOZ_OVERRIDE; |
michael@0 | 97 | |
michael@0 | 98 | // We must allow Print Preview UI to have a background, no matter what the |
michael@0 | 99 | // user's settings |
michael@0 | 100 | virtual bool HonorPrintBackgroundSettings() MOZ_OVERRIDE { return false; } |
michael@0 | 101 | |
michael@0 | 102 | virtual bool HasTransformGetter() const MOZ_OVERRIDE { return true; } |
michael@0 | 103 | |
michael@0 | 104 | /** |
michael@0 | 105 | * Get the "type" of the frame |
michael@0 | 106 | * |
michael@0 | 107 | * @see nsGkAtoms::sequenceFrame |
michael@0 | 108 | */ |
michael@0 | 109 | virtual nsIAtom* GetType() const MOZ_OVERRIDE; |
michael@0 | 110 | |
michael@0 | 111 | #ifdef DEBUG_FRAME_DUMP |
michael@0 | 112 | virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE; |
michael@0 | 113 | #endif |
michael@0 | 114 | |
michael@0 | 115 | protected: |
michael@0 | 116 | nsSimplePageSequenceFrame(nsStyleContext* aContext); |
michael@0 | 117 | virtual ~nsSimplePageSequenceFrame(); |
michael@0 | 118 | |
michael@0 | 119 | void SetPageNumberFormat(const char* aPropName, const char* aDefPropVal, bool aPageNumOnly); |
michael@0 | 120 | |
michael@0 | 121 | // SharedPageData Helper methods |
michael@0 | 122 | void SetDateTimeStr(const nsAString& aDateTimeStr); |
michael@0 | 123 | void SetPageNumberFormat(const nsAString& aFormatStr, bool aForPageNumOnly); |
michael@0 | 124 | |
michael@0 | 125 | // Sets the frame desired size to the size of the viewport, or the given |
michael@0 | 126 | // nscoords, whichever is larger. Print scaling is applied in this function. |
michael@0 | 127 | void SetDesiredSize(nsHTMLReflowMetrics& aDesiredSize, |
michael@0 | 128 | const nsHTMLReflowState& aReflowState, |
michael@0 | 129 | nscoord aWidth, nscoord aHeight); |
michael@0 | 130 | |
michael@0 | 131 | void DetermineWhetherToPrintPage(); |
michael@0 | 132 | nsIFrame* GetCurrentPageFrame(); |
michael@0 | 133 | |
michael@0 | 134 | nsMargin mMargin; |
michael@0 | 135 | |
michael@0 | 136 | // I18N date formatter service which we'll want to cache locally. |
michael@0 | 137 | nsCOMPtr<nsIDateTimeFormat> mDateFormatter; |
michael@0 | 138 | |
michael@0 | 139 | nsSize mSize; |
michael@0 | 140 | nsSharedPageData* mPageData; // data shared by all the nsPageFrames |
michael@0 | 141 | |
michael@0 | 142 | // Asynch Printing |
michael@0 | 143 | int32_t mPageNum; |
michael@0 | 144 | int32_t mTotalPages; |
michael@0 | 145 | int32_t mPrintRangeType; |
michael@0 | 146 | int32_t mFromPageNum; |
michael@0 | 147 | int32_t mToPageNum; |
michael@0 | 148 | nsTArray<int32_t> mPageRanges; |
michael@0 | 149 | nsTArray<nsRefPtr<mozilla::dom::HTMLCanvasElement> > mCurrentCanvasList; |
michael@0 | 150 | |
michael@0 | 151 | // Selection Printing Info |
michael@0 | 152 | nscoord mSelectionHeight; |
michael@0 | 153 | nscoord mYSelOffset; |
michael@0 | 154 | |
michael@0 | 155 | // Asynch Printing |
michael@0 | 156 | bool mPrintThisPage; |
michael@0 | 157 | bool mDoingPageRange; |
michael@0 | 158 | |
michael@0 | 159 | bool mIsPrintingSelection; |
michael@0 | 160 | |
michael@0 | 161 | bool mCalledBeginPage; |
michael@0 | 162 | |
michael@0 | 163 | bool mCurrentCanvasListSetup; |
michael@0 | 164 | }; |
michael@0 | 165 | |
michael@0 | 166 | #endif /* nsSimplePageSequenceFrame_h___ */ |
michael@0 | 167 |