tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

nsPrintObject.h (2661B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
      3 /* This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 #ifndef nsPrintObject_h___
      7 #define nsPrintObject_h___
      8 
      9 #include "mozilla/UniquePtr.h"
     10 
     11 // Interfaces
     12 #include "nsCOMPtr.h"
     13 #include "nsIDocShell.h"
     14 #include "nsIDocShellTreeOwner.h"
     15 
     16 class nsIContent;
     17 class nsPresContext;
     18 
     19 namespace mozilla {
     20 class PresShell;
     21 }  // namespace mozilla
     22 
     23 //---------------------------------------------------
     24 //-- nsPrintObject Class
     25 //---------------------------------------------------
     26 class nsPrintObject final {
     27 public:
     28  /**
     29   * If aParent is nullptr (default), then this instance will be initialized as
     30   * a "root" nsPrintObject.  Otherwise, this will be a "nested" nsPrintObject.
     31   */
     32  nsPrintObject(nsIDocShell& aDocShell, mozilla::dom::Document& aDoc,
     33                nsPrintObject* aParent = nullptr);
     34  ~nsPrintObject();
     35 
     36  void DestroyPresentation();
     37 
     38  /**
     39   * Recursively sets all the PO items to be printed
     40   * from the given item down into the tree
     41   */
     42  void EnablePrinting(bool aEnable);
     43 
     44  /**
     45   * Recursively sets all the PO items to be printed if they have a selection.
     46   */
     47  void EnablePrintingSelectionOnly();
     48 
     49  bool PrintingIsEnabled() const { return mPrintingIsEnabled; }
     50 
     51  bool HasSelection() const;
     52 
     53  // Data Members
     54  nsCOMPtr<nsIDocShell> mDocShell;
     55  nsCOMPtr<nsIDocShellTreeOwner> mTreeOwner;
     56  RefPtr<mozilla::dom::Document> mDocument;
     57 
     58  RefPtr<nsPresContext> mPresContext;
     59  RefPtr<mozilla::PresShell> mPresShell;
     60 
     61  nsCOMPtr<nsIContent> mContent;
     62 
     63  nsTArray<mozilla::UniquePtr<nsPrintObject>> mKids;
     64  const nsPrintObject* mParent;  // This is a non-owning pointer.
     65  bool mHasBeenPrinted = false;
     66  bool mInvisible = false;  // Indicates PO is set to not visible by CSS
     67 
     68  // The scale factor that sheets should be scaled by. This is either the
     69  // explicit scale chosen by the user or else the shrink-to-fit scale factor
     70  // if the user selects shrink-to-fit. Only set on the top-level nsPrintObject
     71  // since this is only used by nsPageFrame (via nsPresContext::GetPageScale()).
     72  float mZoomRatio = 1.0;
     73 
     74  // If the user selects the shrink-to-fit option, the shrink-to-fit scale
     75  // factor is calculated and stored here. Only set on the top-level
     76  // nsPrintObject.
     77  float mShrinkRatio = 1.0;
     78 
     79 private:
     80  nsPrintObject& operator=(const nsPrintObject& aOther) = delete;
     81 
     82  bool mPrintingIsEnabled = false;
     83 };
     84 
     85 #endif /* nsPrintObject_h___ */