OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
323 return parseInt(matches[1], 10); | 323 return parseInt(matches[1], 10); |
324 } | 324 } |
325 | 325 |
326 /** | 326 /** |
327 * @param {!RuntimeAgent.RemoteObject|!WebInspector.RemoteObject|number|string|b oolean|undefined|null} object | 327 * @param {!RuntimeAgent.RemoteObject|!WebInspector.RemoteObject|number|string|b oolean|undefined|null} object |
328 * @return {!RuntimeAgent.CallArgument} | 328 * @return {!RuntimeAgent.CallArgument} |
329 */ | 329 */ |
330 WebInspector.RemoteObject.toCallArgument = function(object) | 330 WebInspector.RemoteObject.toCallArgument = function(object) |
331 { | 331 { |
332 var type = typeof object; | 332 var type = typeof object; |
333 var value = object; | 333 if (type === "undefined") |
334 var objectId = undefined; | 334 return {}; |
335 var description = String(object); | 335 if (type === "number") { |
336 var description = String(object); | |
337 if (object === 0 && 1 / object < 0) | |
338 return { unserializableValue: RuntimeAgent.UnserializableValue.Negat ive0 }; | |
339 if (description === "NaN") | |
340 return { unserializableValue: RuntimeAgent.UnserializableValue.NaN } ; | |
341 if (description === "Infinity") | |
342 return { unserializableValue: RuntimeAgent.UnserializableValue.Infin ity }; | |
343 if (description === "-Infinity") | |
344 return { unserializableValue: RuntimeAgent.UnserializableValue.Negat iveInfinity }; | |
345 return { value: object }; | |
346 } | |
347 if (type === "string" || type === "boolean") | |
348 return { value: object }; | |
336 | 349 |
337 if (type === "number" && value === 0 && 1 / value < 0) | 350 if (!object) |
338 description = "-0"; | 351 return { value: null }; |
339 | 352 |
340 switch (type) { | 353 if (typeof object.unserializableValue !== "undefined") |
kozy
2016/08/05 01:21:02
Why do you need both checks?
dgozman
2016/08/05 02:01:07
Because it takes both WI.RemoteObject and RA.Remot
| |
341 case "number": | 354 return { unserializableValue: object.unserializableValue }; |
342 case "string": | 355 if (typeof object._unserializableValue !== "undefined") |
343 case "boolean": | 356 return { unserializableValue: object._unserializableValue }; |
344 case "undefined": | |
345 break; | |
346 default: | |
347 if (object) { | |
348 type = object.type; | |
349 value = object.value; | |
350 objectId = object.objectId; | |
351 description = object.description; | |
352 } | |
353 break; | |
354 } | |
355 | 357 |
356 // Handle special numbers: NaN, Infinity, -Infinity, -0. | 358 if (typeof object.objectId !== "undefined") |
357 if (type === "number") { | 359 return { objectId: object.objectId }; |
358 switch (description) { | 360 if (typeof object._objectId !== "undefined") |
359 case "NaN": | 361 return { objectId: object._objectId }; |
360 case "Infinity": | |
361 case "-Infinity": | |
362 case "-0": | |
363 value = description; | |
364 break; | |
365 } | |
366 } | |
367 | 362 |
368 return { | 363 return { value: object.value }; |
369 value: value, | |
370 objectId: objectId, | |
371 type: /** @type {!RuntimeAgent.CallArgumentType.<string>} */ (type) | |
372 }; | |
373 } | 364 } |
374 | 365 |
375 /** | 366 /** |
376 * @constructor | 367 * @constructor |
377 * @extends {WebInspector.RemoteObject} | 368 * @extends {WebInspector.RemoteObject} |
378 * @param {!WebInspector.Target} target | 369 * @param {!WebInspector.Target} target |
379 * @param {string|undefined} objectId | 370 * @param {string|undefined} objectId |
380 * @param {string} type | 371 * @param {string} type |
381 * @param {string|undefined} subtype | 372 * @param {string|undefined} subtype |
382 * @param {*} value | 373 * @param {*} value |
374 * @param {!RuntimeAgent.UnserializableValue=} unserializableValue | |
383 * @param {string=} description | 375 * @param {string=} description |
384 * @param {!RuntimeAgent.ObjectPreview=} preview | 376 * @param {!RuntimeAgent.ObjectPreview=} preview |
385 * @param {!RuntimeAgent.CustomPreview=} customPreview | 377 * @param {!RuntimeAgent.CustomPreview=} customPreview |
386 */ | 378 */ |
387 WebInspector.RemoteObjectImpl = function(target, objectId, type, subtype, value, description, preview, customPreview) | 379 WebInspector.RemoteObjectImpl = function(target, objectId, type, subtype, value, unserializableValue, description, preview, customPreview) |
388 { | 380 { |
389 WebInspector.RemoteObject.call(this); | 381 WebInspector.RemoteObject.call(this); |
390 | 382 |
391 this._target = target; | 383 this._target = target; |
392 this._runtimeAgent = target.runtimeAgent(); | 384 this._runtimeAgent = target.runtimeAgent(); |
393 this._debuggerModel = WebInspector.DebuggerModel.fromTarget(target); | 385 this._debuggerModel = WebInspector.DebuggerModel.fromTarget(target); |
394 | 386 |
395 this._type = type; | 387 this._type = type; |
396 this._subtype = subtype; | 388 this._subtype = subtype; |
397 if (objectId) { | 389 if (objectId) { |
398 // handle | 390 // handle |
399 this._objectId = objectId; | 391 this._objectId = objectId; |
400 this._description = description; | 392 this._description = description; |
401 this._hasChildren = (type !== "symbol"); | 393 this._hasChildren = (type !== "symbol"); |
402 this._preview = preview; | 394 this._preview = preview; |
403 } else { | 395 } else { |
404 // Primitive or null object. | 396 // Primitive or null object. |
405 this._description = description || (value + ""); | 397 this._description = description || (value + ""); |
406 this._hasChildren = false; | 398 this._hasChildren = false; |
407 // Handle special numbers: NaN, Infinity, -Infinity, -0. | 399 if (typeof unserializableValue !== "undefined") { |
408 if (type === "number" && typeof value !== "number") | 400 this._unserializableValue = unserializableValue; |
409 this.value = Number(value); | 401 if (unserializableValue === RuntimeAgent.UnserializableValue.Infinit y || |
410 else | 402 unserializableValue === RuntimeAgent.UnserializableValue.Negativ eInfinity || |
403 unserializableValue === RuntimeAgent.UnserializableValue.Negativ e0 || | |
404 unserializableValue === RuntimeAgent.UnserializableValue.NaN) { | |
405 this.value = Number(unserializableValue); | |
406 } else { | |
407 this.value = unserializableValue; | |
408 } | |
409 } else { | |
411 this.value = value; | 410 this.value = value; |
411 } | |
412 } | 412 } |
413 this._customPreview = customPreview || null; | 413 this._customPreview = customPreview || null; |
414 } | 414 } |
415 | 415 |
416 WebInspector.RemoteObjectImpl.prototype = { | 416 WebInspector.RemoteObjectImpl.prototype = { |
417 | 417 |
418 /** | 418 /** |
419 * @override | 419 * @override |
420 * @return {?RuntimeAgent.CustomPreview} | 420 * @return {?RuntimeAgent.CustomPreview} |
421 */ | 421 */ |
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
908 | 908 |
909 /** | 909 /** |
910 * @constructor | 910 * @constructor |
911 * @extends {WebInspector.RemoteObjectImpl} | 911 * @extends {WebInspector.RemoteObjectImpl} |
912 * @param {!WebInspector.Target} target | 912 * @param {!WebInspector.Target} target |
913 * @param {string|undefined} objectId | 913 * @param {string|undefined} objectId |
914 * @param {!WebInspector.ScopeRef} scopeRef | 914 * @param {!WebInspector.ScopeRef} scopeRef |
915 * @param {string} type | 915 * @param {string} type |
916 * @param {string|undefined} subtype | 916 * @param {string|undefined} subtype |
917 * @param {*} value | 917 * @param {*} value |
918 * @param {!RuntimeAgent.UnserializableValue=} unserializableValue | |
918 * @param {string=} description | 919 * @param {string=} description |
919 * @param {!RuntimeAgent.ObjectPreview=} preview | 920 * @param {!RuntimeAgent.ObjectPreview=} preview |
920 */ | 921 */ |
921 WebInspector.ScopeRemoteObject = function(target, objectId, scopeRef, type, subt ype, value, description, preview) | 922 WebInspector.ScopeRemoteObject = function(target, objectId, scopeRef, type, subt ype, value, unserializableValue, description, preview) |
922 { | 923 { |
923 WebInspector.RemoteObjectImpl.call(this, target, objectId, type, subtype, va lue, description, preview); | 924 WebInspector.RemoteObjectImpl.call(this, target, objectId, type, subtype, va lue, unserializableValue, description, preview); |
924 this._scopeRef = scopeRef; | 925 this._scopeRef = scopeRef; |
925 this._savedScopeProperties = undefined; | 926 this._savedScopeProperties = undefined; |
926 }; | 927 }; |
927 | 928 |
928 WebInspector.ScopeRemoteObject.prototype = { | 929 WebInspector.ScopeRemoteObject.prototype = { |
929 /** | 930 /** |
930 * @override | 931 * @override |
931 * @param {boolean} ownProperties | 932 * @param {boolean} ownProperties |
932 * @param {boolean} accessorPropertiesOnly | 933 * @param {boolean} accessorPropertiesOnly |
933 * @param {boolean} generatePreview | 934 * @param {boolean} generatePreview |
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1509 }, | 1510 }, |
1510 | 1511 |
1511 /** | 1512 /** |
1512 * @return {!WebInspector.RemoteObject} | 1513 * @return {!WebInspector.RemoteObject} |
1513 */ | 1514 */ |
1514 object: function() | 1515 object: function() |
1515 { | 1516 { |
1516 return this._object; | 1517 return this._object; |
1517 } | 1518 } |
1518 } | 1519 } |
OLD | NEW |