| 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 /** | 5 /** |
| 6 * @typedef {{accessibility: Function, | 6 * @typedef {{accessibility: Function, |
| 7 * documentLoadComplete: Function, | 7 * documentLoadComplete: Function, |
| 8 * getHeight: Function, | 8 * getHeight: Function, |
| 9 * getHorizontalScrollbarThickness: Function, | 9 * getHorizontalScrollbarThickness: Function, |
| 10 * getPageLocationNormalized: Function, | 10 * getPageLocationNormalized: Function, |
| (...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 * Called when the preview generation is complete and the document is ready | 595 * Called when the preview generation is complete and the document is ready |
| 596 * to print. | 596 * to print. |
| 597 * @private | 597 * @private |
| 598 */ | 598 */ |
| 599 onDocumentReady_: function(event) { | 599 onDocumentReady_: function(event) { |
| 600 this.isDocumentReady_ = true; | 600 this.isDocumentReady_ = true; |
| 601 this.dispatchPreviewGenerationDoneIfReady_(); | 601 this.dispatchPreviewGenerationDoneIfReady_(); |
| 602 }, | 602 }, |
| 603 | 603 |
| 604 /** | 604 /** |
| 605 * Cancels the timeout so that an error message can be shown. |
| 606 */ |
| 607 cancelTimeout: function() { |
| 608 if (this.loadingTimeout_) { |
| 609 clearTimeout(this.loadingTimeout_); |
| 610 this.loadingTimeout_ = null; |
| 611 } |
| 612 }, |
| 613 |
| 614 /** |
| 605 * Called when the generation of a preview fails. Shows an error message. | 615 * Called when the generation of a preview fails. Shows an error message. |
| 606 * @private | 616 * @private |
| 607 */ | 617 */ |
| 608 onPreviewGenerationFail_: function() { | 618 onPreviewGenerationFail_: function() { |
| 609 if (this.loadingTimeout_) { | 619 this.cancelTimeout(); |
| 610 clearTimeout(this.loadingTimeout_); | |
| 611 this.loadingTimeout_ = null; | |
| 612 } | |
| 613 this.showMessage_(PreviewArea.MessageId_.PREVIEW_FAILED); | 620 this.showMessage_(PreviewArea.MessageId_.PREVIEW_FAILED); |
| 614 cr.dispatchSimpleEvent( | 621 cr.dispatchSimpleEvent( |
| 615 this, PreviewArea.EventType.PREVIEW_GENERATION_FAIL); | 622 this, PreviewArea.EventType.PREVIEW_GENERATION_FAIL); |
| 616 }, | 623 }, |
| 617 | 624 |
| 618 /** | 625 /** |
| 619 * Called when the plugin loads. This is a consequence of calling | 626 * Called when the plugin loads. This is a consequence of calling |
| 620 * plugin.reload(). Certain plugin state can only be set after the plugin | 627 * plugin.reload(). Certain plugin state can only be set after the plugin |
| 621 * has loaded. | 628 * has loaded. |
| 622 * @private | 629 * @private |
| 623 */ | 630 */ |
| 624 onPluginLoad_: function() { | 631 onPluginLoad_: function() { |
| 625 if (this.loadingTimeout_) { | 632 this.cancelTimeout(); |
| 626 clearTimeout(this.loadingTimeout_); | |
| 627 this.loadingTimeout_ = null; | |
| 628 } | |
| 629 | |
| 630 this.setOverlayVisible_(false); | 633 this.setOverlayVisible_(false); |
| 631 this.isPluginReloaded_ = true; | 634 this.isPluginReloaded_ = true; |
| 632 this.dispatchPreviewGenerationDoneIfReady_(); | 635 this.dispatchPreviewGenerationDoneIfReady_(); |
| 633 }, | 636 }, |
| 634 | 637 |
| 635 /** | 638 /** |
| 636 * Called when the preview plugin's visual state has changed. This is a | 639 * Called when the preview plugin's visual state has changed. This is a |
| 637 * consequence of scrolling or zooming the plugin. Updates the custom | 640 * consequence of scrolling or zooming the plugin. Updates the custom |
| 638 * margins component if shown. | 641 * margins component if shown. |
| 639 * @private | 642 * @private |
| (...skipping 26 matching lines...) Expand all Loading... |
| 666 // being draggable. | 669 // being draggable. |
| 667 this.plugin_.style.pointerEvents = isDragging ? 'none' : 'auto'; | 670 this.plugin_.style.pointerEvents = isDragging ? 'none' : 'auto'; |
| 668 } | 671 } |
| 669 }; | 672 }; |
| 670 | 673 |
| 671 // Export | 674 // Export |
| 672 return { | 675 return { |
| 673 PreviewArea: PreviewArea | 676 PreviewArea: PreviewArea |
| 674 }; | 677 }; |
| 675 }); | 678 }); |
| OLD | NEW |