Skip to content

Commit 5f21abd

Browse files
author
Brian Vaughn
committed
Removed redundant width param from drawText utility
1 parent fb887f2 commit 5f21abd

File tree

6 files changed

+7
-10
lines changed

6 files changed

+7
-10
lines changed

packages/react-devtools-scheduling-profiler/src/content-views/ComponentMeasuresView.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export class ComponentMeasuresView extends View {
116116

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

119-
drawText(label, context, componentMeasureRect, drawableRect, width);
119+
drawText(label, context, componentMeasureRect, drawableRect);
120120

121121
return true;
122122
}
@@ -162,7 +162,6 @@ export class ComponentMeasuresView extends View {
162162
context,
163163
visibleArea,
164164
visibleArea,
165-
visibleArea.size.width,
166165
'center',
167166
COLORS.TEXT_DIM_COLOR,
168167
);

packages/react-devtools-scheduling-profiler/src/content-views/FlamechartView.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ class FlamechartStackLayerView extends View {
172172
drawableRect.size.height,
173173
);
174174

175-
drawText(name, context, nodeRect, drawableRect, width);
175+
drawText(name, context, nodeRect, drawableRect);
176176
}
177177

178178
// Render bottom border.

packages/react-devtools-scheduling-profiler/src/content-views/NativeEventsView.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ export class NativeEventsView extends View {
143143

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

146-
drawText(label, context, eventRect, drawableRect, width);
146+
drawText(label, context, eventRect, drawableRect);
147147
}
148148

149149
draw(context: CanvasRenderingContext2D) {

packages/react-devtools-scheduling-profiler/src/content-views/SuspenseEventsView.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ export class SuspenseEventsView extends View {
231231
label += ` - ${formatDuration(duration)}`;
232232
}
233233

234-
drawText(label, context, eventRect, drawableRect, width);
234+
drawText(label, context, eventRect, drawableRect);
235235
}
236236
}
237237

packages/react-devtools-scheduling-profiler/src/content-views/utils/text.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,10 @@ export function drawText(
4141
context: CanvasRenderingContext2D,
4242
fullRect: Rect,
4343
drawableRect: Rect,
44-
availableWidth: number, // TODO Do we need this?
4544
textAlign: 'left' | 'center' = 'left',
4645
fillStyle: string = COLORS.TEXT_COLOR,
4746
): void {
48-
if (availableWidth > TEXT_PADDING * 2) {
47+
if (fullRect.size.width > TEXT_PADDING * 2) {
4948
context.textAlign = textAlign;
5049
context.textBaseline = 'middle';
5150
context.font = `${FONT_SIZE}px sans-serif`;
@@ -55,7 +54,7 @@ export function drawText(
5554
const trimmedName = trimText(
5655
context,
5756
text,
58-
availableWidth - TEXT_PADDING * 2 + (x < 0 ? x : 0),
57+
fullRect.size.width - TEXT_PADDING * 2 + (x < 0 ? x : 0),
5958
);
6059

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

8281
let textX;
8382
if (textAlign === 'center') {
84-
textX = x + availableWidth / 2 + TEXT_PADDING - (x < 0 ? x : 0);
83+
textX = x + fullRect.size.width / 2 + TEXT_PADDING - (x < 0 ? x : 0);
8584
} else {
8685
textX = x + TEXT_PADDING - (x < 0 ? x : 0);
8786
}

packages/react-devtools-scheduling-profiler/src/view-base/ResizableView.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ class ResizeBar extends View {
110110
context,
111111
labelRect,
112112
drawableRect,
113-
visibleArea.size.width,
114113
'center',
115114
COLORS.REACT_RESIZE_BAR_DOT,
116115
);

0 commit comments

Comments
 (0)