| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 * @constructor | 6 * @constructor |
| 7 * @extends {WebInspector.VBox} | 7 * @extends {WebInspector.VBox} |
| 8 * @implements {WebInspector.OverridesSupport.PageResizer} | 8 * @implements {WebInspector.OverridesSupport.PageResizer} |
| 9 * @implements {WebInspector.TargetManager.Observer} | 9 * @implements {WebInspector.TargetManager.Observer} |
| 10 * @param {!WebInspector.InspectedPagePlaceholder} inspectedPagePlaceholder | 10 * @param {!WebInspector.InspectedPagePlaceholder} inspectedPagePlaceholder |
| (...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 780 this._viewport = viewport; | 780 this._viewport = viewport; |
| 781 this._viewport.minimumPageScaleFactor = Math.max(0.1, this._viewport
.minimumPageScaleFactor); | 781 this._viewport.minimumPageScaleFactor = Math.max(0.1, this._viewport
.minimumPageScaleFactor); |
| 782 this._viewport.minimumPageScaleFactor = Math.min(this._viewport.mini
mumPageScaleFactor, this._viewport.pageScaleFactor); | 782 this._viewport.minimumPageScaleFactor = Math.min(this._viewport.mini
mumPageScaleFactor, this._viewport.pageScaleFactor); |
| 783 this._viewport.maximumPageScaleFactor = Math.min(10, this._viewport.
maximumPageScaleFactor); | 783 this._viewport.maximumPageScaleFactor = Math.min(10, this._viewport.
maximumPageScaleFactor); |
| 784 this._viewport.maximumPageScaleFactor = Math.max(this._viewport.maxi
mumPageScaleFactor, this._viewport.pageScaleFactor); | 784 this._viewport.maximumPageScaleFactor = Math.max(this._viewport.maxi
mumPageScaleFactor, this._viewport.pageScaleFactor); |
| 785 this._viewportChangedThrottler.schedule(this._updateUIThrottled.bind
(this)); | 785 this._viewportChangedThrottler.schedule(this._updateUIThrottled.bind
(this)); |
| 786 } | 786 } |
| 787 }, | 787 }, |
| 788 | 788 |
| 789 /** | 789 /** |
| 790 * @param {!WebInspector.Throttler.FinishCallback} finishCallback | 790 * @return {!Promise.<?>} |
| 791 */ | 791 */ |
| 792 _updateUIThrottled: function(finishCallback) | 792 _updateUIThrottled: function() |
| 793 { | 793 { |
| 794 this._updateUI(); | 794 this._updateUI(); |
| 795 finishCallback(); | 795 return Promise.resolve(); |
| 796 }, | 796 }, |
| 797 | 797 |
| 798 /** | 798 /** |
| 799 * @param {boolean} increase | 799 * @param {boolean} increase |
| 800 * @param {!Event} event | 800 * @param {!Event} event |
| 801 */ | 801 */ |
| 802 _pageScaleButtonClicked: function(increase, event) | 802 _pageScaleButtonClicked: function(increase, event) |
| 803 { | 803 { |
| 804 this._pageScaleFactorThrottler.schedule(updatePageScaleFactor.bind(this)
); | 804 this._pageScaleFactorThrottler.schedule(updatePageScaleFactor.bind(this)
); |
| 805 | 805 |
| 806 /** | 806 /** |
| 807 * @param {!WebInspector.Throttler.FinishCallback} finishCallback | 807 * @return {!Promise.<?>} |
| 808 * @this {WebInspector.ResponsiveDesignView} | 808 * @this {WebInspector.ResponsiveDesignView} |
| 809 */ | 809 */ |
| 810 function updatePageScaleFactor(finishCallback) | 810 function updatePageScaleFactor() |
| 811 { | 811 { |
| 812 if (this._target && this._viewport) { | 812 if (this._target && this._viewport) { |
| 813 var value = this._viewport.pageScaleFactor; | 813 var value = this._viewport.pageScaleFactor; |
| 814 value = increase ? value * 1.1 : value / 1.1; | 814 value = increase ? value * 1.1 : value / 1.1; |
| 815 value = Math.min(this._viewport.maximumPageScaleFactor, value); | 815 value = Math.min(this._viewport.maximumPageScaleFactor, value); |
| 816 value = Math.max(this._viewport.minimumPageScaleFactor, value); | 816 value = Math.max(this._viewport.minimumPageScaleFactor, value); |
| 817 this._target.emulationAgent().setPageScaleFactor(value); | 817 this._target.emulationAgent().setPageScaleFactor(value); |
| 818 } | 818 } |
| 819 finishCallback(); | 819 return Promise.resolve(); |
| 820 } | 820 } |
| 821 }, | 821 }, |
| 822 | 822 |
| 823 _resetPageScale: function() | 823 _resetPageScale: function() |
| 824 { | 824 { |
| 825 this._pageScaleFactorThrottler.schedule(updatePageScaleFactor.bind(this)
); | 825 this._pageScaleFactorThrottler.schedule(updatePageScaleFactor.bind(this)
); |
| 826 | 826 |
| 827 /** | 827 /** |
| 828 * @param {!WebInspector.Throttler.FinishCallback} finishCallback | 828 * @return {!Promise.<?>} |
| 829 * @this {WebInspector.ResponsiveDesignView} | 829 * @this {WebInspector.ResponsiveDesignView} |
| 830 */ | 830 */ |
| 831 function updatePageScaleFactor(finishCallback) | 831 function updatePageScaleFactor() |
| 832 { | 832 { |
| 833 if (this._target && this._viewport && this._viewport.minimumPageScal
eFactor <= 1 && this._viewport.maximumPageScaleFactor >= 1) | 833 if (this._target && this._viewport && this._viewport.minimumPageScal
eFactor <= 1 && this._viewport.maximumPageScaleFactor >= 1) |
| 834 this._target.emulationAgent().setPageScaleFactor(1); | 834 this._target.emulationAgent().setPageScaleFactor(1); |
| 835 finishCallback(); | 835 return Promise.resolve(); |
| 836 } | 836 } |
| 837 }, | 837 }, |
| 838 | 838 |
| 839 __proto__: WebInspector.VBox.prototype | 839 __proto__: WebInspector.VBox.prototype |
| 840 }; | 840 }; |
| 841 | 841 |
| 842 | 842 |
| 843 /** | 843 /** |
| 844 * @constructor | 844 * @constructor |
| 845 * @implements {EmulationAgent.Dispatcher} | 845 * @implements {EmulationAgent.Dispatcher} |
| 846 * @param {!WebInspector.ResponsiveDesignView} responsiveDesignView | 846 * @param {!WebInspector.ResponsiveDesignView} responsiveDesignView |
| 847 */ | 847 */ |
| 848 WebInspector.EmulationDispatcher = function(responsiveDesignView) | 848 WebInspector.EmulationDispatcher = function(responsiveDesignView) |
| 849 { | 849 { |
| 850 this._responsiveDesignView = responsiveDesignView; | 850 this._responsiveDesignView = responsiveDesignView; |
| 851 } | 851 } |
| 852 | 852 |
| 853 WebInspector.EmulationDispatcher.prototype = { | 853 WebInspector.EmulationDispatcher.prototype = { |
| 854 /** | 854 /** |
| 855 * @override | 855 * @override |
| 856 * @param {!EmulationAgent.Viewport=} viewport | 856 * @param {!EmulationAgent.Viewport=} viewport |
| 857 */ | 857 */ |
| 858 viewportChanged: function(viewport) | 858 viewportChanged: function(viewport) |
| 859 { | 859 { |
| 860 this._responsiveDesignView._viewportChanged(viewport); | 860 this._responsiveDesignView._viewportChanged(viewport); |
| 861 } | 861 } |
| 862 } | 862 } |
| OLD | NEW |