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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/source_frame/UISourceCodeFrame.js

Issue 2729783002: DevTools: Diff subsystem (Closed)
Patch Set: nullable diff Created 3 years, 9 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
OLDNEW
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 21 matching lines...) Expand all
32 SourceFrame.UISourceCodeFrame = class extends SourceFrame.SourceFrame { 32 SourceFrame.UISourceCodeFrame = class extends SourceFrame.SourceFrame {
33 /** 33 /**
34 * @param {!Workspace.UISourceCode} uiSourceCode 34 * @param {!Workspace.UISourceCode} uiSourceCode
35 */ 35 */
36 constructor(uiSourceCode) { 36 constructor(uiSourceCode) {
37 super(uiSourceCode.contentURL(), workingCopy); 37 super(uiSourceCode.contentURL(), workingCopy);
38 this._uiSourceCode = uiSourceCode; 38 this._uiSourceCode = uiSourceCode;
39 this.setEditable(this._canEditSource()); 39 this.setEditable(this._canEditSource());
40 40
41 if (Runtime.experiments.isEnabled('sourceDiff')) 41 if (Runtime.experiments.isEnabled('sourceDiff'))
42 this._diff = new SourceFrame.SourceCodeDiff(uiSourceCode.requestOriginalCo ntent(), this.textEditor); 42 this._diff = new SourceFrame.SourceCodeDiff(WorkspaceDiff.workspaceDiff(), uiSourceCode, this.textEditor);
43
43 44
44 /** @type {?UI.AutocompleteConfig} */ 45 /** @type {?UI.AutocompleteConfig} */
45 this._autocompleteConfig = {isWordChar: Common.TextUtils.isWordChar}; 46 this._autocompleteConfig = {isWordChar: Common.TextUtils.isWordChar};
46 Common.moduleSetting('textEditorAutocompletion').addChangeListener(this._upd ateAutocomplete, this); 47 Common.moduleSetting('textEditorAutocompletion').addChangeListener(this._upd ateAutocomplete, this);
47 this._updateAutocomplete(); 48 this._updateAutocomplete();
48 49
49 /** @type {?Persistence.PersistenceBinding} */ 50 /** @type {?Persistence.PersistenceBinding} */
50 this._persistenceBinding = Persistence.persistence.binding(uiSourceCode); 51 this._persistenceBinding = Persistence.persistence.binding(uiSourceCode);
51 52
52 /** @type {!Map<number, !SourceFrame.UISourceCodeFrame.RowMessageBucket>} */ 53 /** @type {!Map<number, !SourceFrame.UISourceCodeFrame.RowMessageBucket>} */
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 161
161 this._muteSourceCodeEvents = true; 162 this._muteSourceCodeEvents = true;
162 this._uiSourceCode.commitWorkingCopy(); 163 this._uiSourceCode.commitWorkingCopy();
163 delete this._muteSourceCodeEvents; 164 delete this._muteSourceCodeEvents;
164 } 165 }
165 166
166 /** 167 /**
167 * @override 168 * @override
168 */ 169 */
169 onTextEditorContentSet() { 170 onTextEditorContentSet() {
170 if (this._diff)
171 this._diff.updateDiffMarkersImmediately();
172 super.onTextEditorContentSet(); 171 super.onTextEditorContentSet();
173 for (var message of this._allMessages()) 172 for (var message of this._allMessages())
174 this._addMessageToSource(message); 173 this._addMessageToSource(message);
175 this._decorateAllTypes(); 174 this._decorateAllTypes();
176 } 175 }
177 176
178 /** 177 /**
179 * @return {!Array<!Workspace.UISourceCode.Message>} 178 * @return {!Array<!Workspace.UISourceCode.Message>}
180 */ 179 */
181 _allMessages() { 180 _allMessages() {
182 return this._persistenceBinding ? 181 return this._persistenceBinding ?
183 this._persistenceBinding.network.messages().concat(this._persistenceBind ing.fileSystem.messages()) : 182 this._persistenceBinding.network.messages().concat(this._persistenceBind ing.fileSystem.messages()) :
184 this._uiSourceCode.messages(); 183 this._uiSourceCode.messages();
185 } 184 }
186 185
187 /** 186 /**
188 * @override 187 * @override
189 * @param {!Common.TextRange} oldRange 188 * @param {!Common.TextRange} oldRange
190 * @param {!Common.TextRange} newRange 189 * @param {!Common.TextRange} newRange
191 */ 190 */
192 onTextChanged(oldRange, newRange) { 191 onTextChanged(oldRange, newRange) {
193 if (this._diff)
194 this._diff.updateDiffMarkersWhenPossible();
195 super.onTextChanged(oldRange, newRange); 192 super.onTextChanged(oldRange, newRange);
196 this._errorPopoverHelper.hidePopover(); 193 this._errorPopoverHelper.hidePopover();
197 if (this._isSettingContent) 194 if (this._isSettingContent)
198 return; 195 return;
199 this._muteSourceCodeEvents = true; 196 this._muteSourceCodeEvents = true;
200 if (this.textEditor.isClean()) 197 if (this.textEditor.isClean())
201 this._uiSourceCode.resetWorkingCopy(); 198 this._uiSourceCode.resetWorkingCopy();
202 else 199 else
203 this._uiSourceCode.setWorkingCopyGetter(this.textEditor.text.bind(this.tex tEditor)); 200 this._uiSourceCode.setWorkingCopyGetter(this.textEditor.text.bind(this.tex tEditor));
204 delete this._muteSourceCodeEvents; 201 delete this._muteSourceCodeEvents;
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 var infobar = infobars[i]; 311 var infobar = infobars[i];
315 if (!infobar) 312 if (!infobar)
316 continue; 313 continue;
317 this.element.insertBefore(infobar.element, this.element.children[0]); 314 this.element.insertBefore(infobar.element, this.element.children[0]);
318 infobar.setParentView(this); 315 infobar.setParentView(this);
319 } 316 }
320 this.doResize(); 317 this.doResize();
321 } 318 }
322 319
323 dispose() { 320 dispose() {
321 if (this._diff)
322 this._diff.dispose();
324 this.textEditor.dispose(); 323 this.textEditor.dispose();
325 Common.moduleSetting('textEditorAutocompletion').removeChangeListener(this._ updateAutocomplete, this); 324 Common.moduleSetting('textEditorAutocompletion').removeChangeListener(this._ updateAutocomplete, this);
326 this.detach(); 325 this.detach();
327 } 326 }
328 327
329 /** 328 /**
330 * @param {!Common.Event} event 329 * @param {!Common.Event} event
331 */ 330 */
332 _onMessageAdded(event) { 331 _onMessageAdded(event) {
333 var message = /** @type {!Workspace.UISourceCode.Message} */ (event.data); 332 var message = /** @type {!Workspace.UISourceCode.Message} */ (event.data);
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 681
683 /** 682 /**
684 * @param {!Workspace.UISourceCode.Message} a 683 * @param {!Workspace.UISourceCode.Message} a
685 * @param {!Workspace.UISourceCode.Message} b 684 * @param {!Workspace.UISourceCode.Message} b
686 * @return {number} 685 * @return {number}
687 */ 686 */
688 Workspace.UISourceCode.Message.messageLevelComparator = function(a, b) { 687 Workspace.UISourceCode.Message.messageLevelComparator = function(a, b) {
689 return Workspace.UISourceCode.Message._messageLevelPriority[a.level()] - 688 return Workspace.UISourceCode.Message._messageLevelPriority[a.level()] -
690 Workspace.UISourceCode.Message._messageLevelPriority[b.level()]; 689 Workspace.UISourceCode.Message._messageLevelPriority[b.level()];
691 }; 690 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698