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

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

Issue 50043007: DevTools: check for canForceCompositingMode before trying to emulate device metrics. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed comments Created 7 years, 1 month 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
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 12 matching lines...) Expand all
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 /** 31 /**
32 * @constructor 32 * @constructor
33 * @extends {WebInspector.Object}
33 */ 34 */
34 WebInspector.OverridesSupport = function() 35 WebInspector.OverridesSupport = function()
35 { 36 {
36 this._updateAllOverrides(); 37 this._canForceCompositingMode = true;
38 WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeMod el.EventTypes.MainFrameNavigated, this.updateCanForceCompositingMode.bind(this, null), this);
37 39
38 WebInspector.settings.overrideUserAgent.addChangeListener(this._userAgentCha nged, this); 40 WebInspector.settings.overrideUserAgent.addChangeListener(this._userAgentCha nged, this);
39 WebInspector.settings.userAgent.addChangeListener(this._userAgentChanged, th is); 41 WebInspector.settings.userAgent.addChangeListener(this._userAgentChanged, th is);
40 42
41 WebInspector.settings.overrideDeviceMetrics.addChangeListener(this._deviceMe tricsChanged, this); 43 WebInspector.settings.overrideDeviceMetrics.addChangeListener(this._deviceMe tricsChanged, this);
42 WebInspector.settings.deviceMetrics.addChangeListener(this._deviceMetricsCha nged, this); 44 WebInspector.settings.deviceMetrics.addChangeListener(this._deviceMetricsCha nged, this);
43 WebInspector.settings.deviceFitWindow.addChangeListener(this._deviceMetricsC hanged, this); 45 WebInspector.settings.deviceFitWindow.addChangeListener(this._deviceMetricsC hanged, this);
44 46
45 WebInspector.settings.overrideGeolocation.addChangeListener(this._geolocatio nPositionChanged, this); 47 WebInspector.settings.overrideGeolocation.addChangeListener(this._geolocatio nPositionChanged, this);
46 WebInspector.settings.geolocationOverride.addChangeListener(this._geolocatio nPositionChanged, this); 48 WebInspector.settings.geolocationOverride.addChangeListener(this._geolocatio nPositionChanged, this);
47 49
48 WebInspector.settings.overrideDeviceOrientation.addChangeListener(this._devi ceOrientationChanged, this); 50 WebInspector.settings.overrideDeviceOrientation.addChangeListener(this._devi ceOrientationChanged, this);
49 WebInspector.settings.deviceOrientationOverride.addChangeListener(this._devi ceOrientationChanged, this); 51 WebInspector.settings.deviceOrientationOverride.addChangeListener(this._devi ceOrientationChanged, this);
50 52
51 WebInspector.settings.emulateTouchEvents.addChangeListener(this._emulateTouc hEventsChanged, this); 53 WebInspector.settings.emulateTouchEvents.addChangeListener(this._emulateTouc hEventsChanged, this);
52 54
53 WebInspector.settings.overrideCSSMedia.addChangeListener(this._cssMediaChang ed, this); 55 WebInspector.settings.overrideCSSMedia.addChangeListener(this._cssMediaChang ed, this);
54 WebInspector.settings.emulatedCSSMedia.addChangeListener(this._cssMediaChang ed, this); 56 WebInspector.settings.emulatedCSSMedia.addChangeListener(this._cssMediaChang ed, this);
55 } 57 }
56 58
59 WebInspector.OverridesSupport.Events = {
60 CanForceCompositingModeChanged: "CanForceCompositingModeChanged",
61 }
62
57 /** 63 /**
58 * @constructor 64 * @constructor
59 * @param {number} width 65 * @param {number} width
60 * @param {number} height 66 * @param {number} height
61 * @param {number} deviceScaleFactor 67 * @param {number} deviceScaleFactor
62 * @param {number} fontScaleFactor 68 * @param {number} fontScaleFactor
63 * @param {boolean} textAutosizing 69 * @param {boolean} textAutosizing
64 */ 70 */
65 WebInspector.OverridesSupport.DeviceMetrics = function(width, height, deviceScal eFactor, fontScaleFactor, textAutosizing) 71 WebInspector.OverridesSupport.DeviceMetrics = function(width, height, deviceScal eFactor, fontScaleFactor, textAutosizing)
66 { 72 {
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 reset: function() 414 reset: function()
409 { 415 {
410 WebInspector.settings.overrideDeviceMetrics.set(false); 416 WebInspector.settings.overrideDeviceMetrics.set(false);
411 WebInspector.settings.overrideUserAgent.set(false); 417 WebInspector.settings.overrideUserAgent.set(false);
412 WebInspector.settings.emulateTouchEvents.set(false); 418 WebInspector.settings.emulateTouchEvents.set(false);
413 WebInspector.settings.overrideDeviceOrientation.set(false); 419 WebInspector.settings.overrideDeviceOrientation.set(false);
414 WebInspector.settings.overrideGeolocation.set(false); 420 WebInspector.settings.overrideGeolocation.set(false);
415 WebInspector.settings.overrideCSSMedia.set(false); 421 WebInspector.settings.overrideCSSMedia.set(false);
416 }, 422 },
417 423
418 _updateAllOverrides: function() 424 applyInitialOverrides: function()
419 { 425 {
420 this._userAgentChanged(); 426 this._userAgentChanged();
421 this._deviceMetricsChanged(); 427 if (WebInspector.settings.overrideDeviceMetrics.get())
428 this.updateCanForceCompositingMode(this._deviceMetricsChanged.bind(t his));
429 else
430 this._deviceMetricsChanged();
422 this._deviceOrientationChanged(); 431 this._deviceOrientationChanged();
423 this._geolocationPositionChanged(); 432 this._geolocationPositionChanged();
424 this._emulateTouchEventsChanged(); 433 this._emulateTouchEventsChanged();
425 this._cssMediaChanged(); 434 this._cssMediaChanged();
426 }, 435 },
427 436
428 _userAgentChanged: function() 437 _userAgentChanged: function()
429 { 438 {
430 NetworkAgent.setUserAgentOverride(WebInspector.settings.overrideUserAgen t.get() ? WebInspector.settings.userAgent.get() : ""); 439 NetworkAgent.setUserAgentOverride(WebInspector.settings.overrideUserAgen t.get() ? WebInspector.settings.userAgent.get() : "");
431 }, 440 },
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 490
482 _revealOverridesTabIfNeeded: function() 491 _revealOverridesTabIfNeeded: function()
483 { 492 {
484 if (WebInspector.settings.overrideUserAgent.get() || WebInspector.settin gs.overrideDeviceMetrics.get() || 493 if (WebInspector.settings.overrideUserAgent.get() || WebInspector.settin gs.overrideDeviceMetrics.get() ||
485 WebInspector.settings.overrideGeolocation.get() || WebInspector. settings.overrideDeviceOrientation.get() || 494 WebInspector.settings.overrideGeolocation.get() || WebInspector. settings.overrideDeviceOrientation.get() ||
486 WebInspector.settings.emulateTouchEvents.get() || WebInspector.s ettings.overrideCSSMedia.get()) { 495 WebInspector.settings.emulateTouchEvents.get() || WebInspector.s ettings.overrideCSSMedia.get()) {
487 if (!WebInspector.settings.showEmulationViewInDrawer.get()) 496 if (!WebInspector.settings.showEmulationViewInDrawer.get())
488 WebInspector.settings.showEmulationViewInDrawer.set(true); 497 WebInspector.settings.showEmulationViewInDrawer.set(true);
489 WebInspector.inspectorView.showViewInDrawer("emulation"); 498 WebInspector.inspectorView.showViewInDrawer("emulation");
490 } 499 }
491 } 500 },
501
502 updateCanForceCompositingMode: function(callback)
503 {
504 function apiCallback(error, result)
505 {
506 if (!error) {
507 if (!result && WebInspector.settings.overrideDeviceMetrics.get() )
508 WebInspector.settings.overrideDeviceMetrics.set(false);
509
510 if (this._canForceCompositingMode !== result) {
511 this._canForceCompositingMode = result;
512 this.dispatchEventToListeners(WebInspector.OverridesSupport. Events.CanForceCompositingModeChanged);
513 }
514 }
515 if (callback)
516 callback();
517 }
518 PageAgent.canForceCompositingMode(apiCallback.bind(this));
519 },
520
521 canForceCompositingMode: function()
522 {
523 return this._canForceCompositingMode;
524 },
525
526 __proto__: WebInspector.Object.prototype
492 } 527 }
493 528
494 529
495 /** 530 /**
496 * @type {WebInspector.OverridesSupport} 531 * @type {WebInspector.OverridesSupport}
497 */ 532 */
498 WebInspector.overridesSupport; 533 WebInspector.overridesSupport;
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorPageAgent.cpp ('k') | Source/devtools/front_end/OverridesView.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698