Commit b7212aff authored by Benedikt Meurer's avatar Benedikt Meurer Committed by Commit Bot

[devtools] Cleanup return type of Timeline.TimelineUIUtils.eventStyle().

In `Timeline.TimelineUIUtils.eventStyle()` we used to return either a
`Timeline.TimelineUIUtils` instance or a custom object literal, we even
put a custom type annotation here to make that pass Closure type
checking. But it's better to just use `Timeline.TimelineRecordStyle`
consistently here, and also faster.

Change-Id: Ie8834b7a4f8862fde3d2d7c6d6c5ee04dec76b53
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1845752
Auto-Submit: Benedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Yang Guo <yangguo@chromium.org>
Reviewed-by: default avatarYang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#703649}
parent 90dbd5aa
......@@ -273,13 +273,13 @@ Timeline.TimelineUIUtils = class {
/**
* @param {!SDK.TracingModel.Event} event
* @return {!{title: string, category: !Timeline.TimelineCategory}}
* @return {!Timeline.TimelineRecordStyle}
*/
static eventStyle(event) {
const eventStyles = Timeline.TimelineUIUtils._initEventStyles();
if (event.hasCategory(TimelineModel.TimelineModel.Category.Console) ||
event.hasCategory(TimelineModel.TimelineModel.Category.UserTiming)) {
return {title: event.name, category: Timeline.TimelineUIUtils.categories()['scripting']};
return new Timeline.TimelineRecordStyle(event.name, Timeline.TimelineUIUtils.categories()['scripting']);
}
if (event.hasCategory(TimelineModel.TimelineModel.Category.LatencyInfo)) {
......@@ -288,7 +288,8 @@ Timeline.TimelineUIUtils = class {
const inputEventType = event.name.startsWith(prefix) ? event.name.substr(prefix.length) : event.name;
const displayName = Timeline.TimelineUIUtils.inputEventDisplayName(
/** @type {!TimelineModel.TimelineIRModel.InputEvents} */ (inputEventType));
return {title: displayName || inputEventType, category: Timeline.TimelineUIUtils.categories()['scripting']};
return new Timeline.TimelineRecordStyle(
displayName || inputEventType, Timeline.TimelineUIUtils.categories()['scripting']);
}
let result = eventStyles[event.name];
if (!result) {
......@@ -2051,19 +2052,16 @@ Timeline.TimelineUIUtils = class {
}
};
/**
* @unrestricted
*/
Timeline.TimelineRecordStyle = class {
/**
* @param {string} title
* @param {!Timeline.TimelineCategory} category
* @param {boolean=} hidden
*/
constructor(title, category, hidden) {
constructor(title, category, hidden = false) {
this.title = title;
this.category = category;
this.hidden = !!hidden;
this.hidden = hidden;
}
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment