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

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

Issue 2567573002: DevTools: fix private field usage violation discovered after the compiler roll. (Closed)
Patch Set: Created 4 years 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 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 return; 334 return;
335 } 335 }
336 336
337 this._restoreBreakpointsAfterEditing(); 337 this._restoreBreakpointsAfterEditing();
338 } 338 }
339 339
340 _restoreBreakpointsAfterEditing() { 340 _restoreBreakpointsAfterEditing() {
341 delete this._muted; 341 delete this._muted;
342 var decorations = Array.from(this._breakpointDecorations); 342 var decorations = Array.from(this._breakpointDecorations);
343 this._breakpointDecorations.clear(); 343 this._breakpointDecorations.clear();
344 this._textEditor.operation(() => decorations.map(decoration => decoration.hi de())); 344 this.textEditor.operation(() => decorations.map(decoration => decoration.hid e()));
345 for (var decoration of decorations) { 345 for (var decoration of decorations) {
346 if (!decoration.breakpoint) 346 if (!decoration.breakpoint)
347 continue; 347 continue;
348 var enabled = decoration.enabled; 348 var enabled = decoration.enabled;
349 decoration.breakpoint.remove(); 349 decoration.breakpoint.remove();
350 var location = decoration.handle.resolve(); 350 var location = decoration.handle.resolve();
351 if (location) 351 if (location)
352 this._setBreakpoint(location.lineNumber, location.columnNumber, decorati on.condition, enabled); 352 this._setBreakpoint(location.lineNumber, location.columnNumber, decorati on.condition, enabled);
353 } 353 }
354 } 354 }
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 } 777 }
778 delete this._scheduledBreakpointDecorationUpdates; 778 delete this._scheduledBreakpointDecorationUpdates;
779 for (var lineNumber of lineNumbers) { 779 for (var lineNumber of lineNumbers) {
780 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint', false); 780 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint', false);
781 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint-disabled', fa lse); 781 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint-disabled', fa lse);
782 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint-conditional', false); 782 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint-conditional', false);
783 783
784 var decorations = this._lineBreakpointDecorations(lineNumber); 784 var decorations = this._lineBreakpointDecorations(lineNumber);
785 var actualBookmarks = 785 var actualBookmarks =
786 new Set(decorations.map(decoration => decoration.bookmark).filter(bo okmark => !!bookmark)); 786 new Set(decorations.map(decoration => decoration.bookmark).filter(bo okmark => !!bookmark));
787 var lineEnd = this._textEditor.line(lineNumber).length; 787 var lineEnd = this.textEditor.line(lineNumber).length;
788 var bookmarks = this._textEditor.bookmarks( 788 var bookmarks = this.textEditor.bookmarks(
789 new Common.TextRange(lineNumber, 0, lineNumber, lineEnd), 789 new Common.TextRange(lineNumber, 0, lineNumber, lineEnd),
790 Sources.JavaScriptSourceFrame.BreakpointDecoration.bookmarkSymbol); 790 Sources.JavaScriptSourceFrame.BreakpointDecoration.bookmarkSymbol);
791 for (var bookmark of bookmarks) { 791 for (var bookmark of bookmarks) {
792 if (!actualBookmarks.has(bookmark)) 792 if (!actualBookmarks.has(bookmark))
793 bookmark.clear(); 793 bookmark.clear();
794 } 794 }
795 if (!decorations.length) 795 if (!decorations.length)
796 continue; 796 continue;
797 decorations.sort(Sources.JavaScriptSourceFrame.BreakpointDecoration.most SpecificFirst); 797 decorations.sort(Sources.JavaScriptSourceFrame.BreakpointDecoration.most SpecificFirst);
798 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint', true); 798 this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint', true);
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 * @param {!Bindings.BreakpointManager.Breakpoint} breakpoint 898 * @param {!Bindings.BreakpointManager.Breakpoint} breakpoint
899 */ 899 */
900 _addBreakpoint(uiLocation, breakpoint) { 900 _addBreakpoint(uiLocation, breakpoint) {
901 var lineDecorations = this._lineBreakpointDecorations(uiLocation.lineNumber) ; 901 var lineDecorations = this._lineBreakpointDecorations(uiLocation.lineNumber) ;
902 var decoration = this._breakpointDecoration(uiLocation.lineNumber, uiLocatio n.columnNumber); 902 var decoration = this._breakpointDecoration(uiLocation.lineNumber, uiLocatio n.columnNumber);
903 if (decoration) { 903 if (decoration) {
904 decoration.breakpoint = breakpoint; 904 decoration.breakpoint = breakpoint;
905 decoration.condition = breakpoint.condition(); 905 decoration.condition = breakpoint.condition();
906 decoration.enabled = breakpoint.enabled(); 906 decoration.enabled = breakpoint.enabled();
907 } else { 907 } else {
908 var handle = this._textEditor.textEditorPositionHandle(uiLocation.lineNumb er, uiLocation.columnNumber); 908 var handle = this.textEditor.textEditorPositionHandle(uiLocation.lineNumbe r, uiLocation.columnNumber);
909 decoration = new Sources.JavaScriptSourceFrame.BreakpointDecoration( 909 decoration = new Sources.JavaScriptSourceFrame.BreakpointDecoration(
910 this._textEditor, handle, breakpoint.condition(), breakpoint.enabled() , breakpoint); 910 this.textEditor, handle, breakpoint.condition(), breakpoint.enabled(), breakpoint);
911 decoration.element.addEventListener('click', this._inlineBreakpointClick.b ind(this, decoration), true); 911 decoration.element.addEventListener('click', this._inlineBreakpointClick.b ind(this, decoration), true);
912 decoration.element.addEventListener( 912 decoration.element.addEventListener(
913 'contextmenu', this._inlineBreakpointContextMenu.bind(this, decoration ), true); 913 'contextmenu', this._inlineBreakpointContextMenu.bind(this, decoration ), true);
914 this._breakpointDecorations.add(decoration); 914 this._breakpointDecorations.add(decoration);
915 } 915 }
916 this._decorationByBreakpoint.set(breakpoint, decoration); 916 this._decorationByBreakpoint.set(breakpoint, decoration);
917 this._updateBreakpointDecoration(decoration); 917 this._updateBreakpointDecoration(decoration);
918 if (!lineDecorations.length) { 918 if (!lineDecorations.length) {
919 this._willAddInlineDecorationsForTest(); 919 this._willAddInlineDecorationsForTest();
920 this._breakpointManager 920 this._breakpointManager
(...skipping 18 matching lines...) Expand all
939 for (var decoration of decorations) { 939 for (var decoration of decorations) {
940 var location = decoration.handle.resolve(); 940 var location = decoration.handle.resolve();
941 if (!location) 941 if (!location)
942 continue; 942 continue;
943 columns.add(location.columnNumber); 943 columns.add(location.columnNumber);
944 } 944 }
945 var updateWasScheduled = false; 945 var updateWasScheduled = false;
946 for (var location of possibleLocations) { 946 for (var location of possibleLocations) {
947 if (columns.has(location.columnNumber)) 947 if (columns.has(location.columnNumber))
948 continue; 948 continue;
949 var handle = this._textEditor.textEditorPositionHandle(location.lineNumb er, location.columnNumber); 949 var handle = this.textEditor.textEditorPositionHandle(location.lineNumbe r, location.columnNumber);
950 var decoration = 950 var decoration =
951 new Sources.JavaScriptSourceFrame.BreakpointDecoration(this._textEdi tor, handle, '', false, null); 951 new Sources.JavaScriptSourceFrame.BreakpointDecoration(this.textEdit or, handle, '', false, null);
952 decoration.element.addEventListener('click', this._inlineBreakpointClick .bind(this, decoration), true); 952 decoration.element.addEventListener('click', this._inlineBreakpointClick .bind(this, decoration), true);
953 decoration.element.addEventListener( 953 decoration.element.addEventListener(
954 'contextmenu', this._inlineBreakpointContextMenu.bind(this, decorati on), true); 954 'contextmenu', this._inlineBreakpointContextMenu.bind(this, decorati on), true);
955 this._breakpointDecorations.add(decoration); 955 this._breakpointDecorations.add(decoration);
956 updateWasScheduled = true; 956 updateWasScheduled = true;
957 this._updateBreakpointDecoration(decoration); 957 this._updateBreakpointDecoration(decoration);
958 } 958 }
959 this._didAddInlineDecorationsForTest(updateWasScheduled); 959 this._didAddInlineDecorationsForTest(updateWasScheduled);
960 } 960 }
961 } 961 }
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1182 /** 1182 /**
1183 * @param {number} lineNumber 1183 * @param {number} lineNumber
1184 * @param {boolean} onlyDisable 1184 * @param {boolean} onlyDisable
1185 */ 1185 */
1186 _toggleBreakpoint(lineNumber, onlyDisable) { 1186 _toggleBreakpoint(lineNumber, onlyDisable) {
1187 var decorations = this._lineBreakpointDecorations(lineNumber); 1187 var decorations = this._lineBreakpointDecorations(lineNumber);
1188 if (!decorations.length) { 1188 if (!decorations.length) {
1189 this._createNewBreakpoint(lineNumber, '', true); 1189 this._createNewBreakpoint(lineNumber, '', true);
1190 return; 1190 return;
1191 } 1191 }
1192 var hasDisabled = this._textEditor.hasLineClass(lineNumber, 'cm-breakpoint-d isabled'); 1192 var hasDisabled = this.textEditor.hasLineClass(lineNumber, 'cm-breakpoint-di sabled');
1193 var breakpoints = decorations.map(decoration => decoration.breakpoint).filte r(breakpoint => !!breakpoint); 1193 var breakpoints = decorations.map(decoration => decoration.breakpoint).filte r(breakpoint => !!breakpoint);
1194 for (var breakpoint of breakpoints) { 1194 for (var breakpoint of breakpoints) {
1195 if (onlyDisable) 1195 if (onlyDisable)
1196 breakpoint.setEnabled(hasDisabled); 1196 breakpoint.setEnabled(hasDisabled);
1197 else 1197 else
1198 breakpoint.remove(); 1198 breakpoint.remove();
1199 } 1199 }
1200 } 1200 }
1201 1201
1202 /** 1202 /**
1203 * @param {number} lineNumber 1203 * @param {number} lineNumber
1204 * @param {string} condition 1204 * @param {string} condition
1205 * @param {boolean} enabled 1205 * @param {boolean} enabled
1206 */ 1206 */
1207 _createNewBreakpoint(lineNumber, condition, enabled) { 1207 _createNewBreakpoint(lineNumber, condition, enabled) {
1208 findPossibleBreakpoints.call(this, lineNumber) 1208 findPossibleBreakpoints.call(this, lineNumber)
1209 .then(checkNextLineIfNeeded.bind(this, lineNumber, 4)) 1209 .then(checkNextLineIfNeeded.bind(this, lineNumber, 4))
1210 .then(setBreakpoint.bind(this, condition, enabled)); 1210 .then(setBreakpoint.bind(this, condition, enabled));
1211 1211
1212 /** 1212 /**
1213 * @this {!Sources.JavaScriptSourceFrame} 1213 * @this {!Sources.JavaScriptSourceFrame}
1214 * @param {number} lineNumber 1214 * @param {number} lineNumber
1215 * @return {!Promise<?Array<!Workspace.UILocation>>} 1215 * @return {!Promise<?Array<!Workspace.UILocation>>}
1216 */ 1216 */
1217 function findPossibleBreakpoints(lineNumber) { 1217 function findPossibleBreakpoints(lineNumber) {
1218 const maxLengthToCheck = 1024; 1218 const maxLengthToCheck = 1024;
1219 if (lineNumber >= this._textEditor.linesCount) 1219 if (lineNumber >= this.textEditor.linesCount)
1220 return Promise.resolve(/** @type {?Array<!Workspace.UILocation>} */ ([]) ); 1220 return Promise.resolve(/** @type {?Array<!Workspace.UILocation>} */ ([]) );
1221 if (this._textEditor.line(lineNumber).length >= maxLengthToCheck) 1221 if (this.textEditor.line(lineNumber).length >= maxLengthToCheck)
1222 return Promise.resolve(/** @type {?Array<!Workspace.UILocation>} */ ([]) ); 1222 return Promise.resolve(/** @type {?Array<!Workspace.UILocation>} */ ([]) );
1223 return this._breakpointManager 1223 return this._breakpointManager
1224 .possibleBreakpoints(this._debuggerSourceCode, new Common.TextRange(li neNumber, 0, lineNumber + 1, 0)) 1224 .possibleBreakpoints(this._debuggerSourceCode, new Common.TextRange(li neNumber, 0, lineNumber + 1, 0))
1225 .then(locations => locations.length ? locations : null); 1225 .then(locations => locations.length ? locations : null);
1226 } 1226 }
1227 1227
1228 /** 1228 /**
1229 * @this {!Sources.JavaScriptSourceFrame} 1229 * @this {!Sources.JavaScriptSourceFrame}
1230 * @param {number} currentLineNumber 1230 * @param {number} currentLineNumber
1231 * @param {number} linesToCheck 1231 * @param {number} linesToCheck
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1317 */ 1317 */
1318 Sources.JavaScriptSourceFrame.BreakpointDecoration = class { 1318 Sources.JavaScriptSourceFrame.BreakpointDecoration = class {
1319 /** 1319 /**
1320 * @param {!TextEditor.CodeMirrorTextEditor} textEditor 1320 * @param {!TextEditor.CodeMirrorTextEditor} textEditor
1321 * @param {!TextEditor.TextEditorPositionHandle} handle 1321 * @param {!TextEditor.TextEditorPositionHandle} handle
1322 * @param {string} condition 1322 * @param {string} condition
1323 * @param {boolean} enabled 1323 * @param {boolean} enabled
1324 * @param {?Bindings.BreakpointManager.Breakpoint} breakpoint 1324 * @param {?Bindings.BreakpointManager.Breakpoint} breakpoint
1325 */ 1325 */
1326 constructor(textEditor, handle, condition, enabled, breakpoint) { 1326 constructor(textEditor, handle, condition, enabled, breakpoint) {
1327 this._textEditor = textEditor; 1327 this.textEditor = textEditor;
1328 this.handle = handle; 1328 this.handle = handle;
1329 this.condition = condition; 1329 this.condition = condition;
1330 this.enabled = enabled; 1330 this.enabled = enabled;
1331 this.breakpoint = breakpoint; 1331 this.breakpoint = breakpoint;
1332 this.element = UI.Icon.create('smallicon-inline-breakpoint'); 1332 this.element = UI.Icon.create('smallicon-inline-breakpoint');
1333 this.element.classList.toggle('cm-inline-breakpoint', true); 1333 this.element.classList.toggle('cm-inline-breakpoint', true);
1334 1334
1335 /** @type {?TextEditor.TextEditorBookMark} */ 1335 /** @type {?TextEditor.TextEditorBookMark} */
1336 this.bookmark = null; 1336 this.bookmark = null;
1337 } 1337 }
(...skipping 18 matching lines...) Expand all
1356 this.element.setIconType('smallicon-inline-breakpoint-conditional'); 1356 this.element.setIconType('smallicon-inline-breakpoint-conditional');
1357 this.element.classList.toggle('cm-inline-disabled', !this.enabled); 1357 this.element.classList.toggle('cm-inline-disabled', !this.enabled);
1358 } 1358 }
1359 1359
1360 show() { 1360 show() {
1361 if (this.bookmark) 1361 if (this.bookmark)
1362 return; 1362 return;
1363 var location = this.handle.resolve(); 1363 var location = this.handle.resolve();
1364 if (!location) 1364 if (!location)
1365 return; 1365 return;
1366 this.bookmark = this._textEditor.addBookmark( 1366 this.bookmark = this.textEditor.addBookmark(
1367 location.lineNumber, location.columnNumber, this.element, 1367 location.lineNumber, location.columnNumber, this.element,
1368 Sources.JavaScriptSourceFrame.BreakpointDecoration.bookmarkSymbol); 1368 Sources.JavaScriptSourceFrame.BreakpointDecoration.bookmarkSymbol);
1369 this.bookmark[Sources.JavaScriptSourceFrame.BreakpointDecoration._elementSym bolForTest] = this.element; 1369 this.bookmark[Sources.JavaScriptSourceFrame.BreakpointDecoration._elementSym bolForTest] = this.element;
1370 } 1370 }
1371 1371
1372 hide() { 1372 hide() {
1373 if (!this.bookmark) 1373 if (!this.bookmark)
1374 return; 1374 return;
1375 this.bookmark.clear(); 1375 this.bookmark.clear();
1376 this.bookmark = null; 1376 this.bookmark = null;
1377 } 1377 }
1378 }; 1378 };
1379 1379
1380 Sources.JavaScriptSourceFrame.BreakpointDecoration.bookmarkSymbol = Symbol('book mark'); 1380 Sources.JavaScriptSourceFrame.BreakpointDecoration.bookmarkSymbol = Symbol('book mark');
1381 Sources.JavaScriptSourceFrame.BreakpointDecoration._elementSymbolForTest = Symbo l('element'); 1381 Sources.JavaScriptSourceFrame.BreakpointDecoration._elementSymbolForTest = Symbo l('element');
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698