layout/generic/nsSimplePageSequenceFrame.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial