MCPcopy Create free account
hub / github.com/codeaashu/claude-code / boundAxis

Function boundAxis

src/native-ts/yoga-layout/index.ts:2352–2384  ·  view source on GitHub ↗
(
  style: Style,
  isWidth: boolean,
  value: number,
  ownerWidth: number,
  ownerHeight: number,
)

Source from the content-addressed store, hash-verified

2350}
2351
2352function boundAxis(
2353 style: Style,
2354 isWidth: boolean,
2355 value: number,
2356 ownerWidth: number,
2357 ownerHeight: number,
2358): number {
2359 const minV = isWidth ? style.minWidth : style.minHeight
2360 const maxV = isWidth ? style.maxWidth : style.maxHeight
2361 const minU = minV.unit
2362 const maxU = maxV.unit
2363 // Fast path: no min/max constraints set. Per CPU profile this is the
2364 // overwhelmingly common case (~32k calls/layout on the 1000-node bench,
2365 // nearly all with undefined min/max) — skipping 2× resolveValue + 2× isNaN
2366 // that always no-op. Unit.Undefined = 0.
2367 if (minU === 0 && maxU === 0) return value
2368 const owner = isWidth ? ownerWidth : ownerHeight
2369 let v = value
2370 // Inlined resolveValue: Unit.Point=1, Unit.Percent=2. `m === m` is !isNaN.
2371 if (maxU === 1) {
2372 if (v > maxV.value) v = maxV.value
2373 } else if (maxU === 2) {
2374 const m = (maxV.value * owner) / 100
2375 if (m === m && v > m) v = m
2376 }
2377 if (minU === 1) {
2378 if (v < minV.value) v = minV.value
2379 } else if (minU === 2) {
2380 const m = (minV.value * owner) / 100
2381 if (m === m && v < m) v = m
2382 }
2383 return v
2384}
2385
2386function zeroLayoutRecursive(node: Node): void {
2387 for (const c of node.children) {

Callers 2

layoutNodeFunction · 0.85
resolveFlexibleLengthsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected