Bug 1257825: Remove checks for paper height and width <= 0 in nsPrintSettings. r=dvander
authorBob Owen <bobowencode@gmail.com>
Sat, 19 Mar 2016 11:07:16 +0000
changeset 289458 1a47789d4d15826865858d4fd7100f7db73e67f3
parent 289457 7a5de08942cad3abf6df73334c92adc23810225c
child 289459 ac58a56021acde418bcf6b9175e757ca90880356
push id30102
push userryanvm@gmail.com
push dateSat, 19 Mar 2016 15:23:17 +0000
treeherdermozilla-central@720fb3d55e28 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdvander
bugs1257825
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1257825: Remove checks for paper height and width <= 0 in nsPrintSettings. r=dvander Also added the check for invalid width / height into nsDeviceContextSpecProxy that was added into nsDeviceContextSpecWin.
widget/nsDeviceContextSpecProxy.cpp
widget/nsPrintSettingsImpl.cpp
--- a/widget/nsDeviceContextSpecProxy.cpp
+++ b/widget/nsDeviceContextSpecProxy.cpp
@@ -64,18 +64,18 @@ nsDeviceContextSpecProxy::Init(nsIWidget
 NS_IMETHODIMP
 nsDeviceContextSpecProxy::GetSurfaceForPrinter(gfxASurface** aSurface)
 {
   MOZ_ASSERT(aSurface);
   MOZ_ASSERT(mRealDeviceContextSpec);
 
   double width, height;
   nsresult rv = mPrintSettings->GetEffectivePageSize(&width, &height);
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    return rv;
+  if (NS_WARN_IF(NS_FAILED(rv)) || width <= 0 || height <= 0) {
+    return NS_ERROR_FAILURE;
   }
 
   // convert twips to points
   width /= TWIPS_PER_POINT_FLOAT;
   height /= TWIPS_PER_POINT_FLOAT;
 
   RefPtr<gfxASurface> surface = gfxPlatform::GetPlatform()->
     CreateOffscreenSurface(mozilla::gfx::IntSize(width, height),
--- a/widget/nsPrintSettingsImpl.cpp
+++ b/widget/nsPrintSettingsImpl.cpp
@@ -2,17 +2,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsPrintSettingsImpl.h"
 #include "nsReadableUtils.h"
 #include "nsIPrintSession.h"
 #include "mozilla/RefPtr.h"
-#include "mozilla/gfx/Logging.h"
 
 #define DEFAULT_MARGIN_WIDTH 0.5
 
 NS_IMPL_ISUPPORTS(nsPrintSettings, nsIPrintSettings)
 
 /** ---------------------------------------------------
  *  See documentation in nsPrintSettingsImpl.h
  *	@update 6/21/00 dwc
@@ -807,34 +806,28 @@ NS_IMETHODIMP nsPrintSettings::GetPaperW
 {
   NS_ENSURE_ARG_POINTER(aPaperWidth);
   *aPaperWidth = mPaperWidth;
   return NS_OK;
 }
 NS_IMETHODIMP nsPrintSettings::SetPaperWidth(double aPaperWidth)
 {
   mPaperWidth = aPaperWidth;
-  if (mPaperWidth <= 0) {
-    gfxCriticalError(gfxCriticalError::DefaultOptions(false)) << "Setting paper width to bad value " << mPaperWidth;
-  }
   return NS_OK;
 }
 
 NS_IMETHODIMP nsPrintSettings::GetPaperHeight(double *aPaperHeight)
 {
   NS_ENSURE_ARG_POINTER(aPaperHeight);
   *aPaperHeight = mPaperHeight;
   return NS_OK;
 }
 NS_IMETHODIMP nsPrintSettings::SetPaperHeight(double aPaperHeight)
 {
   mPaperHeight = aPaperHeight;
-  if (mPaperHeight <= 0) {
-    gfxCriticalError(gfxCriticalError::DefaultOptions(false)) << "Setting paper height to bad value " << mPaperHeight;
-  }
   return NS_OK;
 }
 
 NS_IMETHODIMP nsPrintSettings::GetPaperSizeUnit(int16_t *aPaperSizeUnit)
 {
   NS_ENSURE_ARG_POINTER(aPaperSizeUnit);
   *aPaperSizeUnit = mPaperSizeUnit;
   return NS_OK;