Chromium Code Reviews| Index: Source/devtools/front_end/sources/JavaScriptSourceFrame.js |
| diff --git a/Source/devtools/front_end/sources/JavaScriptSourceFrame.js b/Source/devtools/front_end/sources/JavaScriptSourceFrame.js |
| index f2331b8913c89994b9ae2f855f63f3babf659da0..64a840e1572f55dfbf69789293a0203b06fd314b 100644 |
| --- a/Source/devtools/front_end/sources/JavaScriptSourceFrame.js |
| +++ b/Source/devtools/front_end/sources/JavaScriptSourceFrame.js |
| @@ -280,16 +280,29 @@ WebInspector.JavaScriptSourceFrame.prototype = { |
| // FIXME: Change condition above to explicitly check that current uiSourceCode is created by default debugger mapping |
| // and move the code adding this menu item to generic context menu provider for UISourceCode. |
| var liveEditLabel = WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Live edit" : "Live Edit"); |
| - contextMenu.appendItem(liveEditLabel, liveEdit.bind(this)); |
| + var projectId = this._uiSourceCode.project().id(); |
|
vsevik
2014/06/26 14:16:19
Let's make this static method in LiveEditSupport
sergeyv
2014/06/26 14:38:35
Done.
|
| + var target; |
| + var targets = WebInspector.targetManager.targets(); |
| + for (var i = 0; i < targets.length; ++i) { |
| + if (projectId === WebInspector.DefaultScriptMapping.projectIdForTarget(targets[i])) { |
| + target = targets[i]; |
| + break; |
| + } |
| + } |
| + if (!target) |
| + return; |
| + |
| + contextMenu.appendItem(liveEditLabel, liveEdit.bind(this, target.liveEditSupport)); |
| contextMenu.appendSeparator(); |
| } |
| /** |
| * @this {WebInspector.JavaScriptSourceFrame} |
| + * @param {!WebInspector.LiveEditSupport} liveEditSupport |
| */ |
| - function liveEdit() |
| + function liveEdit(liveEditSupport) |
| { |
| - var liveEditUISourceCode = WebInspector.liveEditSupport.uiSourceCodeForLiveEdit(this._uiSourceCode); |
| + var liveEditUISourceCode = liveEditSupport.uiSourceCodeForLiveEdit(this._uiSourceCode); |
| WebInspector.Revealer.reveal(liveEditUISourceCode.uiLocation(lineNumber)); |
| } |
| @@ -309,13 +322,47 @@ WebInspector.JavaScriptSourceFrame.prototype = { |
| _workingCopyCommitted: function(event) |
| { |
| + |
| + var callbackCount; |
|
vsevik
2014/06/26 14:16:19
redundant
sergeyv
2014/06/26 14:38:35
Done.
|
| + var liveEditError; |
| + var liveEditErrorData; |
| + var contextScript; |
| + var succeededEdits = 0; |
| + var failedEdits = 0; |
| + |
| + /** |
| + * @param {?string} error |
| + * @param {!DebuggerAgent.SetScriptSourceError=} errorData |
| + * @param {!WebInspector.Script=} script |
| + */ |
| + function liveEditCallback(error, errorData, script) |
| + { |
| + if (error) { |
| + liveEditError = error; |
| + liveEditErrorData = errorData; |
| + contextScript = script; |
| + failedEdits--; |
|
vsevik
2014/06/26 14:16:19
++
sergeyv
2014/06/26 14:38:35
Done.
|
| + } else |
| + succeededEdits++; |
| + |
| + if (succeededEdits + failedEdits !== callbackCount) |
| + return; |
| + |
| + if (succeededEdits === callbackCount) |
|
vsevik
2014/06/26 14:16:19
failedEdits === 0
sergeyv
2014/06/26 14:38:35
Done.
|
| + WebInspector.LiveEditSupport.logSuccess(); |
| + else |
| + WebInspector.LiveEditSupport.logDetailedError(liveEditError, liveEditErrorData, contextScript) |
| + |
| + } |
| + |
| if (this._supportsEnabledBreakpointsWhileEditing()) |
| return; |
| if (this._scriptFileForTarget.size()) { |
| this._hasCommittedLiveEdit = true; |
| var scriptFiles = this._scriptFileForTarget.values(); |
| + callbackCount = scriptFiles.length; |
| for (var i = 0; i < scriptFiles.length; ++i) |
| - scriptFiles[i].commitLiveEdit(); |
| + scriptFiles[i].commitLiveEdit(liveEditCallback); |
| return; |
| } |
| this._restoreBreakpointsAfterEditing(); |