| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 Mobile: "Mobile", | 78 Mobile: "Mobile", |
| 79 Desktop: "Desktop", | 79 Desktop: "Desktop", |
| 80 DesktopTouch: "DesktopTouch" | 80 DesktopTouch: "DesktopTouch" |
| 81 } | 81 } |
| 82 | 82 |
| 83 WebInspector.DeviceModeModel.MinDeviceSize = 50; | 83 WebInspector.DeviceModeModel.MinDeviceSize = 50; |
| 84 WebInspector.DeviceModeModel.MaxDeviceSize = 9999; | 84 WebInspector.DeviceModeModel.MaxDeviceSize = 9999; |
| 85 | 85 |
| 86 /** | 86 /** |
| 87 * @param {string} value | 87 * @param {string} value |
| 88 * @return {string} | 88 * @return {boolean} |
| 89 */ | 89 */ |
| 90 WebInspector.DeviceModeModel.deviceSizeValidator = function(value) | 90 WebInspector.DeviceModeModel.deviceSizeValidator = function(value) |
| 91 { | 91 { |
| 92 if (/^[\d]+$/.test(value) && value >= WebInspector.DeviceModeModel.MinDevice
Size && value <= WebInspector.DeviceModeModel.MaxDeviceSize) | 92 if (/^[\d]+$/.test(value) && value >= WebInspector.DeviceModeModel.MinDevice
Size && value <= WebInspector.DeviceModeModel.MaxDeviceSize) |
| 93 return ""; | 93 return true; |
| 94 return WebInspector.UIString("Value must be positive integer"); | 94 return false; |
| 95 } | 95 } |
| 96 | 96 |
| 97 /** | 97 /** |
| 98 * @param {string} value | 98 * @param {string} value |
| 99 * @return {string} | 99 * @return {boolean} |
| 100 */ | 100 */ |
| 101 WebInspector.DeviceModeModel.deviceScaleFactorValidator = function(value) | 101 WebInspector.DeviceModeModel.deviceScaleFactorValidator = function(value) |
| 102 { | 102 { |
| 103 if (!value || (/^[\d]+(\.\d+)?|\.\d+$/.test(value) && value >= 0 && value <=
10)) | 103 if (!value || (/^[\d]+(\.\d+)?|\.\d+$/.test(value) && value >= 0 && value <=
10)) |
| 104 return ""; | 104 return true; |
| 105 return WebInspector.UIString("Value must be non-negative float"); | 105 return false; |
| 106 } | 106 } |
| 107 | 107 |
| 108 WebInspector.DeviceModeModel._touchEventsScriptIdSymbol = Symbol("DeviceModeMode
l.touchEventsScriptIdSymbol"); | 108 WebInspector.DeviceModeModel._touchEventsScriptIdSymbol = Symbol("DeviceModeMode
l.touchEventsScriptIdSymbol"); |
| 109 WebInspector.DeviceModeModel._defaultMobileUserAgent = "Mozilla/5.0 (Linux; Andr
oid 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.
0.2490.76 Mobile Safari/537.36"; | 109 WebInspector.DeviceModeModel._defaultMobileUserAgent = "Mozilla/5.0 (Linux; Andr
oid 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.
0.2490.76 Mobile Safari/537.36"; |
| 110 WebInspector.DeviceModeModel._defaultMobileScaleFactor = 2; | 110 WebInspector.DeviceModeModel._defaultMobileScaleFactor = 2; |
| 111 | 111 |
| 112 WebInspector.DeviceModeModel.prototype = { | 112 WebInspector.DeviceModeModel.prototype = { |
| 113 /** | 113 /** |
| 114 * @param {!Size} availableSize | 114 * @param {!Size} availableSize |
| 115 * @param {!Size} preferredSize | 115 * @param {!Size} preferredSize |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 610 if (!this._target || orientation === this._screenOrientation) | 610 if (!this._target || orientation === this._screenOrientation) |
| 611 return; | 611 return; |
| 612 | 612 |
| 613 this._screenOrientation = orientation; | 613 this._screenOrientation = orientation; |
| 614 if (!this._screenOrientation) | 614 if (!this._screenOrientation) |
| 615 this._target.screenOrientationAgent().clearScreenOrientationOverride
(); | 615 this._target.screenOrientationAgent().clearScreenOrientationOverride
(); |
| 616 else | 616 else |
| 617 this._target.screenOrientationAgent().setScreenOrientationOverride(t
his._screenOrientation === "landscapePrimary" ? 90 : 0, /** @type {!ScreenOrient
ationAgent.OrientationType} */ (this._screenOrientation)); | 617 this._target.screenOrientationAgent().setScreenOrientationOverride(t
his._screenOrientation === "landscapePrimary" ? 90 : 0, /** @type {!ScreenOrient
ationAgent.OrientationType} */ (this._screenOrientation)); |
| 618 } | 618 } |
| 619 } | 619 } |
| OLD | NEW |