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

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

Issue 1403373013: DevTools: move ui messages from SourceFrame to UISourceCodeFrame (step2) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments addressed Created 5 years, 1 month 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) 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 this._popoverHelper = new WebInspector.ObjectPopoverHelper(scriptsPanel.elem ent, 47 this._popoverHelper = new WebInspector.ObjectPopoverHelper(scriptsPanel.elem ent,
48 this._getPopoverAnchor.bind(this), this._resolveObjectForPopover.bind(th is), this._onHidePopover.bind(this), true); 48 this._getPopoverAnchor.bind(this), this._resolveObjectForPopover.bind(th is), this._onHidePopover.bind(this), true);
49 49
50 this.textEditor.element.addEventListener("keydown", this._onKeyDown.bind(thi s), true); 50 this.textEditor.element.addEventListener("keydown", this._onKeyDown.bind(thi s), true);
51 51
52 this.textEditor.addEventListener(WebInspector.CodeMirrorTextEditor.Events.Gu tterClick, this._handleGutterClick.bind(this), this); 52 this.textEditor.addEventListener(WebInspector.CodeMirrorTextEditor.Events.Gu tterClick, this._handleGutterClick.bind(this), this);
53 53
54 this._breakpointManager.addEventListener(WebInspector.BreakpointManager.Even ts.BreakpointAdded, this._breakpointAdded, this); 54 this._breakpointManager.addEventListener(WebInspector.BreakpointManager.Even ts.BreakpointAdded, this._breakpointAdded, this);
55 this._breakpointManager.addEventListener(WebInspector.BreakpointManager.Even ts.BreakpointRemoved, this._breakpointRemoved, this); 55 this._breakpointManager.addEventListener(WebInspector.BreakpointManager.Even ts.BreakpointRemoved, this._breakpointRemoved, this);
56 56
57 WebInspector.presentationConsoleMessageHelper.addConsoleMessageEventListener (WebInspector.PresentationConsoleMessageHelper.Events.ConsoleMessageAdded, this. _uiSourceCode, this._consoleMessageAdded, this);
58 WebInspector.presentationConsoleMessageHelper.addConsoleMessageEventListener (WebInspector.PresentationConsoleMessageHelper.Events.ConsoleMessageRemoved, thi s._uiSourceCode, this._consoleMessageRemoved, this);
59 WebInspector.presentationConsoleMessageHelper.addConsoleMessageEventListener (WebInspector.PresentationConsoleMessageHelper.Events.ConsoleMessagesCleared, th is._uiSourceCode, this._consoleMessagesCleared, this);
60 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.SourceM appingChanged, this._onSourceMappingChanged, this); 57 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.SourceM appingChanged, this._onSourceMappingChanged, this);
61 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Working CopyChanged, this._workingCopyChanged, this); 58 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Working CopyChanged, this._workingCopyChanged, this);
62 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Working CopyCommitted, this._workingCopyCommitted, this); 59 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Working CopyCommitted, this._workingCopyCommitted, this);
63 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.TitleCh anged, this._showBlackboxInfobarIfNeeded, this); 60 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.TitleCh anged, this._showBlackboxInfobarIfNeeded, this);
64 61
65 /** @type {!Map.<!WebInspector.Target, !WebInspector.ResourceScriptFile>}*/ 62 /** @type {!Map.<!WebInspector.Target, !WebInspector.ResourceScriptFile>}*/
66 this._scriptFileForTarget = new Map(); 63 this._scriptFileForTarget = new Map();
67 this._registerShortcuts(); 64 this._registerShortcuts();
68 var targets = WebInspector.targetManager.targets(); 65 var targets = WebInspector.targetManager.targets();
69 for (var i = 0; i < targets.length; ++i) { 66 for (var i = 0; i < targets.length; ++i) {
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 374
378 var warningLevel = WebInspector.Console.MessageLevel.Warning; 375 var warningLevel = WebInspector.Console.MessageLevel.Warning;
379 if (!liveEditErrorData) { 376 if (!liveEditErrorData) {
380 if (liveEditError) 377 if (liveEditError)
381 WebInspector.console.addMessage(WebInspector.UIString("LiveE dit failed: %s", liveEditError), warningLevel); 378 WebInspector.console.addMessage(WebInspector.UIString("LiveE dit failed: %s", liveEditError), warningLevel);
382 return; 379 return;
383 } 380 }
384 var compileError = liveEditErrorData.compileError; 381 var compileError = liveEditErrorData.compileError;
385 if (compileError) { 382 if (compileError) {
386 var messageText = WebInspector.UIString("LiveEdit compile failed : %s", compileError.message); 383 var messageText = WebInspector.UIString("LiveEdit compile failed : %s", compileError.message);
387 var message = new WebInspector.UISourceCode.Message(WebInspector .UISourceCode.Message.Level.Error, messageText, compileError.lineNumber - 1, com pileError.columnNumber + 1); 384 this.uiSourceCode().addMessage(WebInspector.UISourceCode.Message .Level.Error, messageText, compileError.lineNumber - 1, compileError.columnNumbe r + 1);
388 this.addMessageToSource(message);
389 } else { 385 } else {
390 WebInspector.console.addMessage(WebInspector.UIString("Unknown L iveEdit error: %s; %s", JSON.stringify(liveEditErrorData), liveEditError), warni ngLevel); 386 WebInspector.console.addMessage(WebInspector.UIString("Unknown L iveEdit error: %s; %s", JSON.stringify(liveEditErrorData), liveEditError), warni ngLevel);
391 } 387 }
392 } 388 }
393 389
394 this._scriptsPanel.setIgnoreExecutionLineEvents(true); 390 this._scriptsPanel.setIgnoreExecutionLineEvents(true);
395 this._hasCommittedLiveEdit = true; 391 this._hasCommittedLiveEdit = true;
396 var scriptFiles = this._scriptFileForTarget.valuesArray(); 392 var scriptFiles = this._scriptFileForTarget.valuesArray();
397 for (var i = 0; i < scriptFiles.length; ++i) 393 for (var i = 0; i < scriptFiles.length; ++i)
398 scriptFiles[i].commitLiveEdit(liveEditCallback.bind(this)); 394 scriptFiles[i].commitLiveEdit(liveEditCallback.bind(this));
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after
931 if (uiLocation.uiSourceCode !== this._uiSourceCode) 927 if (uiLocation.uiSourceCode !== this._uiSourceCode)
932 return; 928 return;
933 if (this._shouldIgnoreExternalBreakpointEvents()) 929 if (this._shouldIgnoreExternalBreakpointEvents())
934 return; 930 return;
935 931
936 var remainingBreakpoint = this._breakpointManager.findBreakpointOnLine(t his._uiSourceCode, uiLocation.lineNumber); 932 var remainingBreakpoint = this._breakpointManager.findBreakpointOnLine(t his._uiSourceCode, uiLocation.lineNumber);
937 if (!remainingBreakpoint && this.loaded) 933 if (!remainingBreakpoint && this.loaded)
938 this._removeBreakpointDecoration(uiLocation.lineNumber); 934 this._removeBreakpointDecoration(uiLocation.lineNumber);
939 }, 935 },
940 936
941 _consoleMessageAdded: function(event)
942 {
943 var message = /** @type {!WebInspector.PresentationConsoleMessage} */ (e vent.data);
944 if (this.loaded)
945 this.addMessageToSource(this._sourceFrameMessage(message));
946 },
947
948 _consoleMessageRemoved: function(event)
949 {
950 var message = /** @type {!WebInspector.PresentationConsoleMessage} */ (e vent.data);
951 if (this.loaded)
952 this.removeMessageFromSource(this._sourceFrameMessage(message));
953 },
954
955 /**
956 * @param {!WebInspector.PresentationConsoleMessage} message
957 * @return {!WebInspector.UISourceCode.Message}
958 */
959 _sourceFrameMessage: function(message)
960 {
961 return WebInspector.UISourceCodeFrame.uiMessageFromConsoleMessage(messag e.originalMessage, message.lineNumber(), message.columnNumber());
962 },
963
964 _consoleMessagesCleared: function(event)
965 {
966 this.clearMessages();
967 },
968
969 /** 937 /**
970 * @param {!WebInspector.Event} event 938 * @param {!WebInspector.Event} event
971 */ 939 */
972 _onSourceMappingChanged: function(event) 940 _onSourceMappingChanged: function(event)
973 { 941 {
974 var data = /** @type {{target: !WebInspector.Target}} */ (event.data); 942 var data = /** @type {{target: !WebInspector.Target}} */ (event.data);
975 this._updateScriptFile(data.target); 943 this._updateScriptFile(data.target);
976 this._updateLinesWithoutMappingHighlight(); 944 this._updateLinesWithoutMappingHighlight();
977 }, 945 },
978 946
(...skipping 30 matching lines...) Expand all
1009 this._updateDivergedInfobar(); 977 this._updateDivergedInfobar();
1010 978
1011 if (newScriptFile) { 979 if (newScriptFile) {
1012 newScriptFile.addEventListener(WebInspector.ResourceScriptFile.Event s.DidMergeToVM, this._didMergeToVM, this); 980 newScriptFile.addEventListener(WebInspector.ResourceScriptFile.Event s.DidMergeToVM, this._didMergeToVM, this);
1013 newScriptFile.addEventListener(WebInspector.ResourceScriptFile.Event s.DidDivergeFromVM, this._didDivergeFromVM, this); 981 newScriptFile.addEventListener(WebInspector.ResourceScriptFile.Event s.DidDivergeFromVM, this._didDivergeFromVM, this);
1014 if (this.loaded) 982 if (this.loaded)
1015 newScriptFile.checkMapping(); 983 newScriptFile.checkMapping();
1016 } 984 }
1017 }, 985 },
1018 986
987 /**
988 * @override
989 */
1019 onTextEditorContentLoaded: function() 990 onTextEditorContentLoaded: function()
1020 { 991 {
1021 WebInspector.UISourceCodeFrame.prototype.onTextEditorContentLoaded.call( this); 992 WebInspector.UISourceCodeFrame.prototype.onTextEditorContentLoaded.call( this);
1022 if (this._executionLocation) 993 if (this._executionLocation)
1023 this.setExecutionLocation(this._executionLocation); 994 this.setExecutionLocation(this._executionLocation);
1024 995
1025 var breakpointLocations = this._breakpointManager.breakpointLocationsFor UISourceCode(this._uiSourceCode); 996 var breakpointLocations = this._breakpointManager.breakpointLocationsFor UISourceCode(this._uiSourceCode);
1026 for (var i = 0; i < breakpointLocations.length; ++i) 997 for (var i = 0; i < breakpointLocations.length; ++i)
1027 this._breakpointAdded({data:breakpointLocations[i]}); 998 this._breakpointAdded({data:breakpointLocations[i]});
1028 999
1029 var messages = WebInspector.presentationConsoleMessageHelper.consoleMess ages(this._uiSourceCode);
1030 for (var message of messages)
1031 this.addMessageToSource(this._sourceFrameMessage(message));
1032
1033 var scriptFiles = this._scriptFileForTarget.valuesArray(); 1000 var scriptFiles = this._scriptFileForTarget.valuesArray();
1034 for (var i = 0; i < scriptFiles.length; ++i) 1001 for (var i = 0; i < scriptFiles.length; ++i)
1035 scriptFiles[i].checkMapping(); 1002 scriptFiles[i].checkMapping();
1036 1003
1037 this._updateLinesWithoutMappingHighlight(); 1004 this._updateLinesWithoutMappingHighlight();
1038 }, 1005 },
1039 1006
1040 /** 1007 /**
1041 * @param {!WebInspector.Event} event 1008 * @param {!WebInspector.Event} event
1042 */ 1009 */
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1103 */ 1070 */
1104 _setBreakpoint: function(lineNumber, columnNumber, condition, enabled) 1071 _setBreakpoint: function(lineNumber, columnNumber, condition, enabled)
1105 { 1072 {
1106 this._breakpointManager.setBreakpoint(this._uiSourceCode, lineNumber, co lumnNumber, condition, enabled); 1073 this._breakpointManager.setBreakpoint(this._uiSourceCode, lineNumber, co lumnNumber, condition, enabled);
1107 }, 1074 },
1108 1075
1109 dispose: function() 1076 dispose: function()
1110 { 1077 {
1111 this._breakpointManager.removeEventListener(WebInspector.BreakpointManag er.Events.BreakpointAdded, this._breakpointAdded, this); 1078 this._breakpointManager.removeEventListener(WebInspector.BreakpointManag er.Events.BreakpointAdded, this._breakpointAdded, this);
1112 this._breakpointManager.removeEventListener(WebInspector.BreakpointManag er.Events.BreakpointRemoved, this._breakpointRemoved, this); 1079 this._breakpointManager.removeEventListener(WebInspector.BreakpointManag er.Events.BreakpointRemoved, this._breakpointRemoved, this);
1113 WebInspector.presentationConsoleMessageHelper.removeConsoleMessageEventL istener(WebInspector.PresentationConsoleMessageHelper.Events.ConsoleMessageAdded , this._uiSourceCode, this._consoleMessageAdded, this);
1114 WebInspector.presentationConsoleMessageHelper.removeConsoleMessageEventL istener(WebInspector.PresentationConsoleMessageHelper.Events.ConsoleMessageRemov ed, this._uiSourceCode, this._consoleMessageRemoved, this);
1115 WebInspector.presentationConsoleMessageHelper.removeConsoleMessageEventL istener(WebInspector.PresentationConsoleMessageHelper.Events.ConsoleMessagesClea red, this._uiSourceCode, this._consoleMessagesCleared, this);
1116 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. SourceMappingChanged, this._onSourceMappingChanged, this); 1080 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. SourceMappingChanged, this._onSourceMappingChanged, this);
1117 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. WorkingCopyChanged, this._workingCopyChanged, this); 1081 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. WorkingCopyChanged, this._workingCopyChanged, this);
1118 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. WorkingCopyCommitted, this._workingCopyCommitted, this); 1082 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. WorkingCopyCommitted, this._workingCopyCommitted, this);
1119 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. TitleChanged, this._showBlackboxInfobarIfNeeded, this); 1083 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. TitleChanged, this._showBlackboxInfobarIfNeeded, this);
1120 WebInspector.moduleSetting("skipStackFramesPattern").removeChangeListene r(this._showBlackboxInfobarIfNeeded, this); 1084 WebInspector.moduleSetting("skipStackFramesPattern").removeChangeListene r(this._showBlackboxInfobarIfNeeded, this);
1121 WebInspector.moduleSetting("skipContentScripts").removeChangeListener(th is._showBlackboxInfobarIfNeeded, this); 1085 WebInspector.moduleSetting("skipContentScripts").removeChangeListener(th is._showBlackboxInfobarIfNeeded, this);
1122 WebInspector.UISourceCodeFrame.prototype.dispose.call(this); 1086 WebInspector.UISourceCodeFrame.prototype.dispose.call(this);
1123 }, 1087 },
1124 1088
1125 __proto__: WebInspector.UISourceCodeFrame.prototype 1089 __proto__: WebInspector.UISourceCodeFrame.prototype
1126 } 1090 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698