| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 WebInspector.CoverageProfile = class { | 5 Components.CoverageProfile = class { |
| 6 constructor() { | 6 constructor() { |
| 7 this._updateTimer = null; | 7 this._updateTimer = null; |
| 8 this.reset(); | 8 this.reset(); |
| 9 } | 9 } |
| 10 | 10 |
| 11 /** | 11 /** |
| 12 * @return {!WebInspector.CoverageProfile} | 12 * @return {!Components.CoverageProfile} |
| 13 */ | 13 */ |
| 14 static instance() { | 14 static instance() { |
| 15 if (!WebInspector.CoverageProfile._instance) | 15 if (!Components.CoverageProfile._instance) |
| 16 WebInspector.CoverageProfile._instance = new WebInspector.CoverageProfile(
); | 16 Components.CoverageProfile._instance = new Components.CoverageProfile(); |
| 17 | 17 |
| 18 return WebInspector.CoverageProfile._instance; | 18 return Components.CoverageProfile._instance; |
| 19 } | 19 } |
| 20 | 20 |
| 21 /** | 21 /** |
| 22 * @param {string} url | 22 * @param {string} url |
| 23 * @param {!Protocol.CSS.SourceRange} range | 23 * @param {!Protocol.CSS.SourceRange} range |
| 24 */ | 24 */ |
| 25 appendUnusedRule(url, range) { | 25 appendUnusedRule(url, range) { |
| 26 if (!url) | 26 if (!url) |
| 27 return; | 27 return; |
| 28 | 28 |
| 29 var uiSourceCode = WebInspector.workspace.uiSourceCodeForURL(url); | 29 var uiSourceCode = Workspace.workspace.uiSourceCodeForURL(url); |
| 30 if (!uiSourceCode) | 30 if (!uiSourceCode) |
| 31 return; | 31 return; |
| 32 | 32 |
| 33 for (var line = range.startLine; line <= range.endLine; ++line) | 33 for (var line = range.startLine; line <= range.endLine; ++line) |
| 34 uiSourceCode.addLineDecoration(line, WebInspector.CoverageProfile.LineDeco
rator.type, range.startColumn); | 34 uiSourceCode.addLineDecoration(line, Components.CoverageProfile.LineDecora
tor.type, range.startColumn); |
| 35 } | 35 } |
| 36 | 36 |
| 37 reset() { | 37 reset() { |
| 38 WebInspector.workspace.uiSourceCodes().forEach( | 38 Workspace.workspace.uiSourceCodes().forEach( |
| 39 uiSourceCode => uiSourceCode.removeAllLineDecorations(WebInspector.Cover
ageProfile.LineDecorator.type)); | 39 uiSourceCode => uiSourceCode.removeAllLineDecorations(Components.Coverag
eProfile.LineDecorator.type)); |
| 40 } | 40 } |
| 41 }; | 41 }; |
| 42 | 42 |
| 43 /** | 43 /** |
| 44 * @implements {WebInspector.UISourceCodeFrame.LineDecorator} | 44 * @implements {Sources.UISourceCodeFrame.LineDecorator} |
| 45 */ | 45 */ |
| 46 WebInspector.CoverageProfile.LineDecorator = class { | 46 Components.CoverageProfile.LineDecorator = class { |
| 47 /** | 47 /** |
| 48 * @override | 48 * @override |
| 49 * @param {!WebInspector.UISourceCode} uiSourceCode | 49 * @param {!Workspace.UISourceCode} uiSourceCode |
| 50 * @param {!WebInspector.CodeMirrorTextEditor} textEditor | 50 * @param {!TextEditor.CodeMirrorTextEditor} textEditor |
| 51 */ | 51 */ |
| 52 decorate(uiSourceCode, textEditor) { | 52 decorate(uiSourceCode, textEditor) { |
| 53 var gutterType = 'CodeMirror-gutter-coverage'; | 53 var gutterType = 'CodeMirror-gutter-coverage'; |
| 54 | 54 |
| 55 var decorations = uiSourceCode.lineDecorations(WebInspector.CoverageProfile.
LineDecorator.type); | 55 var decorations = uiSourceCode.lineDecorations(Components.CoverageProfile.Li
neDecorator.type); |
| 56 textEditor.uninstallGutter(gutterType); | 56 textEditor.uninstallGutter(gutterType); |
| 57 if (!decorations) | 57 if (!decorations) |
| 58 return; | 58 return; |
| 59 | 59 |
| 60 textEditor.installGutter(gutterType, false); | 60 textEditor.installGutter(gutterType, false); |
| 61 | 61 |
| 62 for (var decoration of decorations.values()) { | 62 for (var decoration of decorations.values()) { |
| 63 var element = createElementWithClass('div', 'text-editor-line-marker-cover
age'); | 63 var element = createElementWithClass('div', 'text-editor-line-marker-cover
age'); |
| 64 textEditor.setGutterDecoration(decoration.line(), gutterType, element); | 64 textEditor.setGutterDecoration(decoration.line(), gutterType, element); |
| 65 } | 65 } |
| 66 } | 66 } |
| 67 }; | 67 }; |
| 68 | 68 |
| 69 WebInspector.CoverageProfile.LineDecorator.type = 'coverage'; | 69 Components.CoverageProfile.LineDecorator.type = 'coverage'; |
| OLD | NEW |