Commit c75ef6f2 authored by Stanca Serban's avatar Stanca Serban
Browse files

Backed out 3 changesets (bug 1833244) for causing multiple failures.

Backed out changeset 7bc8c25b2935 (bug 1833244)
Backed out changeset 4576af83a4ec (bug 1833244)
Backed out changeset 90a5bbba7b9c (bug 1833244)
parent c7a2a7de
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -327,14 +327,14 @@ nsresult nsDeviceContext::AbortDocument() {
  return rv;
}

nsresult nsDeviceContext::BeginPage(const IntSize& aSizeInPoints) {
nsresult nsDeviceContext::BeginPage() {
  MOZ_DIAGNOSTIC_ASSERT(!mIsCurrentlyPrintingDoc || mPrintTarget,
                        "What nulled out our print target while printing?");
  if (mDeviceContextSpec) {
    MOZ_TRY(mDeviceContextSpec->BeginPage(aSizeInPoints));
    MOZ_TRY(mDeviceContextSpec->BeginPage());
  }
  if (mPrintTarget) {
    MOZ_TRY(mPrintTarget->BeginPage(aSizeInPoints));
    MOZ_TRY(mPrintTarget->BeginPage());
  }
  return NS_OK;
}
+2 −12
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@
#include "nscore.h"                   // for char16_t, nsAString
#include "mozilla/AppUnits.h"         // for AppUnits
#include "nsFontMetrics.h"            // for nsFontMetrics::Params
#include "mozilla/gfx/Point.h"        // for IntSize
#include "mozilla/gfx/PrintTarget.h"  // for PrintTarget::PageDoneCallback
#include "mozilla/gfx/PrintPromise.h"

@@ -49,8 +48,7 @@ class Screen;

class nsDeviceContext final {
 public:
  using IntSize = mozilla::gfx::IntSize;
  using PrintTarget = mozilla::gfx::PrintTarget;
  typedef mozilla::gfx::PrintTarget PrintTarget;

  nsDeviceContext();

@@ -225,17 +223,9 @@ class nsDeviceContext final {
   * Inform the output device that output of a page is beginning
   * Used for print related device contexts. Must be matched 1:1 with
   * EndPage() and within a BeginDocument()/EndDocument() pair.
   *
   * @param aSizeInPoints - The physical dimensions of the page in points.
   *                        Currently only supported (used) by print-to-PDF
   *                        print targets, and then only to switch the
   *                        orientation for a specific page (arbitrary page
   *                        sizes are not supported by the Core Graphics print-
   *                        to-PDF APIs, for example).
   *
   * @return error status
   */
  nsresult BeginPage(const IntSize& aSizeInPoints);
  nsresult BeginPage();

  /**
   * Inform the output device that output of a page is ending
+1 −5
Original line number Diff line number Diff line
@@ -43,11 +43,7 @@ class PrintTarget {
#endif
    return NS_OK;
  }
  /**
   * Note: not all print devices implement mixed page sizing. Most PrintTarget
   * subclasses will ignore `aSizeInPoints`.
   */
  virtual nsresult BeginPage(const IntSize& aSizeInPoints) {
  virtual nsresult BeginPage() {
#ifdef DEBUG
    MOZ_ASSERT(!mHasActivePage, "Missing EndPage() call");
    mHasActivePage = true;
+1 −1
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ class PrintTargetCG final : public PrintTarget {
                         int32_t aEndPage) final;
  nsresult EndPrinting() final;
  nsresult AbortPrinting() final;
  nsresult BeginPage(const IntSize& aSizeInPoints) final;
  nsresult BeginPage() final;
  nsresult EndPage() final;

  already_AddRefed<DrawTarget> GetReferenceDrawTarget() final;
+4 −20
Original line number Diff line number Diff line
@@ -8,7 +8,6 @@
#include "cairo.h"
#include "cairo-quartz.h"
#include "mozilla/gfx/HelpersCairo.h"
#include "mozilla/StaticPrefs_layout.h"
#include "nsObjCExceptions.h"
#include "nsString.h"
#include "nsIOutputStream.h"
@@ -211,7 +210,7 @@ nsresult PrintTargetCG::AbortPrinting() {
  return EndPrinting();
}

nsresult PrintTargetCG::BeginPage(const IntSize& aSizeInPoints) {
nsresult PrintTargetCG::BeginPage() {
  NS_OBJC_BEGIN_TRY_BLOCK_RETURN;

  CGContextRef context;
@@ -219,15 +218,7 @@ nsresult PrintTargetCG::BeginPage(const IntSize& aSizeInPoints) {
    CGContextBeginPage(mPrintToStreamContext, nullptr);
    context = mPrintToStreamContext;
  } else {
    // XXX Why are we calling this if we don't check the return value?
    PMSessionError(mPrintSession);

    if (StaticPrefs::layout_css_page_orientation_enabled()) {
      ::PMOrientation pageOrientation =
          aSizeInPoints.width < aSizeInPoints.height ? kPMPortrait : kPMLandscape;
      ::PMSetOrientation(mPageFormat, pageOrientation, kPMUnlocked);
      // We don't need to reset the orientation, since we set it for every page.
    }
    OSStatus status = ::PMSessionBeginPageNoDialog(mPrintSession, mPageFormat, nullptr);
    if (status != noErr) {
      return NS_ERROR_ABORT;
@@ -242,15 +233,8 @@ nsresult PrintTargetCG::BeginPage(const IntSize& aSizeInPoints) {
    }
  }

  unsigned int width;
  unsigned int height;
  if (StaticPrefs::layout_css_page_orientation_enabled()) {
    width = static_cast<unsigned int>(aSizeInPoints.width);
    height = static_cast<unsigned int>(aSizeInPoints.height);
  } else {
    width = static_cast<unsigned int>(mSize.width);
    height = static_cast<unsigned int>(mSize.height);
  }
  unsigned int width = static_cast<unsigned int>(mSize.width);
  unsigned int height = static_cast<unsigned int>(mSize.height);

  // Initially, origin is at bottom-left corner of the paper.
  // Here, we translate it to top-left corner of the paper.
@@ -265,7 +249,7 @@ nsresult PrintTargetCG::BeginPage(const IntSize& aSizeInPoints) {

  mCairoSurface = surface;

  return PrintTarget::BeginPage(aSizeInPoints);
  return PrintTarget::BeginPage();

  NS_OBJC_END_TRY_BLOCK_RETURN(NS_ERROR_FAILURE);
}
Loading