Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit b9943ff

Browse files
committed
Bug 1691286: Fix nsPrintSettingsWin::CopyFromNative to reliably encode the pages' orientation in the mOrientation field (fixing mismatched landscape/portrait rendering in some cases). r=jfkthame, a=pascalc
This was just a silly typo; I got the order of the ternary expression's options backwards. The mistake wasn't obvious from testing, because this function isn't always invoked. In particular, it's not invoked if I print "https://example.org" in a fresh profile, but it *is* invoked if I print "about:support" or other browser-internal pages. Differential Revision: https://phabricator.services.mozilla.com/D104354
1 parent b0a386e commit b9943ff

File tree

3 files changed

+54
-2
lines changed

3 files changed

+54
-2
lines changed

layout/base/tests/chrome/chrome.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ skip-if = (verify && (os == 'win'))
103103
skip-if = webrender
104104
[test_get_printer_basic_attributes.html]
105105
[test_get_printer_paper_sizes.html]
106+
[test_get_printer_orientation.html]
106107
[test_getClientRectsAndTexts.html]
107108
[test_css_visibility_propagation.xhtml]
108109
support-files =
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<!DOCTYPE HTML>
2+
<html>
3+
<head>
4+
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
5+
</head>
6+
<body onload="run()">
7+
<script>
8+
9+
SimpleTest.waitForExplicitFinish();
10+
11+
async function run() {
12+
try {
13+
let printerList = Cc["@mozilla.org/gfx/printerlist;1"].getService(
14+
Ci.nsIPrinterList
15+
);
16+
var settingsSvc = Cc["@mozilla.org/gfx/printsettings-service;1"].getService(
17+
Ci.nsIPrintSettingsService
18+
);
19+
20+
let printers = await printerList.printers;
21+
for (let printer of printers) {
22+
printer.QueryInterface(Ci.nsIPrinter);
23+
let printerInfo = await printer.printerInfo;
24+
25+
// Look up the printer's defaultSettings:
26+
let defaultSettings = printerInfo.defaultSettings;
27+
28+
// Let the printer impose its defaults onto a fresh settings object:
29+
let freshSettings = settingsSvc.newPrintSettings;
30+
printerList.initPrintSettingsFromPrinter(printer.name, freshSettings);
31+
32+
// Make sure they agree on the default orientation:
33+
is(freshSettings.orientation, defaultSettings.orientation,
34+
"initPrintSettingsFromPrinter should produce the same orientation " +
35+
"as the printer's defaultSettings");
36+
}
37+
38+
// This ok() just lets us avoid failure-due-to-no-tests-being-run, on
39+
// devices that have no printers available & hence skip the loop above:
40+
ok(true, "Finished traversing printers.");
41+
} catch (e) {
42+
ok(false, `Error thrown while retrieving printer info: ${e}.`);
43+
Cu.reportError(e);
44+
}
45+
SimpleTest.finish();
46+
}
47+
48+
</script>
49+
</body>
50+
</html>

widget/windows/nsPrintSettingsWin.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,9 @@ void nsPrintSettingsWin::CopyFromNative(HDC aHdc, DEVMODEW* aDevMode) {
334334
const bool arePagesPortraitMode =
335335
(areSheetsOfPaperPortraitMode != HasOrthogonalSheetsAndPages());
336336

337-
mOrientation = int32_t(arePagesPortraitMode ? kLandscapeOrientation
338-
: kPortraitOrientation);
337+
// Record the orientation of the pages (determined above) in mOrientation:
338+
mOrientation = int32_t(arePagesPortraitMode ? kPortraitOrientation
339+
: kLandscapeOrientation);
339340
}
340341

341342
if (aDevMode->dmFields & DM_COPIES) {

0 commit comments

Comments
 (0)