| 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 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 }, | 269 }, |
| 270 | 270 |
| 271 /** | 271 /** |
| 272 * @param {boolean} enabled | 272 * @param {boolean} enabled |
| 273 */ | 273 */ |
| 274 setEmulationEnabled: function(enabled) | 274 setEmulationEnabled: function(enabled) |
| 275 { | 275 { |
| 276 if (this.canEmulate()) { | 276 if (this.canEmulate()) { |
| 277 this.settings._emulationEnabled.set(enabled); | 277 this.settings._emulationEnabled.set(enabled); |
| 278 this.dispatchEventToListeners(WebInspector.OverridesSupport.Events.E
mulationStateChanged); | 278 this.dispatchEventToListeners(WebInspector.OverridesSupport.Events.E
mulationStateChanged); |
| 279 if (enabled && this.settings.emulateResolution.get()) | |
| 280 this._target.pageAgent().resetScrollAndPageScaleFactor(); | |
| 281 } | 279 } |
| 282 }, | 280 }, |
| 283 | 281 |
| 284 /** | 282 /** |
| 285 * @return {boolean} | 283 * @return {boolean} |
| 286 */ | 284 */ |
| 287 responsiveDesignAvailable: function() | 285 responsiveDesignAvailable: function() |
| 288 { | 286 { |
| 289 return this._responsiveDesignAvailable; | 287 return this._responsiveDesignAvailable; |
| 290 }, | 288 }, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 this.settings.deviceHeight.set(device.height); | 325 this.settings.deviceHeight.set(device.height); |
| 328 this.settings.deviceScaleFactor.set(device.deviceScaleFactor); | 326 this.settings.deviceScaleFactor.set(device.deviceScaleFactor); |
| 329 this.settings.emulateTouch.set(device.touch); | 327 this.settings.emulateTouch.set(device.touch); |
| 330 this.settings.emulateMobile.set(device.mobile); | 328 this.settings.emulateMobile.set(device.mobile); |
| 331 delete this._deviceMetricsChangedListenerMuted; | 329 delete this._deviceMetricsChangedListenerMuted; |
| 332 delete this._userAgentChangedListenerMuted; | 330 delete this._userAgentChangedListenerMuted; |
| 333 | 331 |
| 334 if (this._initialized) { | 332 if (this._initialized) { |
| 335 this._deviceMetricsChanged(); | 333 this._deviceMetricsChanged(); |
| 336 this._userAgentChanged(); | 334 this._userAgentChanged(); |
| 337 this._target.pageAgent().resetScrollAndPageScaleFactor(); | 335 PageAgent.resetScrollAndPageScaleFactor(); |
| 338 } | 336 } |
| 339 }, | 337 }, |
| 340 | 338 |
| 341 reset: function() | 339 reset: function() |
| 342 { | 340 { |
| 343 this._deviceMetricsChangedListenerMuted = true; | 341 this._deviceMetricsChangedListenerMuted = true; |
| 344 this._userAgentChangedListenerMuted = true; | 342 this._userAgentChangedListenerMuted = true; |
| 345 this.settings.userAgent.set(""); | 343 this.settings.userAgent.set(""); |
| 346 this.settings.emulateResolution.set(false); | 344 this.settings.emulateResolution.set(false); |
| 347 this.settings.deviceScaleFactor.set(0); | 345 this.settings.deviceScaleFactor.set(0); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 if (this.settings.overrideGeolocation.get()) | 457 if (this.settings.overrideGeolocation.get()) |
| 460 this._geolocationPositionChanged(); | 458 this._geolocationPositionChanged(); |
| 461 | 459 |
| 462 if (this.settings.emulateTouch.get()) | 460 if (this.settings.emulateTouch.get()) |
| 463 this._emulateTouchEventsChanged(); | 461 this._emulateTouchEventsChanged(); |
| 464 | 462 |
| 465 if (this.settings.overrideCSSMedia.get()) | 463 if (this.settings.overrideCSSMedia.get()) |
| 466 this._cssMediaChanged(); | 464 this._cssMediaChanged(); |
| 467 | 465 |
| 468 this._deviceMetricsChanged(); | 466 this._deviceMetricsChanged(); |
| 469 if (this.settings.emulateResolution.get()) | |
| 470 this._target.pageAgent().resetScrollAndPageScaleFactor(); | |
| 471 | 467 |
| 472 this._userAgentChanged(); | 468 this._userAgentChanged(); |
| 473 | 469 |
| 474 if (this.networkThroughputIsLimited()) | 470 if (this.networkThroughputIsLimited()) |
| 475 this._networkConditionsChanged(); | 471 this._networkConditionsChanged(); |
| 476 }, | 472 }, |
| 477 | 473 |
| 478 _userAgentChanged: function() | 474 _userAgentChanged: function() |
| 479 { | 475 { |
| 480 if (this._userAgentChangedListenerMuted) | 476 if (this._userAgentChangedListenerMuted) |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 this._deviceScale = scale; | 565 this._deviceScale = scale; |
| 570 | 566 |
| 571 this._deviceMetricsThrottler.schedule(setDeviceMetricsOverride.bind(this
)); | 567 this._deviceMetricsThrottler.schedule(setDeviceMetricsOverride.bind(this
)); |
| 572 | 568 |
| 573 /** | 569 /** |
| 574 * @param {!WebInspector.Throttler.FinishCallback} finishCallback | 570 * @param {!WebInspector.Throttler.FinishCallback} finishCallback |
| 575 * @this {WebInspector.OverridesSupport} | 571 * @this {WebInspector.OverridesSupport} |
| 576 */ | 572 */ |
| 577 function setDeviceMetricsOverride(finishCallback) | 573 function setDeviceMetricsOverride(finishCallback) |
| 578 { | 574 { |
| 579 this._target.pageAgent().setDeviceMetricsOverride( | 575 PageAgent.setDeviceMetricsOverride( |
| 580 overrideWidth, overrideHeight, this.settings.emulateResolution.g
et() ? this.settings.deviceScaleFactor.get() : 0, | 576 overrideWidth, overrideHeight, this.settings.emulateResolution.g
et() ? this.settings.deviceScaleFactor.get() : 0, |
| 581 this.settings.emulateMobile.get(), this._pageResizer ? false : t
his.settings.deviceFitWindow.get(), scale, 0, 0, | 577 this.settings.emulateMobile.get(), this._pageResizer ? false : t
his.settings.deviceFitWindow.get(), scale, 0, 0, |
| 582 apiCallback.bind(this, finishCallback)); | 578 apiCallback.bind(this, finishCallback)); |
| 583 } | 579 } |
| 584 | 580 |
| 585 /** | 581 /** |
| 586 * @param {!WebInspector.Throttler.FinishCallback} finishCallback | 582 * @param {!WebInspector.Throttler.FinishCallback} finishCallback |
| 587 * @this {WebInspector.OverridesSupport} | 583 * @this {WebInspector.OverridesSupport} |
| 588 */ | 584 */ |
| 589 function clearDeviceMetricsOverride(finishCallback) | 585 function clearDeviceMetricsOverride(finishCallback) |
| 590 { | 586 { |
| 591 this._target.pageAgent().clearDeviceMetricsOverride(apiCallback.bind
(this, finishCallback)); | 587 PageAgent.clearDeviceMetricsOverride(apiCallback.bind(this, finishCa
llback)); |
| 592 } | 588 } |
| 593 | 589 |
| 594 /** | 590 /** |
| 595 * @param {!WebInspector.Throttler.FinishCallback} finishCallback | 591 * @param {!WebInspector.Throttler.FinishCallback} finishCallback |
| 596 * @param {?Protocol.Error} error | 592 * @param {?Protocol.Error} error |
| 597 * @this {WebInspector.OverridesSupport} | 593 * @this {WebInspector.OverridesSupport} |
| 598 */ | 594 */ |
| 599 function apiCallback(finishCallback, error) | 595 function apiCallback(finishCallback, error) |
| 600 { | 596 { |
| 601 if (error) { | 597 if (error) { |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 826 }, | 822 }, |
| 827 | 823 |
| 828 __proto__: WebInspector.Object.prototype | 824 __proto__: WebInspector.Object.prototype |
| 829 } | 825 } |
| 830 | 826 |
| 831 | 827 |
| 832 /** | 828 /** |
| 833 * @type {!WebInspector.OverridesSupport} | 829 * @type {!WebInspector.OverridesSupport} |
| 834 */ | 830 */ |
| 835 WebInspector.overridesSupport; | 831 WebInspector.overridesSupport; |
| OLD | NEW |