Skip to content

Commit

Permalink
Add flag in YGConfig for running experiments
Browse files Browse the repository at this point in the history
Reviewed By: emilsjolander

Differential Revision: D6948702

fbshipit-source-id: 009fe2d64b6098f8c3a0289f0e6939dea5ce0d37
  • Loading branch information
priteshrnandgaonkar authored and facebook-github-bot committed Feb 9, 2018
1 parent 400a29e commit fdef378
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions ReactCommon/yoga/yoga/Yoga-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ struct YGConfig {
bool experimentalFeatures[YGExperimentalFeatureCount + 1];
bool useWebDefaults;
bool useLegacyStretchBehaviour;
bool shouldDiffLayoutWithoutLegacyStretchBehaviour;
float pointScaleFactor;
YGLogger logger;
YGNodeClonedFunc cloneNodeCallback;
Expand Down
10 changes: 6 additions & 4 deletions ReactCommon/yoga/yoga/Yoga.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ static YGConfig gYGConfigDefaults = {
},
.useWebDefaults = false,
.useLegacyStretchBehaviour = false,
.shouldDiffLayoutWithoutLegacyStretchBehaviour = false,
.pointScaleFactor = 1.0f,
#ifdef ANDROID
.logger = &YGAndroidLog,
Expand Down Expand Up @@ -3613,14 +3614,15 @@ void YGNodeCalculateLayout(const YGNodeRef node,
}
}

bool didUseLegacyFlag = node->didUseLegacyFlag();

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

0 comments on commit fdef378

Please sign in to comment.