Chromium Code Reviews| 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 11 matching lines...) Expand all Loading... | |
| 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} | |
| 32 * @constructor | 33 * @constructor |
| 33 */ | 34 */ |
| 34 WebInspector.OverridesSupport = function() | 35 WebInspector.OverridesSupport = function() |
| 35 { | 36 { |
| 37 WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeMod el.EventTypes.MainFrameNavigated, this._updateCanForceCompositingMode.bind(this) , this); | |
| 38 this.canForceCompositingMode = true; | |
|
pfeldman
2013/10/31 11:23:58
Should be private w/ accessor if necessary.
dgozman
2013/10/31 12:39:50
Done.
| |
| 39 this._updateCanForceCompositingMode(); | |
|
pfeldman
2013/10/31 11:23:58
It is too early, you should do this if you are abo
dgozman
2013/10/31 12:39:50
No, it's needed right away to disable UI elements.
| |
| 40 | |
| 36 this._updateAllOverrides(); | 41 this._updateAllOverrides(); |
| 37 | 42 |
| 38 WebInspector.settings.overrideUserAgent.addChangeListener(this._userAgentCha nged, this); | 43 WebInspector.settings.overrideUserAgent.addChangeListener(this._userAgentCha nged, this); |
| 39 WebInspector.settings.userAgent.addChangeListener(this._userAgentChanged, th is); | 44 WebInspector.settings.userAgent.addChangeListener(this._userAgentChanged, th is); |
| 40 | 45 |
| 41 WebInspector.settings.overrideDeviceMetrics.addChangeListener(this._deviceMe tricsChanged, this); | 46 WebInspector.settings.overrideDeviceMetrics.addChangeListener(this._deviceMe tricsChanged, this); |
| 42 WebInspector.settings.deviceMetrics.addChangeListener(this._deviceMetricsCha nged, this); | 47 WebInspector.settings.deviceMetrics.addChangeListener(this._deviceMetricsCha nged, this); |
| 43 WebInspector.settings.deviceFitWindow.addChangeListener(this._deviceMetricsC hanged, this); | 48 WebInspector.settings.deviceFitWindow.addChangeListener(this._deviceMetricsC hanged, this); |
| 44 | 49 |
| 45 WebInspector.settings.overrideGeolocation.addChangeListener(this._geolocatio nPositionChanged, this); | 50 WebInspector.settings.overrideGeolocation.addChangeListener(this._geolocatio nPositionChanged, this); |
| 46 WebInspector.settings.geolocationOverride.addChangeListener(this._geolocatio nPositionChanged, this); | 51 WebInspector.settings.geolocationOverride.addChangeListener(this._geolocatio nPositionChanged, this); |
| 47 | 52 |
| 48 WebInspector.settings.overrideDeviceOrientation.addChangeListener(this._devi ceOrientationChanged, this); | 53 WebInspector.settings.overrideDeviceOrientation.addChangeListener(this._devi ceOrientationChanged, this); |
| 49 WebInspector.settings.deviceOrientationOverride.addChangeListener(this._devi ceOrientationChanged, this); | 54 WebInspector.settings.deviceOrientationOverride.addChangeListener(this._devi ceOrientationChanged, this); |
| 50 | 55 |
| 51 WebInspector.settings.emulateTouchEvents.addChangeListener(this._emulateTouc hEventsChanged, this); | 56 WebInspector.settings.emulateTouchEvents.addChangeListener(this._emulateTouc hEventsChanged, this); |
| 52 | 57 |
| 53 WebInspector.settings.overrideCSSMedia.addChangeListener(this._cssMediaChang ed, this); | 58 WebInspector.settings.overrideCSSMedia.addChangeListener(this._cssMediaChang ed, this); |
| 54 WebInspector.settings.emulatedCSSMedia.addChangeListener(this._cssMediaChang ed, this); | 59 WebInspector.settings.emulatedCSSMedia.addChangeListener(this._cssMediaChang ed, this); |
| 55 } | 60 } |
| 56 | 61 |
| 62 WebInspector.OverridesSupport.Events = { | |
| 63 CanForceCompositingModeChanged: "CanForceCompositingModeChanged", | |
| 64 } | |
| 65 | |
| 57 /** | 66 /** |
| 58 * @constructor | 67 * @constructor |
| 59 * @param {number} width | 68 * @param {number} width |
| 60 * @param {number} height | 69 * @param {number} height |
| 61 * @param {number} deviceScaleFactor | 70 * @param {number} deviceScaleFactor |
| 62 * @param {number} fontScaleFactor | 71 * @param {number} fontScaleFactor |
| 63 * @param {boolean} textAutosizing | 72 * @param {boolean} textAutosizing |
| 64 */ | 73 */ |
| 65 WebInspector.OverridesSupport.DeviceMetrics = function(width, height, deviceScal eFactor, fontScaleFactor, textAutosizing) | 74 WebInspector.OverridesSupport.DeviceMetrics = function(width, height, deviceScal eFactor, fontScaleFactor, textAutosizing) |
| 66 { | 75 { |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 393 | 402 |
| 394 WebInspector.OverridesSupport.prototype = { | 403 WebInspector.OverridesSupport.prototype = { |
| 395 /** | 404 /** |
| 396 * @param {string} deviceMetrics | 405 * @param {string} deviceMetrics |
| 397 * @param {string} userAgent | 406 * @param {string} userAgent |
| 398 */ | 407 */ |
| 399 emulateDevice: function(deviceMetrics, userAgent) | 408 emulateDevice: function(deviceMetrics, userAgent) |
| 400 { | 409 { |
| 401 WebInspector.settings.deviceMetrics.set(deviceMetrics); | 410 WebInspector.settings.deviceMetrics.set(deviceMetrics); |
| 402 WebInspector.settings.userAgent.set(userAgent); | 411 WebInspector.settings.userAgent.set(userAgent); |
| 403 WebInspector.settings.overrideDeviceMetrics.set(true); | 412 if (this.canForceCompositingMode) |
| 413 WebInspector.settings.overrideDeviceMetrics.set(true); | |
| 404 WebInspector.settings.overrideUserAgent.set(true); | 414 WebInspector.settings.overrideUserAgent.set(true); |
| 405 WebInspector.settings.emulateTouchEvents.set(true); | 415 WebInspector.settings.emulateTouchEvents.set(true); |
| 406 }, | 416 }, |
| 407 | 417 |
| 408 reset: function() | 418 reset: function() |
| 409 { | 419 { |
| 410 WebInspector.settings.overrideDeviceMetrics.set(false); | 420 WebInspector.settings.overrideDeviceMetrics.set(false); |
| 411 WebInspector.settings.overrideUserAgent.set(false); | 421 WebInspector.settings.overrideUserAgent.set(false); |
| 412 WebInspector.settings.emulateTouchEvents.set(false); | 422 WebInspector.settings.emulateTouchEvents.set(false); |
| 413 WebInspector.settings.overrideDeviceOrientation.set(false); | 423 WebInspector.settings.overrideDeviceOrientation.set(false); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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() | |
| 504 { | |
| 505 function callback(error, result) | |
| 506 { | |
| 507 if (!error) { | |
| 508 this.canForceCompositingMode = result; | |
| 509 this.dispatchEventToListeners(WebInspector.OverridesSupport.Even ts.CanForceCompositingModeChanged); | |
|
pfeldman
2013/10/31 11:23:58
You should only dispatch it if this.canForce != re
dgozman
2013/10/31 12:39:50
Done.
| |
| 510 if (!result && WebInspector.settings.overrideDeviceMetrics.get() ) | |
| 511 WebInspector.settings.overrideDeviceMetrics.set(false); | |
| 512 } | |
| 513 } | |
| 514 PageAgent.canForceCompositingMode(callback.bind(this)); | |
| 515 }, | |
| 516 | |
| 517 __proto__: WebInspector.Object.prototype | |
| 492 } | 518 } |
| 493 | 519 |
| 494 | 520 |
| 495 /** | 521 /** |
| 496 * @type {WebInspector.OverridesSupport} | 522 * @type {WebInspector.OverridesSupport} |
| 497 */ | 523 */ |
| 498 WebInspector.overridesSupport; | 524 WebInspector.overridesSupport; |
| OLD | NEW |