| 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 * @unrestricted | 5 * @unrestricted |
| 6 */ | 6 */ |
| 7 Emulation.EmulatedDevice = class { | 7 Emulation.EmulatedDevice = class { |
| 8 constructor() { | 8 constructor() { |
| 9 /** @type {string} */ | 9 /** @type {string} */ |
| 10 this.title = ''; | 10 this.title = ''; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 */ | 64 */ |
| 65 function parseIntValue(object, key) { | 65 function parseIntValue(object, key) { |
| 66 var value = /** @type {number} */ (parseValue(object, key, 'number')); | 66 var value = /** @type {number} */ (parseValue(object, key, 'number')); |
| 67 if (value !== Math.abs(value)) | 67 if (value !== Math.abs(value)) |
| 68 throw new Error('Emulated device value \'' + key + '\' must be integer
'); | 68 throw new Error('Emulated device value \'' + key + '\' must be integer
'); |
| 69 return value; | 69 return value; |
| 70 } | 70 } |
| 71 | 71 |
| 72 /** | 72 /** |
| 73 * @param {*} json | 73 * @param {*} json |
| 74 * @return {!Insets} | 74 * @return {!UI.Insets} |
| 75 */ | 75 */ |
| 76 function parseInsets(json) { | 76 function parseInsets(json) { |
| 77 return new Insets( | 77 return new UI.Insets( |
| 78 parseIntValue(json, 'left'), parseIntValue(json, 'top'), parseIntVal
ue(json, 'right'), | 78 parseIntValue(json, 'left'), parseIntValue(json, 'top'), parseIntVal
ue(json, 'right'), |
| 79 parseIntValue(json, 'bottom')); | 79 parseIntValue(json, 'bottom')); |
| 80 } | 80 } |
| 81 | 81 |
| 82 /** | 82 /** |
| 83 * @param {*} json | 83 * @param {*} json |
| 84 * @return {!Emulation.EmulatedDevice.Orientation} | 84 * @return {!Emulation.EmulatedDevice.Orientation} |
| 85 */ | 85 */ |
| 86 function parseOrientation(json) { | 86 function parseOrientation(json) { |
| 87 var result = {}; | 87 var result = {}; |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 } | 323 } |
| 324 | 324 |
| 325 /** | 325 /** |
| 326 * @return {boolean} | 326 * @return {boolean} |
| 327 */ | 327 */ |
| 328 mobile() { | 328 mobile() { |
| 329 return this.capabilities.indexOf(Emulation.EmulatedDevice.Capability.Mobile)
!== -1; | 329 return this.capabilities.indexOf(Emulation.EmulatedDevice.Capability.Mobile)
!== -1; |
| 330 } | 330 } |
| 331 }; | 331 }; |
| 332 | 332 |
| 333 /** @typedef {!{title: string, orientation: string, insets: !Insets, image: ?str
ing}} */ | 333 /** @typedef {!{title: string, orientation: string, insets: !UI.Insets, image: ?
string}} */ |
| 334 Emulation.EmulatedDevice.Mode; | 334 Emulation.EmulatedDevice.Mode; |
| 335 | 335 |
| 336 /** @typedef {!{width: number, height: number, outlineInsets: ?Insets, outlineIm
age: ?string}} */ | 336 /** @typedef {!{width: number, height: number, outlineInsets: ?UI.Insets, outlin
eImage: ?string}} */ |
| 337 Emulation.EmulatedDevice.Orientation; | 337 Emulation.EmulatedDevice.Orientation; |
| 338 | 338 |
| 339 Emulation.EmulatedDevice.Horizontal = 'horizontal'; | 339 Emulation.EmulatedDevice.Horizontal = 'horizontal'; |
| 340 Emulation.EmulatedDevice.Vertical = 'vertical'; | 340 Emulation.EmulatedDevice.Vertical = 'vertical'; |
| 341 | 341 |
| 342 Emulation.EmulatedDevice.Type = { | 342 Emulation.EmulatedDevice.Type = { |
| 343 Phone: 'phone', | 343 Phone: 'phone', |
| 344 Tablet: 'tablet', | 344 Tablet: 'tablet', |
| 345 Notebook: 'notebook', | 345 Notebook: 'notebook', |
| 346 Desktop: 'desktop', | 346 Desktop: 'desktop', |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 return false; | 413 return false; |
| 414 var success = true; | 414 var success = true; |
| 415 for (var i = 0; i < jsonArray.length; ++i) { | 415 for (var i = 0; i < jsonArray.length; ++i) { |
| 416 var device = Emulation.EmulatedDevice.fromJSONV1(jsonArray[i]); | 416 var device = Emulation.EmulatedDevice.fromJSONV1(jsonArray[i]); |
| 417 if (device) { | 417 if (device) { |
| 418 result.push(device); | 418 result.push(device); |
| 419 if (!device.modes.length) { | 419 if (!device.modes.length) { |
| 420 device.modes.push({ | 420 device.modes.push({ |
| 421 title: '', | 421 title: '', |
| 422 orientation: Emulation.EmulatedDevice.Horizontal, | 422 orientation: Emulation.EmulatedDevice.Horizontal, |
| 423 insets: new Insets(0, 0, 0, 0), | 423 insets: new UI.Insets(0, 0, 0, 0), |
| 424 image: null | 424 image: null |
| 425 }); | 425 }); |
| 426 device.modes.push( | 426 device.modes.push({ |
| 427 {title: '', orientation: Emulation.EmulatedDevice.Vertical, insets
: new Insets(0, 0, 0, 0), image: null}); | 427 title: '', |
| 428 orientation: Emulation.EmulatedDevice.Vertical, |
| 429 insets: new UI.Insets(0, 0, 0, 0), |
| 430 image: null |
| 431 }); |
| 428 } | 432 } |
| 429 } else { | 433 } else { |
| 430 success = false; | 434 success = false; |
| 431 } | 435 } |
| 432 } | 436 } |
| 433 return success; | 437 return success; |
| 434 } | 438 } |
| 435 | 439 |
| 436 /** | 440 /** |
| 437 * @return {!Array.<!Emulation.EmulatedDevice>} | 441 * @return {!Array.<!Emulation.EmulatedDevice>} |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 }; | 505 }; |
| 502 | 506 |
| 503 /** @enum {symbol} */ | 507 /** @enum {symbol} */ |
| 504 Emulation.EmulatedDevicesList.Events = { | 508 Emulation.EmulatedDevicesList.Events = { |
| 505 CustomDevicesUpdated: Symbol('CustomDevicesUpdated'), | 509 CustomDevicesUpdated: Symbol('CustomDevicesUpdated'), |
| 506 StandardDevicesUpdated: Symbol('StandardDevicesUpdated') | 510 StandardDevicesUpdated: Symbol('StandardDevicesUpdated') |
| 507 }; | 511 }; |
| 508 | 512 |
| 509 /** @type {?Emulation.EmulatedDevicesList} */ | 513 /** @type {?Emulation.EmulatedDevicesList} */ |
| 510 Emulation.EmulatedDevicesList._instance; | 514 Emulation.EmulatedDevicesList._instance; |
| OLD | NEW |