OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
596 screenWidth = dipWidth + insets.left + insets.right; | 596 screenWidth = dipWidth + insets.left + insets.right; |
597 screenHeight = dipHeight + insets.top + insets.bottom; | 597 screenHeight = dipHeight + insets.top + insets.bottom; |
598 positionX = insets.left; | 598 positionX = insets.left; |
599 positionY = insets.top; | 599 positionY = insets.top; |
600 } | 600 } |
601 this._deviceScale = scale; | 601 this._deviceScale = scale; |
602 | 602 |
603 this._deviceMetricsThrottler.schedule(setDeviceMetricsOverride.bind(this
)); | 603 this._deviceMetricsThrottler.schedule(setDeviceMetricsOverride.bind(this
)); |
604 | 604 |
605 /** | 605 /** |
606 * @param {!WebInspector.Throttler.FinishCallback} finishCallback | |
607 * @this {WebInspector.OverridesSupport} | 606 * @this {WebInspector.OverridesSupport} |
| 607 * @return {!Promise.<undefined>} |
608 */ | 608 */ |
609 function setDeviceMetricsOverride(finishCallback) | 609 function setDeviceMetricsOverride() |
610 { | 610 { |
611 this._target.emulationAgent().setDeviceMetricsOverride( | 611 var promise = this._target.emulationAgent().setDeviceMetricsOverride
( |
612 overrideWidth, overrideHeight, this.settings.emulateResolution.g
et() ? this.settings.deviceScaleFactor.get() : 0, | 612 overrideWidth, overrideHeight, this.settings.emulateResolution.g
et() ? this.settings.deviceScaleFactor.get() : 0, |
613 this.settings.emulateMobile.get(), this._pageResizer ? false : t
his.settings.deviceFitWindow.get(), scale, 0, 0, | 613 this.settings.emulateMobile.get(), this._pageResizer ? false : t
his.settings.deviceFitWindow.get(), scale, 0, 0, |
614 screenWidth, screenHeight, positionX, positionY, apiCallback.bin
d(this)) | 614 screenWidth, screenHeight, positionX, positionY, apiCallback.bin
d(this)) |
615 .then(finishCallback) | |
616 .catch(/** @type {function()} */(finishCallback)); | |
617 if (resetScrollAndPageScale) | 615 if (resetScrollAndPageScale) |
618 this._target.emulationAgent().resetScrollAndPageScaleFactor(); | 616 this._target.emulationAgent().resetScrollAndPageScaleFactor(); |
| 617 return promise; |
619 } | 618 } |
620 | 619 |
621 /** | 620 /** |
622 * @param {!WebInspector.Throttler.FinishCallback} finishCallback | |
623 * @this {WebInspector.OverridesSupport} | 621 * @this {WebInspector.OverridesSupport} |
| 622 * @return {!Promise.<undefined>} |
624 */ | 623 */ |
625 function clearDeviceMetricsOverride(finishCallback) | 624 function clearDeviceMetricsOverride() |
626 { | 625 { |
627 this._target.emulationAgent().clearDeviceMetricsOverride(apiCallback
.bind(this)) | 626 return this._target.emulationAgent().clearDeviceMetricsOverride(apiC
allback.bind(this)) |
628 .then(finishCallback) | |
629 .catch(/** @type {function()} */(finishCallback)); | |
630 } | 627 } |
631 | 628 |
632 /** | 629 /** |
633 * @param {?Protocol.Error} error | 630 * @param {?Protocol.Error} error |
634 * @this {WebInspector.OverridesSupport} | 631 * @this {WebInspector.OverridesSupport} |
635 */ | 632 */ |
636 function apiCallback(error) | 633 function apiCallback(error) |
637 { | 634 { |
638 if (error) { | 635 if (error) { |
639 this._updateDeviceMetricsWarningMessage(WebInspector.UIString("S
creen emulation is not available on this page.")); | 636 this._updateDeviceMetricsWarningMessage(WebInspector.UIString("S
creen emulation is not available on this page.")); |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
820 }, | 817 }, |
821 | 818 |
822 __proto__: WebInspector.Object.prototype | 819 __proto__: WebInspector.Object.prototype |
823 } | 820 } |
824 | 821 |
825 | 822 |
826 /** | 823 /** |
827 * @type {!WebInspector.OverridesSupport} | 824 * @type {!WebInspector.OverridesSupport} |
828 */ | 825 */ |
829 WebInspector.overridesSupport; | 826 WebInspector.overridesSupport; |
OLD | NEW |