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

Side by Side Diff: Source/devtools/front_end/RemoteObject.js

Issue 201613004: DevTools: Add context menu option for objects to save to temp variable. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: addressed Created 6 years, 9 months 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 | Annotate | Revision Log
OLDNEW
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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 return "null"; 172 return "null";
173 173
174 var type = typeof remoteObject; 174 var type = typeof remoteObject;
175 if (type !== "object" && type !== "function") 175 if (type !== "object" && type !== "function")
176 return type; 176 return type;
177 177
178 return remoteObject.type; 178 return remoteObject.type;
179 } 179 }
180 180
181 /** 181 /**
182 * @param {!RuntimeAgent.RemoteObject|!WebInspector.RemoteObject} remoteObject
183 * @return {!RuntimeAgent.CallArgument}
184 */
185 WebInspector.RemoteObject.toCallArgument = function(remoteObject)
186 {
187 var type = /** @type {!RuntimeAgent.CallArgumentType.<string>} */ (remoteObj ect.type);
188 var value = remoteObject.value;
189
190 // Handle special numbers: NaN, Infinity, -Infinity, -0.
191 if (type === "number") {
192 switch (remoteObject.description) {
193 case "NaN":
194 case "Infinity":
195 case "-Infinity":
196 case "-0":
197 value = remoteObject.description;
198 break;
199 }
200 }
201
202 return {
203 value: value,
204 objectId: remoteObject.objectId,
205 type: type
206 };
207 }
208
209 /**
182 * @constructor 210 * @constructor
183 * @extends {WebInspector.RemoteObject} 211 * @extends {WebInspector.RemoteObject}
184 * @param {!WebInspector.Target|undefined} target 212 * @param {!WebInspector.Target|undefined} target
185 * @param {string|undefined} objectId 213 * @param {string|undefined} objectId
186 * @param {string} type 214 * @param {string} type
187 * @param {string|undefined} subtype 215 * @param {string|undefined} subtype
188 * @param {*} value 216 * @param {*} value
189 * @param {string=} description 217 * @param {string=} description
190 * @param {!RuntimeAgent.ObjectPreview=} preview 218 * @param {!RuntimeAgent.ObjectPreview=} preview
191 */ 219 */
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 * @param {function(string=)} callback 410 * @param {function(string=)} callback
383 */ 411 */
384 doSetObjectPropertyValue: function(result, name, callback) 412 doSetObjectPropertyValue: function(result, name, callback)
385 { 413 {
386 // This assignment may be for a regular (data) property, and for an accc essor property (with getter/setter). 414 // This assignment may be for a regular (data) property, and for an accc essor property (with getter/setter).
387 // Note the sensitive matter about accessor property: the property may b e physically defined in some proto object, 415 // Note the sensitive matter about accessor property: the property may b e physically defined in some proto object,
388 // but logically it is bound to the object in question. JavaScript passe s this object to getters/setters, not the object 416 // but logically it is bound to the object in question. JavaScript passe s this object to getters/setters, not the object
389 // where property was defined; so do we. 417 // where property was defined; so do we.
390 var setPropertyValueFunction = "function(a, b) { this[a] = b; }"; 418 var setPropertyValueFunction = "function(a, b) { this[a] = b; }";
391 419
392 var argv = [{ value: name }, this._toCallArgument(result)] 420 var argv = [{ value: name }, WebInspector.RemoteObject.toCallArgument(re sult)]
393 this._runtimeAgent.callFunctionOn(this._objectId, setPropertyValueFuncti on, argv, true, undefined, undefined, propertySetCallback); 421 this._runtimeAgent.callFunctionOn(this._objectId, setPropertyValueFuncti on, argv, true, undefined, undefined, propertySetCallback);
394 422
395 /** 423 /**
396 * @param {?Protocol.Error} error 424 * @param {?Protocol.Error} error
397 * @param {!RuntimeAgent.RemoteObject} result 425 * @param {!RuntimeAgent.RemoteObject} result
398 * @param {boolean=} wasThrown 426 * @param {boolean=} wasThrown
399 */ 427 */
400 function propertySetCallback(error, result, wasThrown) 428 function propertySetCallback(error, result, wasThrown)
401 { 429 {
402 if (error || wasThrown) { 430 if (error || wasThrown) {
403 callback(error || result.description); 431 callback(error || result.description);
404 return; 432 return;
405 } 433 }
406 callback(); 434 callback();
407 } 435 }
408 }, 436 },
409 437
410 /** 438 /**
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 /**
420 * @param {function(?DOMAgent.NodeId)} callback 439 * @param {function(?DOMAgent.NodeId)} callback
421 */ 440 */
422 pushNodeToFrontend: function(callback) 441 pushNodeToFrontend: function(callback)
423 { 442 {
424 if (this._objectId) 443 if (this._objectId)
425 this._domAgent.pushNodeToFrontend(this._objectId, callback); 444 this._domAgent.pushNodeToFrontend(this._objectId, callback);
426 else 445 else
427 callback(0); 446 callback(0);
428 }, 447 },
429 448
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 }, 666 },
648 667
649 /** 668 /**
650 * @override 669 * @override
651 * @param {!RuntimeAgent.RemoteObject} result 670 * @param {!RuntimeAgent.RemoteObject} result
652 * @param {string} name 671 * @param {string} name
653 * @param {function(string=)} callback 672 * @param {function(string=)} callback
654 */ 673 */
655 doSetObjectPropertyValue: function(result, name, callback) 674 doSetObjectPropertyValue: function(result, name, callback)
656 { 675 {
657 this._debuggerAgent.setVariableValue(this._scopeRef.number, name, this._ toCallArgument(result), this._scopeRef.callFrameId, this._scopeRef.functionId, s etVariableValueCallback.bind(this)); 676 this._debuggerAgent.setVariableValue(this._scopeRef.number, name, WebIns pector.RemoteObject.toCallArgument(result), this._scopeRef.callFrameId, this._sc opeRef.functionId, setVariableValueCallback.bind(this));
658 677
659 /** 678 /**
660 * @param {?Protocol.Error} error 679 * @param {?Protocol.Error} error
661 * @this {WebInspector.ScopeRemoteObject} 680 * @this {WebInspector.ScopeRemoteObject}
662 */ 681 */
663 function setVariableValueCallback(error) 682 function setVariableValueCallback(error)
664 { 683 {
665 if (error) { 684 if (error) {
666 callback(error); 685 callback(error);
667 return; 686 return;
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
973 result = functionDeclaration.apply(target, rawArgs); 992 result = functionDeclaration.apply(target, rawArgs);
974 } catch (e) { 993 } catch (e) {
975 result = null; 994 result = null;
976 } 995 }
977 996
978 callback(result); 997 callback(result);
979 }, 998 },
980 999
981 __proto__: WebInspector.RemoteObject.prototype 1000 __proto__: WebInspector.RemoteObject.prototype
982 } 1001 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698