diff --git a/React/CSSLayout/CSSEnums.h b/React/CSSLayout/CSSEnums.h index dbcb58e27b8fa2..94a6ba1b4a7055 100644 --- a/React/CSSLayout/CSSEnums.h +++ b/React/CSSLayout/CSSEnums.h @@ -68,6 +68,7 @@ typedef enum CSSDirection { typedef enum CSSExperimentalFeature { CSSExperimentalFeatureRounding, + CSSExperimentalFeatureWebFlexBasis, CSSExperimentalFeatureCount, } CSSExperimentalFeature; diff --git a/React/CSSLayout/CSSLayout.c b/React/CSSLayout/CSSLayout.c index eeb99195f7e960..4cabd86449b80a 100644 --- a/React/CSSLayout/CSSLayout.c +++ b/React/CSSLayout/CSSLayout.c @@ -49,7 +49,6 @@ typedef struct CSSLayout { float dimensions[2]; CSSDirection direction; - uint32_t computedFlexBasisGeneration; float computedFlexBasis; // Instead of recomputing the entire layout every single time, we @@ -974,10 +973,14 @@ static void computeChildFlexBasis(const CSSNodeRef node, const bool isRowStyleDimDefined = isStyleDimDefined(child, CSSFlexDirectionRow); const bool isColumnStyleDimDefined = isStyleDimDefined(child, CSSFlexDirectionColumn); - if (!CSSValueIsUndefined(CSSNodeStyleGetFlexBasis(child)) && - !CSSValueIsUndefined(isMainAxisRow ? width : height)) { - if (CSSValueIsUndefined(child->layout.computedFlexBasis) || - child->layout.computedFlexBasisGeneration != gCurrentGenerationCount) { + if (CSSLayoutIsExperimentalFeatureEnabled(CSSExperimentalFeatureWebFlexBasis) && + !CSSValueIsUndefined(CSSNodeStyleGetFlexBasis(child))) { + child->layout.computedFlexBasis = + fmaxf(CSSNodeStyleGetFlexBasis(child), getPaddingAndBorderAxis(child, mainAxis)); + } else if (!CSSLayoutIsExperimentalFeatureEnabled(CSSExperimentalFeatureWebFlexBasis) && + !CSSValueIsUndefined(CSSNodeStyleGetFlexBasis(child)) && + !CSSValueIsUndefined(isMainAxisRow ? width : height)) { + if (CSSValueIsUndefined(child->layout.computedFlexBasis)) { child->layout.computedFlexBasis = fmaxf(CSSNodeStyleGetFlexBasis(child), getPaddingAndBorderAxis(child, mainAxis)); } @@ -1076,8 +1079,6 @@ static void computeChildFlexBasis(const CSSNodeRef node, : child->layout.measuredDimensions[CSSDimensionHeight], getPaddingAndBorderAxis(child, mainAxis)); } - - child->layout.computedFlexBasisGeneration = gCurrentGenerationCount; } static void absoluteLayoutChild(const CSSNodeRef node, @@ -1535,7 +1536,6 @@ static void layoutNodeImpl(const CSSNodeRef node, child->nextChild = NULL; } else { if (child == singleFlexChild) { - child->layout.computedFlexBasisGeneration = gCurrentGenerationCount; child->layout.computedFlexBasis = 0; } else { computeChildFlexBasis(node, diff --git a/ReactAndroid/src/main/java/com/facebook/csslayout/CSSExperimentalFeature.java b/ReactAndroid/src/main/java/com/facebook/csslayout/CSSExperimentalFeature.java index c2b8b7af226114..d9476e8117e114 100644 --- a/ReactAndroid/src/main/java/com/facebook/csslayout/CSSExperimentalFeature.java +++ b/ReactAndroid/src/main/java/com/facebook/csslayout/CSSExperimentalFeature.java @@ -10,7 +10,8 @@ package com.facebook.csslayout; public enum CSSExperimentalFeature { - ROUNDING(0); + ROUNDING(0), + WEB_FLEX_BASIS(1); private int mIntValue; @@ -25,6 +26,7 @@ public int intValue() { public static CSSExperimentalFeature fromInt(int value) { switch (value) { case 0: return ROUNDING; + case 1: return WEB_FLEX_BASIS; default: throw new IllegalArgumentException("Unkown enum value: " + value); } } diff --git a/ReactCommon/CSSLayout/CSSLayout/CSSEnums.h b/ReactCommon/CSSLayout/CSSLayout/CSSEnums.h index dbcb58e27b8fa2..94a6ba1b4a7055 100644 --- a/ReactCommon/CSSLayout/CSSLayout/CSSEnums.h +++ b/ReactCommon/CSSLayout/CSSLayout/CSSEnums.h @@ -68,6 +68,7 @@ typedef enum CSSDirection { typedef enum CSSExperimentalFeature { CSSExperimentalFeatureRounding, + CSSExperimentalFeatureWebFlexBasis, CSSExperimentalFeatureCount, } CSSExperimentalFeature; diff --git a/ReactCommon/CSSLayout/CSSLayout/CSSLayout.c b/ReactCommon/CSSLayout/CSSLayout/CSSLayout.c index eeb99195f7e960..5b1025093de88f 100644 --- a/ReactCommon/CSSLayout/CSSLayout/CSSLayout.c +++ b/ReactCommon/CSSLayout/CSSLayout/CSSLayout.c @@ -977,7 +977,8 @@ static void computeChildFlexBasis(const CSSNodeRef node, if (!CSSValueIsUndefined(CSSNodeStyleGetFlexBasis(child)) && !CSSValueIsUndefined(isMainAxisRow ? width : height)) { if (CSSValueIsUndefined(child->layout.computedFlexBasis) || - child->layout.computedFlexBasisGeneration != gCurrentGenerationCount) { + (CSSLayoutIsExperimentalFeatureEnabled(CSSExperimentalFeatureWebFlexBasis) && + child->layout.computedFlexBasisGeneration != gCurrentGenerationCount)) { child->layout.computedFlexBasis = fmaxf(CSSNodeStyleGetFlexBasis(child), getPaddingAndBorderAxis(child, mainAxis)); }