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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 this._availableSize = availableSize; | 118 this._availableSize = availableSize; |
119 this._preferredSize = preferredSize; | 119 this._preferredSize = preferredSize; |
120 this._initialized = true; | 120 this._initialized = true; |
121 this._calculateAndEmulate(false); | 121 this._calculateAndEmulate(false); |
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 * @param {number=} scale |
128 */ | 129 */ |
129 emulate: function(type, device, mode) | 130 emulate: function(type, device, mode, scale) |
130 { | 131 { |
131 var resetPageScaleFactor = this._type !== type || this._device !== devic
e || this._mode !== mode; | 132 var resetPageScaleFactor = this._type !== type || this._device !== devic
e || this._mode !== mode; |
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 this._mode = mode; |
136 this._device = device; | 138 this._device = device; |
137 this._mode = mode; | |
138 if (this._initialized) { | 139 if (this._initialized) { |
139 var orientation = device.orientationByName(mode.orientation); | 140 var orientation = device.orientationByName(mode.orientation); |
140 this._scaleSetting.set(this._calculateFitScale(orientation.width
, orientation.height, this._currentOutline(), this._currentInsets())); | 141 this._scaleSetting.set(scale || this._calculateFitScale(orientat
ion.width, orientation.height, this._currentOutline(), this._currentInsets())); |
141 } | 142 } |
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 }, |
(...skipping 479 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 |