Bug 1257825: Remove checks for paper height and width <= 0 in nsPrintSettings. r=dvander, a=ritu
authorBob Owen <bobowencode@gmail.com>
Sat, 19 Mar 2016 11:07:16 +0000
changeset 319415 456366b1ff239b5d7b7cf6823ce0906215279834
parent 319414 bdfc2038590c952a5c56cb6d586ce2f52af24ced
child 319416 eb275ae09be427d8a78bda2c9fab86418f67c5d8
push id1079
push userjlund@mozilla.com
push dateFri, 15 Apr 2016 21:02:33 +0000
treeherdermozilla-release@575fbf6786d5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdvander, ritu
bugs1257825
milestone46.0
Bug 1257825: Remove checks for paper height and width <= 0 in nsPrintSettings. r=dvander, a=ritu 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;