Fixup recent fix to flex basis and put it behind an experimental flag
Summary: D4207106 previously fixed an issue where the computed flex basis was cached in between layout calculations, potentially caching wrong values. After landing we noticed that some product were implicitly relying on this behavior so this diff instead puts that behind a feature flag. Reviewed By: gkassabli Differential Revision: D4222910 fbshipit-source-id: d693482441fcc4d37a288e2e3529057a04f60541
This commit is contained in:
committed by
Facebook Github Bot
parent
dc10fdd958
commit
a0d560a24b
@@ -68,6 +68,7 @@ typedef enum CSSDirection {
|
|||||||
|
|
||||||
typedef enum CSSExperimentalFeature {
|
typedef enum CSSExperimentalFeature {
|
||||||
CSSExperimentalFeatureRounding,
|
CSSExperimentalFeatureRounding,
|
||||||
|
CSSExperimentalFeatureWebFlexBasis,
|
||||||
CSSExperimentalFeatureCount,
|
CSSExperimentalFeatureCount,
|
||||||
} CSSExperimentalFeature;
|
} CSSExperimentalFeature;
|
||||||
|
|
||||||
|
@@ -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));
|
||||||
}
|
}
|
||||||
|
@@ -16,6 +16,12 @@
|
|||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation CSSNodeBridge
|
@implementation CSSNodeBridge
|
||||||
|
|
||||||
|
+ (void)initialize
|
||||||
|
{
|
||||||
|
CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureWebFlexBasis, true);
|
||||||
|
}
|
||||||
|
|
||||||
- (instancetype)init
|
- (instancetype)init
|
||||||
{
|
{
|
||||||
if ([super init]) {
|
if ([super init]) {
|
||||||
|
@@ -12,5 +12,6 @@ namespace Facebook.CSSLayout
|
|||||||
public enum CSSExperimentalFeature
|
public enum CSSExperimentalFeature
|
||||||
{
|
{
|
||||||
Rounding,
|
Rounding,
|
||||||
|
WebFlexBasis,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
enums.py
2
enums.py
@@ -79,6 +79,8 @@ ENUMS = {
|
|||||||
],
|
],
|
||||||
'CSSExperimentalFeature': [
|
'CSSExperimentalFeature': [
|
||||||
'Rounding',
|
'Rounding',
|
||||||
|
# Mimic web flex-basis behavior.
|
||||||
|
'WebFlexBasis',
|
||||||
],
|
],
|
||||||
'CSSPrintOptions': [
|
'CSSPrintOptions': [
|
||||||
('Layout', 1),
|
('Layout', 1),
|
||||||
|
@@ -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;
|
||||||
|
|
||||||
@@ -25,6 +26,7 @@ public enum CSSExperimentalFeature {
|
|||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,19 @@
|
|||||||
#include <CSSLayout/CSSLayout.h>
|
#include <CSSLayout/CSSLayout.h>
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
TEST(CSSLayoutTest, dont_cache_computed_flex_basis_between_layouts) {
|
class CSSLayoutRelayoutTest : public ::testing::Test {
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void SetUp() {
|
||||||
|
CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureWebFlexBasis, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void TearDown() {
|
||||||
|
CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureWebFlexBasis, false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_F(CSSLayoutRelayoutTest, dont_cache_computed_flex_basis_between_layouts) {
|
||||||
const CSSNodeRef root = CSSNodeNew();
|
const CSSNodeRef root = CSSNodeNew();
|
||||||
|
|
||||||
const CSSNodeRef root_child0 = CSSNodeNew();
|
const CSSNodeRef root_child0 = CSSNodeNew();
|
||||||
|
Reference in New Issue
Block a user