Permalink
Browse files

Fixup recent fix to flex basis and put it behind an experimental flag

Reviewed By: gkassabli

Differential Revision: D4222910

fbshipit-source-id: d693482441fcc4d37a288e2e3529057a04f60541
  • Loading branch information...
1 parent 68c6d71 commit dad520476ef5e82bf3b71b29311c3a472a0a93eb @emilsjolander emilsjolander committed with Facebook Github Bot Nov 23, 2016
@@ -68,6 +68,7 @@ typedef enum CSSDirection {
typedef enum CSSExperimentalFeature {
CSSExperimentalFeatureRounding,
+ CSSExperimentalFeatureWebFlexBasis,
CSSExperimentalFeatureCount,
} CSSExperimentalFeature;
@@ -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,
@@ -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);
}
}
@@ -68,6 +68,7 @@ typedef enum CSSDirection {
typedef enum CSSExperimentalFeature {
CSSExperimentalFeatureRounding,
+ CSSExperimentalFeatureWebFlexBasis,
CSSExperimentalFeatureCount,
} CSSExperimentalFeature;
@@ -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));
}

0 comments on commit dad5204

Please sign in to comment.