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 * Creates a PreviewArea object. It represents the area where the preview | 9 * Creates a PreviewArea object. It represents the area where the preview |
10 * document is displayed. | 10 * document is displayed. |
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 * consequence of scrolling or zooming the plugin. Updates the custom | 560 * consequence of scrolling or zooming the plugin. Updates the custom |
561 * margins component if shown. | 561 * margins component if shown. |
562 * @private | 562 * @private |
563 */ | 563 */ |
564 onPreviewVisualStateChange_: function() { | 564 onPreviewVisualStateChange_: function() { |
565 if (this.isPluginReloaded_) { | 565 if (this.isPluginReloaded_) { |
566 this.zoomLevel_ = this.plugin_.getZoomLevel(); | 566 this.zoomLevel_ = this.plugin_.getZoomLevel(); |
567 this.pageOffset_ = new print_preview.Coordinate2d( | 567 this.pageOffset_ = new print_preview.Coordinate2d( |
568 this.plugin_.pageXOffset(), this.plugin_.pageYOffset()); | 568 this.plugin_.pageXOffset(), this.plugin_.pageYOffset()); |
569 } | 569 } |
570 var normalized = this.plugin_.getPageLocationNormalized().split(';'); | 570 var pageLocationNormalizedStr = this.plugin_.getPageLocationNormalized(); |
| 571 if (!pageLocationNormalizedStr) { |
| 572 return; |
| 573 } |
| 574 var normalized = pageLocationNormalizedStr.split(';'); |
571 var pluginWidth = this.plugin_.getWidth(); | 575 var pluginWidth = this.plugin_.getWidth(); |
572 var pluginHeight = this.plugin_.getHeight(); | 576 var pluginHeight = this.plugin_.getHeight(); |
573 var translationTransform = new print_preview.Coordinate2d( | 577 var translationTransform = new print_preview.Coordinate2d( |
574 parseFloat(normalized[0]) * pluginWidth, | 578 parseFloat(normalized[0]) * pluginWidth, |
575 parseFloat(normalized[1]) * pluginHeight); | 579 parseFloat(normalized[1]) * pluginHeight); |
576 this.marginControlContainer_.updateTranslationTransform( | 580 this.marginControlContainer_.updateTranslationTransform( |
577 translationTransform); | 581 translationTransform); |
578 var pageWidthInPixels = parseFloat(normalized[2]) * pluginWidth; | 582 var pageWidthInPixels = parseFloat(normalized[2]) * pluginWidth; |
579 this.marginControlContainer_.updateScaleTransform( | 583 this.marginControlContainer_.updateScaleTransform( |
580 pageWidthInPixels / this.printTicketStore_.pageSize.width); | 584 pageWidthInPixels / this.printTicketStore_.pageSize.width); |
581 this.marginControlContainer_.updateClippingMask( | 585 this.marginControlContainer_.updateClippingMask( |
582 new print_preview.Size( | 586 new print_preview.Size( |
583 pluginWidth - this.plugin_.getVerticalScrollbarThickness(), | 587 pluginWidth - this.plugin_.getVerticalScrollbarThickness(), |
584 pluginHeight - this.plugin_.getHorizontalScrollbarThickness())); | 588 pluginHeight - this.plugin_.getHorizontalScrollbarThickness())); |
585 } | 589 } |
586 }; | 590 }; |
587 | 591 |
588 // Export | 592 // Export |
589 return { | 593 return { |
590 PreviewArea: PreviewArea | 594 PreviewArea: PreviewArea |
591 }; | 595 }; |
592 }); | 596 }); |
OLD | NEW |