Skip to content

Commit

Permalink
Removed redundant width param from drawText utility
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Vaughn committed Aug 3, 2021
1 parent fb887f2 commit 5f21abd
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export class ComponentMeasuresView extends View {

const label = `${componentName} rendered - ${formatDuration(duration)}`;

drawText(label, context, componentMeasureRect, drawableRect, width);
drawText(label, context, componentMeasureRect, drawableRect);

return true;
}
Expand Down Expand Up @@ -162,7 +162,6 @@ export class ComponentMeasuresView extends View {
context,
visibleArea,
visibleArea,
visibleArea.size.width,
'center',
COLORS.TEXT_DIM_COLOR,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class FlamechartStackLayerView extends View {
drawableRect.size.height,
);

drawText(name, context, nodeRect, drawableRect, width);
drawText(name, context, nodeRect, drawableRect);
}

// Render bottom border.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export class NativeEventsView extends View {

const label = `${type} - ${formatDuration(duration)}`;

drawText(label, context, eventRect, drawableRect, width);
drawText(label, context, eventRect, drawableRect);
}

draw(context: CanvasRenderingContext2D) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ export class SuspenseEventsView extends View {
label += ` - ${formatDuration(duration)}`;
}

drawText(label, context, eventRect, drawableRect, width);
drawText(label, context, eventRect, drawableRect);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,10 @@ export function drawText(
context: CanvasRenderingContext2D,
fullRect: Rect,
drawableRect: Rect,
availableWidth: number, // TODO Do we need this?
textAlign: 'left' | 'center' = 'left',
fillStyle: string = COLORS.TEXT_COLOR,
): void {
if (availableWidth > TEXT_PADDING * 2) {
if (fullRect.size.width > TEXT_PADDING * 2) {
context.textAlign = textAlign;
context.textBaseline = 'middle';
context.font = `${FONT_SIZE}px sans-serif`;
Expand All @@ -55,7 +54,7 @@ export function drawText(
const trimmedName = trimText(
context,
text,
availableWidth - TEXT_PADDING * 2 + (x < 0 ? x : 0),
fullRect.size.width - TEXT_PADDING * 2 + (x < 0 ? x : 0),
);

if (trimmedName !== null) {
Expand All @@ -81,7 +80,7 @@ export function drawText(

let textX;
if (textAlign === 'center') {
textX = x + availableWidth / 2 + TEXT_PADDING - (x < 0 ? x : 0);
textX = x + fullRect.size.width / 2 + TEXT_PADDING - (x < 0 ? x : 0);
} else {
textX = x + TEXT_PADDING - (x < 0 ? x : 0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ class ResizeBar extends View {
context,
labelRect,
drawableRect,
visibleArea.size.width,
'center',
COLORS.REACT_RESIZE_BAR_DOT,
);
Expand Down

0 comments on commit 5f21abd

Please sign in to comment.