Commit db898579 authored by Jonathan Watt's avatar Jonathan Watt
Browse files

Bug 1770539 p3 - Move nsPrintData::mShrinkRatio to nsPrintJob::mShrinkToFitFactor. r=emilio

Depends on D146974

Differential Revision: https://phabricator.services.mozilla.com/D146975
parent c0b9f77a
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -29,8 +29,7 @@ nsPrintData::nsPrintData(ePrintDataType aType)
      mOnStartSent(false),
      mIsAborted(false),
      mPreparingForPrint(false),
      mNumPrintablePages(0),
      mShrinkRatio(1.0) {}
      mNumPrintablePages(0) {}

nsPrintData::~nsPrintData() {
  // Only Send an OnEndPrinting if we have started printing
+0 −1
Original line number Diff line number Diff line
@@ -64,7 +64,6 @@ class nsPrintData {
  bool mIsAborted;          // tells us the document is being aborted
  bool mPreparingForPrint;  // see comments above
  int32_t mNumPrintablePages;
  float mShrinkRatio;

 private:
  nsPrintData() = delete;
+4 −5
Original line number Diff line number Diff line
@@ -832,9 +832,9 @@ nsresult nsPrintJob::SetupToPrintContent() {
  // Here is where we figure out if extra reflow for shrinking the content
  // is required.
  if (mShrinkToFit) {
    printData->mShrinkRatio = printData->mPrintObject->mShrinkRatio;
    mShrinkToFitFactor = printData->mPrintObject->mShrinkRatio;

    if (printData->mShrinkRatio < 0.998f) {
    if (mShrinkToFitFactor < 0.998f) {
      nsresult rv = ReconstructAndReflow();
      if (NS_WARN_IF(NS_FAILED(rv))) {
        return rv;
@@ -853,8 +853,7 @@ nsresult nsPrintJob::SetupToPrintContent() {
          ("*******************************************************************"
           "*******\n"));
      PR_PL(("STF Ratio is: %8.5f Effective Ratio: %8.5f Diff: %8.5f\n",
             printData->mShrinkRatio, calcRatio,
             printData->mShrinkRatio - calcRatio));
             mShrinkToFitFactor, calcRatio, mShrinkToFitFactor - calcRatio));
      PR_PL(
          ("*******************************************************************"
           "*******\n"));
@@ -1137,7 +1136,7 @@ nsPrintJob::OnContentBlockingEvent(nsIWebProgress* aWebProgress,
void nsPrintJob::UpdateZoomRatio(nsPrintObject* aPO) {
  if (!aPO->mParent) {
    if (mShrinkToFit) {
      aPO->mZoomRatio = mPrt->mShrinkRatio;
      aPO->mZoomRatio = mShrinkToFitFactor;
      // If we're actually going to scale (the factor is less than 1), we
      // reduce the scale factor slightly to avoid the possibility of floating
      // point rounding error causing slight clipping of the longest lines.
+4 −0
Original line number Diff line number Diff line
@@ -260,6 +260,10 @@ class nsPrintJob final : public nsIWebProgressListener,
  // callback is stored here.
  PrintPreviewResolver mPrintPreviewCallback;

  // The scale factor that would need to be applied to all pages to make the
  // widest page fit without overflowing/clipping.
  float mShrinkToFitFactor = 1.0f;

  float mScreenDPI = 115.0f;

  bool mCreatedForPrintPreview = false;