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

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

Issue 1748993002: DevTools: Initial implementation of line-level CPU profile. (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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/devtools/front_end/timeline/TimelineUIUtils.js
diff --git a/third_party/WebKit/Source/devtools/front_end/timeline/TimelineUIUtils.js b/third_party/WebKit/Source/devtools/front_end/timeline/TimelineUIUtils.js
index 7cdc39252c448b7e16b557380db3dcd374154e7e..a69268d31b60d690496e6cf1554a9937562246cb 100644
--- a/third_party/WebKit/Source/devtools/front_end/timeline/TimelineUIUtils.js
+++ b/third_party/WebKit/Source/devtools/front_end/timeline/TimelineUIUtils.js
@@ -2101,3 +2101,36 @@ WebInspector.TimelineUIUtils.eventWarning = function(event, warningType)
}
return span;
}
+
+/**
+ * @constructor
+ * @implements {WebInspector.UISourceCodeFrame.LineDecorator}
+ */
+WebInspector.TimelineUIUtils.PerformanceLineDecorator = function()
+{
+}
+
+WebInspector.TimelineUIUtils.PerformanceLineDecorator.type = "performance";
+
+WebInspector.TimelineUIUtils.PerformanceLineDecorator.prototype = {
+ /**
+ * @override
+ * @param {!WebInspector.UISourceCode} uiSourceCode
+ * @param {!WebInspector.CodeMirrorTextEditor} textEditor
+ */
+ decorate: function(uiSourceCode, textEditor)
+ {
+ var type = WebInspector.TimelineUIUtils.PerformanceLineDecorator.type;
+ var decorations = uiSourceCode.lineDecorations(type) || [];
+ textEditor.resetGutterDecorations(type);
+ for (var decoration of decorations) {
+ var time = /** @type {number} */ (decoration.data());
+ var text = WebInspector.UIString("%.1f\xa0ms", time);
+ var intensity = Number.constrain(Math.log10(1 + 2 * time) / 5, 0.02, 1);
+ var element = createElementWithClass("div", "text-editor-line-marker-performance");
+ element.textContent = text;
+ element.style.backgroundColor = `rgba(255, 0, 0, ${intensity.toFixed(3)})`;
+ textEditor.setGutterDecoration(decoration.line(), decoration.type(), element);
+ }
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698