| 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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 // handle | 207 // handle |
| 208 this._objectId = objectId; | 208 this._objectId = objectId; |
| 209 this._description = description; | 209 this._description = description; |
| 210 this._hasChildren = true; | 210 this._hasChildren = true; |
| 211 this._preview = preview; | 211 this._preview = preview; |
| 212 } else { | 212 } else { |
| 213 // Primitive or null object. | 213 // Primitive or null object. |
| 214 console.assert(type !== "object" || value === null); | 214 console.assert(type !== "object" || value === null); |
| 215 this._description = description || (value + ""); | 215 this._description = description || (value + ""); |
| 216 this._hasChildren = false; | 216 this._hasChildren = false; |
| 217 this.value = value; | 217 // Handle special numbers: NaN, Infinity, -Infinity, -0. |
| 218 if (type === "number" && typeof value !== "number") |
| 219 this.value = Number(value); |
| 220 else |
| 221 this.value = value; |
| 218 } | 222 } |
| 219 } | 223 } |
| 220 | 224 |
| 221 WebInspector.RemoteObjectImpl.prototype = { | 225 WebInspector.RemoteObjectImpl.prototype = { |
| 222 /** @return {!RuntimeAgent.RemoteObjectId} */ | 226 /** @return {!RuntimeAgent.RemoteObjectId} */ |
| 223 get objectId() | 227 get objectId() |
| 224 { | 228 { |
| 225 return this._objectId; | 229 return this._objectId; |
| 226 }, | 230 }, |
| 227 | 231 |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 * @param {function(string=)} callback | 382 * @param {function(string=)} callback |
| 379 */ | 383 */ |
| 380 doSetObjectPropertyValue: function(result, name, callback) | 384 doSetObjectPropertyValue: function(result, name, callback) |
| 381 { | 385 { |
| 382 // This assignment may be for a regular (data) property, and for an accc
essor property (with getter/setter). | 386 // This assignment may be for a regular (data) property, and for an accc
essor property (with getter/setter). |
| 383 // Note the sensitive matter about accessor property: the property may b
e physically defined in some proto object, | 387 // Note the sensitive matter about accessor property: the property may b
e physically defined in some proto object, |
| 384 // but logically it is bound to the object in question. JavaScript passe
s this object to getters/setters, not the object | 388 // but logically it is bound to the object in question. JavaScript passe
s this object to getters/setters, not the object |
| 385 // where property was defined; so do we. | 389 // where property was defined; so do we. |
| 386 var setPropertyValueFunction = "function(a, b) { this[a] = b; }"; | 390 var setPropertyValueFunction = "function(a, b) { this[a] = b; }"; |
| 387 | 391 |
| 388 // Special case for NaN, Infinity, -Infinity, -0. | 392 var argv = [{ value: name }, this._toCallArgument(result)] |
| 389 if (result.type === "number" && String(result.value) !== result.descript
ion) | 393 this._runtimeAgent.callFunctionOn(this._objectId, setPropertyValueFuncti
on, argv, true, undefined, undefined, propertySetCallback.bind(this)); |
| 390 setPropertyValueFunction = "function(a) { this[a] = " + result.descr
iption + "; }"; | |
| 391 | |
| 392 delete result.description; // Optimize on traffic. | |
| 393 this._runtimeAgent.callFunctionOn(this._objectId, setPropertyValueFuncti
on, [{ value:name }, result], true, undefined, undefined, propertySetCallback.bi
nd(this)); | |
| 394 | 394 |
| 395 /** | 395 /** |
| 396 * @param {?Protocol.Error} error | 396 * @param {?Protocol.Error} error |
| 397 * @param {!RuntimeAgent.RemoteObject} result | 397 * @param {!RuntimeAgent.RemoteObject} result |
| 398 * @param {boolean=} wasThrown | 398 * @param {boolean=} wasThrown |
| 399 */ | 399 */ |
| 400 function propertySetCallback(error, result, wasThrown) | 400 function propertySetCallback(error, result, wasThrown) |
| 401 { | 401 { |
| 402 if (error || wasThrown) { | 402 if (error || wasThrown) { |
| 403 callback(error || result.description); | 403 callback(error || result.description); |
| 404 return; | 404 return; |
| 405 } | 405 } |
| 406 callback(); | 406 callback(); |
| 407 } | 407 } |
| 408 }, | 408 }, |
| 409 | 409 |
| 410 /** | 410 /** |
| 411 * @param {!RuntimeAgent.RemoteObject} object |
| 412 * @return {!RuntimeAgent.CallArgument} |
| 413 */ |
| 414 _toCallArgument: function(object) |
| 415 { |
| 416 return { value: object.value, objectId: object.objectId, type: /** @type
{!RuntimeAgent.CallArgumentType.<string>} */ (object.type) }; |
| 417 }, |
| 418 |
| 419 /** |
| 411 * @param {function(?DOMAgent.NodeId)} callback | 420 * @param {function(?DOMAgent.NodeId)} callback |
| 412 */ | 421 */ |
| 413 pushNodeToFrontend: function(callback) | 422 pushNodeToFrontend: function(callback) |
| 414 { | 423 { |
| 415 if (this._objectId) | 424 if (this._objectId) |
| 416 this._domAgent.pushNodeToFrontend(this._objectId, callback); | 425 this._domAgent.pushNodeToFrontend(this._objectId, callback); |
| 417 else | 426 else |
| 418 callback(0); | 427 callback(0); |
| 419 }, | 428 }, |
| 420 | 429 |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 }, | 647 }, |
| 639 | 648 |
| 640 /** | 649 /** |
| 641 * @override | 650 * @override |
| 642 * @param {!RuntimeAgent.RemoteObject} result | 651 * @param {!RuntimeAgent.RemoteObject} result |
| 643 * @param {string} name | 652 * @param {string} name |
| 644 * @param {function(string=)} callback | 653 * @param {function(string=)} callback |
| 645 */ | 654 */ |
| 646 doSetObjectPropertyValue: function(result, name, callback) | 655 doSetObjectPropertyValue: function(result, name, callback) |
| 647 { | 656 { |
| 648 var newValue; | 657 this._debuggerAgent.setVariableValue(this._scopeRef.number, name, this._
toCallArgument(result), this._scopeRef.callFrameId, this._scopeRef.functionId, s
etVariableValueCallback.bind(this)); |
| 649 | |
| 650 switch (result.type) { | |
| 651 case "undefined": | |
| 652 newValue = {}; | |
| 653 break; | |
| 654 case "object": | |
| 655 case "function": | |
| 656 newValue = { objectId: result.objectId }; | |
| 657 break; | |
| 658 default: | |
| 659 newValue = { value: result.value }; | |
| 660 } | |
| 661 | |
| 662 this._debuggerAgent.setVariableValue(this._scopeRef.number, name, newVal
ue, this._scopeRef.callFrameId, this._scopeRef.functionId, setVariableValueCallb
ack.bind(this)); | |
| 663 | 658 |
| 664 /** | 659 /** |
| 665 * @param {?Protocol.Error} error | 660 * @param {?Protocol.Error} error |
| 666 * @this {WebInspector.ScopeRemoteObject} | 661 * @this {WebInspector.ScopeRemoteObject} |
| 667 */ | 662 */ |
| 668 function setVariableValueCallback(error) | 663 function setVariableValueCallback(error) |
| 669 { | 664 { |
| 670 if (error) { | 665 if (error) { |
| 671 callback(error); | 666 callback(error); |
| 672 return; | 667 return; |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 978 result = functionDeclaration.apply(target, rawArgs); | 973 result = functionDeclaration.apply(target, rawArgs); |
| 979 } catch (e) { | 974 } catch (e) { |
| 980 result = null; | 975 result = null; |
| 981 } | 976 } |
| 982 | 977 |
| 983 callback(result); | 978 callback(result); |
| 984 }, | 979 }, |
| 985 | 980 |
| 986 __proto__: WebInspector.RemoteObject.prototype | 981 __proto__: WebInspector.RemoteObject.prototype |
| 987 } | 982 } |
| OLD | NEW |