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

Side by Side Diff: Source/devtools/front_end/sources/JavaScriptSourceFrame.js

Issue 352953002: DevTools: properly support targets in LiveEditSupport (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix test Created 6 years, 5 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
« no previous file with comments | « Source/devtools/front_end/sdk/Target.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 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 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 var selection = this.textEditor.copyRange(textSelection); 273 var selection = this.textEditor.copyRange(textSelection);
274 var addToWatchLabel = WebInspector.UIString(WebInspector.useLowerCas eMenuTitles() ? "Add to watch" : "Add to Watch"); 274 var addToWatchLabel = WebInspector.UIString(WebInspector.useLowerCas eMenuTitles() ? "Add to watch" : "Add to Watch");
275 contextMenu.appendItem(addToWatchLabel, this._innerAddToWatch.bind(t his, selection)); 275 contextMenu.appendItem(addToWatchLabel, this._innerAddToWatch.bind(t his, selection));
276 var evaluateLabel = WebInspector.UIString(WebInspector.useLowerCaseM enuTitles() ? "Evaluate in console" : "Evaluate in Console"); 276 var evaluateLabel = WebInspector.UIString(WebInspector.useLowerCaseM enuTitles() ? "Evaluate in console" : "Evaluate in Console");
277 contextMenu.appendItem(evaluateLabel, this._evaluateInConsole.bind(t his, selection)); 277 contextMenu.appendItem(evaluateLabel, this._evaluateInConsole.bind(t his, selection));
278 contextMenu.appendSeparator(); 278 contextMenu.appendSeparator();
279 } else if (this._uiSourceCode.project().type() === WebInspector.projectT ypes.Debugger) { 279 } else if (this._uiSourceCode.project().type() === WebInspector.projectT ypes.Debugger) {
280 // FIXME: Change condition above to explicitly check that current ui SourceCode is created by default debugger mapping 280 // FIXME: Change condition above to explicitly check that current ui SourceCode is created by default debugger mapping
281 // and move the code adding this menu item to generic context menu p rovider for UISourceCode. 281 // and move the code adding this menu item to generic context menu p rovider for UISourceCode.
282 var liveEditLabel = WebInspector.UIString(WebInspector.useLowerCaseM enuTitles() ? "Live edit" : "Live Edit"); 282 var liveEditLabel = WebInspector.UIString(WebInspector.useLowerCaseM enuTitles() ? "Live edit" : "Live Edit");
283 contextMenu.appendItem(liveEditLabel, liveEdit.bind(this)); 283 var liveEditSupport = WebInspector.LiveEditSupport.liveEditSupportFo rUISourceCode(this._uiSourceCode);
284 if (!liveEditSupport)
285 return;
286
287 contextMenu.appendItem(liveEditLabel, liveEdit.bind(this, liveEditSu pport));
284 contextMenu.appendSeparator(); 288 contextMenu.appendSeparator();
285 } 289 }
286 290
287 /** 291 /**
288 * @this {WebInspector.JavaScriptSourceFrame} 292 * @this {WebInspector.JavaScriptSourceFrame}
293 * @param {!WebInspector.LiveEditSupport} liveEditSupport
289 */ 294 */
290 function liveEdit() 295 function liveEdit(liveEditSupport)
291 { 296 {
292 var liveEditUISourceCode = WebInspector.liveEditSupport.uiSourceCode ForLiveEdit(this._uiSourceCode); 297 var liveEditUISourceCode = liveEditSupport.uiSourceCodeForLiveEdit(t his._uiSourceCode);
293 WebInspector.Revealer.reveal(liveEditUISourceCode.uiLocation(lineNum ber)); 298 WebInspector.Revealer.reveal(liveEditUISourceCode.uiLocation(lineNum ber));
294 } 299 }
295 300
296 WebInspector.UISourceCodeFrame.prototype.populateTextAreaContextMenu.cal l(this, contextMenu, lineNumber); 301 WebInspector.UISourceCodeFrame.prototype.populateTextAreaContextMenu.cal l(this, contextMenu, lineNumber);
297 }, 302 },
298 303
299 _workingCopyChanged: function(event) 304 _workingCopyChanged: function(event)
300 { 305 {
301 if (this._supportsEnabledBreakpointsWhileEditing() || this._scriptFileFo rTarget.size()) 306 if (this._supportsEnabledBreakpointsWhileEditing() || this._scriptFileFo rTarget.size())
302 return; 307 return;
303 308
304 if (this._uiSourceCode.isDirty()) 309 if (this._uiSourceCode.isDirty())
305 this._muteBreakpointsWhileEditing(); 310 this._muteBreakpointsWhileEditing();
306 else 311 else
307 this._restoreBreakpointsAfterEditing(); 312 this._restoreBreakpointsAfterEditing();
308 }, 313 },
309 314
310 _workingCopyCommitted: function(event) 315 _workingCopyCommitted: function(event)
311 { 316 {
317
318 var liveEditError;
319 var liveEditErrorData;
320 var contextScript;
321 var succeededEdits = 0;
322 var failedEdits = 0;
323
324 /**
325 * @param {?string} error
326 * @param {!DebuggerAgent.SetScriptSourceError=} errorData
327 * @param {!WebInspector.Script=} script
328 */
329 function liveEditCallback(error, errorData, script)
330 {
331 if (error) {
332 liveEditError = error;
333 liveEditErrorData = errorData;
334 contextScript = script;
335 failedEdits++;
336 } else
337 succeededEdits++;
338
339 if (succeededEdits + failedEdits !== scriptFiles.length)
340 return;
341
342 if (!failedEdits)
343 WebInspector.LiveEditSupport.logSuccess();
344 else
345 WebInspector.LiveEditSupport.logDetailedError(liveEditError, liv eEditErrorData, contextScript)
346
347 }
348
312 if (this._supportsEnabledBreakpointsWhileEditing()) 349 if (this._supportsEnabledBreakpointsWhileEditing())
313 return; 350 return;
314 if (this._scriptFileForTarget.size()) { 351 if (this._scriptFileForTarget.size()) {
315 this._hasCommittedLiveEdit = true; 352 this._hasCommittedLiveEdit = true;
316 var scriptFiles = this._scriptFileForTarget.values(); 353 var scriptFiles = this._scriptFileForTarget.values();
317 for (var i = 0; i < scriptFiles.length; ++i) 354 for (var i = 0; i < scriptFiles.length; ++i)
318 scriptFiles[i].commitLiveEdit(); 355 scriptFiles[i].commitLiveEdit(liveEditCallback);
319 return; 356 return;
320 } 357 }
321 this._restoreBreakpointsAfterEditing(); 358 this._restoreBreakpointsAfterEditing();
322 }, 359 },
323 360
324 _didMergeToVM: function() 361 _didMergeToVM: function()
325 { 362 {
326 if (this._supportsEnabledBreakpointsWhileEditing()) 363 if (this._supportsEnabledBreakpointsWhileEditing())
327 return; 364 return;
328 this._updateDivergedInfobar(); 365 this._updateDivergedInfobar();
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. ConsoleMessageRemoved, this._consoleMessageRemoved, this); 876 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. ConsoleMessageRemoved, this._consoleMessageRemoved, this);
840 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. ConsoleMessagesCleared, this._consoleMessagesCleared, this); 877 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. ConsoleMessagesCleared, this._consoleMessagesCleared, this);
841 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. SourceMappingChanged, this._onSourceMappingChanged, this); 878 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. SourceMappingChanged, this._onSourceMappingChanged, this);
842 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. WorkingCopyChanged, this._workingCopyChanged, this); 879 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. WorkingCopyChanged, this._workingCopyChanged, this);
843 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. WorkingCopyCommitted, this._workingCopyCommitted, this); 880 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. WorkingCopyCommitted, this._workingCopyCommitted, this);
844 WebInspector.UISourceCodeFrame.prototype.dispose.call(this); 881 WebInspector.UISourceCodeFrame.prototype.dispose.call(this);
845 }, 882 },
846 883
847 __proto__: WebInspector.UISourceCodeFrame.prototype 884 __proto__: WebInspector.UISourceCodeFrame.prototype
848 } 885 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/sdk/Target.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698