Chromium Code Reviews| Index: third_party/WebKit/Source/devtools/front_end/sources/JavaScriptSourceFrame.js |
| diff --git a/third_party/WebKit/Source/devtools/front_end/sources/JavaScriptSourceFrame.js b/third_party/WebKit/Source/devtools/front_end/sources/JavaScriptSourceFrame.js |
| index c547c015cd22cf40b10720aa6c8fe3944efa712b..b83f64ccc3548dabb464bae82434a71e49bb7927 100644 |
| --- a/third_party/WebKit/Source/devtools/front_end/sources/JavaScriptSourceFrame.js |
| +++ b/third_party/WebKit/Source/devtools/front_end/sources/JavaScriptSourceFrame.js |
| @@ -82,6 +82,8 @@ Sources.JavaScriptSourceFrame = class extends SourceFrame.UISourceCodeFrame { |
| this._breakpointDecorations = new Set(); |
| /** @type {!Map<!Bindings.BreakpointManager.Breakpoint, !Sources.JavaScriptSourceFrame.BreakpointDecoration>} */ |
| this._decorationByBreakpoint = new Map(); |
| + /** @type {!Set<number>} */ |
| + this._possibleBreakpointsRequested = new Set(); |
| /** @type {!Map.<!SDK.DebuggerModel, !Bindings.ResourceScriptFile>}*/ |
| this._scriptFileForDebuggerModel = new Map(); |
| @@ -1081,41 +1083,62 @@ Sources.JavaScriptSourceFrame = class extends SourceFrame.UISourceCodeFrame { |
| } |
| delete this._scheduledBreakpointDecorationUpdates; |
| for (var lineNumber of lineNumbers) { |
| - this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint', false); |
| - this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint-disabled', false); |
| - this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint-conditional', false); |
| - |
| var decorations = this._lineBreakpointDecorations(lineNumber); |
| - var actualBookmarks = |
| - new Set(decorations.map(decoration => decoration.bookmark).filter(bookmark => !!bookmark)); |
| - var lineEnd = this.textEditor.line(lineNumber).length; |
| - var bookmarks = this.textEditor.bookmarks( |
| - new TextUtils.TextRange(lineNumber, 0, lineNumber, lineEnd), |
| - Sources.JavaScriptSourceFrame.BreakpointDecoration.bookmarkSymbol); |
| - for (var bookmark of bookmarks) { |
| - if (!actualBookmarks.has(bookmark)) |
| - bookmark.clear(); |
| - } |
| - if (!decorations.length) |
| + updateGutter.call(this, lineNumber, decorations); |
| + if (this._possibleBreakpointsRequested.has(location.lineNumber)) |
| continue; |
| + updateInlineDecorations.call(this, lineNumber, decorations); |
| + } |
| + this._breakpointDecorationsUpdatedForTest(); |
| + } |
| + |
| + /** |
| + * @param {number} lineNumber |
| + * @param {!Array<!Sources.JavaScriptSourceFrame.BreakpointDecoration>} decorations |
| + * @this {Sources.JavaScriptSourceFrame} |
| + */ |
| + function updateGutter(lineNumber, decorations) { |
| + this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint', false); |
| + this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint-disabled', false); |
| + this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint-conditional', false); |
| + |
| + if (decorations.length) { |
| decorations.sort(Sources.JavaScriptSourceFrame.BreakpointDecoration.mostSpecificFirst); |
| this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint', true); |
| this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint-disabled', !decorations[0].enabled || this._muted); |
| this.textEditor.toggleLineClass(lineNumber, 'cm-breakpoint-conditional', !!decorations[0].condition); |
| - if (decorations.length > 1) { |
| - for (var decoration of decorations) { |
| - decoration.update(); |
| - if (!this._muted) |
| - decoration.show(); |
| - else |
| - decoration.hide(); |
| - } |
| - } else { |
| - decorations[0].update(); |
| - decorations[0].hide(); |
| + } |
| + } |
| + |
| + /** |
| + * @param {number} lineNumber |
| + * @param {!Array<!Sources.JavaScriptSourceFrame.BreakpointDecoration>} decorations |
| + * @this {Sources.JavaScriptSourceFrame} |
| + */ |
| + function updateInlineDecorations(lineNumber, decorations) { |
| + var actualBookmarks = new Set(decorations.map(decoration => decoration.bookmark).filter(bookmark => !!bookmark)); |
| + var lineEnd = this.textEditor.line(lineNumber).length; |
| + var bookmarks = this.textEditor.bookmarks( |
| + new TextUtils.TextRange(lineNumber, 0, lineNumber, lineEnd), |
| + Sources.JavaScriptSourceFrame.BreakpointDecoration.bookmarkSymbol); |
| + for (var bookmark of bookmarks) { |
| + if (!actualBookmarks.has(bookmark)) |
| + bookmark.clear(); |
| + } |
| + if (!decorations.length) |
| + return; |
| + if (decorations.length > 1) { |
| + for (var decoration of decorations) { |
| + decoration.update(); |
| + if (!this._muted) |
| + decoration.show(); |
| + else |
| + decoration.hide(); |
| } |
| + } else { |
| + decorations[0].update(); |
| + decorations[0].hide(); |
| } |
| - this._breakpointDecorationsUpdatedForTest(); |
| } |
| } |
| @@ -1221,6 +1244,7 @@ Sources.JavaScriptSourceFrame = class extends SourceFrame.UISourceCodeFrame { |
| this._updateBreakpointDecoration(decoration); |
| if (!lineDecorations.length) { |
| this._willAddInlineDecorationsForTest(); |
| + this._possibleBreakpointsRequested.add(uiLocation.lineNumber); |
| this._breakpointManager |
| .possibleBreakpoints( |
| this._debuggerSourceCode, new TextUtils.TextRange(uiLocation.lineNumber, 0, uiLocation.lineNumber + 1, 0)) |
| @@ -1233,9 +1257,15 @@ Sources.JavaScriptSourceFrame = class extends SourceFrame.UISourceCodeFrame { |
| * @param {!Array<!Workspace.UILocation>} possibleLocations |
| */ |
| function addInlineDecorations(lineNumber, possibleLocations) { |
| + this._possibleBreakpointsRequested.delete(lineNumber); |
| var decorations = this._lineBreakpointDecorations(lineNumber); |
| + var updateWasScheduled = false; |
| + for (var decoration of decorations) { |
| + updateWasScheduled = true; |
| + this._updateBreakpointDecoration(decoration); |
| + } |
| if (!decorations.some(decoration => !!decoration.breakpoint)) { |
| - this._didAddInlineDecorationsForTest(false); |
| + this._didAddInlineDecorationsForTest(updateWasScheduled); |
|
dgozman
2017/05/16 22:54:20
Should we remove this flag?
|
| return; |
| } |
| /** @type {!Set<number>} */ |
| @@ -1246,7 +1276,6 @@ Sources.JavaScriptSourceFrame = class extends SourceFrame.UISourceCodeFrame { |
| continue; |
| columns.add(location.columnNumber); |
| } |
| - var updateWasScheduled = false; |
| for (var location of possibleLocations) { |
| if (columns.has(location.columnNumber)) |
| continue; |