Set web defaults when resetting

Summary: Set web defaults when resetting

Reviewed By: astreet

Differential Revision: D4779742

fbshipit-source-id: 5b8c5d7bd432a12984e4ebfd3187da3d680272cd
This commit is contained in:
Emil Sjolander
2017-03-29 03:06:19 -07:00
committed by Facebook Github Bot
parent bc2fb5c7ab
commit 5b173c1b61
2 changed files with 18 additions and 0 deletions

View File

@@ -103,3 +103,17 @@ TEST(YogaTest, assert_webdefault_values) {
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, assert_webdefault_values_reset) {
YGConfig * config = YGConfigNew();
YGConfigSetUseWebDefaults(config, true);
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeReset(root);
ASSERT_EQ(YGFlexDirectionRow, YGNodeStyleGetFlexDirection(root));
ASSERT_EQ(YGAlignStretch, YGNodeStyleGetAlignContent(root));
ASSERT_FLOAT_EQ(1.0f, YGNodeStyleGetFlexShrink(root));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}

View File

@@ -362,6 +362,10 @@ void YGNodeReset(const YGNodeRef node) {
const YGConfigRef config = node->config;
memcpy(node, &gYGNodeDefaults, sizeof(YGNode));
if (config->useWebDefaults) {
node->style.flexDirection = YGFlexDirectionRow;
node->style.alignContent = YGAlignStretch;
}
node->config = config;
}