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

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

Issue 2887903002: [DevTools] update decorations when there is no pending possibleBreakpoints (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « no previous file | 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 979 matching lines...) Expand 10 before | Expand all | Expand 10 after
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;
1083 for (var lineNumber of lineNumbers) { 1085 for (var lineNumber of lineNumbers) {
1084 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint', false); 1086 var decorations = this._lineBreakpointDecorations(lineNumber);
1085 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint-disabled', fa lse); 1087 updateGutter.call(this, lineNumber, decorations);
1086 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint-conditional', false); 1088 if (this._possibleBreakpointsRequested.has(location.lineNumber))
1089 continue;
1090 updateInlineDecorations.call(this, lineNumber, decorations);
1091 }
1092 this._breakpointDecorationsUpdatedForTest();
1093 }
1087 1094
1088 var decorations = this._lineBreakpointDecorations(lineNumber); 1095 /**
1089 var actualBookmarks = 1096 * @param {number} lineNumber
1090 new Set(decorations.map(decoration => decoration.bookmark).filter(bo okmark => !!bookmark)); 1097 * @param {!Array<!Sources.JavaScriptSourceFrame.BreakpointDecoration>} deco rations
1091 var lineEnd = this.textEditor.line(lineNumber).length; 1098 * @this {Sources.JavaScriptSourceFrame}
1092 var bookmarks = this.textEditor.bookmarks( 1099 */
1093 new TextUtils.TextRange(lineNumber, 0, lineNumber, lineEnd), 1100 function updateGutter(lineNumber, decorations) {
1094 Sources.JavaScriptSourceFrame.BreakpointDecoration.bookmarkSymbol); 1101 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint', false);
1095 for (var bookmark of bookmarks) { 1102 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint-disabled', fals e);
1096 if (!actualBookmarks.has(bookmark)) 1103 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint-conditional', f alse);
1097 bookmark.clear(); 1104
1098 } 1105 if (decorations.length) {
1099 if (!decorations.length)
1100 continue;
1101 decorations.sort(Sources.JavaScriptSourceFrame.BreakpointDecoration.most SpecificFirst); 1106 decorations.sort(Sources.JavaScriptSourceFrame.BreakpointDecoration.most SpecificFirst);
1102 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint', true); 1107 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint', true);
1103 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint-disabled', !d ecorations[0].enabled || this._muted); 1108 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint-disabled', !d ecorations[0].enabled || this._muted);
1104 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint-conditional', !!decorations[0].condition); 1109 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint-conditional', !!decorations[0].condition);
1105 if (decorations.length > 1) { 1110 }
1106 for (var decoration of decorations) { 1111 }
1107 decoration.update(); 1112
1108 if (!this._muted) 1113 /**
1109 decoration.show(); 1114 * @param {number} lineNumber
1110 else 1115 * @param {!Array<!Sources.JavaScriptSourceFrame.BreakpointDecoration>} deco rations
1111 decoration.hide(); 1116 * @this {Sources.JavaScriptSourceFrame}
1112 } 1117 */
1113 } else { 1118 function updateInlineDecorations(lineNumber, decorations) {
1114 decorations[0].update(); 1119 var actualBookmarks = new Set(decorations.map(decoration => decoration.boo kmark).filter(bookmark => !!bookmark));
1115 decorations[0].hide(); 1120 var lineEnd = this.textEditor.line(lineNumber).length;
1121 var bookmarks = this.textEditor.bookmarks(
1122 new TextUtils.TextRange(lineNumber, 0, lineNumber, lineEnd),
1123 Sources.JavaScriptSourceFrame.BreakpointDecoration.bookmarkSymbol);
1124 for (var bookmark of bookmarks) {
1125 if (!actualBookmarks.has(bookmark))
1126 bookmark.clear();
1127 }
1128 if (!decorations.length)
1129 return;
1130 if (decorations.length > 1) {
1131 for (var decoration of decorations) {
1132 decoration.update();
1133 if (!this._muted)
1134 decoration.show();
1135 else
1136 decoration.hide();
1116 } 1137 }
1138 } else {
1139 decorations[0].update();
1140 decorations[0].hide();
1117 } 1141 }
1118 this._breakpointDecorationsUpdatedForTest();
1119 } 1142 }
1120 } 1143 }
1121 1144
1122 _breakpointDecorationsUpdatedForTest() { 1145 _breakpointDecorationsUpdatedForTest() {
1123 } 1146 }
1124 1147
1125 /** 1148 /**
1126 * @param {!Sources.JavaScriptSourceFrame.BreakpointDecoration} decoration 1149 * @param {!Sources.JavaScriptSourceFrame.BreakpointDecoration} decoration
1127 * @param {!Event} event 1150 * @param {!Event} event
1128 */ 1151 */
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1214 this.textEditor, handle, breakpoint.condition(), breakpoint.enabled(), breakpoint); 1237 this.textEditor, handle, breakpoint.condition(), breakpoint.enabled(), breakpoint);
1215 decoration.element.addEventListener('click', this._inlineBreakpointClick.b ind(this, decoration), true); 1238 decoration.element.addEventListener('click', this._inlineBreakpointClick.b ind(this, decoration), true);
1216 decoration.element.addEventListener( 1239 decoration.element.addEventListener(
1217 'contextmenu', this._inlineBreakpointContextMenu.bind(this, decoration ), true); 1240 'contextmenu', this._inlineBreakpointContextMenu.bind(this, decoration ), true);
1218 this._breakpointDecorations.add(decoration); 1241 this._breakpointDecorations.add(decoration);
1219 } 1242 }
1220 this._decorationByBreakpoint.set(breakpoint, decoration); 1243 this._decorationByBreakpoint.set(breakpoint, decoration);
1221 this._updateBreakpointDecoration(decoration); 1244 this._updateBreakpointDecoration(decoration);
1222 if (!lineDecorations.length) { 1245 if (!lineDecorations.length) {
1223 this._willAddInlineDecorationsForTest(); 1246 this._willAddInlineDecorationsForTest();
1247 this._possibleBreakpointsRequested.add(uiLocation.lineNumber);
1224 this._breakpointManager 1248 this._breakpointManager
1225 .possibleBreakpoints( 1249 .possibleBreakpoints(
1226 this._debuggerSourceCode, new TextUtils.TextRange(uiLocation.lineN umber, 0, uiLocation.lineNumber + 1, 0)) 1250 this._debuggerSourceCode, new TextUtils.TextRange(uiLocation.lineN umber, 0, uiLocation.lineNumber + 1, 0))
1227 .then(addInlineDecorations.bind(this, uiLocation.lineNumber)); 1251 .then(addInlineDecorations.bind(this, uiLocation.lineNumber));
1228 } 1252 }
1229 1253
1230 /** 1254 /**
1231 * @this {Sources.JavaScriptSourceFrame} 1255 * @this {Sources.JavaScriptSourceFrame}
1232 * @param {number} lineNumber 1256 * @param {number} lineNumber
1233 * @param {!Array<!Workspace.UILocation>} possibleLocations 1257 * @param {!Array<!Workspace.UILocation>} possibleLocations
1234 */ 1258 */
1235 function addInlineDecorations(lineNumber, possibleLocations) { 1259 function addInlineDecorations(lineNumber, possibleLocations) {
1260 this._possibleBreakpointsRequested.delete(lineNumber);
1236 var decorations = this._lineBreakpointDecorations(lineNumber); 1261 var decorations = this._lineBreakpointDecorations(lineNumber);
1262 var updateWasScheduled = false;
1263 for (var decoration of decorations) {
1264 updateWasScheduled = true;
1265 this._updateBreakpointDecoration(decoration);
1266 }
1237 if (!decorations.some(decoration => !!decoration.breakpoint)) { 1267 if (!decorations.some(decoration => !!decoration.breakpoint)) {
1238 this._didAddInlineDecorationsForTest(false); 1268 this._didAddInlineDecorationsForTest(updateWasScheduled);
dgozman 2017/05/16 22:54:20 Should we remove this flag?
1239 return; 1269 return;
1240 } 1270 }
1241 /** @type {!Set<number>} */ 1271 /** @type {!Set<number>} */
1242 var columns = new Set(); 1272 var columns = new Set();
1243 for (var decoration of decorations) { 1273 for (var decoration of decorations) {
1244 var location = decoration.handle.resolve(); 1274 var location = decoration.handle.resolve();
1245 if (!location) 1275 if (!location)
1246 continue; 1276 continue;
1247 columns.add(location.columnNumber); 1277 columns.add(location.columnNumber);
1248 } 1278 }
1249 var updateWasScheduled = false;
1250 for (var location of possibleLocations) { 1279 for (var location of possibleLocations) {
1251 if (columns.has(location.columnNumber)) 1280 if (columns.has(location.columnNumber))
1252 continue; 1281 continue;
1253 var handle = this.textEditor.textEditorPositionHandle(location.lineNumbe r, location.columnNumber); 1282 var handle = this.textEditor.textEditorPositionHandle(location.lineNumbe r, location.columnNumber);
1254 var decoration = 1283 var decoration =
1255 new Sources.JavaScriptSourceFrame.BreakpointDecoration(this.textEdit or, handle, '', false, null); 1284 new Sources.JavaScriptSourceFrame.BreakpointDecoration(this.textEdit or, handle, '', false, null);
1256 decoration.element.addEventListener('click', this._inlineBreakpointClick .bind(this, decoration), true); 1285 decoration.element.addEventListener('click', this._inlineBreakpointClick .bind(this, decoration), true);
1257 decoration.element.addEventListener( 1286 decoration.element.addEventListener(
1258 'contextmenu', this._inlineBreakpointContextMenu.bind(this, decorati on), true); 1287 'contextmenu', this._inlineBreakpointContextMenu.bind(this, decorati on), true);
1259 this._breakpointDecorations.add(decoration); 1288 this._breakpointDecorations.add(decoration);
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
1675 return; 1704 return;
1676 this.bookmark.clear(); 1705 this.bookmark.clear();
1677 this.bookmark = null; 1706 this.bookmark = null;
1678 } 1707 }
1679 }; 1708 };
1680 1709
1681 Sources.JavaScriptSourceFrame.BreakpointDecoration.bookmarkSymbol = Symbol('book mark'); 1710 Sources.JavaScriptSourceFrame.BreakpointDecoration.bookmarkSymbol = Symbol('book mark');
1682 Sources.JavaScriptSourceFrame.BreakpointDecoration._elementSymbolForTest = Symbo l('element'); 1711 Sources.JavaScriptSourceFrame.BreakpointDecoration._elementSymbolForTest = Symbo l('element');
1683 1712
1684 Sources.JavaScriptSourceFrame.continueToLocationDecorationSymbol = Symbol('bookm ark'); 1713 Sources.JavaScriptSourceFrame.continueToLocationDecorationSymbol = Symbol('bookm ark');
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698