Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visually distinguish user timing marks from React events #19663

Merged
merged 1 commit into from Aug 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -26,11 +26,12 @@ import {
import {
COLORS,
EVENT_ROW_PADDING,
EVENT_DIAMETER,
USER_TIMING_MARK_SIZE,
BORDER_SIZE,
} from './constants';

const ROW_HEIGHT_FIXED = EVENT_ROW_PADDING + EVENT_DIAMETER + EVENT_ROW_PADDING;
const ROW_HEIGHT_FIXED =
EVENT_ROW_PADDING + USER_TIMING_MARK_SIZE + EVENT_ROW_PADDING;

export class UserTimingMarksView extends View {
_marks: UserTimingMark[];
Expand Down Expand Up @@ -81,13 +82,15 @@ export class UserTimingMarksView extends View {
const {timestamp} = mark;

const x = timestampToPosition(timestamp, scaleFactor, frame);
const radius = EVENT_DIAMETER / 2;
const size = USER_TIMING_MARK_SIZE;
const halfSize = size / 2;

const markRect: Rect = {
origin: {
x: x - radius,
x: x - halfSize,
y: baseY,
},
size: {width: EVENT_DIAMETER, height: EVENT_DIAMETER},
size: {width: size, height: size},
};
if (!rectIntersectsRect(markRect, rect)) {
return; // Not in view
Expand All @@ -98,11 +101,14 @@ export class UserTimingMarksView extends View {
: COLORS.USER_TIMING;

if (fillStyle !== null) {
const y = markRect.origin.y + radius;
const y = baseY + halfSize;

context.beginPath();
context.fillStyle = fillStyle;
context.arc(x, y, radius, 0, 2 * Math.PI);
context.moveTo(x, y - halfSize);
context.lineTo(x + halfSize, y);
context.lineTo(x, y + halfSize);
context.lineTo(x - halfSize, y);
context.fill();
}
}
Expand Down Expand Up @@ -198,7 +204,7 @@ export class UserTimingMarksView extends View {
);
const hoverTimestamp = positionToTimestamp(location.x, scaleFactor, frame);
const markTimestampAllowance = widthToDuration(
EVENT_DIAMETER / 2,
USER_TIMING_MARK_SIZE / 2,
scaleFactor,
);

Expand Down
Expand Up @@ -33,6 +33,7 @@ export const MIN_INTERVAL_SIZE_PX = 70;

export const EVENT_ROW_PADDING = 4;
export const EVENT_DIAMETER = 6;
export const USER_TIMING_MARK_SIZE = 8;
export const REACT_MEASURE_HEIGHT = 9;
export const BORDER_SIZE = 1;

Expand Down