Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(168)

Side by Side Diff: Source/devtools/front_end/emulation/OverridesSupport.js

Issue 1220643002: Revert of [DevTools] Implement screen orientation override. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 this.settings.emulateMobile = WebInspector.settings.createSetting("emulateMo bile", false); 56 this.settings.emulateMobile = WebInspector.settings.createSetting("emulateMo bile", false);
57 57
58 this.settings.emulateTouch = WebInspector.settings.createSetting("emulateTou ch", false); 58 this.settings.emulateTouch = WebInspector.settings.createSetting("emulateTou ch", false);
59 59
60 this.settings.overrideGeolocation = WebInspector.settings.createSetting("ove rrideGeolocation", false); 60 this.settings.overrideGeolocation = WebInspector.settings.createSetting("ove rrideGeolocation", false);
61 this.settings.geolocationOverride = WebInspector.settings.createSetting("geo locationOverride", ""); 61 this.settings.geolocationOverride = WebInspector.settings.createSetting("geo locationOverride", "");
62 62
63 this.settings.overrideDeviceOrientation = WebInspector.settings.createSettin g("overrideDeviceOrientation", false); 63 this.settings.overrideDeviceOrientation = WebInspector.settings.createSettin g("overrideDeviceOrientation", false);
64 this.settings.deviceOrientationOverride = WebInspector.settings.createSettin g("deviceOrientationOverride", ""); 64 this.settings.deviceOrientationOverride = WebInspector.settings.createSettin g("deviceOrientationOverride", "");
65 65
66 this.settings.screenOrientationOverride = WebInspector.settings.createSettin g("screenOrientationOverride", "");
67
68 this.settings.overrideCSSMedia = WebInspector.settings.createSetting("overri deCSSMedia", false); 66 this.settings.overrideCSSMedia = WebInspector.settings.createSetting("overri deCSSMedia", false);
69 this.settings.emulatedCSSMedia = WebInspector.settings.createSetting("emulat edCSSMedia", "print"); 67 this.settings.emulatedCSSMedia = WebInspector.settings.createSetting("emulat edCSSMedia", "print");
70 68
71 this.settings.javaScriptDisabled = WebInspector.moduleSetting("javaScriptDis abled"); 69 this.settings.javaScriptDisabled = WebInspector.moduleSetting("javaScriptDis abled");
72 } 70 }
73 71
74 WebInspector.OverridesSupport.Events = { 72 WebInspector.OverridesSupport.Events = {
75 OverridesWarningUpdated: "OverridesWarningUpdated", 73 OverridesWarningUpdated: "OverridesWarningUpdated",
76 EmulationStateChanged: "EmulationStateChanged" 74 EmulationStateChanged: "EmulationStateChanged"
77 } 75 }
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 reset: function() 380 reset: function()
383 { 381 {
384 this._deviceMetricsChangedListenerMuted = true; 382 this._deviceMetricsChangedListenerMuted = true;
385 this._userAgentChangedListenerMuted = true; 383 this._userAgentChangedListenerMuted = true;
386 this.settings.userAgent.set(""); 384 this.settings.userAgent.set("");
387 this.settings.emulateResolution.set(false); 385 this.settings.emulateResolution.set(false);
388 this.settings.deviceScaleFactor.set(0); 386 this.settings.deviceScaleFactor.set(0);
389 this.settings.emulateTouch.set(false); 387 this.settings.emulateTouch.set(false);
390 this.settings.emulateMobile.set(false); 388 this.settings.emulateMobile.set(false);
391 this.settings.overrideDeviceOrientation.set(false); 389 this.settings.overrideDeviceOrientation.set(false);
392 this.settings.screenOrientationOverride.set("");
393 this.settings.overrideGeolocation.set(false); 390 this.settings.overrideGeolocation.set(false);
394 this.settings.overrideCSSMedia.set(false); 391 this.settings.overrideCSSMedia.set(false);
395 delete this._deviceMetricsChangedListenerMuted; 392 delete this._deviceMetricsChangedListenerMuted;
396 delete this._userAgentChangedListenerMuted; 393 delete this._userAgentChangedListenerMuted;
397 394
398 if (this._initialized) { 395 if (this._initialized) {
399 this._deviceMetricsChanged(); 396 this._deviceMetricsChanged();
400 this._userAgentChanged(); 397 this._userAgentChanged();
401 } 398 }
402 }, 399 },
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 this.settings.deviceFitWindow.addChangeListener(this._deviceMetricsChang ed, this); 437 this.settings.deviceFitWindow.addChangeListener(this._deviceMetricsChang ed, this);
441 438
442 this.settings._emulationEnabled.addChangeListener(this._geolocationPosit ionChanged, this); 439 this.settings._emulationEnabled.addChangeListener(this._geolocationPosit ionChanged, this);
443 this.settings.overrideGeolocation.addChangeListener(this._geolocationPos itionChanged, this); 440 this.settings.overrideGeolocation.addChangeListener(this._geolocationPos itionChanged, this);
444 this.settings.geolocationOverride.addChangeListener(this._geolocationPos itionChanged, this); 441 this.settings.geolocationOverride.addChangeListener(this._geolocationPos itionChanged, this);
445 442
446 this.settings._emulationEnabled.addChangeListener(this._deviceOrientatio nChanged, this); 443 this.settings._emulationEnabled.addChangeListener(this._deviceOrientatio nChanged, this);
447 this.settings.overrideDeviceOrientation.addChangeListener(this._deviceOr ientationChanged, this); 444 this.settings.overrideDeviceOrientation.addChangeListener(this._deviceOr ientationChanged, this);
448 this.settings.deviceOrientationOverride.addChangeListener(this._deviceOr ientationChanged, this); 445 this.settings.deviceOrientationOverride.addChangeListener(this._deviceOr ientationChanged, this);
449 446
450 this.settings._emulationEnabled.addChangeListener(this._screenOrientatio nChanged, this);
451 this.settings.screenOrientationOverride.addChangeListener(this._screenOr ientationChanged, this);
452
453 this.settings._emulationEnabled.addChangeListener(this._emulateTouchEven tsChanged, this); 447 this.settings._emulationEnabled.addChangeListener(this._emulateTouchEven tsChanged, this);
454 this.settings.emulateTouch.addChangeListener(this._emulateTouchEventsCha nged, this); 448 this.settings.emulateTouch.addChangeListener(this._emulateTouchEventsCha nged, this);
455 449
456 this.settings._emulationEnabled.addChangeListener(this._cssMediaChanged, this); 450 this.settings._emulationEnabled.addChangeListener(this._cssMediaChanged, this);
457 this.settings.overrideCSSMedia.addChangeListener(this._cssMediaChanged, this); 451 this.settings.overrideCSSMedia.addChangeListener(this._cssMediaChanged, this);
458 this.settings.emulatedCSSMedia.addChangeListener(this._cssMediaChanged, this); 452 this.settings.emulatedCSSMedia.addChangeListener(this._cssMediaChanged, this);
459 453
460 this.settings.javaScriptDisabled.addChangeListener(this._javaScriptDisab ledChanged, this); 454 this.settings.javaScriptDisabled.addChangeListener(this._javaScriptDisab ledChanged, this);
461 this._javaScriptDisabledChanged(); 455 this._javaScriptDisabledChanged();
462 456
463 this.settings._emulationEnabled.addChangeListener(this._showRulersChange d, this); 457 this.settings._emulationEnabled.addChangeListener(this._showRulersChange d, this);
464 WebInspector.moduleSetting("showMetricsRulers").addChangeListener(this._ showRulersChanged, this); 458 WebInspector.moduleSetting("showMetricsRulers").addChangeListener(this._ showRulersChanged, this);
465 this._showRulersChanged(); 459 this._showRulersChanged();
466 460
467 if (this.emulationEnabled()) { 461 if (this.emulationEnabled()) {
468 if (this.settings.overrideDeviceOrientation.get()) 462 if (this.settings.overrideDeviceOrientation.get())
469 this._deviceOrientationChanged(); 463 this._deviceOrientationChanged();
470 464
471 if (this.settings.screenOrientationOverride.get())
472 this._screenOrientationChanged();
473
474 if (this.settings.overrideGeolocation.get()) 465 if (this.settings.overrideGeolocation.get())
475 this._geolocationPositionChanged(); 466 this._geolocationPositionChanged();
476 467
477 if (this.settings.emulateTouch.get()) 468 if (this.settings.emulateTouch.get())
478 this._emulateTouchEventsChanged(); 469 this._emulateTouchEventsChanged();
479 470
480 if (this.settings.overrideCSSMedia.get()) 471 if (this.settings.overrideCSSMedia.get())
481 this._cssMediaChanged(); 472 this._cssMediaChanged();
482 473
483 this._deviceMetricsChanged(); 474 this._deviceMetricsChanged();
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 { 660 {
670 if (!this.emulationEnabled() || !this.settings.overrideDeviceOrientation .get()) { 661 if (!this.emulationEnabled() || !this.settings.overrideDeviceOrientation .get()) {
671 this._target.deviceOrientationAgent().clearDeviceOrientationOverride (); 662 this._target.deviceOrientationAgent().clearDeviceOrientationOverride ();
672 return; 663 return;
673 } 664 }
674 665
675 var deviceOrientation = WebInspector.OverridesSupport.DeviceOrientation. parseSetting(this.settings.deviceOrientationOverride.get()); 666 var deviceOrientation = WebInspector.OverridesSupport.DeviceOrientation. parseSetting(this.settings.deviceOrientationOverride.get());
676 this._target.deviceOrientationAgent().setDeviceOrientationOverride(devic eOrientation.alpha, deviceOrientation.beta, deviceOrientation.gamma); 667 this._target.deviceOrientationAgent().setDeviceOrientationOverride(devic eOrientation.alpha, deviceOrientation.beta, deviceOrientation.gamma);
677 }, 668 },
678 669
679 _screenOrientationChanged: function()
680 {
681 if (!this.emulationEnabled() || !this.settings.screenOrientationOverride .get()) {
682 this._target.screenOrientationAgent().clearScreenOrientationOverride ();
683 return;
684 }
685
686 var screenOrientation = this.settings.screenOrientationOverride.get();
687 this._target.screenOrientationAgent().setScreenOrientationOverride(scree nOrientation === "landscapePrimary" ? 90 : 0, screenOrientation);
688 },
689
690 _emulateTouchEventsChanged: function() 670 _emulateTouchEventsChanged: function()
691 { 671 {
692 var emulationEnabled = this.emulationEnabled() && this.settings.emulateT ouch.get() && !this._touchEmulationSuspended; 672 var emulationEnabled = this.emulationEnabled() && this.settings.emulateT ouch.get() && !this._touchEmulationSuspended;
693 var configuration = this.settings.emulateMobile.get() ? "mobile" : "desk top"; 673 var configuration = this.settings.emulateMobile.get() ? "mobile" : "desk top";
694 var target = this._target; 674 var target = this._target;
695 675
696 /** 676 /**
697 * @suppressGlobalPropertiesCheck 677 * @suppressGlobalPropertiesCheck
698 */ 678 */
699 const injectedFunction = function() { 679 const injectedFunction = function() {
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 }, 798 },
819 799
820 __proto__: WebInspector.Object.prototype 800 __proto__: WebInspector.Object.prototype
821 } 801 }
822 802
823 803
824 /** 804 /**
825 * @type {!WebInspector.OverridesSupport} 805 * @type {!WebInspector.OverridesSupport}
826 */ 806 */
827 WebInspector.overridesSupport; 807 WebInspector.overridesSupport;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698