Commit 8827bc2b authored by Jonathan Watt's avatar Jonathan Watt
Browse files

Bug 1770539 p6 - Move nsPrintData::mPrintDocList to nsPrintJob. r=emilio

parent 224cfeb1
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ extern mozilla::LazyLogModule gPrintingLog;
//-- nsPrintData Class Impl
//---------------------------------------------------
nsPrintData::nsPrintData(ePrintDataType aType)
    : mType(aType), mPrintDocList(0), mOnStartSent(false), mIsAborted(false) {}
    : mType(aType), mOnStartSent(false), mIsAborted(false) {}

nsPrintData::~nsPrintData() {
  // Only Send an OnEndPrinting if we have started printing
+0 −6
Original line number Diff line number Diff line
@@ -14,7 +14,6 @@
#include "nsDeviceContext.h"
#include "nsIPrintSettings.h"
#include "nsISupportsImpl.h"
#include "nsTArray.h"
#include "nsCOMArray.h"

class nsPrintObject;
@@ -48,11 +47,6 @@ class nsPrintData {
  // Otherwise, it is unset.
  nsPrintObject* mSelectionRoot = nullptr;

  // Array of non-owning pointers to all the nsPrintObjects owned by this
  // nsPrintData. This includes this->mPrintObject, as well as all of its
  // mKids (and their mKids, etc.)
  nsTArray<nsPrintObject*> mPrintDocList;

  bool mOnStartSent;
  bool mIsAborted;  // tells us the document is being aborted

+8 −14
Original line number Diff line number Diff line
@@ -134,7 +134,7 @@ static void DumpPrintObjectsTreeLayout(const UniquePtr<nsPrintObject>& aPO,
                                       FILE* aFD = nullptr);

#  define DUMP_DOC_LIST(_title) \
    DumpPrintObjectsListStart((_title), mPrt->mPrintDocList);
    DumpPrintObjectsListStart((_title), mPrintDocList);
#  define DUMP_DOC_TREE DumpPrintObjectsTree(mPrt->mPrintObject.get());
#  define DUMP_DOC_TREELAYOUT \
    DumpPrintObjectsTreeLayout(mPrt->mPrintObject, mPrt->mPrintDC);
@@ -150,7 +150,7 @@ static void DumpPrintObjectsTreeLayout(const UniquePtr<nsPrintObject>& aPO,

/**
 * Build a tree of nsPrintObjects under aPO. It also appends a (depth first)
 * flat list of all the nsPrintObjects created to mPrt->mPrintDocList. If
 * flat list of all the nsPrintObjects created to mPrintDocList. If
 * one of the nsPrintObject's document is the focused document, then the print
 * object is set as mPrt->mSelectionRoot.
 * @param aParentPO The parent nsPrintObject to populate, must not be null.
@@ -201,7 +201,7 @@ void nsPrintJob::BuildNestedPrintObjects(
      MOZ_ASSERT_UNREACHABLE("Init failed?");
    }

    mPrt->mPrintDocList.AppendElement(childPO.get());
    mPrintDocList.AppendElement(childPO.get());
    BuildNestedPrintObjects(childPO);
    aParentPO->mKids.AppendElement(std::move(childPO));
  }
@@ -412,7 +412,7 @@ nsresult nsPrintJob::DoCommonPrint(bool aIsPrintPreview,
                                                   mIsCreatingPrintPreview);
    NS_ENSURE_SUCCESS(rv, rv);

    printData->mPrintDocList.AppendElement(printData->mPrintObject.get());
    mPrintDocList.AppendElement(printData->mPrintObject.get());

    printData->mPrintObject->mFrameType = eDoc;

@@ -699,10 +699,7 @@ nsresult nsPrintJob::ReconstructAndReflow() {
  // while we're using it & its members!  So we capture it in an owning local
  // reference & use that instead of using mPrt directly.
  RefPtr<nsPrintData> printData = mPrt;
  for (uint32_t i = 0; i < printData->mPrintDocList.Length(); ++i) {
    nsPrintObject* po = printData->mPrintDocList.ElementAt(i);
    NS_ASSERTION(po, "nsPrintObject can't be null!");

  for (nsPrintObject* po : mPrintDocList) {
    if (!po->PrintingIsEnabled() || po->mInvisible) {
      continue;
    }
@@ -741,7 +738,7 @@ nsresult nsPrintJob::ReconstructAndReflow() {
    // For all views except the first one, setup the root view.
    // ??? Can there be multiple po for the top-level-document?
    bool documentIsTopLevel = true;
    if (i != 0) {
    if (po->mParent) {
      nsSize adjSize;
      bool doReturn;
      nsresult rv = SetRootView(po, doReturn, documentIsTopLevel, adjSize);
@@ -1445,11 +1442,8 @@ nsresult nsPrintJob::ReflowPrintObject(const UniquePtr<nsPrintObject>& aPO) {
// Figure out how many documents and how many total pages we are printing
void nsPrintJob::CalcNumPrintablePages(int32_t& aNumPages) {
  aNumPages = 0;
  // Count the number of printable documents
  // and printable pages
  for (uint32_t i = 0; i < mPrt->mPrintDocList.Length(); i++) {
    nsPrintObject* po = mPrt->mPrintDocList.ElementAt(i);
    NS_ASSERTION(po, "nsPrintObject can't be null!");
  // Count the number of printable documents and printable pages
  for (nsPrintObject* po : mPrintDocList) {
    // Note: The po->mPresContext null-check below is necessary, because it's
    // possible po->mPresContext might never have been set.  (e.g., if
    // PrintingIsEnabled() returns false, ReflowPrintObject bails before setting
+6 −0
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
#include "nsHashKeys.h"
#include "nsIFrame.h"  // For WeakFrame
#include "nsSize.h"
#include "nsTArray.h"
#include "nsTHashtable.h"
#include "nsWeakReference.h"

@@ -254,6 +255,11 @@ class nsPrintJob final : public nsIWebProgressListener,
  // Only set if this nsPrintJob was created for a real print.
  RefPtr<RemotePrintJobChild> mRemotePrintJob;

  // Array of non-owning pointers to all the nsPrintObjects owned by this
  // nsPrintJob. This includes mPrintObject, as well as all of its mKids (and
  // their mKids, etc.)
  nsTArray<nsPrintObject*> mPrintDocList;

  // If the code that initiates a print preview passes a PrintPreviewResolver
  // (a std::function) to be notified of the final sheet/page counts (once
  // we've sufficiently laid out the document to know what those are), that