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...
emilsjolander authored and Facebook Github Bot committed Nov 23, 2016
1 parent 68c6d71 commit dad520476ef5e82bf3b71b29311c3a472a0a93eb
@@ -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));
}

1 comment on commit dad5204

@rikur

This comment has been minimized.

rikur commented on dad5204 Feb 3, 2017

The Layout of our application is very much off after upgrading from 0.39.x to 0.40.0..

What does this do? Are we supposed to use flex: 1? What should we replace it with?

I couldn't find any mention anywhere on how to use that experimental flag.

Please sign in to comment.