Mark all children as dirty if display changes
Summary: If we set ```display:none``` all children are set with layout sizes/values of 0. We need do mark all those children as dirty to force a relayout if we toggle the display on a higher parent node. This fixes #443 Closes https://github.com/facebook/yoga/pull/448 Reviewed By: astreet Differential Revision: D4642273 Pulled By: emilsjolander fbshipit-source-id: dfdb920e2049952bd6c7f48cfa53b1448e1f3e8f
This commit is contained in:
committed by
Facebook Github Bot
parent
feb365a77b
commit
a706f4c97c
@@ -70,6 +70,54 @@ TEST(YogaTest, dirty_propagation_only_if_prop_changed) {
|
||||
YGNodeFreeRecursive(root);
|
||||
}
|
||||
|
||||
TEST(Yogatest, dirty_mark_all_children_as_dirty_when_display_changes){
|
||||
const YGNodeRef root = YGNodeNew();
|
||||
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
|
||||
YGNodeStyleSetHeight(root, 100);
|
||||
|
||||
const YGNodeRef child0 = YGNodeNew();
|
||||
YGNodeStyleSetFlexGrow(child0, 1);
|
||||
const YGNodeRef child1 = YGNodeNew();
|
||||
YGNodeStyleSetFlexGrow(child1, 1);
|
||||
|
||||
const YGNodeRef child1_child0 = YGNodeNew();
|
||||
const YGNodeRef child1_child0_child0 = YGNodeNew();
|
||||
YGNodeStyleSetWidth(child1_child0_child0, 8);
|
||||
YGNodeStyleSetHeight(child1_child0_child0, 16);
|
||||
|
||||
YGNodeInsertChild(child1_child0, child1_child0_child0, 0);
|
||||
|
||||
YGNodeInsertChild(child1, child1_child0, 0);
|
||||
YGNodeInsertChild(root, child0, 0);
|
||||
YGNodeInsertChild(root, child1, 0);
|
||||
|
||||
YGNodeStyleSetDisplay(child0, YGDisplayFlex);
|
||||
YGNodeStyleSetDisplay(child1, YGDisplayNone);
|
||||
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(child1_child0_child0));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(child1_child0_child0));
|
||||
|
||||
YGNodeStyleSetDisplay(child0, YGDisplayNone);
|
||||
YGNodeStyleSetDisplay(child1, YGDisplayFlex);
|
||||
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||
ASSERT_FLOAT_EQ(8, YGNodeLayoutGetWidth(child1_child0_child0));
|
||||
ASSERT_FLOAT_EQ(16, YGNodeLayoutGetHeight(child1_child0_child0));
|
||||
|
||||
YGNodeStyleSetDisplay(child0, YGDisplayFlex);
|
||||
YGNodeStyleSetDisplay(child1, YGDisplayNone);
|
||||
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(child1_child0_child0));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(child1_child0_child0));
|
||||
|
||||
YGNodeStyleSetDisplay(child0, YGDisplayNone);
|
||||
YGNodeStyleSetDisplay(child1, YGDisplayFlex);
|
||||
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||
ASSERT_FLOAT_EQ(8, YGNodeLayoutGetWidth(child1_child0_child0));
|
||||
ASSERT_FLOAT_EQ(16, YGNodeLayoutGetHeight(child1_child0_child0));
|
||||
|
||||
YGNodeFreeRecursive(root);
|
||||
}
|
||||
|
||||
TEST(YogaTest, dirty_node_only_if_children_are_actually_removed) {
|
||||
const YGNodeRef root = YGNodeNew();
|
||||
YGNodeStyleSetAlignItems(root, YGAlignFlexStart);
|
||||
|
Reference in New Issue
Block a user