Make new nodes dirty by default (#1641)

Summary:
X-link: https://github.com/facebook/react-native/pull/44010

Pull Request resolved: https://github.com/facebook/yoga/pull/1641

Yoga has quirk where newly constructed nodes are clean, which isn't really correct. Normally never shows in in real code because setting a style or children  will dirty. Fabric doesn't use the public APIs that do this dirtying, so it ends up getting creative instead.

We should fix so that newly constructed nodes are dirty. Copy-constructed Nodes (also only a Fabric thing, will retain original dirty flag.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D55855328

fbshipit-source-id: be49efaf8ac29351f8e5ec509bd9912546944332
This commit is contained in:
Nick Gerleman
2024-04-10 22:15:25 -07:00
committed by Facebook GitHub Bot
parent bbdd1afe59
commit 70de2da05f
2 changed files with 1 additions and 7 deletions

View File

@@ -11,10 +11,8 @@
TEST(YogaTest, copy_style_same) {
const YGNodeRef node0 = YGNodeNew();
const YGNodeRef node1 = YGNodeNew();
ASSERT_FALSE(YGNodeIsDirty(node0));
YGNodeCopyStyle(node0, node1);
ASSERT_FALSE(YGNodeIsDirty(node0));
YGNodeFree(node0);
YGNodeFree(node1);
@@ -22,7 +20,6 @@ TEST(YogaTest, copy_style_same) {
TEST(YogaTest, copy_style_modified) {
const YGNodeRef node0 = YGNodeNew();
ASSERT_FALSE(YGNodeIsDirty(node0));
ASSERT_EQ(YGFlexDirectionColumn, YGNodeStyleGetFlexDirection(node0));
ASSERT_FALSE(YGNodeStyleGetMaxHeight(node0).unit != YGUnitUndefined);
@@ -31,7 +28,6 @@ TEST(YogaTest, copy_style_modified) {
YGNodeStyleSetMaxHeight(node1, 10);
YGNodeCopyStyle(node0, node1);
ASSERT_TRUE(YGNodeIsDirty(node0));
ASSERT_EQ(YGFlexDirectionRow, YGNodeStyleGetFlexDirection(node0));
ASSERT_FLOAT_EQ(10, YGNodeStyleGetMaxHeight(node0).value);
@@ -44,14 +40,12 @@ TEST(YogaTest, copy_style_modified_same) {
YGNodeStyleSetFlexDirection(node0, YGFlexDirectionRow);
YGNodeStyleSetMaxHeight(node0, 10);
YGNodeCalculateLayout(node0, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FALSE(YGNodeIsDirty(node0));
const YGNodeRef node1 = YGNodeNew();
YGNodeStyleSetFlexDirection(node1, YGFlexDirectionRow);
YGNodeStyleSetMaxHeight(node1, 10);
YGNodeCopyStyle(node0, node1);
ASSERT_FALSE(YGNodeIsDirty(node0));
YGNodeFree(node0);
YGNodeFree(node1);