| OLD | NEW |
| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 Workspace.UISourceCode.Events.WorkingCopyChanged, this._workingCopyChang
ed, this); | 75 Workspace.UISourceCode.Events.WorkingCopyChanged, this._workingCopyChang
ed, this); |
| 76 this.uiSourceCode().addEventListener( | 76 this.uiSourceCode().addEventListener( |
| 77 Workspace.UISourceCode.Events.WorkingCopyCommitted, this._workingCopyCom
mitted, this); | 77 Workspace.UISourceCode.Events.WorkingCopyCommitted, this._workingCopyCom
mitted, this); |
| 78 this.uiSourceCode().addEventListener( | 78 this.uiSourceCode().addEventListener( |
| 79 Workspace.UISourceCode.Events.TitleChanged, this._showBlackboxInfobarIfN
eeded, this); | 79 Workspace.UISourceCode.Events.TitleChanged, this._showBlackboxInfobarIfN
eeded, this); |
| 80 | 80 |
| 81 /** @type {!Set<!Sources.JavaScriptSourceFrame.BreakpointDecoration>} */ | 81 /** @type {!Set<!Sources.JavaScriptSourceFrame.BreakpointDecoration>} */ |
| 82 this._breakpointDecorations = new Set(); | 82 this._breakpointDecorations = new Set(); |
| 83 /** @type {!Map<!Bindings.BreakpointManager.Breakpoint, !Sources.JavaScriptS
ourceFrame.BreakpointDecoration>} */ | 83 /** @type {!Map<!Bindings.BreakpointManager.Breakpoint, !Sources.JavaScriptS
ourceFrame.BreakpointDecoration>} */ |
| 84 this._decorationByBreakpoint = new Map(); | 84 this._decorationByBreakpoint = new Map(); |
| 85 /** @type {!Set<number>} */ |
| 86 this._possibleBreakpointsRequested = new Set(); |
| 85 | 87 |
| 86 /** @type {!Map.<!SDK.DebuggerModel, !Bindings.ResourceScriptFile>}*/ | 88 /** @type {!Map.<!SDK.DebuggerModel, !Bindings.ResourceScriptFile>}*/ |
| 87 this._scriptFileForDebuggerModel = new Map(); | 89 this._scriptFileForDebuggerModel = new Map(); |
| 88 | 90 |
| 89 Common.moduleSetting('skipStackFramesPattern').addChangeListener(this._showB
lackboxInfobarIfNeeded, this); | 91 Common.moduleSetting('skipStackFramesPattern').addChangeListener(this._showB
lackboxInfobarIfNeeded, this); |
| 90 Common.moduleSetting('skipContentScripts').addChangeListener(this._showBlack
boxInfobarIfNeeded, this); | 92 Common.moduleSetting('skipContentScripts').addChangeListener(this._showBlack
boxInfobarIfNeeded, this); |
| 91 | 93 |
| 92 /** @type {!Map.<number, !Element>} */ | 94 /** @type {!Map.<number, !Element>} */ |
| 93 this._valueWidgets = new Map(); | 95 this._valueWidgets = new Map(); |
| 94 this.onBindingChanged(); | 96 this.onBindingChanged(); |
| (...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1073 */ | 1075 */ |
| 1074 function update() { | 1076 function update() { |
| 1075 var lineNumbers = new Set(); | 1077 var lineNumbers = new Set(); |
| 1076 for (var decoration of this._scheduledBreakpointDecorationUpdates) { | 1078 for (var decoration of this._scheduledBreakpointDecorationUpdates) { |
| 1077 var location = decoration.handle.resolve(); | 1079 var location = decoration.handle.resolve(); |
| 1078 if (!location) | 1080 if (!location) |
| 1079 continue; | 1081 continue; |
| 1080 lineNumbers.add(location.lineNumber); | 1082 lineNumbers.add(location.lineNumber); |
| 1081 } | 1083 } |
| 1082 delete this._scheduledBreakpointDecorationUpdates; | 1084 delete this._scheduledBreakpointDecorationUpdates; |
| 1085 var waitingForInlineDecorations = false; |
| 1083 for (var lineNumber of lineNumbers) { | 1086 for (var lineNumber of lineNumbers) { |
| 1084 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint', false); | 1087 var decorations = this._lineBreakpointDecorations(lineNumber); |
| 1085 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint-disabled', fa
lse); | 1088 updateGutter.call(this, lineNumber, decorations); |
| 1086 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint-conditional',
false); | 1089 if (this._possibleBreakpointsRequested.has(location.lineNumber)) { |
| 1090 waitingForInlineDecorations = true; |
| 1091 continue; |
| 1092 } |
| 1093 updateInlineDecorations.call(this, lineNumber, decorations); |
| 1094 } |
| 1095 if (!waitingForInlineDecorations) |
| 1096 this._breakpointDecorationsUpdatedForTest(); |
| 1097 } |
| 1087 | 1098 |
| 1088 var decorations = this._lineBreakpointDecorations(lineNumber); | 1099 /** |
| 1089 var actualBookmarks = | 1100 * @param {number} lineNumber |
| 1090 new Set(decorations.map(decoration => decoration.bookmark).filter(bo
okmark => !!bookmark)); | 1101 * @param {!Array<!Sources.JavaScriptSourceFrame.BreakpointDecoration>} deco
rations |
| 1091 var lineEnd = this.textEditor.line(lineNumber).length; | 1102 * @this {Sources.JavaScriptSourceFrame} |
| 1092 var bookmarks = this.textEditor.bookmarks( | 1103 */ |
| 1093 new TextUtils.TextRange(lineNumber, 0, lineNumber, lineEnd), | 1104 function updateGutter(lineNumber, decorations) { |
| 1094 Sources.JavaScriptSourceFrame.BreakpointDecoration.bookmarkSymbol); | 1105 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint', false); |
| 1095 for (var bookmark of bookmarks) { | 1106 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint-disabled', fals
e); |
| 1096 if (!actualBookmarks.has(bookmark)) | 1107 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint-conditional', f
alse); |
| 1097 bookmark.clear(); | 1108 |
| 1098 } | 1109 if (decorations.length) { |
| 1099 if (!decorations.length) | |
| 1100 continue; | |
| 1101 decorations.sort(Sources.JavaScriptSourceFrame.BreakpointDecoration.most
SpecificFirst); | 1110 decorations.sort(Sources.JavaScriptSourceFrame.BreakpointDecoration.most
SpecificFirst); |
| 1102 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint', true); | 1111 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint', true); |
| 1103 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint-disabled', !d
ecorations[0].enabled || this._muted); | 1112 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint-disabled', !d
ecorations[0].enabled || this._muted); |
| 1104 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint-conditional',
!!decorations[0].condition); | 1113 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint-conditional',
!!decorations[0].condition); |
| 1105 if (decorations.length > 1) { | 1114 } |
| 1106 for (var decoration of decorations) { | 1115 } |
| 1107 decoration.update(); | 1116 |
| 1108 if (!this._muted) | 1117 /** |
| 1109 decoration.show(); | 1118 * @param {number} lineNumber |
| 1110 else | 1119 * @param {!Array<!Sources.JavaScriptSourceFrame.BreakpointDecoration>} deco
rations |
| 1111 decoration.hide(); | 1120 * @this {Sources.JavaScriptSourceFrame} |
| 1112 } | 1121 */ |
| 1113 } else { | 1122 function updateInlineDecorations(lineNumber, decorations) { |
| 1114 decorations[0].update(); | 1123 var actualBookmarks = new Set(decorations.map(decoration => decoration.boo
kmark).filter(bookmark => !!bookmark)); |
| 1115 decorations[0].hide(); | 1124 var lineEnd = this.textEditor.line(lineNumber).length; |
| 1125 var bookmarks = this.textEditor.bookmarks( |
| 1126 new TextUtils.TextRange(lineNumber, 0, lineNumber, lineEnd), |
| 1127 Sources.JavaScriptSourceFrame.BreakpointDecoration.bookmarkSymbol); |
| 1128 for (var bookmark of bookmarks) { |
| 1129 if (!actualBookmarks.has(bookmark)) |
| 1130 bookmark.clear(); |
| 1131 } |
| 1132 if (!decorations.length) |
| 1133 return; |
| 1134 if (decorations.length > 1) { |
| 1135 for (var decoration of decorations) { |
| 1136 decoration.update(); |
| 1137 if (!this._muted) |
| 1138 decoration.show(); |
| 1139 else |
| 1140 decoration.hide(); |
| 1116 } | 1141 } |
| 1142 } else { |
| 1143 decorations[0].update(); |
| 1144 decorations[0].hide(); |
| 1117 } | 1145 } |
| 1118 this._breakpointDecorationsUpdatedForTest(); | |
| 1119 } | 1146 } |
| 1120 } | 1147 } |
| 1121 | 1148 |
| 1122 _breakpointDecorationsUpdatedForTest() { | 1149 _breakpointDecorationsUpdatedForTest() { |
| 1123 } | 1150 } |
| 1124 | 1151 |
| 1125 /** | 1152 /** |
| 1126 * @param {!Sources.JavaScriptSourceFrame.BreakpointDecoration} decoration | 1153 * @param {!Sources.JavaScriptSourceFrame.BreakpointDecoration} decoration |
| 1127 * @param {!Event} event | 1154 * @param {!Event} event |
| 1128 */ | 1155 */ |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1213 decoration = new Sources.JavaScriptSourceFrame.BreakpointDecoration( | 1240 decoration = new Sources.JavaScriptSourceFrame.BreakpointDecoration( |
| 1214 this.textEditor, handle, breakpoint.condition(), breakpoint.enabled(),
breakpoint); | 1241 this.textEditor, handle, breakpoint.condition(), breakpoint.enabled(),
breakpoint); |
| 1215 decoration.element.addEventListener('click', this._inlineBreakpointClick.b
ind(this, decoration), true); | 1242 decoration.element.addEventListener('click', this._inlineBreakpointClick.b
ind(this, decoration), true); |
| 1216 decoration.element.addEventListener( | 1243 decoration.element.addEventListener( |
| 1217 'contextmenu', this._inlineBreakpointContextMenu.bind(this, decoration
), true); | 1244 'contextmenu', this._inlineBreakpointContextMenu.bind(this, decoration
), true); |
| 1218 this._breakpointDecorations.add(decoration); | 1245 this._breakpointDecorations.add(decoration); |
| 1219 } | 1246 } |
| 1220 this._decorationByBreakpoint.set(breakpoint, decoration); | 1247 this._decorationByBreakpoint.set(breakpoint, decoration); |
| 1221 this._updateBreakpointDecoration(decoration); | 1248 this._updateBreakpointDecoration(decoration); |
| 1222 if (!lineDecorations.length) { | 1249 if (!lineDecorations.length) { |
| 1223 this._willAddInlineDecorationsForTest(); | 1250 this._possibleBreakpointsRequested.add(uiLocation.lineNumber); |
| 1224 this._breakpointManager | 1251 this._breakpointManager |
| 1225 .possibleBreakpoints( | 1252 .possibleBreakpoints( |
| 1226 this._debuggerSourceCode, new TextUtils.TextRange(uiLocation.lineN
umber, 0, uiLocation.lineNumber + 1, 0)) | 1253 this._debuggerSourceCode, new TextUtils.TextRange(uiLocation.lineN
umber, 0, uiLocation.lineNumber + 1, 0)) |
| 1227 .then(addInlineDecorations.bind(this, uiLocation.lineNumber)); | 1254 .then(addInlineDecorations.bind(this, uiLocation.lineNumber)); |
| 1228 } | 1255 } |
| 1229 | 1256 |
| 1230 /** | 1257 /** |
| 1231 * @this {Sources.JavaScriptSourceFrame} | 1258 * @this {Sources.JavaScriptSourceFrame} |
| 1232 * @param {number} lineNumber | 1259 * @param {number} lineNumber |
| 1233 * @param {!Array<!Workspace.UILocation>} possibleLocations | 1260 * @param {!Array<!Workspace.UILocation>} possibleLocations |
| 1234 */ | 1261 */ |
| 1235 function addInlineDecorations(lineNumber, possibleLocations) { | 1262 function addInlineDecorations(lineNumber, possibleLocations) { |
| 1263 this._possibleBreakpointsRequested.delete(lineNumber); |
| 1236 var decorations = this._lineBreakpointDecorations(lineNumber); | 1264 var decorations = this._lineBreakpointDecorations(lineNumber); |
| 1237 if (!decorations.some(decoration => !!decoration.breakpoint)) { | 1265 for (var decoration of decorations) |
| 1238 this._didAddInlineDecorationsForTest(false); | 1266 this._updateBreakpointDecoration(decoration); |
| 1267 if (!decorations.some(decoration => !!decoration.breakpoint)) |
| 1239 return; | 1268 return; |
| 1240 } | |
| 1241 /** @type {!Set<number>} */ | 1269 /** @type {!Set<number>} */ |
| 1242 var columns = new Set(); | 1270 var columns = new Set(); |
| 1243 for (var decoration of decorations) { | 1271 for (var decoration of decorations) { |
| 1244 var location = decoration.handle.resolve(); | 1272 var location = decoration.handle.resolve(); |
| 1245 if (!location) | 1273 if (!location) |
| 1246 continue; | 1274 continue; |
| 1247 columns.add(location.columnNumber); | 1275 columns.add(location.columnNumber); |
| 1248 } | 1276 } |
| 1249 var updateWasScheduled = false; | |
| 1250 for (var location of possibleLocations) { | 1277 for (var location of possibleLocations) { |
| 1251 if (columns.has(location.columnNumber)) | 1278 if (columns.has(location.columnNumber)) |
| 1252 continue; | 1279 continue; |
| 1253 var handle = this.textEditor.textEditorPositionHandle(location.lineNumbe
r, location.columnNumber); | 1280 var handle = this.textEditor.textEditorPositionHandle(location.lineNumbe
r, location.columnNumber); |
| 1254 var decoration = | 1281 var decoration = |
| 1255 new Sources.JavaScriptSourceFrame.BreakpointDecoration(this.textEdit
or, handle, '', false, null); | 1282 new Sources.JavaScriptSourceFrame.BreakpointDecoration(this.textEdit
or, handle, '', false, null); |
| 1256 decoration.element.addEventListener('click', this._inlineBreakpointClick
.bind(this, decoration), true); | 1283 decoration.element.addEventListener('click', this._inlineBreakpointClick
.bind(this, decoration), true); |
| 1257 decoration.element.addEventListener( | 1284 decoration.element.addEventListener( |
| 1258 'contextmenu', this._inlineBreakpointContextMenu.bind(this, decorati
on), true); | 1285 'contextmenu', this._inlineBreakpointContextMenu.bind(this, decorati
on), true); |
| 1259 this._breakpointDecorations.add(decoration); | 1286 this._breakpointDecorations.add(decoration); |
| 1260 updateWasScheduled = true; | |
| 1261 this._updateBreakpointDecoration(decoration); | 1287 this._updateBreakpointDecoration(decoration); |
| 1262 } | 1288 } |
| 1263 this._didAddInlineDecorationsForTest(updateWasScheduled); | |
| 1264 } | 1289 } |
| 1265 } | 1290 } |
| 1266 | 1291 |
| 1267 _willAddInlineDecorationsForTest() { | |
| 1268 } | |
| 1269 | |
| 1270 /** | |
| 1271 * @param {boolean} updateWasScheduled | |
| 1272 */ | |
| 1273 _didAddInlineDecorationsForTest(updateWasScheduled) { | |
| 1274 } | |
| 1275 | |
| 1276 /** | 1292 /** |
| 1277 * @param {!Common.Event} event | 1293 * @param {!Common.Event} event |
| 1278 */ | 1294 */ |
| 1279 _breakpointRemoved(event) { | 1295 _breakpointRemoved(event) { |
| 1280 if (this._shouldIgnoreExternalBreakpointEvents(event)) | 1296 if (this._shouldIgnoreExternalBreakpointEvents(event)) |
| 1281 return; | 1297 return; |
| 1282 var uiLocation = /** @type {!Workspace.UILocation} */ (event.data.uiLocation
); | 1298 var uiLocation = /** @type {!Workspace.UILocation} */ (event.data.uiLocation
); |
| 1283 var breakpoint = /** @type {!Bindings.BreakpointManager.Breakpoint} */ (even
t.data.breakpoint); | 1299 var breakpoint = /** @type {!Bindings.BreakpointManager.Breakpoint} */ (even
t.data.breakpoint); |
| 1284 var decoration = this._decorationByBreakpoint.get(breakpoint); | 1300 var decoration = this._decorationByBreakpoint.get(breakpoint); |
| 1285 if (!decoration) | 1301 if (!decoration) |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1675 return; | 1691 return; |
| 1676 this.bookmark.clear(); | 1692 this.bookmark.clear(); |
| 1677 this.bookmark = null; | 1693 this.bookmark = null; |
| 1678 } | 1694 } |
| 1679 }; | 1695 }; |
| 1680 | 1696 |
| 1681 Sources.JavaScriptSourceFrame.BreakpointDecoration.bookmarkSymbol = Symbol('book
mark'); | 1697 Sources.JavaScriptSourceFrame.BreakpointDecoration.bookmarkSymbol = Symbol('book
mark'); |
| 1682 Sources.JavaScriptSourceFrame.BreakpointDecoration._elementSymbolForTest = Symbo
l('element'); | 1698 Sources.JavaScriptSourceFrame.BreakpointDecoration._elementSymbolForTest = Symbo
l('element'); |
| 1683 | 1699 |
| 1684 Sources.JavaScriptSourceFrame.continueToLocationDecorationSymbol = Symbol('bookm
ark'); | 1700 Sources.JavaScriptSourceFrame.continueToLocationDecorationSymbol = Symbol('bookm
ark'); |
| OLD | NEW |