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

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: 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 11 matching lines...) Expand all
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
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 * @extends {WebInspector.Object}
pfeldman 2013/10/31 17:45:31 We define @extends below @constructor
dgozman 2013/10/31 17:57:48 Done.
32 * @constructor 33 * @constructor
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), 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 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 WebInspector.OverridesSupport.DeviceOrientation.clearDeviceOrientationOverride = function() 395 WebInspector.OverridesSupport.DeviceOrientation.clearDeviceOrientationOverride = function()
390 { 396 {
391 PageAgent.clearDeviceOrientationOverride(); 397 PageAgent.clearDeviceOrientationOverride();
392 } 398 }
393 399
394 WebInspector.OverridesSupport.prototype = { 400 WebInspector.OverridesSupport.prototype = {
395 /** 401 /**
396 * @param {string} deviceMetrics 402 * @param {string} deviceMetrics
397 * @param {string} userAgent 403 * @param {string} userAgent
398 */ 404 */
399 emulateDevice: function(deviceMetrics, userAgent) 405 emulateDevice: function(deviceMetrics, userAgent)
pfeldman 2013/10/31 17:45:31 Lets disable the whole button instead.
dgozman 2013/10/31 17:57:48 Done.
400 { 406 {
401 WebInspector.settings.deviceMetrics.set(deviceMetrics); 407 WebInspector.settings.deviceMetrics.set(deviceMetrics);
402 WebInspector.settings.userAgent.set(userAgent); 408 WebInspector.settings.userAgent.set(userAgent);
403 WebInspector.settings.overrideDeviceMetrics.set(true); 409 if (this._canForceCompositingMode)
410 WebInspector.settings.overrideDeviceMetrics.set(true);
404 WebInspector.settings.overrideUserAgent.set(true); 411 WebInspector.settings.overrideUserAgent.set(true);
405 WebInspector.settings.emulateTouchEvents.set(true); 412 WebInspector.settings.emulateTouchEvents.set(true);
406 }, 413 },
407 414
408 reset: function() 415 reset: function()
409 { 416 {
410 WebInspector.settings.overrideDeviceMetrics.set(false); 417 WebInspector.settings.overrideDeviceMetrics.set(false);
411 WebInspector.settings.overrideUserAgent.set(false); 418 WebInspector.settings.overrideUserAgent.set(false);
412 WebInspector.settings.emulateTouchEvents.set(false); 419 WebInspector.settings.emulateTouchEvents.set(false);
413 WebInspector.settings.overrideDeviceOrientation.set(false); 420 WebInspector.settings.overrideDeviceOrientation.set(false);
414 WebInspector.settings.overrideGeolocation.set(false); 421 WebInspector.settings.overrideGeolocation.set(false);
415 WebInspector.settings.overrideCSSMedia.set(false); 422 WebInspector.settings.overrideCSSMedia.set(false);
416 }, 423 },
417 424
418 _updateAllOverrides: function() 425 applyInitialOverrides: function()
419 { 426 {
420 this._userAgentChanged(); 427 this._userAgentChanged();
421 this._deviceMetricsChanged(); 428 if (WebInspector.settings.overrideDeviceMetrics.get())
429 this.updateCanForceCompositingMode(this._deviceMetricsChanged.bind(t his));
430 else
431 this._deviceMetricsChanged();
422 this._deviceOrientationChanged(); 432 this._deviceOrientationChanged();
423 this._geolocationPositionChanged(); 433 this._geolocationPositionChanged();
424 this._emulateTouchEventsChanged(); 434 this._emulateTouchEventsChanged();
425 this._cssMediaChanged(); 435 this._cssMediaChanged();
426 }, 436 },
427 437
428 _userAgentChanged: function() 438 _userAgentChanged: function()
429 { 439 {
430 NetworkAgent.setUserAgentOverride(WebInspector.settings.overrideUserAgen t.get() ? WebInspector.settings.userAgent.get() : ""); 440 NetworkAgent.setUserAgentOverride(WebInspector.settings.overrideUserAgen t.get() ? WebInspector.settings.userAgent.get() : "");
431 }, 441 },
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 491
482 _revealOverridesTabIfNeeded: function() 492 _revealOverridesTabIfNeeded: function()
483 { 493 {
484 if (WebInspector.settings.overrideUserAgent.get() || WebInspector.settin gs.overrideDeviceMetrics.get() || 494 if (WebInspector.settings.overrideUserAgent.get() || WebInspector.settin gs.overrideDeviceMetrics.get() ||
485 WebInspector.settings.overrideGeolocation.get() || WebInspector. settings.overrideDeviceOrientation.get() || 495 WebInspector.settings.overrideGeolocation.get() || WebInspector. settings.overrideDeviceOrientation.get() ||
486 WebInspector.settings.emulateTouchEvents.get() || WebInspector.s ettings.overrideCSSMedia.get()) { 496 WebInspector.settings.emulateTouchEvents.get() || WebInspector.s ettings.overrideCSSMedia.get()) {
487 if (!WebInspector.settings.showEmulationViewInDrawer.get()) 497 if (!WebInspector.settings.showEmulationViewInDrawer.get())
488 WebInspector.settings.showEmulationViewInDrawer.set(true); 498 WebInspector.settings.showEmulationViewInDrawer.set(true);
489 WebInspector.inspectorView.showViewInDrawer("emulation"); 499 WebInspector.inspectorView.showViewInDrawer("emulation");
490 } 500 }
491 } 501 },
502
503 updateCanForceCompositingMode: function(callback)
504 {
505 function apiCallback(error, result)
506 {
507 if (!error) {
508 if (!result && WebInspector.settings.overrideDeviceMetrics.get() )
509 WebInspector.settings.overrideDeviceMetrics.set(false);
510
511 if (this._canForceCompositingMode !== result) {
512 this._canForceCompositingMode = result;
513 this.dispatchEventToListeners(WebInspector.OverridesSupport. Events.CanForceCompositingModeChanged);
514 }
515 }
516 if (callback)
517 callback();
518 }
519 PageAgent.canForceCompositingMode(apiCallback.bind(this));
520 },
521
522 canForceCompositingMode: function()
523 {
524 return this._canForceCompositingMode;
525 },
526
527 __proto__: WebInspector.Object.prototype
492 } 528 }
493 529
494 530
495 /** 531 /**
496 * @type {WebInspector.OverridesSupport} 532 * @type {WebInspector.OverridesSupport}
497 */ 533 */
498 WebInspector.overridesSupport; 534 WebInspector.overridesSupport;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698