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

Function layoutAbsoluteChild

src/native-ts/yoga-layout/index.ts:1904–2021  ·  view source on GitHub ↗
(
  parent: Node,
  child: Node,
  parentWidth: number,
  parentHeight: number,
  pad: [number, number, number, number],
  bor: [number, number, number, number],
)

Source from the content-addressed store, hash-verified

1902}
1903
1904function layoutAbsoluteChild(
1905 parent: Node,
1906 child: Node,
1907 parentWidth: number,
1908 parentHeight: number,
1909 pad: [number, number, number, number],
1910 bor: [number, number, number, number],
1911): void {
1912 const cs = child.style
1913 const posLeft = resolveEdgeRaw(cs.position, EDGE_LEFT)
1914 const posRight = resolveEdgeRaw(cs.position, EDGE_RIGHT)
1915 const posTop = resolveEdgeRaw(cs.position, EDGE_TOP)
1916 const posBottom = resolveEdgeRaw(cs.position, EDGE_BOTTOM)
1917
1918 const rLeft = resolveValue(posLeft, parentWidth)
1919 const rRight = resolveValue(posRight, parentWidth)
1920 const rTop = resolveValue(posTop, parentHeight)
1921 const rBottom = resolveValue(posBottom, parentHeight)
1922
1923 // Absolute children's percentage dimensions resolve against the containing
1924 // block's padding-box (parent size minus border), per CSS §10.1.
1925 const paddingBoxW = parentWidth - bor[0] - bor[2]
1926 const paddingBoxH = parentHeight - bor[1] - bor[3]
1927 let cw = resolveValue(cs.width, paddingBoxW)
1928 let ch = resolveValue(cs.height, paddingBoxH)
1929
1930 // If both left+right defined and width not, derive width
1931 if (!isDefined(cw) && isDefined(rLeft) && isDefined(rRight)) {
1932 cw = paddingBoxW - rLeft - rRight
1933 }
1934 if (!isDefined(ch) && isDefined(rTop) && isDefined(rBottom)) {
1935 ch = paddingBoxH - rTop - rBottom
1936 }
1937
1938 layoutNode(
1939 child,
1940 cw,
1941 ch,
1942 isDefined(cw) ? MeasureMode.Exactly : MeasureMode.Undefined,
1943 isDefined(ch) ? MeasureMode.Exactly : MeasureMode.Undefined,
1944 paddingBoxW,
1945 paddingBoxH,
1946 true,
1947 )
1948
1949 // Margin of absolute child (applied in addition to insets)
1950 const mL = resolveEdge(cs.margin, EDGE_LEFT, parentWidth)
1951 const mT = resolveEdge(cs.margin, EDGE_TOP, parentWidth)
1952 const mR = resolveEdge(cs.margin, EDGE_RIGHT, parentWidth)
1953 const mB = resolveEdge(cs.margin, EDGE_BOTTOM, parentWidth)
1954
1955 const mainAxis = parent.style.flexDirection
1956 const reversed = isReverse(mainAxis)
1957 const mainRow = isRow(mainAxis)
1958 const wrapReverse = parent.style.flexWrap === Wrap.WrapReverse
1959 // alignSelf overrides alignItems for absolute children (same as flow items)
1960 const alignment =
1961 cs.alignSelf === Align.Auto ? parent.style.alignItems : cs.alignSelf

Callers 1

layoutNodeFunction · 0.85

Calls 9

resolveEdgeRawFunction · 0.85
isDefinedFunction · 0.85
layoutNodeFunction · 0.85
resolveEdgeFunction · 0.85
isReverseFunction · 0.85
isRowFunction · 0.85
justifyAbsoluteFunction · 0.85
alignAbsoluteFunction · 0.85
resolveValueFunction · 0.70

Tested by

no test coverage detected