( child: Node, mainAxis: FlexDirection, availableMain: number, availableCross: number, crossMode: MeasureMode, ownerWidth: number, ownerHeight: number, )
| 2057 | } |
| 2058 | |
| 2059 | function computeFlexBasis( |
| 2060 | child: Node, |
| 2061 | mainAxis: FlexDirection, |
| 2062 | availableMain: number, |
| 2063 | availableCross: number, |
| 2064 | crossMode: MeasureMode, |
| 2065 | ownerWidth: number, |
| 2066 | ownerHeight: number, |
| 2067 | ): number { |
| 2068 | // Same-generation cache hit: basis was computed THIS calculateLayout, so |
| 2069 | // it's fresh regardless of isDirty_. Covers both clean children (scrolling |
| 2070 | // past unchanged messages) AND fresh-mounted dirty children (virtual |
| 2071 | // scroll mounts new items — the dirty chain's measure→layout cascade |
| 2072 | // invokes this ≥2^depth times, but the child's subtree doesn't change |
| 2073 | // between calls within one calculateLayout). For clean children with |
| 2074 | // cache from a PREVIOUS generation, also hit if inputs match — isDirty_ |
| 2075 | // gates since a dirty child's previous-gen cache is stale. |
| 2076 | const sameGen = child._fbGen === _generation |
| 2077 | if ( |
| 2078 | (sameGen || !child.isDirty_) && |
| 2079 | child._fbCrossMode === crossMode && |
| 2080 | sameFloat(child._fbOwnerW, ownerWidth) && |
| 2081 | sameFloat(child._fbOwnerH, ownerHeight) && |
| 2082 | sameFloat(child._fbAvailMain, availableMain) && |
| 2083 | sameFloat(child._fbAvailCross, availableCross) |
| 2084 | ) { |
| 2085 | return child._fbBasis |
| 2086 | } |
| 2087 | const cs = child.style |
| 2088 | const isMainRow = isRow(mainAxis) |
| 2089 | |
| 2090 | // Explicit flex-basis |
| 2091 | const basis = resolveValue(cs.flexBasis, availableMain) |
| 2092 | if (isDefined(basis)) { |
| 2093 | const b = Math.max(0, basis) |
| 2094 | child._fbBasis = b |
| 2095 | child._fbOwnerW = ownerWidth |
| 2096 | child._fbOwnerH = ownerHeight |
| 2097 | child._fbAvailMain = availableMain |
| 2098 | child._fbAvailCross = availableCross |
| 2099 | child._fbCrossMode = crossMode |
| 2100 | child._fbGen = _generation |
| 2101 | return b |
| 2102 | } |
| 2103 | |
| 2104 | // Style dimension on main axis |
| 2105 | const mainStyleDim = isMainRow ? cs.width : cs.height |
| 2106 | const mainOwner = isMainRow ? ownerWidth : ownerHeight |
| 2107 | const resolved = resolveValue(mainStyleDim, mainOwner) |
| 2108 | if (isDefined(resolved)) { |
| 2109 | const b = Math.max(0, resolved) |
| 2110 | child._fbBasis = b |
| 2111 | child._fbOwnerW = ownerWidth |
| 2112 | child._fbOwnerH = ownerHeight |
| 2113 | child._fbAvailMain = availableMain |
| 2114 | child._fbAvailCross = availableCross |
| 2115 | child._fbCrossMode = crossMode |
| 2116 | child._fbGen = _generation |
no test coverage detected