File tree 3 files changed +18
-13
lines changed
packages/react-devtools-scheduling-profiler/src 3 files changed +18
-13
lines changed Original file line number Diff line number Diff line change @@ -118,6 +118,7 @@ export class SnapshotsView extends View {
118
118
const visibleArea = this . visibleArea ;
119
119
120
120
// Prevent snapshot from visibly overflowing its container when clipped.
121
+ // View clips by default, but since this view may draw async (on Image load) we re-clip.
121
122
const shouldClip = ! rectEqualToRect ( imageRect , visibleArea ) ;
122
123
if ( shouldClip ) {
123
124
const clippedRect = intersectionOfRects ( imageRect , visibleArea ) ;
Original file line number Diff line number Diff line change @@ -168,26 +168,13 @@ export class SuspenseEventsView extends View {
168
168
return ; // Not in view
169
169
}
170
170
171
- const drawableRect = intersectionOfRects ( suspenseRect , rect ) ;
172
-
173
- // Clip diamonds so they don't overflow if the view has been resized (smaller).
174
- const region = new Path2D ( ) ;
175
- region . rect (
176
- drawableRect . origin . x ,
177
- drawableRect . origin . y ,
178
- drawableRect . size . width ,
179
- drawableRect . size . height ,
180
- ) ;
181
- context . save ( ) ;
182
- context . clip ( region ) ;
183
171
context . beginPath ( ) ;
184
172
context . fillStyle = fillStyle ;
185
173
context . moveTo ( xStart , y - halfSize ) ;
186
174
context . lineTo ( xStart + halfSize , y ) ;
187
175
context . lineTo ( xStart , y + halfSize ) ;
188
176
context . lineTo ( xStart - halfSize , y ) ;
189
177
context . fill ( ) ;
190
- context . restore ( ) ;
191
178
} else {
192
179
const xStop = timestampToPosition (
193
180
timestamp + duration ,
Original file line number Diff line number Diff line change @@ -199,7 +199,24 @@ export class View {
199
199
this . layoutSubviews ( ) ;
200
200
if ( this . _needsDisplay ) this . _needsDisplay = false ;
201
201
if ( this . _subviewsNeedDisplay ) this . _subviewsNeedDisplay = false ;
202
+
203
+ // Clip anything drawn by the view to prevent it from overflowing its visible area.
204
+ const visibleArea = this . visibleArea ;
205
+ const region = new Path2D ( ) ;
206
+ region . rect (
207
+ visibleArea . origin . x ,
208
+ visibleArea . origin . y ,
209
+ visibleArea . size . width ,
210
+ visibleArea . size . height ,
211
+ ) ;
212
+ context . save ( ) ;
213
+ context . clip ( region ) ;
214
+ context . beginPath ( ) ;
215
+
202
216
this . draw ( context , viewRefs ) ;
217
+
218
+ // Stop clipping
219
+ context . restore ( ) ;
203
220
}
204
221
}
205
222
You can’t perform that action at this time.
0 commit comments