| 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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 result._show = /** @type {string} */ (parseValue(json, "show", "string",
WebInspector.EmulatedDevice._Show.Default)); | 183 result._show = /** @type {string} */ (parseValue(json, "show", "string",
WebInspector.EmulatedDevice._Show.Default)); |
| 184 | 184 |
| 185 return result; | 185 return result; |
| 186 } catch (e) { | 186 } catch (e) { |
| 187 WebInspector.console.error("Failed to update emulated device list. " + S
tring(e)); | 187 WebInspector.console.error("Failed to update emulated device list. " + S
tring(e)); |
| 188 return null; | 188 return null; |
| 189 } | 189 } |
| 190 } | 190 } |
| 191 | 191 |
| 192 /** | 192 /** |
| 193 * @param {!WebInspector.OverridesSupport.Device} device | |
| 194 * @param {string} title | |
| 195 * @param {string=} type | |
| 196 * @return {!WebInspector.EmulatedDevice} | |
| 197 */ | |
| 198 WebInspector.EmulatedDevice.fromOverridesDevice = function(device, title, type) | |
| 199 { | |
| 200 var result = new WebInspector.EmulatedDevice(); | |
| 201 result.title = title; | |
| 202 result.type = type || WebInspector.EmulatedDevice.Type.Unknown; | |
| 203 result.vertical.width = device.width; | |
| 204 result.vertical.height = device.height; | |
| 205 result.horizontal.width = device.height; | |
| 206 result.horizontal.height = device.width; | |
| 207 result.deviceScaleFactor = device.deviceScaleFactor; | |
| 208 result.userAgent = device.userAgent; | |
| 209 result.capabilities = []; | |
| 210 if (device.touch) | |
| 211 result.capabilities.push(WebInspector.EmulatedDevice.Capability.Touch); | |
| 212 if (device.mobile) | |
| 213 result.capabilities.push(WebInspector.EmulatedDevice.Capability.Mobile); | |
| 214 return result; | |
| 215 } | |
| 216 | |
| 217 /** | |
| 218 * @param {!WebInspector.EmulatedDevice} device1 | 193 * @param {!WebInspector.EmulatedDevice} device1 |
| 219 * @param {!WebInspector.EmulatedDevice} device2 | 194 * @param {!WebInspector.EmulatedDevice} device2 |
| 220 * @return {number} | 195 * @return {number} |
| 221 */ | 196 */ |
| 222 WebInspector.EmulatedDevice.deviceComparator = function(device1, device2) | 197 WebInspector.EmulatedDevice.deviceComparator = function(device1, device2) |
| 223 { | 198 { |
| 224 var order1 = (device1._extension && device1._extension.descriptor()["order"]
) || -1; | 199 var order1 = (device1._extension && device1._extension.descriptor()["order"]
) || -1; |
| 225 var order2 = (device2._extension && device2._extension.descriptor()["order"]
) || -1; | 200 var order2 = (device2._extension && device2._extension.descriptor()["order"]
) || -1; |
| 226 if (order1 > order2) | 201 if (order1 > order2) |
| 227 return 1; | 202 return 1; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 json["outline"]["insets"]["top"] = orientation.outlineInsets.top; | 289 json["outline"]["insets"]["top"] = orientation.outlineInsets.top; |
| 315 json["outline"]["insets"]["right"] = orientation.outlineInsets.right
; | 290 json["outline"]["insets"]["right"] = orientation.outlineInsets.right
; |
| 316 json["outline"]["insets"]["bottom"] = orientation.outlineInsets.bott
om; | 291 json["outline"]["insets"]["bottom"] = orientation.outlineInsets.bott
om; |
| 317 json["outline"]["image"] = orientation.outlineImage; | 292 json["outline"]["image"] = orientation.outlineImage; |
| 318 } | 293 } |
| 319 return json; | 294 return json; |
| 320 }, | 295 }, |
| 321 | 296 |
| 322 /** | 297 /** |
| 323 * @param {!WebInspector.EmulatedDevice.Mode} mode | 298 * @param {!WebInspector.EmulatedDevice.Mode} mode |
| 324 * @return {!WebInspector.OverridesSupport.Device} | |
| 325 */ | |
| 326 modeToOverridesDevice: function(mode) | |
| 327 { | |
| 328 var result = {}; | |
| 329 var orientation = this.orientationByName(mode.orientation); | |
| 330 result.width = orientation.width - mode.insets.left - mode.insets.right; | |
| 331 result.height = orientation.height - mode.insets.top - mode.insets.botto
m; | |
| 332 result.deviceScaleFactor = this.deviceScaleFactor; | |
| 333 result.userAgent = this.userAgent; | |
| 334 result.touch = this.touch(); | |
| 335 result.mobile = this.mobile(); | |
| 336 return result; | |
| 337 }, | |
| 338 | |
| 339 /** | |
| 340 * @param {!WebInspector.EmulatedDevice.Mode} mode | |
| 341 * @return {string} | 299 * @return {string} |
| 342 */ | 300 */ |
| 343 modeImage: function(mode) | 301 modeImage: function(mode) |
| 344 { | 302 { |
| 345 if (!mode.image) | 303 if (!mode.image) |
| 346 return ""; | 304 return ""; |
| 347 if (!this._extension) | 305 if (!this._extension) |
| 348 return mode.image; | 306 return mode.image; |
| 349 return this._extension.module().substituteURL(mode.image); | 307 return this._extension.module().substituteURL(mode.image); |
| 350 }, | 308 }, |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 if (deviceById.has(title)) | 490 if (deviceById.has(title)) |
| 533 to[i].copyShowFrom(/** @type {!WebInspector.EmulatedDevice} */ (
deviceById.get(title))); | 491 to[i].copyShowFrom(/** @type {!WebInspector.EmulatedDevice} */ (
deviceById.get(title))); |
| 534 } | 492 } |
| 535 }, | 493 }, |
| 536 | 494 |
| 537 __proto__: WebInspector.Object.prototype | 495 __proto__: WebInspector.Object.prototype |
| 538 } | 496 } |
| 539 | 497 |
| 540 /** @type {!WebInspector.EmulatedDevicesList} */ | 498 /** @type {!WebInspector.EmulatedDevicesList} */ |
| 541 WebInspector.emulatedDevicesList; | 499 WebInspector.emulatedDevicesList; |
| OLD | NEW |