Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(199)

Unified Diff: chrome/browser/resources/print_preview/preview_generator.js

Issue 2833993004: Print Preview: Make generate draft mode work again. (Closed)
Patch Set: Check NativeLayerStub Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 6a955e055729be92c3d846c4355d7a5ed4caf381..cea71873ebad4ed25ec231298c4d5078977a6dfa 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.MarginsTypeValue.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);

Powered by Google App Engine
This is Rietveld 408576698