Skip to content

Commit fdef378

Browse files
Add flag in YGConfig for running experiments
Reviewed By: emilsjolander Differential Revision: D6948702 fbshipit-source-id: 009fe2d64b6098f8c3a0289f0e6939dea5ce0d37
1 parent 400a29e commit fdef378

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

ReactCommon/yoga/yoga/Yoga-internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ struct YGConfig {
215215
bool experimentalFeatures[YGExperimentalFeatureCount + 1];
216216
bool useWebDefaults;
217217
bool useLegacyStretchBehaviour;
218+
bool shouldDiffLayoutWithoutLegacyStretchBehaviour;
218219
float pointScaleFactor;
219220
YGLogger logger;
220221
YGNodeClonedFunc cloneNodeCallback;

ReactCommon/yoga/yoga/Yoga.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ static YGConfig gYGConfigDefaults = {
4747
},
4848
.useWebDefaults = false,
4949
.useLegacyStretchBehaviour = false,
50+
.shouldDiffLayoutWithoutLegacyStretchBehaviour = false,
5051
.pointScaleFactor = 1.0f,
5152
#ifdef ANDROID
5253
.logger = &YGAndroidLog,
@@ -3613,14 +3614,15 @@ void YGNodeCalculateLayout(const YGNodeRef node,
36133614
}
36143615
}
36153616

3616-
bool didUseLegacyFlag = node->didUseLegacyFlag();
3617-
36183617
// We want to get rid off `useLegacyStretchBehaviour` from YGConfig. But we
36193618
// aren't sure whether client's of yoga have gotten rid off this flag or not.
36203619
// So logging this in YGLayout would help to find out the call sites depending
36213620
// on this flag. This check would be removed once we are sure no one is
3622-
// dependent on this flag anymore.
3623-
if (didUseLegacyFlag) {
3621+
// dependent on this flag anymore. The flag
3622+
// `shouldDiffLayoutWithoutLegacyStretchBehaviour` in YGConfig will help to
3623+
// run experiments.
3624+
if (node->getConfig()->shouldDiffLayoutWithoutLegacyStretchBehaviour &&
3625+
node->didUseLegacyFlag()) {
36243626
const YGNodeRef originalNode = YGNodeDeepClone(node);
36253627
originalNode->resolveDimension();
36263628
// Recursively mark nodes as dirty

0 commit comments

Comments
 (0)