MCPcopy Index your code
hub / github.com/react/react / draw

Method draw

packages/react-devtools-timeline/src/view-base/View.js:265–286  ·  view source on GitHub ↗

* Draw the contents of this view in the given canvas `context`. * * Defaults to drawing this view's `subviews`. * * To be overwritten by subclasses that wish to draw custom content. * * NOTE: Do not call directly! Use `displayIfNeeded`. * * @see displayIfNeeded

(context: CanvasRenderingContext2D, viewRefs: ViewRefs)

Source from the content-addressed store, hash-verified

263 * @see displayIfNeeded
264 */
265 draw(context: CanvasRenderingContext2D, viewRefs: ViewRefs) {
266 const {subviews, visibleArea} = this;
267 subviews.forEach(subview => {
268 if (rectIntersectsRect(visibleArea, subview.visibleArea)) {
269 subview.displayIfNeeded(context, viewRefs);
270 }
271 });
272
273 const backgroundColor = this._backgroundColor;
274 if (backgroundColor !== null) {
275 const desiredSize = this.desiredSize();
276 if (visibleArea.size.height > desiredSize.height) {
277 context.fillStyle = backgroundColor;
278 context.fillRect(
279 visibleArea.origin.x,
280 visibleArea.origin.y + desiredSize.height,
281 visibleArea.size.width,
282 visibleArea.size.height - desiredSize.height,
283 );
284 }
285 }
286 }
287
288 /**
289 * Handle an `interaction`.

Callers 3

displayIfNeededMethod · 0.95
applyShapePropsFunction · 0.45
applyTextPropsFunction · 0.45

Calls 4

desiredSizeMethod · 0.95
rectIntersectsRectFunction · 0.90
forEachMethod · 0.65
displayIfNeededMethod · 0.45

Tested by

no test coverage detected