diff --git a/tests/EventsTest.cpp b/tests/EventsTest.cpp index 5cb5db02..b940c6b1 100644 --- a/tests/EventsTest.cpp +++ b/tests/EventsTest.cpp @@ -96,12 +96,18 @@ TEST_F(EventTest, layout_events) { YGNodeCalculateLayout(root, 123, 456, YGDirectionLTR); - ASSERT_EQ(events[2].node, root); + ASSERT_EQ(events[2].node, child); ASSERT_EQ(events[2].type, Event::NodeLayout); ASSERT_EQ(events[3].node, child); ASSERT_EQ(events[3].type, Event::NodeLayout); + ASSERT_EQ(events[4].node, child); + ASSERT_EQ(events[4].type, Event::NodeLayout); + + ASSERT_EQ(events[5].node, root); + ASSERT_EQ(events[5].type, Event::NodeLayout); + YGNodeFreeRecursive(root); } diff --git a/yoga/Yoga.cpp b/yoga/Yoga.cpp index 3e4ff32e..cfcadf57 100644 --- a/yoga/Yoga.cpp +++ b/yoga/Yoga.cpp @@ -3693,9 +3693,6 @@ bool YGLayoutNodeInternal( const YGConfigRef config, YGMarkerLayoutData& layoutMarkerData, void* const layoutContext) { -#ifdef YG_ENABLE_EVENTS - Event::publish(node, {performLayout, layoutContext}); -#endif YGLayout* layout = &node->getLayout(); gDepth++; @@ -3929,6 +3926,11 @@ bool YGLayoutNodeInternal( gDepth--; layout->generationCount = gCurrentGenerationCount; + +#ifdef YG_ENABLE_EVENTS + Event::publish(node, {performLayout, layoutContext}); +#endif + return (needToVisitNode || cachedResults == nullptr); }