Skip to content

Commit 667da3c

Browse files
authored
Fix Style::operator== ignoring boxSizing (#2029)
`Style::operator==` compares every style field except `boxSizing_`, so two styles that only differ in box sizing compare equal. `YGNodeCopyStyle` then skips the copy and leaves the destination node with the old box sizing, and callers that compare styles to decide whether a node needs relayout miss the change. Compare `boxSizing_` together with the other enum fields.
1 parent 0825043 commit 667da3c

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

‎tests/YGStyleTest.cpp‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,18 @@ TEST(YogaTest, copy_style_modified_same) {
5151
YGNodeFree(node1);
5252
}
5353

54+
TEST(YogaTest, copy_style_box_sizing) {
55+
YGNodeRef node0 = YGNodeNew();
56+
YGNodeRef node1 = YGNodeNew();
57+
YGNodeStyleSetBoxSizing(node1, YGBoxSizingContentBox);
58+
59+
YGNodeCopyStyle(node0, node1);
60+
ASSERT_EQ(YGBoxSizingContentBox, YGNodeStyleGetBoxSizing(node0));
61+
62+
YGNodeFree(node0);
63+
YGNodeFree(node1);
64+
}
65+
5466
TEST(YogaTest, initialise_flexShrink_flexGrow) {
5567
YGNodeRef node0 = YGNodeNew();
5668
YGNodeStyleSetFlexShrink(node0, 1);

‎yoga/style/Style.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,7 @@ class YG_EXPORT Style {
653653
alignItems_ == other.alignItems_ && alignSelf_ == other.alignSelf_ &&
654654
positionType_ == other.positionType_ && flexWrap_ == other.flexWrap_ &&
655655
overflow_ == other.overflow_ && display_ == other.display_ &&
656+
boxSizing_ == other.boxSizing_ &&
656657
numbersEqual(flex_, pool_, other.flex_, other.pool_) &&
657658
numbersEqual(flexGrow_, pool_, other.flexGrow_, other.pool_) &&
658659
numbersEqual(flexShrink_, pool_, other.flexShrink_, other.pool_) &&

0 commit comments

Comments
 (0)