| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * | 10 * |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 * @constructor | 30 * @constructor |
| 31 * @extends {WebInspector.SourceFrame} | 31 * @extends {WebInspector.SourceFrame} |
| 32 * @param {!WebInspector.UISourceCode} uiSourceCode | 32 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 33 */ | 33 */ |
| 34 WebInspector.UISourceCodeFrame = function(uiSourceCode) | 34 WebInspector.UISourceCodeFrame = function(uiSourceCode) |
| 35 { | 35 { |
| 36 this._uiSourceCode = uiSourceCode; | 36 this._uiSourceCode = uiSourceCode; |
| 37 WebInspector.SourceFrame.call(this, uiSourceCode.contentURL(), workingCopy); | 37 WebInspector.SourceFrame.call(this, uiSourceCode.contentURL(), workingCopy); |
| 38 | 38 |
| 39 if (Runtime.experiments.isEnabled("sourceDiff")) | 39 if (Runtime.experiments.isEnabled("sourceDiff")) |
| 40 this._diff = new WebInspector.SourceCodeDiff(uiSourceCode, this.textEdit
or); | 40 this._diff = new WebInspector.SourceCodeDiff(uiSourceCode.requestOrigina
lContent(), this.textEditor); |
| 41 this.textEditor.setAutocompleteDelegate(new WebInspector.SimpleAutocompleteD
elegate()); | 41 this.textEditor.setAutocompleteDelegate(new WebInspector.SimpleAutocompleteD
elegate()); |
| 42 | 42 |
| 43 this._rowMessageBuckets = {}; | 43 this._rowMessageBuckets = {}; |
| 44 /** @type {!Set<string>} */ | 44 /** @type {!Set<string>} */ |
| 45 this._typeDecorationsPending = new Set(); | 45 this._typeDecorationsPending = new Set(); |
| 46 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Working
CopyChanged, this._onWorkingCopyChanged, this); | 46 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Working
CopyChanged, this._onWorkingCopyChanged, this); |
| 47 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Working
CopyCommitted, this._onWorkingCopyCommitted, this); | 47 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Working
CopyCommitted, this._onWorkingCopyCommitted, this); |
| 48 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Message
Added, this._onMessageAdded, this); | 48 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Message
Added, this._onMessageAdded, this); |
| 49 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Message
Removed, this._onMessageRemoved, this); | 49 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Message
Removed, this._onMessageRemoved, this); |
| 50 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.LineDec
orationAdded, this._onLineDecorationAdded, this); | 50 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.LineDec
orationAdded, this._onLineDecorationAdded, this); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 this._muteSourceCodeEvents = true; | 126 this._muteSourceCodeEvents = true; |
| 127 this._uiSourceCode.commitWorkingCopy(); | 127 this._uiSourceCode.commitWorkingCopy(); |
| 128 delete this._muteSourceCodeEvents; | 128 delete this._muteSourceCodeEvents; |
| 129 }, | 129 }, |
| 130 | 130 |
| 131 /** | 131 /** |
| 132 * @override | 132 * @override |
| 133 */ | 133 */ |
| 134 onTextEditorContentLoaded: function() | 134 onTextEditorContentLoaded: function() |
| 135 { | 135 { |
| 136 if (this._diff) |
| 137 this._diff.updateDiffMarkersImmediately(); |
| 136 WebInspector.SourceFrame.prototype.onTextEditorContentLoaded.call(this); | 138 WebInspector.SourceFrame.prototype.onTextEditorContentLoaded.call(this); |
| 137 for (var message of this._uiSourceCode.messages()) | 139 for (var message of this._uiSourceCode.messages()) |
| 138 this._addMessageToSource(message); | 140 this._addMessageToSource(message); |
| 139 this._decorateAllTypes(); | 141 this._decorateAllTypes(); |
| 140 }, | 142 }, |
| 141 | 143 |
| 142 /** | 144 /** |
| 143 * @override | 145 * @override |
| 144 * @param {!WebInspector.TextRange} oldRange | 146 * @param {!WebInspector.TextRange} oldRange |
| 145 * @param {!WebInspector.TextRange} newRange | 147 * @param {!WebInspector.TextRange} newRange |
| 146 */ | 148 */ |
| 147 onTextChanged: function(oldRange, newRange) | 149 onTextChanged: function(oldRange, newRange) |
| 148 { | 150 { |
| 151 if (this._diff) |
| 152 this._diff.updateDiffMarkersWhenPossible(); |
| 149 WebInspector.SourceFrame.prototype.onTextChanged.call(this, oldRange, ne
wRange); | 153 WebInspector.SourceFrame.prototype.onTextChanged.call(this, oldRange, ne
wRange); |
| 150 this._clearMessages(); | 154 this._clearMessages(); |
| 151 if (this._isSettingContent) | 155 if (this._isSettingContent) |
| 152 return; | 156 return; |
| 153 this._muteSourceCodeEvents = true; | 157 this._muteSourceCodeEvents = true; |
| 154 if (this._textEditor.isClean()) | 158 if (this._textEditor.isClean()) |
| 155 this._uiSourceCode.resetWorkingCopy(); | 159 this._uiSourceCode.resetWorkingCopy(); |
| 156 else | 160 else |
| 157 this._uiSourceCode.setWorkingCopyGetter(this._textEditor.text.bind(t
his._textEditor)); | 161 this._uiSourceCode.setWorkingCopyGetter(this._textEditor.text.bind(t
his._textEditor)); |
| 158 delete this._muteSourceCodeEvents; | 162 delete this._muteSourceCodeEvents; |
| 159 }, | 163 }, |
| 160 | 164 |
| 161 /** | 165 /** |
| 162 * @param {!WebInspector.Event} event | 166 * @param {!WebInspector.Event} event |
| 163 */ | 167 */ |
| 164 _onWorkingCopyChanged: function(event) | 168 _onWorkingCopyChanged: function(event) |
| 165 { | 169 { |
| 166 if (this._diff) | |
| 167 this._diff.updateDiffMarkersWhenPossible(); | |
| 168 if (this._muteSourceCodeEvents) | 170 if (this._muteSourceCodeEvents) |
| 169 return; | 171 return; |
| 170 this._innerSetContent(this._uiSourceCode.workingCopy()); | 172 this._innerSetContent(this._uiSourceCode.workingCopy()); |
| 171 this.onUISourceCodeContentChanged(); | 173 this.onUISourceCodeContentChanged(); |
| 172 }, | 174 }, |
| 173 | 175 |
| 174 /** | 176 /** |
| 175 * @param {!WebInspector.Event} event | 177 * @param {!WebInspector.Event} event |
| 176 */ | 178 */ |
| 177 _onWorkingCopyCommitted: function(event) | 179 _onWorkingCopyCommitted: function(event) |
| 178 { | 180 { |
| 179 if (!this._muteSourceCodeEvents) { | 181 if (!this._muteSourceCodeEvents) { |
| 180 this._innerSetContent(this._uiSourceCode.workingCopy()); | 182 this._innerSetContent(this._uiSourceCode.workingCopy()); |
| 181 this.onUISourceCodeContentChanged(); | 183 this.onUISourceCodeContentChanged(); |
| 182 } | 184 } |
| 183 this._textEditor.markClean(); | 185 this._textEditor.markClean(); |
| 184 this._updateStyle(); | 186 this._updateStyle(); |
| 185 if (this._diff) | |
| 186 this._diff.updateDiffMarkersWhenPossible(); | |
| 187 }, | 187 }, |
| 188 | 188 |
| 189 _updateStyle: function() | 189 _updateStyle: function() |
| 190 { | 190 { |
| 191 this.element.classList.toggle("source-frame-unsaved-committed-changes",
this._uiSourceCode.hasUnsavedCommittedChanges()); | 191 this.element.classList.toggle("source-frame-unsaved-committed-changes",
this._uiSourceCode.hasUnsavedCommittedChanges()); |
| 192 }, | 192 }, |
| 193 | 193 |
| 194 onUISourceCodeContentChanged: function() | 194 onUISourceCodeContentChanged: function() |
| 195 { | 195 { |
| 196 }, | 196 }, |
| 197 | 197 |
| 198 /** | 198 /** |
| 199 * @param {string} content | 199 * @param {string} content |
| 200 */ | 200 */ |
| 201 _innerSetContent: function(content) | 201 _innerSetContent: function(content) |
| 202 { | 202 { |
| 203 this._isSettingContent = true; | 203 this._isSettingContent = true; |
| 204 if (this._diff) { | 204 if (this._diff) { |
| 205 var oldContent = this._textEditor.text(); | 205 var oldContent = this._textEditor.text(); |
| 206 this.setContent(content); | 206 this.setContent(content); |
| 207 this._diff.updateDiffMarkersImmediately(); | |
| 208 this._diff.highlightModifiedLines(oldContent, content); | 207 this._diff.highlightModifiedLines(oldContent, content); |
| 209 } else { | 208 } else { |
| 210 this.setContent(content); | 209 this.setContent(content); |
| 211 } | 210 } |
| 212 delete this._isSettingContent; | 211 delete this._isSettingContent; |
| 213 }, | 212 }, |
| 214 | 213 |
| 215 /** | 214 /** |
| 216 * @override | 215 * @override |
| 217 * @return {!Promise} | 216 * @return {!Promise} |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 | 627 |
| 629 /** | 628 /** |
| 630 * @param {!WebInspector.UISourceCode.Message} a | 629 * @param {!WebInspector.UISourceCode.Message} a |
| 631 * @param {!WebInspector.UISourceCode.Message} b | 630 * @param {!WebInspector.UISourceCode.Message} b |
| 632 * @return {number} | 631 * @return {number} |
| 633 */ | 632 */ |
| 634 WebInspector.UISourceCode.Message.messageLevelComparator = function(a, b) | 633 WebInspector.UISourceCode.Message.messageLevelComparator = function(a, b) |
| 635 { | 634 { |
| 636 return WebInspector.UISourceCode.Message._messageLevelPriority[a.level()] -
WebInspector.UISourceCode.Message._messageLevelPriority[b.level()]; | 635 return WebInspector.UISourceCode.Message._messageLevelPriority[a.level()] -
WebInspector.UISourceCode.Message._messageLevelPriority[b.level()]; |
| 637 } | 636 } |
| OLD | NEW |