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

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

Issue 1768183003: DevTools: Support line markers in UISourceCode and Code Mirror (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressing comments. Created 4 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 19 matching lines...) Expand all
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, this._uiSourceCode); 37 WebInspector.SourceFrame.call(this, this._uiSourceCode);
38 this.textEditor.setAutocompleteDelegate(new WebInspector.SimpleAutocompleteD elegate()); 38 this.textEditor.setAutocompleteDelegate(new WebInspector.SimpleAutocompleteD elegate());
39 this._rowMessageBuckets = {}; 39 this._rowMessageBuckets = {};
40 /** @type {!Set<string>} */
41 this._typeDecorationsPending = new Set();
40 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Working CopyChanged, this._onWorkingCopyChanged, this); 42 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Working CopyChanged, this._onWorkingCopyChanged, this);
41 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Working CopyCommitted, this._onWorkingCopyCommitted, this); 43 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Working CopyCommitted, this._onWorkingCopyCommitted, this);
42 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Message Added, this._onMessageAdded, this); 44 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Message Added, this._onMessageAdded, this);
43 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Message Removed, this._onMessageRemoved, this); 45 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Message Removed, this._onMessageRemoved, this);
46 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.LineDec orationAdded, this._onLineDecorationAdded, this);
47 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.LineDec orationRemoved, this._onLineDecorationRemoved, this);
44 this._updateStyle(); 48 this._updateStyle();
45 49
46 this._errorPopoverHelper = new WebInspector.PopoverHelper(this.element, this ._getErrorAnchor.bind(this), this._showErrorPopover.bind(this)); 50 this._errorPopoverHelper = new WebInspector.PopoverHelper(this.element, this ._getErrorAnchor.bind(this), this._showErrorPopover.bind(this));
47 this._errorPopoverHelper.setTimeout(100, 100); 51 this._errorPopoverHelper.setTimeout(100, 100);
48 } 52 }
49 53
50 WebInspector.UISourceCodeFrame.prototype = { 54 WebInspector.UISourceCodeFrame.prototype = {
51 /** 55 /**
52 * @return {!WebInspector.UISourceCode} 56 * @return {!WebInspector.UISourceCode}
53 */ 57 */
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 }, 115 },
112 116
113 /** 117 /**
114 * @override 118 * @override
115 */ 119 */
116 onTextEditorContentLoaded: function() 120 onTextEditorContentLoaded: function()
117 { 121 {
118 WebInspector.SourceFrame.prototype.onTextEditorContentLoaded.call(this); 122 WebInspector.SourceFrame.prototype.onTextEditorContentLoaded.call(this);
119 for (var message of this._uiSourceCode.messages()) 123 for (var message of this._uiSourceCode.messages())
120 this._addMessageToSource(message); 124 this._addMessageToSource(message);
125 this._decorateAllTypes();
121 }, 126 },
122 127
123 /** 128 /**
124 * @override 129 * @override
125 * @param {!WebInspector.TextRange} oldRange 130 * @param {!WebInspector.TextRange} oldRange
126 * @param {!WebInspector.TextRange} newRange 131 * @param {!WebInspector.TextRange} newRange
127 */ 132 */
128 onTextChanged: function(oldRange, newRange) 133 onTextChanged: function(oldRange, newRange)
129 { 134 {
130 WebInspector.SourceFrame.prototype.onTextChanged.call(this, oldRange, ne wRange); 135 WebInspector.SourceFrame.prototype.onTextChanged.call(this, oldRange, ne wRange);
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 }, 328 },
324 329
325 _updateBucketDecorations: function() 330 _updateBucketDecorations: function()
326 { 331 {
327 for (var line in this._rowMessageBuckets) { 332 for (var line in this._rowMessageBuckets) {
328 var bucket = this._rowMessageBuckets[line]; 333 var bucket = this._rowMessageBuckets[line];
329 bucket._updateDecoration(); 334 bucket._updateDecoration();
330 } 335 }
331 }, 336 },
332 337
338 /**
339 * @param {!WebInspector.Event} event
340 */
341 _onLineDecorationAdded: function(event)
342 {
343 var marker = /** @type {!WebInspector.UISourceCode.LineMarker} */ (event .data);
344 this._decorateTypeThrottled(marker.type());
345 },
346
347 /**
348 * @param {!WebInspector.Event} event
349 */
350 _onLineDecorationRemoved: function(event)
351 {
352 var marker = /** @type {!WebInspector.UISourceCode.LineMarker} */ (event .data);
353 this._decorateTypeThrottled(marker.type());
354 },
355
356 /**
357 * @param {string} type
358 */
359 _decorateTypeThrottled: function(type)
360 {
361 if (this._typeDecorationsPending.has(type))
362 return;
363 this._typeDecorationsPending.add(type);
364 self.runtime.extensions(WebInspector.UISourceCodeFrame.LineDecorator).fi nd(extension => extension.descriptor()["decoratorType"] === type).instancePromis e().then(decorator => {
365 this._typeDecorationsPending.delete(type);
366 decorator.decorate(this.uiSourceCode(), this._textEditor);
367 });
368 },
369
370 _decorateAllTypes: function()
371 {
372 var extensions = self.runtime.extensions(WebInspector.UISourceCodeFrame. LineDecorator);
373 extensions.forEach(extension => this._decorateTypeThrottled(extension.de scriptor()["decoratorType"]));
374 },
375
333 __proto__: WebInspector.SourceFrame.prototype 376 __proto__: WebInspector.SourceFrame.prototype
334 } 377 }
335 378
336 WebInspector.UISourceCodeFrame._iconClassPerLevel = {}; 379 WebInspector.UISourceCodeFrame._iconClassPerLevel = {};
337 WebInspector.UISourceCodeFrame._iconClassPerLevel[WebInspector.UISourceCode.Mess age.Level.Error] = "error-icon"; 380 WebInspector.UISourceCodeFrame._iconClassPerLevel[WebInspector.UISourceCode.Mess age.Level.Error] = "error-icon";
338 WebInspector.UISourceCodeFrame._iconClassPerLevel[WebInspector.UISourceCode.Mess age.Level.Warning] = "warning-icon"; 381 WebInspector.UISourceCodeFrame._iconClassPerLevel[WebInspector.UISourceCode.Mess age.Level.Warning] = "warning-icon";
339 382
340 WebInspector.UISourceCodeFrame._lineClassPerLevel = {}; 383 WebInspector.UISourceCodeFrame._lineClassPerLevel = {};
341 WebInspector.UISourceCodeFrame._lineClassPerLevel[WebInspector.UISourceCode.Mess age.Level.Error] = "text-editor-line-with-error"; 384 WebInspector.UISourceCodeFrame._lineClassPerLevel[WebInspector.UISourceCode.Mess age.Level.Error] = "text-editor-line-with-error";
342 WebInspector.UISourceCodeFrame._lineClassPerLevel[WebInspector.UISourceCode.Mess age.Level.Warning] = "text-editor-line-with-warning"; 385 WebInspector.UISourceCodeFrame._lineClassPerLevel[WebInspector.UISourceCode.Mess age.Level.Warning] = "text-editor-line-with-warning";
343 386
344 /** 387 /**
388 * @interface
389 */
390 WebInspector.UISourceCodeFrame.LineDecorator = function() { }
391
392 WebInspector.UISourceCodeFrame.LineDecorator.prototype = {
393 /**
394 * @param {!WebInspector.UISourceCode} uiSourceCode
395 * @param {!WebInspector.CodeMirrorTextEditor} textEditor
396 */
397 decorate: function(uiSourceCode, textEditor) { }
398 }
399
400 /**
345 * @constructor 401 * @constructor
346 * @param {!WebInspector.UISourceCode.Message} message 402 * @param {!WebInspector.UISourceCode.Message} message
347 */ 403 */
348 WebInspector.UISourceCodeFrame.RowMessage = function(message) 404 WebInspector.UISourceCodeFrame.RowMessage = function(message)
349 { 405 {
350 this._message = message; 406 this._message = message;
351 this._repeatCount = 1; 407 this._repeatCount = 1;
352 this.element = createElementWithClass("div", "text-editor-row-message"); 408 this.element = createElementWithClass("div", "text-editor-row-message");
353 this._icon = this.element.createChild("label", "", "dt-icon-label"); 409 this._icon = this.element.createChild("label", "", "dt-icon-label");
354 this._icon.type = WebInspector.UISourceCodeFrame._iconClassPerLevel[message. level()]; 410 this._icon.type = WebInspector.UISourceCodeFrame._iconClassPerLevel[message. level()];
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 603
548 /** 604 /**
549 * @param {!WebInspector.UISourceCode.Message} a 605 * @param {!WebInspector.UISourceCode.Message} a
550 * @param {!WebInspector.UISourceCode.Message} b 606 * @param {!WebInspector.UISourceCode.Message} b
551 * @return {number} 607 * @return {number}
552 */ 608 */
553 WebInspector.UISourceCode.Message.messageLevelComparator = function(a, b) 609 WebInspector.UISourceCode.Message.messageLevelComparator = function(a, b)
554 { 610 {
555 return WebInspector.UISourceCode.Message._messageLevelPriority[a.level()] - WebInspector.UISourceCode.Message._messageLevelPriority[b.level()]; 611 return WebInspector.UISourceCode.Message._messageLevelPriority[a.level()] - WebInspector.UISourceCode.Message._messageLevelPriority[b.level()];
556 } 612 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698