| Index: chrome/browser/resources/print_preview/preview_generator.js
|
| diff --git a/chrome/browser/resources/print_preview/preview_generator.js b/chrome/browser/resources/print_preview/preview_generator.js
|
| index 8313ed736b67de93ec7b07b9178ec17f896dc4f1..bd1f11f9cf85b5a4ebeec1172f90005f3784e854 100644
|
| --- a/chrome/browser/resources/print_preview/preview_generator.js
|
| +++ b/chrome/browser/resources/print_preview/preview_generator.js
|
| @@ -58,6 +58,14 @@ cr.define('print_preview', function() {
|
| this.inFlightRequestId_ = -1;
|
|
|
| /**
|
| + * Whether the current in flight request requires generating draft pages for
|
| + * print preview. This is true only for modifiable documents when the print
|
| + * settings has changed sufficiently to require re-rendering.
|
| + * @private {boolean}
|
| + */
|
| + this.generateDraft_ = false;
|
| +
|
| + /**
|
| * Media size to generate preview with. {@code null} indicates default size.
|
| * @type {cp.cdd.MediaSizeTicketItem}
|
| * @private
|
| @@ -173,7 +181,8 @@ cr.define('print_preview', function() {
|
| !this.destinationStore_.selectedDestination) {
|
| return false;
|
| }
|
| - if (!this.hasPreviewChanged_()) {
|
| + var previewChanged = this.hasPreviewChanged_();
|
| + if (!previewChanged && !this.hasPreviewPageRangeChanged_()) {
|
| // Changes to these ticket items might not trigger a new preview, but
|
| // they still need to be recorded.
|
| this.marginsType_ = this.printTicketStore_.marginsType.getValue();
|
| @@ -195,10 +204,12 @@ cr.define('print_preview', function() {
|
| this.selectedDestination_ = this.destinationStore_.selectedDestination;
|
|
|
| this.inFlightRequestId_++;
|
| + this.generateDraft_ = this.documentInfo_.isModifiable && previewChanged;
|
| this.nativeLayer_.startGetPreview(
|
| this.destinationStore_.selectedDestination,
|
| this.printTicketStore_,
|
| this.documentInfo_,
|
| + this.generateDraft_,
|
| this.inFlightRequestId_);
|
| return true;
|
| },
|
| @@ -273,8 +284,9 @@ cr.define('print_preview', function() {
|
| },
|
|
|
| /**
|
| - * @return {boolean} Whether the print ticket has changed sufficiently to
|
| - * determine whether a new preview request should be issued.
|
| + * @return {boolean} Whether the print ticket, excluding the page range, has
|
| + * changed sufficiently to determine whether a new preview request
|
| + * should be issued.
|
| * @private
|
| */
|
| hasPreviewChanged_: function() {
|
| @@ -286,9 +298,6 @@ cr.define('print_preview', function() {
|
| !ticketStore.color.isValueEqual(this.colorValue_) ||
|
| !ticketStore.scaling.isValueEqual(this.scalingValue_) ||
|
| !ticketStore.fitToPage.isValueEqual(this.isFitToPageEnabled_) ||
|
| - this.pageRanges_ == null ||
|
| - !areRangesEqual(ticketStore.pageRange.getPageRanges(),
|
| - this.pageRanges_) ||
|
| (!ticketStore.marginsType.isValueEqual(this.marginsType_) &&
|
| !ticketStore.marginsType.isValueEqual(
|
| print_preview.ticket_items.MarginsType.Value.CUSTOM)) ||
|
| @@ -305,6 +314,17 @@ cr.define('print_preview', function() {
|
| },
|
|
|
| /**
|
| + * @return {boolean} Whether the page range in the print ticket has changed.
|
| + * @private
|
| + */
|
| + hasPreviewPageRangeChanged_: function() {
|
| + return this.pageRanges_ == null ||
|
| + !areRangesEqual(
|
| + this.printTicketStore_.pageRange.getPageRanges(),
|
| + this.pageRanges_);
|
| + },
|
| +
|
| + /**
|
| * Called when the page layout of the document is ready. Always occurs
|
| * as a result of a preview request.
|
| * @param {Event} event Contains layout info about the document.
|
| @@ -387,9 +407,10 @@ cr.define('print_preview', function() {
|
| if (this.inFlightRequestId_ != event.previewResponseId) {
|
| return; // Ignore old response.
|
| }
|
| - // Dispatch a PREVIEW_START event since non-modifiable documents don't
|
| - // trigger PAGE_READY events.
|
| - if (!this.documentInfo_.isModifiable) {
|
| + if (!this.generateDraft_) {
|
| + // Dispatch a PREVIEW_START event since not generating a draft PDF,
|
| + // which includes print preview for non-modifiable documents, does not
|
| + // trigger PAGE_READY events.
|
| this.dispatchPreviewStartEvent_(event.previewUid, 0);
|
| }
|
| cr.dispatchSimpleEvent(this, PreviewGenerator.EventType.DOCUMENT_READY);
|
|
|