Commit 317e48ff authored by vitalybuka's avatar vitalybuka Committed by Commit bot

Set orientation to 'AUTO' if we hide orientation option from user.

BUG=383877

Review URL: https://codereview.chromium.org/580203002

Cr-Commit-Position: refs/heads/master@{#295545}
parent 55bbefae
...@@ -420,8 +420,13 @@ cr.define('print_preview', function() { ...@@ -420,8 +420,13 @@ cr.define('print_preview', function() {
vendor_id: value.vendor_id vendor_id: value.vendor_id
}; };
} }
if (this.landscape.isCapabilityAvailable() && if (!this.landscape.isCapabilityAvailable()) {
this.landscape.isUserEdited()) { // In this case "orientation" option is hidden from user, so user can't
// adjust it for page content, see Landscape.isCapabilityAvailable().
// We can improve results if we set AUTO here.
if (this.landscape.hasOption('AUTO'))
cjt.print.page_orientation = { type: 'AUTO' };
} else if (this.landscape.isUserEdited()) {
cjt.print.page_orientation = cjt.print.page_orientation =
{type: this.landscape.getValue() ? 'LANDSCAPE' : 'PORTRAIT'}; {type: this.landscape.getValue() ? 'LANDSCAPE' : 'PORTRAIT'};
} }
......
...@@ -57,9 +57,8 @@ cr.define('print_preview.ticket_items', function() { ...@@ -57,9 +57,8 @@ cr.define('print_preview.ticket_items', function() {
/** @override */ /** @override */
isCapabilityAvailable: function() { isCapabilityAvailable: function() {
var cap = this.getPageOrientationCapability_(); var cap = this.getPageOrientationCapability_();
if (!cap) { if (!cap)
return false; return false;
}
var hasAutoOrPortraitOption = false; var hasAutoOrPortraitOption = false;
var hasLandscapeOption = false; var hasLandscapeOption = false;
cap.option.forEach(function(option) { cap.option.forEach(function(option) {
...@@ -109,6 +108,19 @@ cr.define('print_preview.ticket_items', function() { ...@@ -109,6 +108,19 @@ cr.define('print_preview.ticket_items', function() {
} }
}, },
/**
* @return {boolean} Whether capability contains the |value|.
* @param {string} value Option to check.
*/
hasOption: function(value) {
var cap = this.getPageOrientationCapability_();
if (!cap)
return false;
return cap.option.some(function(option) {
return option.type == value;
});
},
/** /**
* @return {Object} Page orientation capability of the selected destination. * @return {Object} Page orientation capability of the selected destination.
* @private * @private
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment