| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 cr.define('print_preview', function() { | 5 cr.define('print_preview', function() { |
| 6 'use strict'; | 6 'use strict'; |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * Interface to the Chromium print preview generator. | 9 * Interface to the Chromium print preview generator. |
| 10 * @param {!print_preview.DestinationStore} destinationStore Used to get the | 10 * @param {!print_preview.DestinationStore} destinationStore Used to get the |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 this.mediaSize_ = null; | 65 this.mediaSize_ = null; |
| 66 | 66 |
| 67 /** | 67 /** |
| 68 * Whether the previews are being generated in landscape mode. | 68 * Whether the previews are being generated in landscape mode. |
| 69 * @type {boolean} | 69 * @type {boolean} |
| 70 * @private | 70 * @private |
| 71 */ | 71 */ |
| 72 this.isLandscapeEnabled_ = false; | 72 this.isLandscapeEnabled_ = false; |
| 73 | 73 |
| 74 /** | 74 /** |
| 75 * Whether the previews are being generated from a distilled page. | |
| 76 * @type {boolean} | |
| 77 * @private | |
| 78 */ | |
| 79 this.isDistillPageEnabled_ = false; | |
| 80 | |
| 81 /** | |
| 82 * Whether the previews are being generated with a header and footer. | 75 * Whether the previews are being generated with a header and footer. |
| 83 * @type {boolean} | 76 * @type {boolean} |
| 84 * @private | 77 * @private |
| 85 */ | 78 */ |
| 86 this.isHeaderFooterEnabled_ = false; | 79 this.isHeaderFooterEnabled_ = false; |
| 87 | 80 |
| 88 /** | 81 /** |
| 89 * Whether the previews are being generated in color. | 82 * Whether the previews are being generated in color. |
| 90 * @type {boolean} | 83 * @type {boolean} |
| 91 * @private | 84 * @private |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 if (!this.hasPreviewChanged_()) { | 168 if (!this.hasPreviewChanged_()) { |
| 176 // Changes to these ticket items might not trigger a new preview, but | 169 // Changes to these ticket items might not trigger a new preview, but |
| 177 // they still need to be recorded. | 170 // they still need to be recorded. |
| 178 this.marginsType_ = this.printTicketStore_.marginsType.getValue(); | 171 this.marginsType_ = this.printTicketStore_.marginsType.getValue(); |
| 179 return false; | 172 return false; |
| 180 } | 173 } |
| 181 this.mediaSize_ = this.printTicketStore_.mediaSize.getValue(); | 174 this.mediaSize_ = this.printTicketStore_.mediaSize.getValue(); |
| 182 this.isLandscapeEnabled_ = this.printTicketStore_.landscape.getValue(); | 175 this.isLandscapeEnabled_ = this.printTicketStore_.landscape.getValue(); |
| 183 this.isHeaderFooterEnabled_ = | 176 this.isHeaderFooterEnabled_ = |
| 184 this.printTicketStore_.headerFooter.getValue(); | 177 this.printTicketStore_.headerFooter.getValue(); |
| 185 this.isDistillPageEnabled_ = | |
| 186 this.printTicketStore_.distillPage.getValue(); | |
| 187 this.colorValue_ = this.printTicketStore_.color.getValue(); | 178 this.colorValue_ = this.printTicketStore_.color.getValue(); |
| 188 this.isFitToPageEnabled_ = this.printTicketStore_.fitToPage.getValue(); | 179 this.isFitToPageEnabled_ = this.printTicketStore_.fitToPage.getValue(); |
| 189 this.pageRanges_ = this.printTicketStore_.pageRange.getPageRanges(); | 180 this.pageRanges_ = this.printTicketStore_.pageRange.getPageRanges(); |
| 190 this.marginsType_ = this.printTicketStore_.marginsType.getValue(); | 181 this.marginsType_ = this.printTicketStore_.marginsType.getValue(); |
| 191 this.isCssBackgroundEnabled_ = | 182 this.isCssBackgroundEnabled_ = |
| 192 this.printTicketStore_.cssBackground.getValue(); | 183 this.printTicketStore_.cssBackground.getValue(); |
| 193 this.isSelectionOnlyEnabled_ = | 184 this.isSelectionOnlyEnabled_ = |
| 194 this.printTicketStore_.selectionOnly.getValue(); | 185 this.printTicketStore_.selectionOnly.getValue(); |
| 195 this.selectedDestination_ = this.destinationStore_.selectedDestination; | 186 this.selectedDestination_ = this.destinationStore_.selectedDestination; |
| 196 | 187 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 * @return {boolean} Whether the print ticket has changed sufficiently to | 267 * @return {boolean} Whether the print ticket has changed sufficiently to |
| 277 * determine whether a new preview request should be issued. | 268 * determine whether a new preview request should be issued. |
| 278 * @private | 269 * @private |
| 279 */ | 270 */ |
| 280 hasPreviewChanged_: function() { | 271 hasPreviewChanged_: function() { |
| 281 var ticketStore = this.printTicketStore_; | 272 var ticketStore = this.printTicketStore_; |
| 282 return this.inFlightRequestId_ == -1 || | 273 return this.inFlightRequestId_ == -1 || |
| 283 !ticketStore.mediaSize.isValueEqual(this.mediaSize_) || | 274 !ticketStore.mediaSize.isValueEqual(this.mediaSize_) || |
| 284 !ticketStore.landscape.isValueEqual(this.isLandscapeEnabled_) || | 275 !ticketStore.landscape.isValueEqual(this.isLandscapeEnabled_) || |
| 285 !ticketStore.headerFooter.isValueEqual(this.isHeaderFooterEnabled_) || | 276 !ticketStore.headerFooter.isValueEqual(this.isHeaderFooterEnabled_) || |
| 286 !ticketStore.distillPage.isValueEqual( | |
| 287 this.isDistillPageEnabled_) || | |
| 288 !ticketStore.color.isValueEqual(this.colorValue_) || | 277 !ticketStore.color.isValueEqual(this.colorValue_) || |
| 289 !ticketStore.fitToPage.isValueEqual(this.isFitToPageEnabled_) || | 278 !ticketStore.fitToPage.isValueEqual(this.isFitToPageEnabled_) || |
| 290 this.pageRanges_ == null || | 279 this.pageRanges_ == null || |
| 291 !areRangesEqual(ticketStore.pageRange.getPageRanges(), | 280 !areRangesEqual(ticketStore.pageRange.getPageRanges(), |
| 292 this.pageRanges_) || | 281 this.pageRanges_) || |
| 293 (!ticketStore.marginsType.isValueEqual(this.marginsType_) && | 282 (!ticketStore.marginsType.isValueEqual(this.marginsType_) && |
| 294 !ticketStore.marginsType.isValueEqual( | 283 !ticketStore.marginsType.isValueEqual( |
| 295 print_preview.ticket_items.MarginsType.Value.CUSTOM)) || | 284 print_preview.ticket_items.MarginsType.Value.CUSTOM)) || |
| 296 (ticketStore.marginsType.isValueEqual( | 285 (ticketStore.marginsType.isValueEqual( |
| 297 print_preview.ticket_items.MarginsType.Value.CUSTOM) && | 286 print_preview.ticket_items.MarginsType.Value.CUSTOM) && |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 // current one. | 394 // current one. |
| 406 cr.dispatchSimpleEvent(this, PreviewGenerator.EventType.FAIL); | 395 cr.dispatchSimpleEvent(this, PreviewGenerator.EventType.FAIL); |
| 407 } | 396 } |
| 408 }; | 397 }; |
| 409 | 398 |
| 410 // Export | 399 // Export |
| 411 return { | 400 return { |
| 412 PreviewGenerator: PreviewGenerator | 401 PreviewGenerator: PreviewGenerator |
| 413 }; | 402 }; |
| 414 }); | 403 }); |
| OLD | NEW |