| 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 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 this.settings.emulateViewport.set(false); | 391 this.settings.emulateViewport.set(false); |
| 392 this.settings.deviceMetrics.set(""); | 392 this.settings.deviceMetrics.set(""); |
| 393 delete this._deviceMetricsChangedListenerMuted; | 393 delete this._deviceMetricsChangedListenerMuted; |
| 394 delete this._userAgentChangedListenerMuted; | 394 delete this._userAgentChangedListenerMuted; |
| 395 this._deviceMetricsChanged(); | 395 this._deviceMetricsChanged(); |
| 396 this._userAgentChanged(); | 396 this._userAgentChanged(); |
| 397 }, | 397 }, |
| 398 | 398 |
| 399 applyInitialOverrides: function() | 399 applyInitialOverrides: function() |
| 400 { | 400 { |
| 401 if (!this._target) { |
| 402 this._applyInitialOverridesOnTargetAdded = true; |
| 403 return; |
| 404 } |
| 405 |
| 401 if (this.settings.overrideDeviceOrientation.get()) | 406 if (this.settings.overrideDeviceOrientation.get()) |
| 402 this._deviceOrientationChanged(); | 407 this._deviceOrientationChanged(); |
| 403 | 408 |
| 404 if (this.settings.overrideGeolocation.get()) | 409 if (this.settings.overrideGeolocation.get()) |
| 405 this._geolocationPositionChanged(); | 410 this._geolocationPositionChanged(); |
| 406 | 411 |
| 407 if (this.settings.emulateTouchEvents.get()) | 412 if (this.settings.emulateTouchEvents.get()) |
| 408 this._emulateTouchEventsChanged(); | 413 this._emulateTouchEventsChanged(); |
| 409 | 414 |
| 410 if (this.settings.overrideCSSMedia.get()) | 415 if (this.settings.overrideCSSMedia.get()) |
| (...skipping 23 matching lines...) Expand all Loading... |
| 434 return; | 439 return; |
| 435 var metrics = WebInspector.OverridesSupport.DeviceMetrics.parseSetting(t
his.settings.overrideDeviceMetrics.get() ? this.settings.deviceMetrics.get() : "
"); | 440 var metrics = WebInspector.OverridesSupport.DeviceMetrics.parseSetting(t
his.settings.overrideDeviceMetrics.get() ? this.settings.deviceMetrics.get() : "
"); |
| 436 if (!metrics.isValid()) | 441 if (!metrics.isValid()) |
| 437 return; | 442 return; |
| 438 | 443 |
| 439 var dipWidth = Math.round(metrics.width); | 444 var dipWidth = Math.round(metrics.width); |
| 440 var dipHeight = Math.round(metrics.height); | 445 var dipHeight = Math.round(metrics.height); |
| 441 var metricsOverrideEnabled = !!(dipWidth && dipHeight); | 446 var metricsOverrideEnabled = !!(dipWidth && dipHeight); |
| 442 | 447 |
| 443 // Disable override without checks. | 448 // Disable override without checks. |
| 444 if (metricsOverrideEnabled && this.isInspectingDevice()) { | 449 if (metricsOverrideEnabled && this.isInspectingDevice()) |
| 445 this._updateDeviceMetricsWarningMessage(WebInspector.UIString("Scree
n emulation on the device is not available.")); | |
| 446 return; | 450 return; |
| 447 } | |
| 448 | 451 |
| 449 PageAgent.setDeviceMetricsOverride(dipWidth, dipHeight, metricsOverrideE
nabled ? metrics.deviceScaleFactor : 0, this.settings.emulateViewport.get(), thi
s.settings.deviceFitWindow.get(), metrics.textAutosizing, metrics.fontScaleFacto
r(), apiCallback.bind(this)); | 452 PageAgent.setDeviceMetricsOverride(dipWidth, dipHeight, metricsOverrideE
nabled ? metrics.deviceScaleFactor : 0, this.settings.emulateViewport.get(), thi
s.settings.deviceFitWindow.get(), metrics.textAutosizing, metrics.fontScaleFacto
r(), apiCallback.bind(this)); |
| 450 this.maybeHasActiveOverridesChanged(); | 453 this.maybeHasActiveOverridesChanged(); |
| 451 | 454 |
| 452 /** | 455 /** |
| 453 * @param {?Protocol.Error} error | 456 * @param {?Protocol.Error} error |
| 454 * @this {WebInspector.OverridesSupport} | 457 * @this {WebInspector.OverridesSupport} |
| 455 */ | 458 */ |
| 456 function apiCallback(error) | 459 function apiCallback(error) |
| 457 { | 460 { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 return; | 498 return; |
| 496 } | 499 } |
| 497 | 500 |
| 498 var deviceOrientation = WebInspector.OverridesSupport.DeviceOrientation.
parseSetting(this.settings.deviceOrientationOverride.get()); | 501 var deviceOrientation = WebInspector.OverridesSupport.DeviceOrientation.
parseSetting(this.settings.deviceOrientationOverride.get()); |
| 499 PageAgent.setDeviceOrientationOverride(deviceOrientation.alpha, deviceOr
ientation.beta, deviceOrientation.gamma); | 502 PageAgent.setDeviceOrientationOverride(deviceOrientation.alpha, deviceOr
ientation.beta, deviceOrientation.gamma); |
| 500 this.maybeHasActiveOverridesChanged(); | 503 this.maybeHasActiveOverridesChanged(); |
| 501 }, | 504 }, |
| 502 | 505 |
| 503 _emulateTouchEventsChanged: function() | 506 _emulateTouchEventsChanged: function() |
| 504 { | 507 { |
| 505 if (WebInspector.overridesSupport.hasTouchInputs() && this.settings.emul
ateTouchEvents.get()) | 508 if (this.hasTouchInputs() && this.settings.emulateTouchEvents.get()) |
| 506 return; | 509 return; |
| 507 | 510 |
| 508 var emulateTouch = this.settings.emulateTouchEvents.get(); | 511 var emulateTouch = this.settings.emulateTouchEvents.get(); |
| 509 var targets = WebInspector.targetManager.targets(); | 512 var targets = WebInspector.targetManager.targets(); |
| 510 for (var i = 0; i < targets.length; ++i) | 513 for (var i = 0; i < targets.length; ++i) |
| 511 targets[i].domModel.emulateTouchEventObjects(emulateTouch); | 514 targets[i].domModel.emulateTouchEventObjects(emulateTouch); |
| 512 this.maybeHasActiveOverridesChanged(); | 515 this.maybeHasActiveOverridesChanged(); |
| 513 }, | 516 }, |
| 514 | 517 |
| 515 _cssMediaChanged: function() | 518 _cssMediaChanged: function() |
| 516 { | 519 { |
| 520 if (this.isInspectingDevice() && this.settings.overrideCSSMedia.get()) |
| 521 return; |
| 522 |
| 517 PageAgent.setEmulatedMedia(this.settings.overrideCSSMedia.get() ? this.s
ettings.emulatedCSSMedia.get() : ""); | 523 PageAgent.setEmulatedMedia(this.settings.overrideCSSMedia.get() ? this.s
ettings.emulatedCSSMedia.get() : ""); |
| 518 var targets = WebInspector.targetManager.targets(); | 524 var targets = WebInspector.targetManager.targets(); |
| 519 for (var i = 0; i < targets.length; ++i) | 525 for (var i = 0; i < targets.length; ++i) |
| 520 targets[i].cssModel.mediaQueryResultChanged(); | 526 targets[i].cssModel.mediaQueryResultChanged(); |
| 521 this.maybeHasActiveOverridesChanged(); | 527 this.maybeHasActiveOverridesChanged(); |
| 522 }, | 528 }, |
| 523 | 529 |
| 524 /** | 530 /** |
| 525 * @return {boolean} | 531 * @return {boolean} |
| 526 */ | 532 */ |
| 527 hasActiveOverrides: function() | 533 hasActiveOverrides: function() |
| 528 { | 534 { |
| 529 return this._hasActiveOverrides; | 535 return this._hasActiveOverrides; |
| 530 }, | 536 }, |
| 531 | 537 |
| 532 maybeHasActiveOverridesChanged: function() | 538 maybeHasActiveOverridesChanged: function() |
| 533 { | 539 { |
| 534 var hasActiveOverrides = this.settings.overrideUserAgent.get() || this.s
ettings.overrideDeviceMetrics.get() || | 540 var hasActiveOverrides = |
| 535 this.settings.overrideGeolocation.get() || this.settings.overrideDev
iceOrientation.get() || | 541 this.settings.overrideUserAgent.get() || |
| 536 this.settings.emulateTouchEvents.get() || this.settings.overrideCSSM
edia.get(); | 542 (this.settings.overrideDeviceMetrics.get() && !this.isInspectingDevi
ce()) || |
| 543 this.settings.overrideGeolocation.get() || |
| 544 this.settings.overrideDeviceOrientation.get() || |
| 545 (this.settings.emulateTouchEvents.get() && !this.hasTouchInputs()) |
| |
| 546 (this.settings.overrideCSSMedia.get() && !this.isInspectingDevice())
; |
| 537 if (this._hasActiveOverrides !== hasActiveOverrides) { | 547 if (this._hasActiveOverrides !== hasActiveOverrides) { |
| 538 this._hasActiveOverrides = hasActiveOverrides; | 548 this._hasActiveOverrides = hasActiveOverrides; |
| 539 this.dispatchEventToListeners(WebInspector.OverridesSupport.Events.H
asActiveOverridesChanged); | 549 this.dispatchEventToListeners(WebInspector.OverridesSupport.Events.H
asActiveOverridesChanged); |
| 540 } | 550 } |
| 541 }, | 551 }, |
| 542 | 552 |
| 543 _onMainFrameNavigated: function() | 553 _onMainFrameNavigated: function() |
| 544 { | 554 { |
| 545 this._deviceMetricsChanged(); | 555 this._deviceMetricsChanged(); |
| 546 this._updateUserAgentWarningMessage(""); | 556 this._updateUserAgentWarningMessage(""); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 610 this.settings.overrideGeolocation.addChangeListener(this._geolocationPos
itionChanged, this); | 620 this.settings.overrideGeolocation.addChangeListener(this._geolocationPos
itionChanged, this); |
| 611 this.settings.geolocationOverride.addChangeListener(this._geolocationPos
itionChanged, this); | 621 this.settings.geolocationOverride.addChangeListener(this._geolocationPos
itionChanged, this); |
| 612 | 622 |
| 613 this.settings.overrideDeviceOrientation.addChangeListener(this._deviceOr
ientationChanged, this); | 623 this.settings.overrideDeviceOrientation.addChangeListener(this._deviceOr
ientationChanged, this); |
| 614 this.settings.deviceOrientationOverride.addChangeListener(this._deviceOr
ientationChanged, this); | 624 this.settings.deviceOrientationOverride.addChangeListener(this._deviceOr
ientationChanged, this); |
| 615 | 625 |
| 616 this.settings.emulateTouchEvents.addChangeListener(this._emulateTouchEve
ntsChanged, this); | 626 this.settings.emulateTouchEvents.addChangeListener(this._emulateTouchEve
ntsChanged, this); |
| 617 | 627 |
| 618 this.settings.overrideCSSMedia.addChangeListener(this._cssMediaChanged,
this); | 628 this.settings.overrideCSSMedia.addChangeListener(this._cssMediaChanged,
this); |
| 619 this.settings.emulatedCSSMedia.addChangeListener(this._cssMediaChanged,
this); | 629 this.settings.emulatedCSSMedia.addChangeListener(this._cssMediaChanged,
this); |
| 630 |
| 631 if (this._applyInitialOverridesOnTargetAdded) { |
| 632 delete this._applyInitialOverridesOnTargetAdded; |
| 633 this.applyInitialOverrides(); |
| 634 } |
| 620 }, | 635 }, |
| 621 | 636 |
| 622 /** | 637 /** |
| 623 * @param {!WebInspector.Target} target | 638 * @param {!WebInspector.Target} target |
| 624 */ | 639 */ |
| 625 targetRemoved: function(target) | 640 targetRemoved: function(target) |
| 626 { | 641 { |
| 627 // FIXME: adapt this to multiple targets. | 642 // FIXME: adapt this to multiple targets. |
| 628 }, | 643 }, |
| 629 | 644 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 644 }, | 659 }, |
| 645 | 660 |
| 646 __proto__: WebInspector.Object.prototype | 661 __proto__: WebInspector.Object.prototype |
| 647 } | 662 } |
| 648 | 663 |
| 649 | 664 |
| 650 /** | 665 /** |
| 651 * @type {!WebInspector.OverridesSupport} | 666 * @type {!WebInspector.OverridesSupport} |
| 652 */ | 667 */ |
| 653 WebInspector.overridesSupport; | 668 WebInspector.overridesSupport; |
| OLD | NEW |