| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 */ | 7 */ |
| 8 WebInspector.EmulatedDevice = function() | 8 WebInspector.EmulatedDevice = function() |
| 9 { | 9 { |
| 10 /** @type {string} */ | 10 /** @type {string} */ |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 if (result.height < 0 || result.height > WebInspector.DeviceModeMode
l.MaxDeviceSize || result.height < WebInspector.DeviceModeModel.MinDeviceSize) | 126 if (result.height < 0 || result.height > WebInspector.DeviceModeMode
l.MaxDeviceSize || result.height < WebInspector.DeviceModeModel.MinDeviceSize) |
| 127 throw new Error("Emulated device has wrong height: " + result.he
ight); | 127 throw new Error("Emulated device has wrong height: " + result.he
ight); |
| 128 | 128 |
| 129 var outlineInsets = parseValue(json["outline"], "insets", "object",
null); | 129 var outlineInsets = parseValue(json["outline"], "insets", "object",
null); |
| 130 if (outlineInsets) { | 130 if (outlineInsets) { |
| 131 result.outlineInsets = parseInsets(outlineInsets); | 131 result.outlineInsets = parseInsets(outlineInsets); |
| 132 if (result.outlineInsets.left < 0 || result.outlineInsets.top <
0) | 132 if (result.outlineInsets.left < 0 || result.outlineInsets.top <
0) |
| 133 throw new Error("Emulated device has wrong outline insets"); | 133 throw new Error("Emulated device has wrong outline insets"); |
| 134 result.outlineImage = /** @type {string} */ (parseValue(json["ou
tline"], "image", "string")); | 134 result.outlineImage = /** @type {string} */ (parseValue(json["ou
tline"], "image", "string")); |
| 135 } | 135 } |
| 136 | |
| 137 return /** @type {!WebInspector.EmulatedDevice.Orientation} */ (resu
lt); | 136 return /** @type {!WebInspector.EmulatedDevice.Orientation} */ (resu
lt); |
| 138 } | 137 } |
| 139 | 138 |
| 140 var result = new WebInspector.EmulatedDevice(); | 139 var result = new WebInspector.EmulatedDevice(); |
| 141 result.title = /** @type {string} */ (parseValue(json, "title", "string"
)); | 140 result.title = /** @type {string} */ (parseValue(json, "title", "string"
)); |
| 142 result.type = /** @type {string} */ (parseValue(json, "type", "string"))
; | 141 result.type = /** @type {string} */ (parseValue(json, "type", "string"))
; |
| 143 result.userAgent = /** @type {string} */ (parseValue(json, "user-agent",
"string")); | 142 result.userAgent = /** @type {string} */ (parseValue(json, "user-agent",
"string")); |
| 144 | 143 |
| 145 var capabilities = parseValue(json, "capabilities", "object", []); | 144 var capabilities = parseValue(json, "capabilities", "object", []); |
| 146 if (!Array.isArray(capabilities)) | 145 if (!Array.isArray(capabilities)) |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 modeImage: function(mode) | 299 modeImage: function(mode) |
| 301 { | 300 { |
| 302 if (!mode.image) | 301 if (!mode.image) |
| 303 return ""; | 302 return ""; |
| 304 if (!this._extension) | 303 if (!this._extension) |
| 305 return mode.image; | 304 return mode.image; |
| 306 return this._extension.module().substituteURL(mode.image); | 305 return this._extension.module().substituteURL(mode.image); |
| 307 }, | 306 }, |
| 308 | 307 |
| 309 /** | 308 /** |
| 309 * @param {!WebInspector.EmulatedDevice.Mode} mode |
| 310 * @return {string} |
| 311 */ |
| 312 outlineImage: function(mode) |
| 313 { |
| 314 var orientation = this.orientationByName(mode.orientation); |
| 315 if (!orientation.outlineImage) |
| 316 return ""; |
| 317 if (!this._extension) |
| 318 return orientation.outlineImage; |
| 319 return this._extension.module().substituteURL(orientation.outlineImage); |
| 320 }, |
| 321 |
| 322 /** |
| 310 * @param {string} name | 323 * @param {string} name |
| 311 * @return {!WebInspector.EmulatedDevice.Orientation} | 324 * @return {!WebInspector.EmulatedDevice.Orientation} |
| 312 */ | 325 */ |
| 313 orientationByName: function(name) | 326 orientationByName: function(name) |
| 314 { | 327 { |
| 315 return name === WebInspector.EmulatedDevice.Vertical ? this.vertical : t
his.horizontal; | 328 return name === WebInspector.EmulatedDevice.Vertical ? this.vertical : t
his.horizontal; |
| 316 }, | 329 }, |
| 317 | 330 |
| 318 /** | 331 /** |
| 319 * @return {boolean} | 332 * @return {boolean} |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 | 518 |
| 506 /** | 519 /** |
| 507 * @return {!WebInspector.EmulatedDevicesList} | 520 * @return {!WebInspector.EmulatedDevicesList} |
| 508 */ | 521 */ |
| 509 WebInspector.EmulatedDevicesList.instance = function() | 522 WebInspector.EmulatedDevicesList.instance = function() |
| 510 { | 523 { |
| 511 if (!WebInspector.EmulatedDevicesList._instance) | 524 if (!WebInspector.EmulatedDevicesList._instance) |
| 512 WebInspector.EmulatedDevicesList._instance = new WebInspector.EmulatedDe
vicesList(); | 525 WebInspector.EmulatedDevicesList._instance = new WebInspector.EmulatedDe
vicesList(); |
| 513 return /** @type {!WebInspector.EmulatedDevicesList} */ (WebInspector.Emulat
edDevicesList._instance); | 526 return /** @type {!WebInspector.EmulatedDevicesList} */ (WebInspector.Emulat
edDevicesList._instance); |
| 514 } | 527 } |
| OLD | NEW |