Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/emulation/EmulatedDevices.js

Issue 2440953003: DevTools: use semicolons after each statement. (Closed)
Patch Set: rebaseline Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 13 matching lines...) Expand all
24 /** @type {!Array.<!WebInspector.EmulatedDevice.Mode>} */ 24 /** @type {!Array.<!WebInspector.EmulatedDevice.Mode>} */
25 this.modes = []; 25 this.modes = [];
26 26
27 /** @type {string} */ 27 /** @type {string} */
28 this._show = WebInspector.EmulatedDevice._Show.Default; 28 this._show = WebInspector.EmulatedDevice._Show.Default;
29 /** @type {boolean} */ 29 /** @type {boolean} */
30 this._showByDefault = true; 30 this._showByDefault = true;
31 31
32 /** @type {?Runtime.Extension} */ 32 /** @type {?Runtime.Extension} */
33 this._extension = null; 33 this._extension = null;
34 } 34 };
35 35
36 /** @typedef {!{title: string, orientation: string, insets: !Insets, image: ?str ing}} */ 36 /** @typedef {!{title: string, orientation: string, insets: !Insets, image: ?str ing}} */
37 WebInspector.EmulatedDevice.Mode; 37 WebInspector.EmulatedDevice.Mode;
38 38
39 /** @typedef {!{width: number, height: number, outlineInsets: ?Insets, outlineIm age: ?string}} */ 39 /** @typedef {!{width: number, height: number, outlineInsets: ?Insets, outlineIm age: ?string}} */
40 WebInspector.EmulatedDevice.Orientation; 40 WebInspector.EmulatedDevice.Orientation;
41 41
42 WebInspector.EmulatedDevice.Horizontal = "horizontal"; 42 WebInspector.EmulatedDevice.Horizontal = "horizontal";
43 WebInspector.EmulatedDevice.Vertical = "vertical"; 43 WebInspector.EmulatedDevice.Vertical = "vertical";
44 44
45 WebInspector.EmulatedDevice.Type = { 45 WebInspector.EmulatedDevice.Type = {
46 Phone: "phone", 46 Phone: "phone",
47 Tablet: "tablet", 47 Tablet: "tablet",
48 Notebook: "notebook", 48 Notebook: "notebook",
49 Desktop: "desktop", 49 Desktop: "desktop",
50 Unknown: "unknown" 50 Unknown: "unknown"
51 } 51 };
52 52
53 WebInspector.EmulatedDevice.Capability = { 53 WebInspector.EmulatedDevice.Capability = {
54 Touch: "touch", 54 Touch: "touch",
55 Mobile: "mobile" 55 Mobile: "mobile"
56 } 56 };
57 57
58 WebInspector.EmulatedDevice._Show = { 58 WebInspector.EmulatedDevice._Show = {
59 Always: "Always", 59 Always: "Always",
60 Default: "Default", 60 Default: "Default",
61 Never: "Never" 61 Never: "Never"
62 } 62 };
63 63
64 /** 64 /**
65 * @param {*} json 65 * @param {*} json
66 * @return {?WebInspector.EmulatedDevice} 66 * @return {?WebInspector.EmulatedDevice}
67 */ 67 */
68 WebInspector.EmulatedDevice.fromJSONV1 = function(json) 68 WebInspector.EmulatedDevice.fromJSONV1 = function(json)
69 { 69 {
70 try { 70 try {
71 /** 71 /**
72 * @param {*} object 72 * @param {*} object
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 result.modes.push(mode); 179 result.modes.push(mode);
180 } 180 }
181 181
182 result._showByDefault = /** @type {boolean} */ (parseValue(json, "show-b y-default", "boolean", undefined)); 182 result._showByDefault = /** @type {boolean} */ (parseValue(json, "show-b y-default", "boolean", undefined));
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 return null; 187 return null;
188 } 188 }
189 } 189 };
190 190
191 /** 191 /**
192 * @param {!WebInspector.EmulatedDevice} device1 192 * @param {!WebInspector.EmulatedDevice} device1
193 * @param {!WebInspector.EmulatedDevice} device2 193 * @param {!WebInspector.EmulatedDevice} device2
194 * @return {number} 194 * @return {number}
195 */ 195 */
196 WebInspector.EmulatedDevice.deviceComparator = function(device1, device2) 196 WebInspector.EmulatedDevice.deviceComparator = function(device1, device2)
197 { 197 {
198 var order1 = (device1._extension && device1._extension.descriptor()["order"] ) || -1; 198 var order1 = (device1._extension && device1._extension.descriptor()["order"] ) || -1;
199 var order2 = (device2._extension && device2._extension.descriptor()["order"] ) || -1; 199 var order2 = (device2._extension && device2._extension.descriptor()["order"] ) || -1;
200 if (order1 > order2) 200 if (order1 > order2)
201 return 1; 201 return 1;
202 if (order2 > order1) 202 if (order2 > order1)
203 return -1; 203 return -1;
204 return device1.title < device2.title ? -1 : (device1.title > device2.title ? 1 : 0); 204 return device1.title < device2.title ? -1 : (device1.title > device2.title ? 1 : 0);
205 } 205 };
206 206
207 WebInspector.EmulatedDevice.prototype = { 207 WebInspector.EmulatedDevice.prototype = {
208 /** 208 /**
209 * @return {?Runtime.Extension} 209 * @return {?Runtime.Extension}
210 */ 210 */
211 extension: function() 211 extension: function()
212 { 212 {
213 return this._extension; 213 return this._extension;
214 }, 214 },
215 215
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 return this.capabilities.indexOf(WebInspector.EmulatedDevice.Capability. Touch) !== -1; 363 return this.capabilities.indexOf(WebInspector.EmulatedDevice.Capability. Touch) !== -1;
364 }, 364 },
365 365
366 /** 366 /**
367 * @return {boolean} 367 * @return {boolean}
368 */ 368 */
369 mobile: function() 369 mobile: function()
370 { 370 {
371 return this.capabilities.indexOf(WebInspector.EmulatedDevice.Capability. Mobile) !== -1; 371 return this.capabilities.indexOf(WebInspector.EmulatedDevice.Capability. Mobile) !== -1;
372 } 372 }
373 } 373 };
374 374
375 375
376 /** 376 /**
377 * @constructor 377 * @constructor
378 * @extends {WebInspector.Object} 378 * @extends {WebInspector.Object}
379 */ 379 */
380 WebInspector.EmulatedDevicesList = function() 380 WebInspector.EmulatedDevicesList = function()
381 { 381 {
382 WebInspector.Object.call(this); 382 WebInspector.Object.call(this);
383 383
384 /** @type {!WebInspector.Setting} */ 384 /** @type {!WebInspector.Setting} */
385 this._standardSetting = WebInspector.settings.createSetting("standardEmulate dDeviceList", []); 385 this._standardSetting = WebInspector.settings.createSetting("standardEmulate dDeviceList", []);
386 /** @type {!Array.<!WebInspector.EmulatedDevice>} */ 386 /** @type {!Array.<!WebInspector.EmulatedDevice>} */
387 this._standard = []; 387 this._standard = [];
388 this._listFromJSONV1(this._standardSetting.get(), this._standard); 388 this._listFromJSONV1(this._standardSetting.get(), this._standard);
389 this._updateStandardDevices(); 389 this._updateStandardDevices();
390 390
391 /** @type {!WebInspector.Setting} */ 391 /** @type {!WebInspector.Setting} */
392 this._customSetting = WebInspector.settings.createSetting("customEmulatedDev iceList", []); 392 this._customSetting = WebInspector.settings.createSetting("customEmulatedDev iceList", []);
393 /** @type {!Array.<!WebInspector.EmulatedDevice>} */ 393 /** @type {!Array.<!WebInspector.EmulatedDevice>} */
394 this._custom = []; 394 this._custom = [];
395 if (!this._listFromJSONV1(this._customSetting.get(), this._custom)) 395 if (!this._listFromJSONV1(this._customSetting.get(), this._custom))
396 this.saveCustomDevices(); 396 this.saveCustomDevices();
397 } 397 };
398 398
399 /** @enum {symbol} */ 399 /** @enum {symbol} */
400 WebInspector.EmulatedDevicesList.Events = { 400 WebInspector.EmulatedDevicesList.Events = {
401 CustomDevicesUpdated: Symbol("CustomDevicesUpdated"), 401 CustomDevicesUpdated: Symbol("CustomDevicesUpdated"),
402 StandardDevicesUpdated: Symbol("StandardDevicesUpdated") 402 StandardDevicesUpdated: Symbol("StandardDevicesUpdated")
403 } 403 };
404 404
405 WebInspector.EmulatedDevicesList.prototype = { 405 WebInspector.EmulatedDevicesList.prototype = {
406 _updateStandardDevices: function() 406 _updateStandardDevices: function()
407 { 407 {
408 var devices = []; 408 var devices = [];
409 var extensions = self.runtime.extensions("emulated-device"); 409 var extensions = self.runtime.extensions("emulated-device");
410 for (var i = 0; i < extensions.length; ++i) { 410 for (var i = 0; i < extensions.length; ++i) {
411 var device = WebInspector.EmulatedDevice.fromJSONV1(extensions[i].de scriptor()["device"]); 411 var device = WebInspector.EmulatedDevice.fromJSONV1(extensions[i].de scriptor()["device"]);
412 device.setExtension(extensions[i]); 412 device.setExtension(extensions[i]);
413 devices.push(device); 413 devices.push(device);
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 deviceById.set(from[i].title, from[i]); 506 deviceById.set(from[i].title, from[i]);
507 507
508 for (var i = 0; i < to.length; ++i) { 508 for (var i = 0; i < to.length; ++i) {
509 var title = to[i].title; 509 var title = to[i].title;
510 if (deviceById.has(title)) 510 if (deviceById.has(title))
511 to[i].copyShowFrom(/** @type {!WebInspector.EmulatedDevice} */ ( deviceById.get(title))); 511 to[i].copyShowFrom(/** @type {!WebInspector.EmulatedDevice} */ ( deviceById.get(title)));
512 } 512 }
513 }, 513 },
514 514
515 __proto__: WebInspector.Object.prototype 515 __proto__: WebInspector.Object.prototype
516 } 516 };
517 517
518 /** @type {?WebInspector.EmulatedDevicesList} */ 518 /** @type {?WebInspector.EmulatedDevicesList} */
519 WebInspector.EmulatedDevicesList._instance; 519 WebInspector.EmulatedDevicesList._instance;
520 520
521 /** 521 /**
522 * @return {!WebInspector.EmulatedDevicesList} 522 * @return {!WebInspector.EmulatedDevicesList}
523 */ 523 */
524 WebInspector.EmulatedDevicesList.instance = function() 524 WebInspector.EmulatedDevicesList.instance = function()
525 { 525 {
526 if (!WebInspector.EmulatedDevicesList._instance) 526 if (!WebInspector.EmulatedDevicesList._instance)
527 WebInspector.EmulatedDevicesList._instance = new WebInspector.EmulatedDe vicesList(); 527 WebInspector.EmulatedDevicesList._instance = new WebInspector.EmulatedDe vicesList();
528 return /** @type {!WebInspector.EmulatedDevicesList} */ (WebInspector.Emulat edDevicesList._instance); 528 return /** @type {!WebInspector.EmulatedDevicesList} */ (WebInspector.Emulat edDevicesList._instance);
529 } 529 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698