-
Notifications
You must be signed in to change notification settings - Fork 462
Expand file tree
/
Copy pathmarker-styles.ts
More file actions
239 lines (227 loc) · 5.52 KB
/
marker-styles.ts
File metadata and controls
239 lines (227 loc) · 5.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import * as colors from 'photon-colors';
import type { CssPixels, Marker } from 'firefox-profiler/types';
import { maybeLightDark } from '../utils/dark-mode';
type MarkerStyle = {
readonly top: CssPixels;
readonly height: CssPixels;
readonly _background: string | [string, string];
readonly getBackground: () => string;
readonly squareCorners: boolean;
readonly _borderLeft: null | string | [string, string];
readonly hasBorderLeft: () => boolean;
readonly getBorderLeft: () => string;
readonly _borderRight: null | string | [string, string];
readonly hasBorderRight: () => boolean;
readonly getBorderRight: () => string;
};
const defaultStyle: MarkerStyle = {
top: 0,
height: 6,
_background: ['black', colors.GREY_40],
getBackground: function () {
return maybeLightDark(this._background);
},
squareCorners: false,
_borderLeft: null,
hasBorderLeft: function () {
return this._borderLeft !== null;
},
getBorderLeft: function () {
return maybeLightDark(this._borderLeft as string | [string, string]);
},
_borderRight: null,
hasBorderRight: function () {
return this._borderRight !== null;
},
getBorderRight: function () {
return maybeLightDark(this._borderRight as string | [string, string]);
},
};
const gcStyle = {
...defaultStyle,
top: 6,
_background: colors.ORANGE_50,
};
const ccStyle = {
...gcStyle,
// This is a paler orange to distinguish CC from GC.
_background: '#ffc600',
};
/**
* Get the marker style. Start off by looking at the marker name, then fallback to
* the marker type.
*/
export function getMarkerStyle(marker: Marker): MarkerStyle {
const { data, name } = marker;
if (name in markerStyles) {
return markerStyles[name];
}
if (data && data.type in markerStyles) {
return markerStyles[data.type];
}
return markerStyles.default;
}
const markerStyles: { readonly [styleName: string]: MarkerStyle } = {
default: defaultStyle,
RefreshDriverTick: {
...defaultStyle,
_background: 'rgba(237, 237, 240, 0.05)',
height: 18,
squareCorners: true,
},
RD: {
...defaultStyle,
_background: 'rgba(237, 237, 240, 0.05)',
height: 18,
squareCorners: true,
},
// Scripts is renamed to 'requestAnimationFrame callbacks' but keeping this
// here for backwards compatibility.
Scripts: {
...defaultStyle,
_background: colors.ORANGE_70,
top: 6,
},
'requestAnimationFrame callbacks': {
...defaultStyle,
_background: colors.ORANGE_70,
top: 6,
},
Styles: {
...defaultStyle,
_background: [colors.TEAL_50, colors.TEAL_70],
top: 7,
},
FireScrollEvent: {
...defaultStyle,
_background: colors.ORANGE_70,
top: 7,
},
Reflow: {
...defaultStyle,
_background: colors.BLUE_50,
top: 7,
},
DispatchSynthMouseMove: {
...defaultStyle,
_background: colors.ORANGE_70,
top: 8,
},
DisplayList: {
...defaultStyle,
_background: colors.PURPLE_50,
top: 9,
},
LayerBuilding: {
...defaultStyle,
_background: colors.ORANGE_50,
top: 9,
},
Rasterize: {
...defaultStyle,
_background: [colors.GREEN_50, colors.GREEN_60],
top: 10,
},
ForwardTransaction: {
...defaultStyle,
_background: colors.RED_70,
top: 11,
},
NotifyDidPaint: {
...defaultStyle,
_background: colors.GREY_40,
top: 12,
},
LayerTransaction: {
...defaultStyle,
_background: colors.RED_70,
},
Composite: {
...defaultStyle,
_background: colors.BLUE_50,
},
Vsync: {
...defaultStyle,
_background: 'rgb(255, 128, 0)',
},
LayerContentGPU: {
...defaultStyle,
_background: 'rgba(0,200,0,0.5)',
},
LayerCompositorGPU: {
...defaultStyle,
_background: 'rgba(0,200,0,0.5)',
},
LayerOther: {
...defaultStyle,
_background: 'rgb(200,0,0)',
},
Jank: {
...defaultStyle,
_background: ['hsl(347, 100%, 60%)', 'hsl(347, 75%, 40%)'],
_borderLeft: [colors.RED_50, colors.RED_70],
_borderRight: [colors.RED_50, colors.RED_70],
squareCorners: true,
},
// BHR markers are displayed in the timeline only if jank markers are
// unavailable. Let's style them like Jank markers.
'BHR-detected hang': {
...defaultStyle,
_background: ['hsl(347, 100%, 60%)', 'hsl(347, 75%, 40%)'],
_borderLeft: [colors.RED_50, colors.RED_70],
_borderRight: [colors.RED_50, colors.RED_70],
squareCorners: true,
},
// Memory:
GCMajor: {
...gcStyle,
squareCorners: true,
top: 0,
},
GCSlice: gcStyle,
GCMinor: gcStyle,
'GC Interrupt': gcStyle,
CC: {
...ccStyle,
squareCorners: true,
top: 0,
},
CCSlice: ccStyle,
ForgetSkippable: ccStyle,
// Note: these Idle* markers have been removed in Firefox 99 (Bug 1752646),
// but they're still here for compatibility for older profiles.
IdleCCSlice: ccStyle,
IdleForgetSkippable: ccStyle,
// IO:
FileIO: {
...defaultStyle,
_background: colors.BLUE_50,
},
IPCOut: {
...defaultStyle,
_background: colors.BLUE_50,
top: 2,
},
SyncIPCOut: {
...defaultStyle,
_background: colors.BLUE_70,
top: 6,
},
IPCIn: {
...defaultStyle,
_background: colors.PURPLE_40,
top: 13,
},
SyncIPCIn: {
...defaultStyle,
_background: colors.PURPLE_70,
top: 17,
},
};
export const overlayFills = {
HOVERED: 'hsla(0,0%,100%,0.3)',
PRESSED: 'rgba(0,0,0,0.3)',
};