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

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

Issue 1748993002: DevTools: Initial implementation of line-level CPU profile. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: moving around 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 23 matching lines...) Expand all
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 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Working CopyChanged, this._onWorkingCopyChanged, this); 40 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Working CopyChanged, this._onWorkingCopyChanged, this);
41 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Working CopyCommitted, this._onWorkingCopyCommitted, this); 41 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Working CopyCommitted, this._onWorkingCopyCommitted, this);
42 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Message Added, this._onMessageAdded, this); 42 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Message Added, this._onMessageAdded, this);
43 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Message Removed, this._onMessageRemoved, this); 43 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Message Removed, this._onMessageRemoved, this);
44 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.LineMar kerAdded, this._onLineMarkerAdded, this);
45 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.LineMar kerRemoved, this._onLineMarkerRemoved, this);
44 this._updateStyle(); 46 this._updateStyle();
45 47
46 this._errorPopoverHelper = new WebInspector.PopoverHelper(this.element, this ._getErrorAnchor.bind(this), this._showErrorPopover.bind(this)); 48 this._errorPopoverHelper = new WebInspector.PopoverHelper(this.element, this ._getErrorAnchor.bind(this), this._showErrorPopover.bind(this));
47 this._errorPopoverHelper.setTimeout(100, 100); 49 this._errorPopoverHelper.setTimeout(100, 100);
48 } 50 }
49 51
50 WebInspector.UISourceCodeFrame.prototype = { 52 WebInspector.UISourceCodeFrame.prototype = {
51 /** 53 /**
52 * @return {!WebInspector.UISourceCode} 54 * @return {!WebInspector.UISourceCode}
53 */ 55 */
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 }, 113 },
112 114
113 /** 115 /**
114 * @override 116 * @override
115 */ 117 */
116 onTextEditorContentLoaded: function() 118 onTextEditorContentLoaded: function()
117 { 119 {
118 WebInspector.SourceFrame.prototype.onTextEditorContentLoaded.call(this); 120 WebInspector.SourceFrame.prototype.onTextEditorContentLoaded.call(this);
119 for (var message of this._uiSourceCode.messages()) 121 for (var message of this._uiSourceCode.messages())
120 this._addMessageToSource(message); 122 this._addMessageToSource(message);
123 this._populateLineMarkers();
121 }, 124 },
122 125
123 /** 126 /**
124 * @override 127 * @override
125 * @param {!WebInspector.TextRange} oldRange 128 * @param {!WebInspector.TextRange} oldRange
126 * @param {!WebInspector.TextRange} newRange 129 * @param {!WebInspector.TextRange} newRange
127 */ 130 */
128 onTextChanged: function(oldRange, newRange) 131 onTextChanged: function(oldRange, newRange)
129 { 132 {
130 WebInspector.SourceFrame.prototype.onTextChanged.call(this, oldRange, ne wRange); 133 WebInspector.SourceFrame.prototype.onTextChanged.call(this, oldRange, ne wRange);
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 }, 326 },
324 327
325 _updateBucketDecorations: function() 328 _updateBucketDecorations: function()
326 { 329 {
327 for (var line in this._rowMessageBuckets) { 330 for (var line in this._rowMessageBuckets) {
328 var bucket = this._rowMessageBuckets[line]; 331 var bucket = this._rowMessageBuckets[line];
329 bucket._updateDecoration(); 332 bucket._updateDecoration();
330 } 333 }
331 }, 334 },
332 335
336 /**
337 * @param {!WebInspector.Event} event
338 */
339 _onLineMarkerAdded: function(event)
340 {
341 var marker = /** @type {!WebInspector.UISourceCode.LineMarker} */ (event .data);
342 var decorator = WebInspector.UISourceCodeFrame._lineMarkerDecorator(mark er.type());
343 if (!decorator)
344 return;
345 this._textEditor.setGutterMarker(marker.line(), marker.type(), decorator .decorate(marker.data()));
346 },
347
348 /**
349 * @param {!WebInspector.Event} event
350 */
351 _onLineMarkerRemoved: function(event)
352 {
353 var marker = /** @type {!WebInspector.UISourceCode.LineMarker} */ (event .data);
354 this._textEditor.setGutterMarker(marker.line(), marker.type(), null);
355 },
356
357 _populateLineMarkers: function()
358 {
359 for (var marker of this.uiSourceCode().lineMarkers()) {
360 var decorator = WebInspector.UISourceCodeFrame._lineMarkerDecorator( marker.type());
361 if (!decorator)
362 continue;
363 this._textEditor.setGutterMarker(marker.line(), marker.type(), decor ator.decorate(marker.data()));
364 }
365 },
366
333 __proto__: WebInspector.SourceFrame.prototype 367 __proto__: WebInspector.SourceFrame.prototype
334 } 368 }
335 369
336 WebInspector.UISourceCodeFrame._iconClassPerLevel = {}; 370 WebInspector.UISourceCodeFrame._iconClassPerLevel = {};
337 WebInspector.UISourceCodeFrame._iconClassPerLevel[WebInspector.UISourceCode.Mess age.Level.Error] = "error-icon"; 371 WebInspector.UISourceCodeFrame._iconClassPerLevel[WebInspector.UISourceCode.Mess age.Level.Error] = "error-icon";
338 WebInspector.UISourceCodeFrame._iconClassPerLevel[WebInspector.UISourceCode.Mess age.Level.Warning] = "warning-icon"; 372 WebInspector.UISourceCodeFrame._iconClassPerLevel[WebInspector.UISourceCode.Mess age.Level.Warning] = "warning-icon";
339 373
340 WebInspector.UISourceCodeFrame._lineClassPerLevel = {}; 374 WebInspector.UISourceCodeFrame._lineClassPerLevel = {};
341 WebInspector.UISourceCodeFrame._lineClassPerLevel[WebInspector.UISourceCode.Mess age.Level.Error] = "text-editor-line-with-error"; 375 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"; 376 WebInspector.UISourceCodeFrame._lineClassPerLevel[WebInspector.UISourceCode.Mess age.Level.Warning] = "text-editor-line-with-warning";
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 581
548 /** 582 /**
549 * @param {!WebInspector.UISourceCode.Message} a 583 * @param {!WebInspector.UISourceCode.Message} a
550 * @param {!WebInspector.UISourceCode.Message} b 584 * @param {!WebInspector.UISourceCode.Message} b
551 * @return {number} 585 * @return {number}
552 */ 586 */
553 WebInspector.UISourceCode.Message.messageLevelComparator = function(a, b) 587 WebInspector.UISourceCode.Message.messageLevelComparator = function(a, b)
554 { 588 {
555 return WebInspector.UISourceCode.Message._messageLevelPriority[a.level()] - WebInspector.UISourceCode.Message._messageLevelPriority[b.level()]; 589 return WebInspector.UISourceCode.Message._messageLevelPriority[a.level()] - WebInspector.UISourceCode.Message._messageLevelPriority[b.level()];
556 } 590 }
591
592 /**
593 * @param {string} type
594 * @return {?WebInspector.UISourceCodeFrame.Decorator}
595 */
596 WebInspector.UISourceCodeFrame._lineMarkerDecorator = function(type)
597 {
598 if (!WebInspector.UISourceCodeFrame._lineMarkerDecorator._decorators) {
599 WebInspector.UISourceCodeFrame._lineMarkerDecorator._decorators = new Ma p();
600 WebInspector.UISourceCodeFrame._lineMarkerDecorator._decorators.set("per formance", new WebInspector.UISourceCodeFrame.PerformanceDecorator());
pfeldman 2016/03/03 02:38:42 this should move to the profiler module.
alph 2016/03/05 00:37:08 Done.
601 }
602 return WebInspector.UISourceCodeFrame._lineMarkerDecorator._decorators.get(t ype) || null;
603 }
604
605 /**
606 * @interface
607 */
608 WebInspector.UISourceCodeFrame.Decorator = function() { }
609
610 WebInspector.UISourceCodeFrame.Decorator.prototype = {
611 /**
612 * @param {?} data
613 * @return {!Element}
614 */
615 decorate: function(data) { }
616 }
617
618 /**
619 * @constructor
620 * @implements {WebInspector.UISourceCodeFrame.Decorator}
621 */
622 WebInspector.UISourceCodeFrame.PerformanceDecorator = function()
623 {
624 }
625
626 WebInspector.UISourceCodeFrame.PerformanceDecorator.prototype = {
627 /**
628 * @override
629 * @param {?} data
630 * @return {!Element}
631 */
632 decorate: function(data)
633 {
634 var info = /** @type {!{text: string, intensity: number}} */ (data);
635 var element = createElementWithClass("div", "text-editor-performance-inf o");
636 element.textContent = info.text;
637 element.style.backgroundColor = `rgba(255, 0, 0, ${info.intensity.toFixe d(3)})`;
638 return element;
639 }
640 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698