Skip to content

Commit dad5204

Browse files
Emil SjolanderFacebook Github Bot
authored andcommitted
Fixup recent fix to flex basis and put it behind an experimental flag
Reviewed By: gkassabli Differential Revision: D4222910 fbshipit-source-id: d693482441fcc4d37a288e2e3529057a04f60541
1 parent 68c6d71 commit dad5204

File tree

5 files changed

+15
-10
lines changed

5 files changed

+15
-10
lines changed

React/CSSLayout/CSSEnums.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ typedef enum CSSDirection {
6868

6969
typedef enum CSSExperimentalFeature {
7070
CSSExperimentalFeatureRounding,
71+
CSSExperimentalFeatureWebFlexBasis,
7172
CSSExperimentalFeatureCount,
7273
} CSSExperimentalFeature;
7374

React/CSSLayout/CSSLayout.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ typedef struct CSSLayout {
4949
float dimensions[2];
5050
CSSDirection direction;
5151

52-
uint32_t computedFlexBasisGeneration;
5352
float computedFlexBasis;
5453

5554
// Instead of recomputing the entire layout every single time, we
@@ -974,10 +973,14 @@ static void computeChildFlexBasis(const CSSNodeRef node,
974973
const bool isRowStyleDimDefined = isStyleDimDefined(child, CSSFlexDirectionRow);
975974
const bool isColumnStyleDimDefined = isStyleDimDefined(child, CSSFlexDirectionColumn);
976975

977-
if (!CSSValueIsUndefined(CSSNodeStyleGetFlexBasis(child)) &&
978-
!CSSValueIsUndefined(isMainAxisRow ? width : height)) {
979-
if (CSSValueIsUndefined(child->layout.computedFlexBasis) ||
980-
child->layout.computedFlexBasisGeneration != gCurrentGenerationCount) {
976+
if (CSSLayoutIsExperimentalFeatureEnabled(CSSExperimentalFeatureWebFlexBasis) &&
977+
!CSSValueIsUndefined(CSSNodeStyleGetFlexBasis(child))) {
978+
child->layout.computedFlexBasis =
979+
fmaxf(CSSNodeStyleGetFlexBasis(child), getPaddingAndBorderAxis(child, mainAxis));
980+
} else if (!CSSLayoutIsExperimentalFeatureEnabled(CSSExperimentalFeatureWebFlexBasis) &&
981+
!CSSValueIsUndefined(CSSNodeStyleGetFlexBasis(child)) &&
982+
!CSSValueIsUndefined(isMainAxisRow ? width : height)) {
983+
if (CSSValueIsUndefined(child->layout.computedFlexBasis)) {
981984
child->layout.computedFlexBasis =
982985
fmaxf(CSSNodeStyleGetFlexBasis(child), getPaddingAndBorderAxis(child, mainAxis));
983986
}
@@ -1076,8 +1079,6 @@ static void computeChildFlexBasis(const CSSNodeRef node,
10761079
: child->layout.measuredDimensions[CSSDimensionHeight],
10771080
getPaddingAndBorderAxis(child, mainAxis));
10781081
}
1079-
1080-
child->layout.computedFlexBasisGeneration = gCurrentGenerationCount;
10811082
}
10821083

10831084
static void absoluteLayoutChild(const CSSNodeRef node,
@@ -1535,7 +1536,6 @@ static void layoutNodeImpl(const CSSNodeRef node,
15351536
child->nextChild = NULL;
15361537
} else {
15371538
if (child == singleFlexChild) {
1538-
child->layout.computedFlexBasisGeneration = gCurrentGenerationCount;
15391539
child->layout.computedFlexBasis = 0;
15401540
} else {
15411541
computeChildFlexBasis(node,

ReactAndroid/src/main/java/com/facebook/csslayout/CSSExperimentalFeature.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
package com.facebook.csslayout;
1111

1212
public enum CSSExperimentalFeature {
13-
ROUNDING(0);
13+
ROUNDING(0),
14+
WEB_FLEX_BASIS(1);
1415

1516
private int mIntValue;
1617

@@ -25,6 +26,7 @@ public int intValue() {
2526
public static CSSExperimentalFeature fromInt(int value) {
2627
switch (value) {
2728
case 0: return ROUNDING;
29+
case 1: return WEB_FLEX_BASIS;
2830
default: throw new IllegalArgumentException("Unkown enum value: " + value);
2931
}
3032
}

ReactCommon/CSSLayout/CSSLayout/CSSEnums.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ typedef enum CSSDirection {
6868

6969
typedef enum CSSExperimentalFeature {
7070
CSSExperimentalFeatureRounding,
71+
CSSExperimentalFeatureWebFlexBasis,
7172
CSSExperimentalFeatureCount,
7273
} CSSExperimentalFeature;
7374

ReactCommon/CSSLayout/CSSLayout/CSSLayout.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -977,7 +977,8 @@ static void computeChildFlexBasis(const CSSNodeRef node,
977977
if (!CSSValueIsUndefined(CSSNodeStyleGetFlexBasis(child)) &&
978978
!CSSValueIsUndefined(isMainAxisRow ? width : height)) {
979979
if (CSSValueIsUndefined(child->layout.computedFlexBasis) ||
980-
child->layout.computedFlexBasisGeneration != gCurrentGenerationCount) {
980+
(CSSLayoutIsExperimentalFeatureEnabled(CSSExperimentalFeatureWebFlexBasis) &&
981+
child->layout.computedFlexBasisGeneration != gCurrentGenerationCount)) {
981982
child->layout.computedFlexBasis =
982983
fmaxf(CSSNodeStyleGetFlexBasis(child), getPaddingAndBorderAxis(child, mainAxis));
983984
}

0 commit comments

Comments
 (0)