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

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

Issue 1195793008: [DevTools] Implement screen orientation override. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Restore test 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
66 this.settings.overrideCSSMedia = WebInspector.settings.createSetting("overri deCSSMedia", false); 68 this.settings.overrideCSSMedia = WebInspector.settings.createSetting("overri deCSSMedia", false);
67 this.settings.emulatedCSSMedia = WebInspector.settings.createSetting("emulat edCSSMedia", "print"); 69 this.settings.emulatedCSSMedia = WebInspector.settings.createSetting("emulat edCSSMedia", "print");
68 70
69 this.settings.javaScriptDisabled = WebInspector.moduleSetting("javaScriptDis abled"); 71 this.settings.javaScriptDisabled = WebInspector.moduleSetting("javaScriptDis abled");
70 } 72 }
71 73
72 WebInspector.OverridesSupport.Events = { 74 WebInspector.OverridesSupport.Events = {
73 OverridesWarningUpdated: "OverridesWarningUpdated", 75 OverridesWarningUpdated: "OverridesWarningUpdated",
74 EmulationStateChanged: "EmulationStateChanged" 76 EmulationStateChanged: "EmulationStateChanged"
75 } 77 }
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 reset: function() 382 reset: function()
381 { 383 {
382 this._deviceMetricsChangedListenerMuted = true; 384 this._deviceMetricsChangedListenerMuted = true;
383 this._userAgentChangedListenerMuted = true; 385 this._userAgentChangedListenerMuted = true;
384 this.settings.userAgent.set(""); 386 this.settings.userAgent.set("");
385 this.settings.emulateResolution.set(false); 387 this.settings.emulateResolution.set(false);
386 this.settings.deviceScaleFactor.set(0); 388 this.settings.deviceScaleFactor.set(0);
387 this.settings.emulateTouch.set(false); 389 this.settings.emulateTouch.set(false);
388 this.settings.emulateMobile.set(false); 390 this.settings.emulateMobile.set(false);
389 this.settings.overrideDeviceOrientation.set(false); 391 this.settings.overrideDeviceOrientation.set(false);
392 this.settings.screenOrientationOverride.set("");
390 this.settings.overrideGeolocation.set(false); 393 this.settings.overrideGeolocation.set(false);
391 this.settings.overrideCSSMedia.set(false); 394 this.settings.overrideCSSMedia.set(false);
392 delete this._deviceMetricsChangedListenerMuted; 395 delete this._deviceMetricsChangedListenerMuted;
393 delete this._userAgentChangedListenerMuted; 396 delete this._userAgentChangedListenerMuted;
394 397
395 if (this._initialized) { 398 if (this._initialized) {
396 this._deviceMetricsChanged(); 399 this._deviceMetricsChanged();
397 this._userAgentChanged(); 400 this._userAgentChanged();
398 } 401 }
399 }, 402 },
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 this.settings.deviceFitWindow.addChangeListener(this._deviceMetricsChang ed, this); 440 this.settings.deviceFitWindow.addChangeListener(this._deviceMetricsChang ed, this);
438 441
439 this.settings._emulationEnabled.addChangeListener(this._geolocationPosit ionChanged, this); 442 this.settings._emulationEnabled.addChangeListener(this._geolocationPosit ionChanged, this);
440 this.settings.overrideGeolocation.addChangeListener(this._geolocationPos itionChanged, this); 443 this.settings.overrideGeolocation.addChangeListener(this._geolocationPos itionChanged, this);
441 this.settings.geolocationOverride.addChangeListener(this._geolocationPos itionChanged, this); 444 this.settings.geolocationOverride.addChangeListener(this._geolocationPos itionChanged, this);
442 445
443 this.settings._emulationEnabled.addChangeListener(this._deviceOrientatio nChanged, this); 446 this.settings._emulationEnabled.addChangeListener(this._deviceOrientatio nChanged, this);
444 this.settings.overrideDeviceOrientation.addChangeListener(this._deviceOr ientationChanged, this); 447 this.settings.overrideDeviceOrientation.addChangeListener(this._deviceOr ientationChanged, this);
445 this.settings.deviceOrientationOverride.addChangeListener(this._deviceOr ientationChanged, this); 448 this.settings.deviceOrientationOverride.addChangeListener(this._deviceOr ientationChanged, this);
446 449
450 this.settings._emulationEnabled.addChangeListener(this._screenOrientatio nChanged, this);
451 this.settings.screenOrientationOverride.addChangeListener(this._screenOr ientationChanged, this);
452
447 this.settings._emulationEnabled.addChangeListener(this._emulateTouchEven tsChanged, this); 453 this.settings._emulationEnabled.addChangeListener(this._emulateTouchEven tsChanged, this);
448 this.settings.emulateTouch.addChangeListener(this._emulateTouchEventsCha nged, this); 454 this.settings.emulateTouch.addChangeListener(this._emulateTouchEventsCha nged, this);
449 455
450 this.settings._emulationEnabled.addChangeListener(this._cssMediaChanged, this); 456 this.settings._emulationEnabled.addChangeListener(this._cssMediaChanged, this);
451 this.settings.overrideCSSMedia.addChangeListener(this._cssMediaChanged, this); 457 this.settings.overrideCSSMedia.addChangeListener(this._cssMediaChanged, this);
452 this.settings.emulatedCSSMedia.addChangeListener(this._cssMediaChanged, this); 458 this.settings.emulatedCSSMedia.addChangeListener(this._cssMediaChanged, this);
453 459
454 this.settings.javaScriptDisabled.addChangeListener(this._javaScriptDisab ledChanged, this); 460 this.settings.javaScriptDisabled.addChangeListener(this._javaScriptDisab ledChanged, this);
455 this._javaScriptDisabledChanged(); 461 this._javaScriptDisabledChanged();
456 462
457 this.settings._emulationEnabled.addChangeListener(this._showRulersChange d, this); 463 this.settings._emulationEnabled.addChangeListener(this._showRulersChange d, this);
458 WebInspector.moduleSetting("showMetricsRulers").addChangeListener(this._ showRulersChanged, this); 464 WebInspector.moduleSetting("showMetricsRulers").addChangeListener(this._ showRulersChanged, this);
459 this._showRulersChanged(); 465 this._showRulersChanged();
460 466
461 if (this.emulationEnabled()) { 467 if (this.emulationEnabled()) {
462 if (this.settings.overrideDeviceOrientation.get()) 468 if (this.settings.overrideDeviceOrientation.get())
463 this._deviceOrientationChanged(); 469 this._deviceOrientationChanged();
464 470
471 if (this.settings.screenOrientationOverride.get())
472 this._screenOrientationChanged();
473
465 if (this.settings.overrideGeolocation.get()) 474 if (this.settings.overrideGeolocation.get())
466 this._geolocationPositionChanged(); 475 this._geolocationPositionChanged();
467 476
468 if (this.settings.emulateTouch.get()) 477 if (this.settings.emulateTouch.get())
469 this._emulateTouchEventsChanged(); 478 this._emulateTouchEventsChanged();
470 479
471 if (this.settings.overrideCSSMedia.get()) 480 if (this.settings.overrideCSSMedia.get())
472 this._cssMediaChanged(); 481 this._cssMediaChanged();
473 482
474 this._deviceMetricsChanged(); 483 this._deviceMetricsChanged();
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 { 669 {
661 if (!this.emulationEnabled() || !this.settings.overrideDeviceOrientation .get()) { 670 if (!this.emulationEnabled() || !this.settings.overrideDeviceOrientation .get()) {
662 this._target.deviceOrientationAgent().clearDeviceOrientationOverride (); 671 this._target.deviceOrientationAgent().clearDeviceOrientationOverride ();
663 return; 672 return;
664 } 673 }
665 674
666 var deviceOrientation = WebInspector.OverridesSupport.DeviceOrientation. parseSetting(this.settings.deviceOrientationOverride.get()); 675 var deviceOrientation = WebInspector.OverridesSupport.DeviceOrientation. parseSetting(this.settings.deviceOrientationOverride.get());
667 this._target.deviceOrientationAgent().setDeviceOrientationOverride(devic eOrientation.alpha, deviceOrientation.beta, deviceOrientation.gamma); 676 this._target.deviceOrientationAgent().setDeviceOrientationOverride(devic eOrientation.alpha, deviceOrientation.beta, deviceOrientation.gamma);
668 }, 677 },
669 678
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
670 _emulateTouchEventsChanged: function() 690 _emulateTouchEventsChanged: function()
671 { 691 {
672 var emulationEnabled = this.emulationEnabled() && this.settings.emulateT ouch.get() && !this._touchEmulationSuspended; 692 var emulationEnabled = this.emulationEnabled() && this.settings.emulateT ouch.get() && !this._touchEmulationSuspended;
673 var configuration = this.settings.emulateMobile.get() ? "mobile" : "desk top"; 693 var configuration = this.settings.emulateMobile.get() ? "mobile" : "desk top";
674 var target = this._target; 694 var target = this._target;
675 695
676 /** 696 /**
677 * @suppressGlobalPropertiesCheck 697 * @suppressGlobalPropertiesCheck
678 */ 698 */
679 const injectedFunction = function() { 699 const injectedFunction = function() {
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 }, 818 },
799 819
800 __proto__: WebInspector.Object.prototype 820 __proto__: WebInspector.Object.prototype
801 } 821 }
802 822
803 823
804 /** 824 /**
805 * @type {!WebInspector.OverridesSupport} 825 * @type {!WebInspector.OverridesSupport}
806 */ 826 */
807 WebInspector.overridesSupport; 827 WebInspector.overridesSupport;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698