Bug 1276717: Add check for old invalid page size prefs of 11x8.5 mm. r=jimm, a=sylvestre
authorBob Owen <bobowencode@gmail.com>
Thu, 02 Jun 2016 10:53:32 +0100
changeset 333278 4cb85604e7d71e3740fa0337da782bbbaf4eddb3
parent 333277 cd44be6d1f822ca3bfe3c4a607b77b1f07923b8e
child 333279 68357b1b2625a5ed509998a494c55a29b758efd9
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimm, sylvestre
bugs1276717
milestone48.0a2
Bug 1276717: Add check for old invalid page size prefs of 11x8.5 mm. r=jimm, a=sylvestre
widget/nsPrintOptionsImpl.cpp
--- a/widget/nsPrintOptionsImpl.cpp
+++ b/widget/nsPrintOptionsImpl.cpp
@@ -528,16 +528,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);