Skip to content

Commit 22daa72

Browse files
finnurbrekiDevtools-frontend LUCI CQ
authored andcommitted
[CustomTracks]: Move '-- Custom track' to a separate subtitle.
This change de-emphasizes the '--Custom track' part in the track names by shrinking the font and making it italic. Bug: 427952360 Change-Id: I7b437a3c7cf1b1cf133db72c49971c850eaa69df Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6771946 Reviewed-by: Mathias Bynens <[email protected]> Commit-Queue: Finnur Thorarinsson <[email protected]>
1 parent fc9eb7d commit 22daa72

File tree

6 files changed

+34
-26
lines changed

6 files changed

+34
-26
lines changed

front_end/panels/timeline/ExtensionTrackAppender.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@ import * as Extensions from './extensions/extensions.js';
1717

1818
const UIStrings = {
1919
/**
20-
* @description The name of a track, which is a horizontal division of the timeline, synonym with "swimlane".
21-
* @example {A track name} PH1
20+
* @description The subtitle to show (by the side of the track name).
2221
*/
23-
customTrackName: '{PH1} — Custom track',
22+
customTrackSubtitle: '— Custom',
2423
} as const;
2524

2625
const str_ = i18n.i18n.registerUIStrings('panels/timeline/ExtensionTrackAppender.ts', UIStrings);
@@ -55,12 +54,13 @@ export class ExtensionTrackAppender implements TrackAppender {
5554
*/
5655
#appendTopLevelHeaderAtLevel(currentLevel: number, expanded?: boolean): void {
5756
const style = buildGroupStyle({shareHeaderLine: false, collapsible: true});
58-
const headerTitle = i18nString(UIStrings.customTrackName, {PH1: this.#extensionTopLevelTrack.name});
57+
const headerTitle = this.#extensionTopLevelTrack.name;
5958
const jsLogContext = this.#extensionTopLevelTrack.name === '🅰️ Angular' ? VisualLoggingTrackName.ANGULAR_TRACK :
6059
VisualLoggingTrackName.EXTENSION;
6160
const group = buildTrackHeader(
6261
jsLogContext, currentLevel, headerTitle, style,
6362
/* selectable= */ true, expanded);
63+
group.subtitle = i18nString(UIStrings.customTrackSubtitle);
6464
this.#compatibilityBuilder.registerTrackForGroup(group, this);
6565
}
6666

front_end/panels/timeline/TimelineFlameChartDataProvider.test.ts

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -158,26 +158,14 @@ describeWithEnvironment('TimelineFlameChartDataProvider', function() {
158158
const {parsedTrace} = await TraceLoader.traceEngine(this, 'extension-tracks-and-marks.json.gz');
159159
const entityMapper = new Timeline.Utils.EntityMapper.EntityMapper(parsedTrace);
160160
dataProvider.setModel(parsedTrace, entityMapper);
161-
const groupNames = dataProvider.timelineData().groups.map(g => g.name);
162-
assert.deepEqual(
163-
groupNames,
164-
[
165-
'Frames',
166-
'Timings',
167-
'Interactions',
168-
'A track group — Custom track',
169-
'Another Extension Track',
170-
'An Extension Track — Custom track',
171-
'TimeStamp track — Custom track',
172-
'Main — http://localhost:3000/',
173-
'Thread pool',
174-
'Thread pool worker 1',
175-
'Thread pool worker 2',
176-
'Thread pool worker 3',
177-
'StackSamplingProfiler',
178-
'GPU',
179-
],
180-
);
161+
const groupNames = dataProvider.timelineData().groups.map(g => [g.name, g.subtitle]);
162+
assert.deepEqual(groupNames, [
163+
['Frames', undefined], ['Timings', undefined], ['Interactions', undefined], ['A track group', '— Custom'],
164+
['Another Extension Track', undefined], ['An Extension Track', '— Custom'], ['TimeStamp track', '— Custom'],
165+
['Main — http://localhost:3000/', undefined], ['Thread pool', undefined], ['Thread pool worker 1', undefined],
166+
['Thread pool worker 2', undefined], ['Thread pool worker 3', undefined], ['StackSamplingProfiler', undefined],
167+
['GPU', undefined]
168+
]);
181169
});
182170

183171
it('can return the FlameChart group for a given event', async function() {

front_end/panels/timeline/track_appenders/ExtensionTrackAppender.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,16 @@ describeWithEnvironment('ExtensionTrackAppender', function() {
5151
describe('appendTrackAtLevel', function() {
5252
it('creates flamechart groups for the Extension tracks properly', function() {
5353
assert.lengthOf(flameChartData.groups, 4);
54-
assert.strictEqual(flameChartData.groups[0].name, 'A track group — Custom track');
54+
assert.strictEqual(flameChartData.groups[0].name, 'A track group');
55+
assert.strictEqual(flameChartData.groups[0].subtitle, '— Custom');
5556
assert.strictEqual(flameChartData.groups[0].startLevel, 0);
5657
assert.strictEqual(flameChartData.groups[0].style.nestingLevel, 0);
5758
assert.strictEqual(flameChartData.groups[1].name, 'Another Extension Track');
59+
assert.isUndefined(flameChartData.groups[1].subtitle);
5860
assert.strictEqual(flameChartData.groups[1].startLevel, 0);
5961
assert.strictEqual(flameChartData.groups[1].style.nestingLevel, 1);
60-
assert.strictEqual(flameChartData.groups[2].name, 'An Extension Track — Custom track');
62+
assert.strictEqual(flameChartData.groups[2].name, 'An Extension Track');
63+
assert.strictEqual(flameChartData.groups[2].subtitle, '— Custom');
6164
assert.strictEqual(flameChartData.groups[2].startLevel, 1);
6265
assert.strictEqual(flameChartData.groups[2].style.nestingLevel, 0);
6366
});

front_end/ui/legacy/components/perf_ui/FlameChart.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ import {type Calculator, TimelineGrid} from './TimelineGrid.js';
5252
*/
5353
const KEYBOARD_FAKED_CONTEXT_MENU_DETAIL = -1;
5454

55+
/**
56+
* The adjustments needed for the subtitle font (based off of the default font).
57+
*/
58+
const SUBTITLE_FONT_SIZE_AND_STYLE = 'italic 10px';
59+
5560
const UIStrings = {
5661
/**
5762
*@description Aria alert used to notify the user when an event has been selected because they tabbed into a group.
@@ -121,6 +126,7 @@ export const ARROW_SIDE = 8;
121126
const EXPANSION_ARROW_INDENT = HEADER_LEFT_PADDING + ARROW_SIDE / 2;
122127
const HEADER_LABEL_X_PADDING = 3;
123128
const HEADER_LABEL_Y_PADDING = 2;
129+
const PADDING_BETWEEN_TITLE_AND_SUBTITLE = 6;
124130

125131
// The width of each of the edit mode icons.
126132
export const EDIT_ICON_WIDTH = 16;
@@ -310,6 +316,7 @@ export class FlameChart extends Common.ObjectWrapper.eventMixin<EventTypes, type
310316
#tooltipPopoverYAdjustment = 0;
311317

312318
#font: string;
319+
#subtitleFont: string;
313320
#groupTreeRoot?: GroupTreeNode|null;
314321
#searchResultEntryIndex: number|null = null;
315322
#inTrackConfigEditMode = false;
@@ -328,6 +335,7 @@ export class FlameChart extends Common.ObjectWrapper.eventMixin<EventTypes, type
328335
optionalConfig: OptionalFlameChartConfig = {}) {
329336
super(true);
330337
this.#font = `${DEFAULT_FONT_SIZE} ${getFontFamilyForCanvas()}`;
338+
this.#subtitleFont = `${SUBTITLE_FONT_SIZE_AND_STYLE} ${getFontFamilyForCanvas()}`;
331339
this.registerRequiredCSS(flameChartStyles);
332340
this.registerRequiredCSS(UI.inspectorCommonStyles);
333341

@@ -2765,6 +2773,14 @@ export class FlameChart extends Common.ObjectWrapper.eventMixin<EventTypes, type
27652773
const titleStart = iconsWidth + EXPANSION_ARROW_INDENT * (group.style.nestingLevel + 1) + ARROW_SIDE / 2 +
27662774
HEADER_LABEL_X_PADDING;
27672775
context.fillText(group.name, titleStart, offset + group.style.height - this.textBaseline);
2776+
if (group.subtitle) {
2777+
const titleMetrics = context.measureText(group.name);
2778+
context.font = this.#subtitleFont;
2779+
context.fillText(
2780+
group.subtitle, titleStart + titleMetrics.width + PADDING_BETWEEN_TITLE_AND_SUBTITLE,
2781+
offset + group.style.height - this.textBaseline);
2782+
context.font = this.#font;
2783+
}
27682784
if (this.#inTrackConfigEditMode && group.hidden) {
27692785
// Draw a strikethrough line for the hidden tracks.
27702786
context.fillRect(
@@ -4362,6 +4378,7 @@ export interface EventTypes {
43624378

43634379
export interface Group {
43644380
name: Common.UIString.LocalizedString;
4381+
subtitle?: Common.UIString.LocalizedString;
43654382
startLevel: number;
43664383
expanded?: boolean;
43674384
hidden?: boolean;
18 KB
Loading
-3.22 KB
Loading

0 commit comments

Comments
 (0)