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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/sdk/RuntimeModel.js

Issue 2800573002: DevTools: editing property values should wrap object literals similar to console (Closed)
Patch Set: Created 3 years, 8 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 this._executionContextById = new Map(); 45 this._executionContextById = new Map();
46 this._executionContextComparator = SDK.ExecutionContext.comparator; 46 this._executionContextComparator = SDK.ExecutionContext.comparator;
47 47
48 if (Common.moduleSetting('customFormatters').get()) 48 if (Common.moduleSetting('customFormatters').get())
49 this._agent.setCustomObjectFormatterEnabled(true); 49 this._agent.setCustomObjectFormatterEnabled(true);
50 50
51 Common.moduleSetting('customFormatters').addChangeListener(this._customForma ttersStateChanged.bind(this)); 51 Common.moduleSetting('customFormatters').addChangeListener(this._customForma ttersStateChanged.bind(this));
52 } 52 }
53 53
54 /** 54 /**
55 * @param {string} code
56 * @return {string}
57 */
58 static wrapObjectLiteralExpressionIfNeeded(code) {
59 // Only parenthesize what appears to be an object literal.
60 if (!(/^\s*\{/.test(code) && /\}\s*$/.test(code)))
61 return code;
62
63 try {
64 // Check if the code can be interpreted as an expression.
65 Function('return ' + code + ';');
66
67 // No syntax error! Does it work parenthesized?
68 var wrappedCode = '(' + code + ')';
69 Function(wrappedCode);
70
71 return wrappedCode;
72 } catch (e) {
73 return code;
74 }
75 }
76
77 /**
55 * @return {!SDK.DebuggerModel} 78 * @return {!SDK.DebuggerModel}
56 */ 79 */
57 debuggerModel() { 80 debuggerModel() {
58 return /** @type {!SDK.DebuggerModel} */ (this.target().model(SDK.DebuggerMo del)); 81 return /** @type {!SDK.DebuggerModel} */ (this.target().model(SDK.DebuggerMo del));
59 } 82 }
60 83
61 /** 84 /**
62 * @return {!SDK.HeapProfilerModel} 85 * @return {!SDK.HeapProfilerModel}
63 */ 86 */
64 heapProfilerModel() { 87 heapProfilerModel() {
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 this._type === 'wheel'; 895 this._type === 'wheel';
873 } 896 }
874 }; 897 };
875 898
876 /** @enum {string} */ 899 /** @enum {string} */
877 SDK.EventListener.Origin = { 900 SDK.EventListener.Origin = {
878 Raw: 'Raw', 901 Raw: 'Raw',
879 Framework: 'Framework', 902 Framework: 'Framework',
880 FrameworkUser: 'FrameworkUser' 903 FrameworkUser: 'FrameworkUser'
881 }; 904 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698