Bug 1276717: Add check for old invalid page size prefs of 11x8.5 mm. r=jimm
authorBob Owen <bobowencode@gmail.com>
Thu, 02 Jun 2016 10:53:32 +0100
changeset 339162 0bc73f0ee72c85847932ae11f57a323ea898f0cb
parent 339161 f4fd6197c80aecef9e38887f4407956c7c667383
child 339163 a4ec9c9adf18e33f71a9a0daa92939900e8501e7
push id6249
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 13:59:36 +0000
treeherdermozilla-beta@bad9d4f5bf7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimm
bugs1276717
milestone49.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 1276717: Add check for old invalid page size prefs of 11x8.5 mm. r=jimm
widget/nsPrintOptionsImpl.cpp
--- a/widget/nsPrintOptionsImpl.cpp
+++ b/widget/nsPrintOptionsImpl.cpp
@@ -538,16 +538,33 @@ nsPrintOptions::ReadPrefs(nsIPrintSettin
 
     // Bug 315687: Sanity check paper size to avoid paper size values in
     // mm when the size unit flag is inches. The value 100 is arbitrary
     // and can be changed.
     if (success) {
       success = (sizeUnit != nsIPrintSettings::kPaperSizeInches)
              || (width < 100.0)
              || (height < 100.0);
+#if defined(XP_WIN)
+      // Work around legacy invalid prefs where the size unit gets set to
+      // millimeters, but the height and width remains as the default inches
+      // ones for letter. See bug 1276717.
+      if (sizeUnit == nsIPrintSettings::kPaperSizeMillimeters &&
+          height == 11L && width == 8.5L) {
+
+        // As an extra precaution only override, when the resolution is also
+        // set to the legacy invalid, uninitialized value. We'll just broadly
+        // assume that anything outside of a million DPI is invalid.
+        if (GETINTPREF(kPrintResolution, &iVal) &&
+            (iVal < 0 || iVal > 1000000)) {
+          height = -1L;
+          width = -1L;
+        }
+      }
+#endif
     }
 
     if (success) {
       aPS->SetPaperSizeUnit(sizeUnit);
       DUMP_INT(kReadStr, kPrintPaperSizeUnit, sizeUnit);
       aPS->SetPaperWidth(width);
       DUMP_DBL(kReadStr, kPrintPaperWidth, width);
       aPS->SetPaperHeight(height);