OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @constructor | 6 * @constructor |
7 * @param {function()} updateCallback | 7 * @param {function()} updateCallback |
8 * @implements {WebInspector.TargetManager.Observer} | 8 * @implements {WebInspector.TargetManager.Observer} |
9 */ | 9 */ |
10 WebInspector.DeviceModeModel = function(updateCallback) | 10 WebInspector.DeviceModeModel = function(updateCallback) |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
122 }, | 122 }, |
123 | 123 |
124 /** | 124 /** |
125 * @param {!WebInspector.DeviceModeModel.Type} type | 125 * @param {!WebInspector.DeviceModeModel.Type} type |
126 * @param {?WebInspector.EmulatedDevice} device | 126 * @param {?WebInspector.EmulatedDevice} device |
127 * @param {?WebInspector.EmulatedDevice.Mode} mode | 127 * @param {?WebInspector.EmulatedDevice.Mode} mode |
128 */ | 128 */ |
129 emulate: function(type, device, mode) | 129 emulate: function(type, device, mode) |
130 { | 130 { |
131 var resetPageScaleFactor = this._type !== type || this._device !== devic e || this._mode !== mode; | 131 var resetPageScaleFactor = this._type !== type || this._device !== devic e || this._mode !== mode; |
132 var lastOrientation = this._mode ? this._mode.orientation : null; | |
132 this._type = type; | 133 this._type = type; |
133 | 134 |
134 if (type === WebInspector.DeviceModeModel.Type.Device) { | 135 if (type === WebInspector.DeviceModeModel.Type.Device) { |
135 console.assert(device && mode, "Must pass device and mode for device emulation"); | 136 console.assert(device && mode, "Must pass device and mode for device emulation"); |
137 if (this._device !== device && lastOrientation && lastOrientation != = mode.orientation) { | |
dgozman
2016/10/19 00:42:45
This should be done in UI which calls emulate() me
luoe
2016/10/20 00:17:08
Done.
| |
138 var matchingModes = device.modes.filter((mode) => mode.orientati on === lastOrientation); | |
139 mode = matchingModes[0] || mode; | |
140 } | |
141 this._mode = mode; | |
136 this._device = device; | 142 this._device = device; |
137 this._mode = mode; | |
138 if (this._initialized) { | |
139 var orientation = device.orientationByName(mode.orientation); | |
140 this._scaleSetting.set(this._calculateFitScale(orientation.width , orientation.height, this._currentOutline(), this._currentInsets())); | |
dgozman
2016/10/19 00:42:45
I don't think that preserving zoom is a good idea.
luoe
2016/10/20 00:17:08
Zoom preservation removed from this CL. (This cod
| |
141 } | |
142 } else { | 143 } else { |
143 this._device = null; | 144 this._device = null; |
144 this._mode = null; | 145 this._mode = null; |
145 } | 146 } |
146 | 147 |
147 if (type !== WebInspector.DeviceModeModel.Type.None) | 148 if (type !== WebInspector.DeviceModeModel.Type.None) |
148 WebInspector.userMetrics.actionTaken(WebInspector.UserMetrics.Action .DeviceModeEnabled); | 149 WebInspector.userMetrics.actionTaken(WebInspector.UserMetrics.Action .DeviceModeEnabled); |
149 this._calculateAndEmulate(resetPageScaleFactor); | 150 this._calculateAndEmulate(resetPageScaleFactor); |
150 }, | 151 }, |
151 | 152 |
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
630 | 631 |
631 /** | 632 /** |
632 * @param {boolean} touchEnabled | 633 * @param {boolean} touchEnabled |
633 * @param {boolean} mobile | 634 * @param {boolean} mobile |
634 */ | 635 */ |
635 _applyTouch: function(touchEnabled, mobile) | 636 _applyTouch: function(touchEnabled, mobile) |
636 { | 637 { |
637 WebInspector.MultitargetTouchModel.instance().setTouchEnabled(touchEnabl ed, mobile); | 638 WebInspector.MultitargetTouchModel.instance().setTouchEnabled(touchEnabl ed, mobile); |
638 } | 639 } |
639 } | 640 } |
OLD | NEW |