Skip to content

Commit

Permalink
Fixup recent fix to flex basis and put it behind an experimental flag
Browse files Browse the repository at this point in the history
Reviewed By: gkassabli

Differential Revision: D4222910

fbshipit-source-id: d693482441fcc4d37a288e2e3529057a04f60541
  • Loading branch information
Emil Sjolander authored and Facebook Github Bot committed Nov 23, 2016
1 parent 68c6d71 commit dad5204
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
1 change: 1 addition & 0 deletions React/CSSLayout/CSSEnums.h
Expand Up @@ -68,6 +68,7 @@ typedef enum CSSDirection {


typedef enum CSSExperimentalFeature { typedef enum CSSExperimentalFeature {
CSSExperimentalFeatureRounding, CSSExperimentalFeatureRounding,
CSSExperimentalFeatureWebFlexBasis,
CSSExperimentalFeatureCount, CSSExperimentalFeatureCount,
} CSSExperimentalFeature; } CSSExperimentalFeature;


Expand Down
16 changes: 8 additions & 8 deletions React/CSSLayout/CSSLayout.c
Expand Up @@ -49,7 +49,6 @@ typedef struct CSSLayout {
float dimensions[2]; float dimensions[2];
CSSDirection direction; CSSDirection direction;


uint32_t computedFlexBasisGeneration;
float computedFlexBasis; float computedFlexBasis;


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


if (!CSSValueIsUndefined(CSSNodeStyleGetFlexBasis(child)) && if (CSSLayoutIsExperimentalFeatureEnabled(CSSExperimentalFeatureWebFlexBasis) &&
!CSSValueIsUndefined(isMainAxisRow ? width : height)) { !CSSValueIsUndefined(CSSNodeStyleGetFlexBasis(child))) {
if (CSSValueIsUndefined(child->layout.computedFlexBasis) || child->layout.computedFlexBasis =
child->layout.computedFlexBasisGeneration != gCurrentGenerationCount) { 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 = child->layout.computedFlexBasis =
fmaxf(CSSNodeStyleGetFlexBasis(child), getPaddingAndBorderAxis(child, mainAxis)); fmaxf(CSSNodeStyleGetFlexBasis(child), getPaddingAndBorderAxis(child, mainAxis));
} }
Expand Down Expand Up @@ -1076,8 +1079,6 @@ static void computeChildFlexBasis(const CSSNodeRef node,
: child->layout.measuredDimensions[CSSDimensionHeight], : child->layout.measuredDimensions[CSSDimensionHeight],
getPaddingAndBorderAxis(child, mainAxis)); getPaddingAndBorderAxis(child, mainAxis));
} }

child->layout.computedFlexBasisGeneration = gCurrentGenerationCount;
} }


static void absoluteLayoutChild(const CSSNodeRef node, static void absoluteLayoutChild(const CSSNodeRef node,
Expand Down Expand Up @@ -1535,7 +1536,6 @@ static void layoutNodeImpl(const CSSNodeRef node,
child->nextChild = NULL; child->nextChild = NULL;
} else { } else {
if (child == singleFlexChild) { if (child == singleFlexChild) {
child->layout.computedFlexBasisGeneration = gCurrentGenerationCount;
child->layout.computedFlexBasis = 0; child->layout.computedFlexBasis = 0;
} else { } else {
computeChildFlexBasis(node, computeChildFlexBasis(node,
Expand Down
Expand Up @@ -10,7 +10,8 @@
package com.facebook.csslayout; package com.facebook.csslayout;


public enum CSSExperimentalFeature { public enum CSSExperimentalFeature {
ROUNDING(0); ROUNDING(0),
WEB_FLEX_BASIS(1);


private int mIntValue; private int mIntValue;


Expand All @@ -25,6 +26,7 @@ public int intValue() {
public static CSSExperimentalFeature fromInt(int value) { public static CSSExperimentalFeature fromInt(int value) {
switch (value) { switch (value) {
case 0: return ROUNDING; case 0: return ROUNDING;
case 1: return WEB_FLEX_BASIS;
default: throw new IllegalArgumentException("Unkown enum value: " + value); default: throw new IllegalArgumentException("Unkown enum value: " + value);
} }
} }
Expand Down
1 change: 1 addition & 0 deletions ReactCommon/CSSLayout/CSSLayout/CSSEnums.h
Expand Up @@ -68,6 +68,7 @@ typedef enum CSSDirection {


typedef enum CSSExperimentalFeature { typedef enum CSSExperimentalFeature {
CSSExperimentalFeatureRounding, CSSExperimentalFeatureRounding,
CSSExperimentalFeatureWebFlexBasis,
CSSExperimentalFeatureCount, CSSExperimentalFeatureCount,
} CSSExperimentalFeature; } CSSExperimentalFeature;


Expand Down
3 changes: 2 additions & 1 deletion ReactCommon/CSSLayout/CSSLayout/CSSLayout.c
Expand Up @@ -977,7 +977,8 @@ static void computeChildFlexBasis(const CSSNodeRef node,
if (!CSSValueIsUndefined(CSSNodeStyleGetFlexBasis(child)) && if (!CSSValueIsUndefined(CSSNodeStyleGetFlexBasis(child)) &&
!CSSValueIsUndefined(isMainAxisRow ? width : height)) { !CSSValueIsUndefined(isMainAxisRow ? width : height)) {
if (CSSValueIsUndefined(child->layout.computedFlexBasis) || if (CSSValueIsUndefined(child->layout.computedFlexBasis) ||
child->layout.computedFlexBasisGeneration != gCurrentGenerationCount) { (CSSLayoutIsExperimentalFeatureEnabled(CSSExperimentalFeatureWebFlexBasis) &&
child->layout.computedFlexBasisGeneration != gCurrentGenerationCount)) {
child->layout.computedFlexBasis = child->layout.computedFlexBasis =
fmaxf(CSSNodeStyleGetFlexBasis(child), getPaddingAndBorderAxis(child, mainAxis)); fmaxf(CSSNodeStyleGetFlexBasis(child), getPaddingAndBorderAxis(child, mainAxis));
} }
Expand Down

1 comment on commit dad5204

@rikur
Copy link

@rikur rikur commented on dad5204 Feb 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.