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:
committed by
Facebook Github Bot
parent
bc2fb5c7ab
commit
5b173c1b61
@@ -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);
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user