| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 this.isHeaderFooterEnabled_ = false; | 79 this.isHeaderFooterEnabled_ = false; |
| 80 | 80 |
| 81 /** | 81 /** |
| 82 * Whether the previews are being generated in color. | 82 * Whether the previews are being generated in color. |
| 83 * @type {boolean} | 83 * @type {boolean} |
| 84 * @private | 84 * @private |
| 85 */ | 85 */ |
| 86 this.colorValue_ = false; | 86 this.colorValue_ = false; |
| 87 | 87 |
| 88 /** | 88 /** |
| 89 * Whether the document should be printed as a raster PDF. |
| 90 * @type {boolean} |
| 91 * @private |
| 92 */ |
| 93 this.rasterizeValue_ = false; |
| 94 |
| 95 /** |
| 89 * Whether the document should be fitted to the page. | 96 * Whether the document should be fitted to the page. |
| 90 * @type {boolean} | 97 * @type {boolean} |
| 91 * @private | 98 * @private |
| 92 */ | 99 */ |
| 93 this.isFitToPageEnabled_ = false; | 100 this.isFitToPageEnabled_ = false; |
| 94 | 101 |
| 95 /** | 102 /** |
| 96 * The scaling factor (in percent) for the document. Ignored if fit to page | 103 * The scaling factor (in percent) for the document. Ignored if fit to page |
| 97 * is true. | 104 * is true. |
| 98 * @type {number} | 105 * @type {number} |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 // Changes to these ticket items might not trigger a new preview, but | 184 // Changes to these ticket items might not trigger a new preview, but |
| 178 // they still need to be recorded. | 185 // they still need to be recorded. |
| 179 this.marginsType_ = this.printTicketStore_.marginsType.getValue(); | 186 this.marginsType_ = this.printTicketStore_.marginsType.getValue(); |
| 180 return false; | 187 return false; |
| 181 } | 188 } |
| 182 this.mediaSize_ = this.printTicketStore_.mediaSize.getValue(); | 189 this.mediaSize_ = this.printTicketStore_.mediaSize.getValue(); |
| 183 this.isLandscapeEnabled_ = this.printTicketStore_.landscape.getValue(); | 190 this.isLandscapeEnabled_ = this.printTicketStore_.landscape.getValue(); |
| 184 this.isHeaderFooterEnabled_ = | 191 this.isHeaderFooterEnabled_ = |
| 185 this.printTicketStore_.headerFooter.getValue(); | 192 this.printTicketStore_.headerFooter.getValue(); |
| 186 this.colorValue_ = this.printTicketStore_.color.getValue(); | 193 this.colorValue_ = this.printTicketStore_.color.getValue(); |
| 194 this.rasterizeValue_ = this.printTicketStore_.rasterize.getValue(); |
| 187 this.isFitToPageEnabled_ = this.printTicketStore_.fitToPage.getValue(); | 195 this.isFitToPageEnabled_ = this.printTicketStore_.fitToPage.getValue(); |
| 188 this.scalingValue_ = this.printTicketStore_.scaling.getValueAsNumber(); | 196 this.scalingValue_ = this.printTicketStore_.scaling.getValueAsNumber(); |
| 189 this.pageRanges_ = this.printTicketStore_.pageRange.getPageRanges(); | 197 this.pageRanges_ = this.printTicketStore_.pageRange.getPageRanges(); |
| 190 this.marginsType_ = this.printTicketStore_.marginsType.getValue(); | 198 this.marginsType_ = this.printTicketStore_.marginsType.getValue(); |
| 191 this.isCssBackgroundEnabled_ = | 199 this.isCssBackgroundEnabled_ = |
| 192 this.printTicketStore_.cssBackground.getValue(); | 200 this.printTicketStore_.cssBackground.getValue(); |
| 193 this.isSelectionOnlyEnabled_ = | 201 this.isSelectionOnlyEnabled_ = |
| 194 this.printTicketStore_.selectionOnly.getValue(); | 202 this.printTicketStore_.selectionOnly.getValue(); |
| 195 this.selectedDestination_ = this.destinationStore_.selectedDestination; | 203 this.selectedDestination_ = this.destinationStore_.selectedDestination; |
| 196 | 204 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 * determine whether a new preview request should be issued. | 285 * determine whether a new preview request should be issued. |
| 278 * @private | 286 * @private |
| 279 */ | 287 */ |
| 280 hasPreviewChanged_: function() { | 288 hasPreviewChanged_: function() { |
| 281 var ticketStore = this.printTicketStore_; | 289 var ticketStore = this.printTicketStore_; |
| 282 return this.inFlightRequestId_ == -1 || | 290 return this.inFlightRequestId_ == -1 || |
| 283 !ticketStore.mediaSize.isValueEqual(this.mediaSize_) || | 291 !ticketStore.mediaSize.isValueEqual(this.mediaSize_) || |
| 284 !ticketStore.landscape.isValueEqual(this.isLandscapeEnabled_) || | 292 !ticketStore.landscape.isValueEqual(this.isLandscapeEnabled_) || |
| 285 !ticketStore.headerFooter.isValueEqual(this.isHeaderFooterEnabled_) || | 293 !ticketStore.headerFooter.isValueEqual(this.isHeaderFooterEnabled_) || |
| 286 !ticketStore.color.isValueEqual(this.colorValue_) || | 294 !ticketStore.color.isValueEqual(this.colorValue_) || |
| 295 !ticketStore.rasterize.isValueEqual(this.rasterizeValue_) || |
| 287 !ticketStore.scaling.isValueEqual(this.scalingValue_) || | 296 !ticketStore.scaling.isValueEqual(this.scalingValue_) || |
| 288 !ticketStore.fitToPage.isValueEqual(this.isFitToPageEnabled_) || | 297 !ticketStore.fitToPage.isValueEqual(this.isFitToPageEnabled_) || |
| 289 this.pageRanges_ == null || | 298 this.pageRanges_ == null || |
| 290 !areRangesEqual(ticketStore.pageRange.getPageRanges(), | 299 !areRangesEqual(ticketStore.pageRange.getPageRanges(), |
| 291 this.pageRanges_) || | 300 this.pageRanges_) || |
| 292 (!ticketStore.marginsType.isValueEqual(this.marginsType_) && | 301 (!ticketStore.marginsType.isValueEqual(this.marginsType_) && |
| 293 !ticketStore.marginsType.isValueEqual( | 302 !ticketStore.marginsType.isValueEqual( |
| 294 print_preview.ticket_items.MarginsType.Value.CUSTOM)) || | 303 print_preview.ticket_items.MarginsType.Value.CUSTOM)) || |
| 295 (ticketStore.marginsType.isValueEqual( | 304 (ticketStore.marginsType.isValueEqual( |
| 296 print_preview.ticket_items.MarginsType.Value.CUSTOM) && | 305 print_preview.ticket_items.MarginsType.Value.CUSTOM) && |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 // current one. | 413 // current one. |
| 405 cr.dispatchSimpleEvent(this, PreviewGenerator.EventType.FAIL); | 414 cr.dispatchSimpleEvent(this, PreviewGenerator.EventType.FAIL); |
| 406 } | 415 } |
| 407 }; | 416 }; |
| 408 | 417 |
| 409 // Export | 418 // Export |
| 410 return { | 419 return { |
| 411 PreviewGenerator: PreviewGenerator | 420 PreviewGenerator: PreviewGenerator |
| 412 }; | 421 }; |
| 413 }); | 422 }); |
| OLD | NEW |