Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions tests/YGDirtyMarkingTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,3 +304,38 @@ TEST(YogaTest, dirty_removed_child_nodes_when_removing_all) {
YGNodeFree(child1);
YGNodeFreeRecursive(root);
}

TEST(YogaTest, dirty_parent_when_child_freed) {
YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);

YGNodeRef child = YGNodeNew();
YGNodeStyleSetWidth(child, 50);
YGNodeStyleSetHeight(child, 50);
YGNodeInsertChild(root, child, 0);

YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
EXPECT_FALSE(YGNodeIsDirty(root));

YGNodeFree(child);

EXPECT_TRUE(YGNodeIsDirty(root));
YGNodeFree(root);
}

TEST(YogaTest, dirty_parent_when_subtree_freed_recursive) {
YGNodeRef root = YGNodeNew();
YGNodeRef child = YGNodeNew();
YGNodeRef grandchild = YGNodeNew();
YGNodeInsertChild(root, child, 0);
YGNodeInsertChild(child, grandchild, 0);

YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
EXPECT_FALSE(YGNodeIsDirty(root));

YGNodeFreeRecursive(child);

EXPECT_TRUE(YGNodeIsDirty(root));
YGNodeFree(root);
}
1 change: 1 addition & 0 deletions yoga/YGNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ void YGNodeFree(const YGNodeRef nodeRef) {
if (auto owner = node->getOwner()) {
owner->removeChild(node);
node->setOwner(nullptr);
owner->markDirtyAndPropagate();
}

const size_t childCount = node->getChildCount();
Expand Down
Loading