diff --git a/ReactCommon/yoga/yoga/Yoga.cpp b/ReactCommon/yoga/yoga/Yoga.cpp index a34c791e82..f7322980fd 100644 --- a/ReactCommon/yoga/yoga/Yoga.cpp +++ b/ReactCommon/yoga/yoga/Yoga.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include "Utils.h" #include "YGNode.h" #include "YGNodePrint.h" @@ -4002,7 +4003,13 @@ void YGNodeCalculateLayoutWithContext( const float ownerHeight, const YGDirection ownerDirection, void* layoutContext) { - marker::MarkerSection marker{node}; + +#ifdef YG_ENABLE_EVENTS + Event::publish(node); +#endif + // unique pointer to allow ending the marker early + std::unique_ptr> marker{ + new marker::MarkerSection{node}}; // Increment the generation count. This will force the recursive routine to // visit all dirty nodes at least once. Subsequent visits will be skipped if @@ -4061,7 +4068,7 @@ void YGNodeCalculateLayoutWithContext( true, "initial", node->getConfig(), - marker.data, + marker->data, layoutContext)) { node->setPosition( node->getLayout().direction, ownerWidth, ownerHeight, ownerWidth); @@ -4078,6 +4085,13 @@ void YGNodeCalculateLayoutWithContext( #endif } + // end marker here + marker = nullptr; + +#ifdef YG_ENABLE_EVENTS + Event::publish(node); +#endif + // We want to get rid off `useLegacyStretchBehaviour` from YGConfig. But we // aren't sure whether client's of yoga have gotten rid off this flag or not. // So logging this in YGLayout would help to find out the call sites depending diff --git a/ReactCommon/yoga/yoga/event/event.h b/ReactCommon/yoga/yoga/event/event.h index e667d2d2bd..c86d5bdebf 100644 --- a/ReactCommon/yoga/yoga/event/event.h +++ b/ReactCommon/yoga/yoga/event/event.h @@ -15,7 +15,13 @@ namespace facebook { namespace yoga { struct Event { - enum Type { NodeAllocation, NodeDeallocation, NodeLayout }; + enum Type { + NodeAllocation, + NodeDeallocation, + NodeLayout, + LayoutPassStart, + LayoutPassEnd + }; class Data; using Subscriber = void(const YGNode&, Type, Data);