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

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

Issue 2450663004: DevTools: do not allow using 'this' before call into super. (Closed)
Patch Set: rebaselined Created 4 years, 1 month 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 15 matching lines...) Expand all
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29 /** 29 /**
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 WebInspector.SourceFrame.call(this, uiSourceCode.contentURL(), workingCopy);
36 this._uiSourceCode = uiSourceCode; 37 this._uiSourceCode = uiSourceCode;
37 WebInspector.SourceFrame.call(this, uiSourceCode.contentURL(), workingCopy); 38 this.setEditable(this._canEditSource());
38 39
39 if (Runtime.experiments.isEnabled("sourceDiff")) 40 if (Runtime.experiments.isEnabled("sourceDiff"))
40 this._diff = new WebInspector.SourceCodeDiff(uiSourceCode.requestOrigina lContent(), this.textEditor); 41 this._diff = new WebInspector.SourceCodeDiff(uiSourceCode.requestOrigina lContent(), this.textEditor);
41 42
42 /** @type {?WebInspector.AutocompleteConfig} */ 43 /** @type {?WebInspector.AutocompleteConfig} */
43 this._autocompleteConfig = {isWordChar: WebInspector.TextUtils.isWordChar}; 44 this._autocompleteConfig = {isWordChar: WebInspector.TextUtils.isWordChar};
44 WebInspector.moduleSetting("textEditorAutocompletion").addChangeListener(thi s._updateAutocomplete, this); 45 WebInspector.moduleSetting("textEditorAutocompletion").addChangeListener(thi s._updateAutocomplete, this);
45 this._updateAutocomplete(); 46 this._updateAutocomplete();
46 47
47 this._rowMessageBuckets = {}; 48 this._rowMessageBuckets = {};
48 /** @type {!Set<string>} */ 49 /** @type {!Set<string>} */
49 this._typeDecorationsPending = new Set(); 50 this._typeDecorationsPending = new Set();
50 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Working CopyChanged, this._onWorkingCopyChanged, this); 51 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Working CopyChanged, this._onWorkingCopyChanged, this);
51 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Working CopyCommitted, this._onWorkingCopyCommitted, this); 52 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Working CopyCommitted, this._onWorkingCopyCommitted, this);
52 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Message Added, this._onMessageAdded, this); 53 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Message Added, this._onMessageAdded, this);
53 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Message Removed, this._onMessageRemoved, this); 54 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Message Removed, this._onMessageRemoved, this);
54 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.LineDec orationAdded, this._onLineDecorationAdded, this); 55 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.LineDec orationAdded, this._onLineDecorationAdded, this);
55 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.LineDec orationRemoved, this._onLineDecorationRemoved, this); 56 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.LineDec orationRemoved, this._onLineDecorationRemoved, this);
56 WebInspector.persistence.addEventListener(WebInspector.Persistence.Events.Bi ndingCreated, this._onBindingChanged, this); 57 WebInspector.persistence.addEventListener(WebInspector.Persistence.Events.Bi ndingCreated, this._onBindingChanged, this);
57 WebInspector.persistence.addEventListener(WebInspector.Persistence.Events.Bi ndingRemoved, this._onBindingChanged, this); 58 WebInspector.persistence.addEventListener(WebInspector.Persistence.Events.Bi ndingRemoved, this._onBindingChanged, this);
58 59
59 this.textEditor.addEventListener(WebInspector.SourcesTextEditor.Events.Edito rBlurred, 60 this.textEditor.addEventListener(WebInspector.SourcesTextEditor.Events.Edito rBlurred,
60 () => WebInspector.context.setFlavor(WebInspector.UISourceCodeFrame, nul l)); 61 () => WebInspector.context.setFlavor(WebInspector.UISourceCodeFrame, nul l));
61 this.textEditor.addEventListener(WebInspector.SourcesTextEditor.Events.Edito rFocused, 62 this.textEditor.addEventListener(WebInspector.SourcesTextEditor.Events.Edito rFocused,
62 () => WebInspector.context.setFlavor(WebInspector.UISourceCodeFrame, thi s)); 63 () => WebInspector.context.setFlavor(WebInspector.UISourceCodeFrame, thi s));
63 64
64 this._updateStyle(); 65 this._updateStyle();
65 66
66 this._errorPopoverHelper = new WebInspector.PopoverHelper(this.element, this ._getErrorAnchor.bind(this), this._showErrorPopover.bind(this)); 67 this._errorPopoverHelper = new WebInspector.PopoverHelper(this.element);
68 this._errorPopoverHelper.initializeCallbacks(this._getErrorAnchor.bind(this) , this._showErrorPopover.bind(this));
69
67 this._errorPopoverHelper.setTimeout(100, 100); 70 this._errorPopoverHelper.setTimeout(100, 100);
68 71
69 /** 72 /**
70 * @return {!Promise<?string>} 73 * @return {!Promise<?string>}
71 */ 74 */
72 function workingCopy() 75 function workingCopy()
73 { 76 {
74 if (uiSourceCode.isDirty()) 77 if (uiSourceCode.isDirty())
75 return /** @type {!Promise<?string>} */(Promise.resolve(uiSourceCode .workingCopy())); 78 return /** @type {!Promise<?string>} */(Promise.resolve(uiSourceCode .workingCopy()));
76 return uiSourceCode.requestContent(); 79 return uiSourceCode.requestContent();
(...skipping 22 matching lines...) Expand all
99 willHide: function() 102 willHide: function()
100 { 103 {
101 WebInspector.SourceFrame.prototype.willHide.call(this); 104 WebInspector.SourceFrame.prototype.willHide.call(this);
102 WebInspector.context.setFlavor(WebInspector.UISourceCodeFrame, null); 105 WebInspector.context.setFlavor(WebInspector.UISourceCodeFrame, null);
103 this.element.ownerDocument.defaultView.removeEventListener("focus", this ._boundWindowFocused, false); 106 this.element.ownerDocument.defaultView.removeEventListener("focus", this ._boundWindowFocused, false);
104 delete this._boundWindowFocused; 107 delete this._boundWindowFocused;
105 this._uiSourceCode.removeWorkingCopyGetter(); 108 this._uiSourceCode.removeWorkingCopyGetter();
106 }, 109 },
107 110
108 /** 111 /**
109 * @override
110 * @return {boolean} 112 * @return {boolean}
111 */ 113 */
112 canEditSource: function() 114 _canEditSource: function()
113 { 115 {
114 if (WebInspector.persistence.binding(this._uiSourceCode)) 116 if (WebInspector.persistence.binding(this._uiSourceCode))
115 return true; 117 return true;
116 var projectType = this._uiSourceCode.project().type(); 118 var projectType = this._uiSourceCode.project().type();
117 if (projectType === WebInspector.projectTypes.Service || projectType === WebInspector.projectTypes.Debugger || projectType === WebInspector.projectTypes .Formatter) 119 if (projectType === WebInspector.projectTypes.Service || projectType === WebInspector.projectTypes.Debugger || projectType === WebInspector.projectTypes .Formatter)
118 return false; 120 return false;
119 if (projectType === WebInspector.projectTypes.Network && this._uiSourceC ode.contentType() === WebInspector.resourceTypes.Document) 121 if (projectType === WebInspector.projectTypes.Network && this._uiSourceC ode.contentType() === WebInspector.resourceTypes.Document)
120 return false; 122 return false;
121 return true; 123 return true;
122 }, 124 },
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 _onBindingChanged: function(event) 209 _onBindingChanged: function(event)
208 { 210 {
209 var binding = /** @type {!WebInspector.PersistenceBinding} */(event.data ); 211 var binding = /** @type {!WebInspector.PersistenceBinding} */(event.data );
210 if (binding.network === this._uiSourceCode || binding.fileSystem === thi s._uiSourceCode) 212 if (binding.network === this._uiSourceCode || binding.fileSystem === thi s._uiSourceCode)
211 this._updateStyle(); 213 this._updateStyle();
212 }, 214 },
213 215
214 _updateStyle: function() 216 _updateStyle: function()
215 { 217 {
216 this.element.classList.toggle("source-frame-unsaved-committed-changes", WebInspector.persistence.hasUnsavedCommittedChanges(this._uiSourceCode)); 218 this.element.classList.toggle("source-frame-unsaved-committed-changes", WebInspector.persistence.hasUnsavedCommittedChanges(this._uiSourceCode));
217 this._textEditor.setReadOnly(!this.canEditSource()); 219 this.setEditable(!this._canEditSource());
218 }, 220 },
219 221
220 onUISourceCodeContentChanged: function() 222 onUISourceCodeContentChanged: function()
221 { 223 {
222 }, 224 },
223 225
224 _updateAutocomplete: function() 226 _updateAutocomplete: function()
225 { 227 {
226 this._textEditor.configureAutocomplete(WebInspector.moduleSetting("textE ditorAutocompletion").get() ? this._autocompleteConfig : null); 228 this._textEditor.configureAutocomplete(WebInspector.moduleSetting("textE ditorAutocompletion").get() ? this._autocompleteConfig : null);
227 }, 229 },
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 672
671 /** 673 /**
672 * @param {!WebInspector.UISourceCode.Message} a 674 * @param {!WebInspector.UISourceCode.Message} a
673 * @param {!WebInspector.UISourceCode.Message} b 675 * @param {!WebInspector.UISourceCode.Message} b
674 * @return {number} 676 * @return {number}
675 */ 677 */
676 WebInspector.UISourceCode.Message.messageLevelComparator = function(a, b) 678 WebInspector.UISourceCode.Message.messageLevelComparator = function(a, b)
677 { 679 {
678 return WebInspector.UISourceCode.Message._messageLevelPriority[a.level()] - WebInspector.UISourceCode.Message._messageLevelPriority[b.level()]; 680 return WebInspector.UISourceCode.Message._messageLevelPriority[a.level()] - WebInspector.UISourceCode.Message._messageLevelPriority[b.level()];
679 }; 681 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698