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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/timeline/TimelineUIUtils.js

Issue 1811773002: DevTools: Use live location for line level profile presentation. (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) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * Copyright (C) 2012 Intel Inc. All rights reserved. 3 * Copyright (C) 2012 Intel Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 2092 matching lines...) Expand 10 before | Expand all | Expand 10 after
2103 span.createTextChild(WebInspector.UIString(": %s", eventData["deoptReaso n"])); 2103 span.createTextChild(WebInspector.UIString(": %s", eventData["deoptReaso n"]));
2104 break; 2104 break;
2105 default: 2105 default:
2106 console.assert(false, "Unhandled TimelineModel.WarningType"); 2106 console.assert(false, "Unhandled TimelineModel.WarningType");
2107 } 2107 }
2108 return span; 2108 return span;
2109 } 2109 }
2110 2110
2111 /** 2111 /**
2112 * @constructor 2112 * @constructor
2113 * @param {!WebInspector.DebuggerModel.Location} rawLocation
2114 * @param {number} time
2115 */
2116 WebInspector.TimelineUIUtils.LineLevelProfilePresentation = function(rawLocation , time)
2117 {
2118 this._time = time;
2119 WebInspector.debuggerWorkspaceBinding.createLiveLocation(rawLocation, this.u pdateLocation.bind(this));
2120 }
2121
2122 WebInspector.TimelineUIUtils.LineLevelProfilePresentation.prototype = {
2123 /**
2124 * @param {!WebInspector.LiveLocation} liveLocation
2125 */
2126 updateLocation: function(liveLocation)
2127 {
2128 if (this._uiLocation)
2129 this._uiLocation.uiSourceCode.removeLineDecoration(this._uiLocation. lineNumber, WebInspector.TimelineUIUtils.PerformanceLineDecorator.type);
2130 this._uiLocation = liveLocation.uiLocation();
2131 if (this._uiLocation)
2132 this._uiLocation.uiSourceCode.addLineDecoration(this._uiLocation.lin eNumber, WebInspector.TimelineUIUtils.PerformanceLineDecorator.type, this._time) ;
2133 }
2134 }
2135
2136 /**
2137 * @constructor
2113 * @implements {WebInspector.UISourceCodeFrame.LineDecorator} 2138 * @implements {WebInspector.UISourceCodeFrame.LineDecorator}
2114 */ 2139 */
2115 WebInspector.TimelineUIUtils.PerformanceLineDecorator = function() 2140 WebInspector.TimelineUIUtils.PerformanceLineDecorator = function()
2116 { 2141 {
2117 } 2142 }
2118 2143
2119 WebInspector.TimelineUIUtils.PerformanceLineDecorator.type = "performance"; 2144 WebInspector.TimelineUIUtils.PerformanceLineDecorator.type = "performance";
2120 2145
2121 WebInspector.TimelineUIUtils.PerformanceLineDecorator.prototype = { 2146 WebInspector.TimelineUIUtils.PerformanceLineDecorator.prototype = {
2122 /** 2147 /**
2123 * @override 2148 * @override
2124 * @param {!WebInspector.UISourceCode} uiSourceCode 2149 * @param {!WebInspector.UISourceCode} uiSourceCode
2125 * @param {!WebInspector.CodeMirrorTextEditor} textEditor 2150 * @param {!WebInspector.CodeMirrorTextEditor} textEditor
2126 */ 2151 */
2127 decorate: function(uiSourceCode, textEditor) 2152 decorate: function(uiSourceCode, textEditor)
2128 { 2153 {
2129 var type = WebInspector.TimelineUIUtils.PerformanceLineDecorator.type; 2154 var type = WebInspector.TimelineUIUtils.PerformanceLineDecorator.type;
2130 var decorations = uiSourceCode.lineDecorations(type) || []; 2155 var decorations = uiSourceCode.lineDecorations(type);
2131 textEditor.resetGutterDecorations(type); 2156 textEditor.resetGutterDecorations(type);
2132 for (var decoration of decorations) { 2157 if (!decorations)
2158 return;
2159 for (var decoration of decorations.values()) {
2133 var time = /** @type {number} */ (decoration.data()); 2160 var time = /** @type {number} */ (decoration.data());
2134 var text = WebInspector.UIString("%.1f\xa0ms", time); 2161 var text = WebInspector.UIString("%.1f\xa0ms", time);
2135 var intensity = Number.constrain(Math.log10(1 + 2 * time) / 5, 0.02, 1); 2162 var intensity = Number.constrain(Math.log10(1 + 2 * time) / 5, 0.02, 1);
2136 var element = createElementWithClass("div", "text-editor-line-marker -performance"); 2163 var element = createElementWithClass("div", "text-editor-line-marker -performance");
2137 element.textContent = text; 2164 element.textContent = text;
2138 element.style.backgroundColor = `hsla(44, 100%, 50%, ${intensity.toF ixed(3)})`; 2165 element.style.backgroundColor = `hsla(44, 100%, 50%, ${intensity.toF ixed(3)})`;
2139 textEditor.setGutterDecoration(decoration.line(), decoration.type(), element); 2166 textEditor.setGutterDecoration(decoration.line(), decoration.type(), element);
2140 } 2167 }
2141 } 2168 }
2142 } 2169 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698