Skip to content

Commit 0b67d2d

Browse files
jackfranklinDevtools-frontend LUCI CQ
authored andcommitted
RPP: add docs and small refactor to maybeAddOutlines
Bug: none Change-Id: I6fc8b64a89c28798d7105057bc83c6c827055422 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6074372 Reviewed-by: Paul Irish <[email protected]> Auto-Submit: Jack Franklin <[email protected]> Commit-Queue: Paul Irish <[email protected]>
1 parent 6bef38a commit 0b67d2d

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

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

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2265,23 +2265,30 @@ export class FlameChart extends Common.ObjectWrapper.eventMixin<EventTypes, type
22652265
this.#drawEventRect(context, timelineData, entryIndex);
22662266
}
22672267

2268-
this.#maybeAddOutlines(context, color, shouldDim);
2268+
if (!shouldDim) {
2269+
// In some scenarios we want to draw outlines around events for added visual contrast.
2270+
// But we only do this if the events are not being dimmed.
2271+
this.#maybeAddOutlines(context, color);
2272+
}
2273+
22692274
context.fillStyle = color;
22702275
context.fill();
22712276
context.restore();
22722277
}
22732278

2274-
/** In some dim/highlight situations, put a darker outline around the rect for added visual contrast */
2275-
#maybeAddOutlines(context: CanvasRenderingContext2D, color: string, shouldDim: boolean): void {
2276-
// We only want to add outlines when in a dimming state
2279+
/**
2280+
* Adds dark outlines to the paths being drawn onto the canvas context if:
2281+
* 1. We are in a dimming state
2282+
* 2. The user has searched the flamechart using Cmd/Ctrl-F
2283+
*
2284+
* @param context - the canvas context to call stroke() on. Assumes there are a series of paths ready to be stroked.
2285+
* @param color - the fill color being used for the paths in the canvas context.
2286+
*/
2287+
#maybeAddOutlines(context: CanvasRenderingContext2D, color: string): void {
2288+
// We only want to add outlines when in a dimming state and the user has searched for something.
22772289
if (!this.entryIndicesToNotDim && !this.#searchResultEntries) {
22782290
return;
22792291
}
2280-
// We only want to add outlines on highlighted/saturated entries (aka not dimmed/grayscale)
2281-
if (shouldDim) {
2282-
return;
2283-
}
2284-
22852292
// This foregroundColor is near-black in light mode, and vice-versa. Color mix so it's a good contrast, but still has the base flavor.
22862293
const foregroundColor = ThemeSupport.ThemeSupport.instance().getComputedValue('--sys-color-on-base');
22872294
context.strokeStyle = `color-mix(in srgb, ${color}, ${foregroundColor} 60%)`;

0 commit comments

Comments
 (0)