@@ -259,8 +259,7 @@ static void _CSSNodeMarkDirty(const CSSNodeRef node) {
259259}
260260
261261void CSSNodeSetMeasureFunc (const CSSNodeRef node , CSSMeasureFunc measureFunc ) {
262- CSS_ASSERT (CSSNodeChildCount (node ) == 0 ,
263- "Cannot set measure function: Nodes with measure functions cannot have children." );
262+ CSS_ASSERT (CSSNodeChildCount (node ) == 0 , "Cannot set measure function: Nodes with measure functions cannot have children." );
264263 node -> measure = measureFunc ;
265264}
266265
@@ -270,8 +269,7 @@ CSSMeasureFunc CSSNodeGetMeasureFunc(const CSSNodeRef node) {
270269
271270void CSSNodeInsertChild (const CSSNodeRef node , const CSSNodeRef child , const uint32_t index ) {
272271 CSS_ASSERT (child -> parent == NULL , "Child already has a parent, it must be removed first." );
273- CSS_ASSERT (node -> measure == NULL ,
274- "Cannot add child: Nodes with measure functions cannot have children." );
272+ CSS_ASSERT (node -> measure == NULL , "Cannot add child: Nodes with measure functions cannot have children." );
275273 CSSNodeListInsert (& node -> children , child , index );
276274 child -> parent = node ;
277275 _CSSNodeMarkDirty (node );
@@ -1369,26 +1367,6 @@ static void layoutNodeImpl(const CSSNodeRef node,
13691367 const float availableInnerMainDim = isMainAxisRow ? availableInnerWidth : availableInnerHeight ;
13701368 const float availableInnerCrossDim = isMainAxisRow ? availableInnerHeight : availableInnerWidth ;
13711369
1372- // If there is only one child with flexGrow + flexShrink it means we can set the
1373- // computedFlexBasis to 0 instead of measuring and shrinking / flexing the child to exactly
1374- // match the remaining space
1375- CSSNodeRef singleFlexChild = NULL ;
1376- if ((isMainAxisRow && widthMeasureMode != CSSMeasureModeUndefined ) ||
1377- (!isMainAxisRow && heightMeasureMode != CSSMeasureModeUndefined )) {
1378- for (uint32_t i = 0 ; i < childCount ; i ++ ) {
1379- const CSSNodeRef child = CSSNodeGetChild (node , i );
1380- if (singleFlexChild ) {
1381- if (isFlex (child )) {
1382- // There is already a flexible child, abort.
1383- singleFlexChild = NULL ;
1384- break ;
1385- }
1386- } else if (CSSNodeStyleGetFlexGrow (child ) > 0 && CSSNodeStyleGetFlexShrink (child ) > 0 ) {
1387- singleFlexChild = child ;
1388- }
1389- }
1390- }
1391-
13921370 // STEP 3: DETERMINE FLEX BASIS FOR EACH ITEM
13931371 for (uint32_t i = 0 ; i < childCount ; i ++ ) {
13941372 const CSSNodeRef child = CSSNodeListGet (node -> children , i );
@@ -1413,17 +1391,13 @@ static void layoutNodeImpl(const CSSNodeRef node,
14131391 currentAbsoluteChild = child ;
14141392 child -> nextChild = NULL ;
14151393 } else {
1416- if (child == singleFlexChild ) {
1417- child -> layout .computedFlexBasis = 0 ;
1418- } else {
1419- computeChildFlexBasis (node ,
1420- child ,
1421- availableInnerWidth ,
1422- widthMeasureMode ,
1423- availableInnerHeight ,
1424- heightMeasureMode ,
1425- direction );
1426- }
1394+ computeChildFlexBasis (node ,
1395+ child ,
1396+ availableInnerWidth ,
1397+ widthMeasureMode ,
1398+ availableInnerHeight ,
1399+ heightMeasureMode ,
1400+ direction );
14271401 }
14281402 }
14291403
@@ -2159,17 +2133,17 @@ static inline bool newMeasureSizeIsStricterAndStillValid(CSSMeasureMode sizeMode
21592133}
21602134
21612135bool CSSNodeCanUseCachedMeasurement (const CSSMeasureMode widthMode ,
2162- const float width ,
2163- const CSSMeasureMode heightMode ,
2164- const float height ,
2165- const CSSMeasureMode lastWidthMode ,
2166- const float lastWidth ,
2167- const CSSMeasureMode lastHeightMode ,
2168- const float lastHeight ,
2169- const float lastComputedWidth ,
2170- const float lastComputedHeight ,
2171- const float marginRow ,
2172- const float marginColumn ) {
2136+ const float width ,
2137+ const CSSMeasureMode heightMode ,
2138+ const float height ,
2139+ const CSSMeasureMode lastWidthMode ,
2140+ const float lastWidth ,
2141+ const CSSMeasureMode lastHeightMode ,
2142+ const float lastHeight ,
2143+ const float lastComputedWidth ,
2144+ const float lastComputedHeight ,
2145+ const float marginRow ,
2146+ const float marginColumn ) {
21732147 if (lastComputedHeight < 0 || lastComputedWidth < 0 ) {
21742148 return false;
21752149 }
@@ -2187,16 +2161,19 @@ bool CSSNodeCanUseCachedMeasurement(const CSSMeasureMode widthMode,
21872161 newMeasureSizeIsStricterAndStillValid (
21882162 widthMode , width - marginRow , lastWidthMode , lastWidth , lastComputedWidth );
21892163
2190- const bool heightIsCompatible =
2191- hasSameHeightSpec || newSizeIsExactAndMatchesOldMeasuredSize (heightMode ,
2164+ const bool heightIsCompatible = hasSameHeightSpec ||
2165+ newSizeIsExactAndMatchesOldMeasuredSize (heightMode ,
2166+ height - marginColumn ,
2167+ lastComputedHeight ) ||
2168+ oldSizeIsUnspecifiedAndStillFits (heightMode ,
21922169 height - marginColumn ,
2170+ lastHeightMode ,
21932171 lastComputedHeight ) ||
2194- oldSizeIsUnspecifiedAndStillFits (heightMode ,
2195- height - marginColumn ,
2196- lastHeightMode ,
2197- lastComputedHeight ) ||
2198- newMeasureSizeIsStricterAndStillValid (
2199- heightMode , height - marginColumn , lastHeightMode , lastHeight , lastComputedHeight );
2172+ newMeasureSizeIsStricterAndStillValid (heightMode ,
2173+ height - marginColumn ,
2174+ lastHeightMode ,
2175+ lastHeight ,
2176+ lastComputedHeight );
22002177
22012178 return widthIsCompatible && heightIsCompatible ;
22022179}
0 commit comments