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

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: remove JSSF to sdk dependency 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.Profile InfoUpdated, this._updateProfileInfo, this);
44 this._updateStyle(); 45 this._updateStyle();
45 46
46 this._errorPopoverHelper = new WebInspector.PopoverHelper(this.element, this ._getErrorAnchor.bind(this), this._showErrorPopover.bind(this)); 47 this._errorPopoverHelper = new WebInspector.PopoverHelper(this.element, this ._getErrorAnchor.bind(this), this._showErrorPopover.bind(this));
47 this._errorPopoverHelper.setTimeout(100, 100); 48 this._errorPopoverHelper.setTimeout(100, 100);
48 } 49 }
49 50
50 WebInspector.UISourceCodeFrame.prototype = { 51 WebInspector.UISourceCodeFrame.prototype = {
51 /** 52 /**
52 * @return {!WebInspector.UISourceCode} 53 * @return {!WebInspector.UISourceCode}
53 */ 54 */
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 }, 112 },
112 113
113 /** 114 /**
114 * @override 115 * @override
115 */ 116 */
116 onTextEditorContentLoaded: function() 117 onTextEditorContentLoaded: function()
117 { 118 {
118 WebInspector.SourceFrame.prototype.onTextEditorContentLoaded.call(this); 119 WebInspector.SourceFrame.prototype.onTextEditorContentLoaded.call(this);
119 for (var message of this._uiSourceCode.messages()) 120 for (var message of this._uiSourceCode.messages())
120 this._addMessageToSource(message); 121 this._addMessageToSource(message);
122 this._updateProfileInfo();
121 }, 123 },
122 124
123 /** 125 /**
124 * @override 126 * @override
125 * @param {!WebInspector.TextRange} oldRange 127 * @param {!WebInspector.TextRange} oldRange
126 * @param {!WebInspector.TextRange} newRange 128 * @param {!WebInspector.TextRange} newRange
127 */ 129 */
128 onTextChanged: function(oldRange, newRange) 130 onTextChanged: function(oldRange, newRange)
129 { 131 {
130 WebInspector.SourceFrame.prototype.onTextChanged.call(this, oldRange, ne wRange); 132 WebInspector.SourceFrame.prototype.onTextChanged.call(this, oldRange, ne wRange);
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 }, 325 },
324 326
325 _updateBucketDecorations: function() 327 _updateBucketDecorations: function()
326 { 328 {
327 for (var line in this._rowMessageBuckets) { 329 for (var line in this._rowMessageBuckets) {
328 var bucket = this._rowMessageBuckets[line]; 330 var bucket = this._rowMessageBuckets[line];
329 bucket._updateDecoration(); 331 bucket._updateDecoration();
330 } 332 }
331 }, 333 },
332 334
335 _updateProfileInfo: function()
336 {
337 this._textEditor.resetProfileInfo();
338 var profileInfo = this._uiSourceCode.profileInfo();
339 if (!profileInfo)
340 return;
341 for (var lineInfo of profileInfo) {
342 var lineNumber = lineInfo[0] - 1;
343 var time = lineInfo[1];
344 var intensity = Number.constrain(Math.log10(1 + 2 * time) / 5, 0.02, 1);
lushnikov 2016/03/02 03:19:13 A thought: maybe consider intensity relative to th
alph 2016/03/02 18:34:34 I'll consider it for the next patch. Not sure thou
345 this._textEditor.addProfileInfo(lineNumber, WebInspector.UIString("% .1f\xa0ms", time), intensity);
346 }
347 },
348
333 __proto__: WebInspector.SourceFrame.prototype 349 __proto__: WebInspector.SourceFrame.prototype
334 } 350 }
335 351
336 WebInspector.UISourceCodeFrame._iconClassPerLevel = {}; 352 WebInspector.UISourceCodeFrame._iconClassPerLevel = {};
337 WebInspector.UISourceCodeFrame._iconClassPerLevel[WebInspector.UISourceCode.Mess age.Level.Error] = "error-icon"; 353 WebInspector.UISourceCodeFrame._iconClassPerLevel[WebInspector.UISourceCode.Mess age.Level.Error] = "error-icon";
338 WebInspector.UISourceCodeFrame._iconClassPerLevel[WebInspector.UISourceCode.Mess age.Level.Warning] = "warning-icon"; 354 WebInspector.UISourceCodeFrame._iconClassPerLevel[WebInspector.UISourceCode.Mess age.Level.Warning] = "warning-icon";
339 355
340 WebInspector.UISourceCodeFrame._lineClassPerLevel = {}; 356 WebInspector.UISourceCodeFrame._lineClassPerLevel = {};
341 WebInspector.UISourceCodeFrame._lineClassPerLevel[WebInspector.UISourceCode.Mess age.Level.Error] = "text-editor-line-with-error"; 357 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"; 358 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 563
548 /** 564 /**
549 * @param {!WebInspector.UISourceCode.Message} a 565 * @param {!WebInspector.UISourceCode.Message} a
550 * @param {!WebInspector.UISourceCode.Message} b 566 * @param {!WebInspector.UISourceCode.Message} b
551 * @return {number} 567 * @return {number}
552 */ 568 */
553 WebInspector.UISourceCode.Message.messageLevelComparator = function(a, b) 569 WebInspector.UISourceCode.Message.messageLevelComparator = function(a, b)
554 { 570 {
555 return WebInspector.UISourceCode.Message._messageLevelPriority[a.level()] - WebInspector.UISourceCode.Message._messageLevelPriority[b.level()]; 571 return WebInspector.UISourceCode.Message._messageLevelPriority[a.level()] - WebInspector.UISourceCode.Message._messageLevelPriority[b.level()];
556 } 572 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698