From 0dafa0de6b33605beaeb32a7e34ce684048c63f3 Mon Sep 17 00:00:00 2001 From: David Aurelio Date: Tue, 29 Jan 2019 10:30:11 -0800 Subject: [PATCH] Layout marker metadata Summary: @public Adds marker meta data to `YGMarkerLayout`: the number of measures, and the numbers of layouts for all nodes in the tree. Reviewed By: SidharthGuglani Differential Revision: D13838975 fbshipit-source-id: d575c26a3d5a4f0b66834eb6bedecadc3f3ca265 --- ReactCommon/yoga/yoga/YGMarker.h | 12 +++++++++++- ReactCommon/yoga/yoga/Yoga.cpp | 2 ++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ReactCommon/yoga/yoga/YGMarker.h b/ReactCommon/yoga/yoga/YGMarker.h index f7da1b58a97..15280927282 100644 --- a/ReactCommon/yoga/yoga/YGMarker.h +++ b/ReactCommon/yoga/yoga/YGMarker.h @@ -18,7 +18,8 @@ typedef YG_ENUM_BEGIN(YGMarker){ } YG_ENUM_END(YGMarker); typedef struct { - int unused; + int layouts; + int measures; } YGMarkerLayoutData; typedef union { @@ -54,6 +55,15 @@ struct MarkerData { }; } // namespace detail + +template +typename detail::MarkerData::type* data(YGMarkerData) = delete; + +template <> +inline YGMarkerLayoutData* data(YGMarkerData d) { + return d.layout; +} + } // namespace marker } // namespace yoga } // namespace facebook diff --git a/ReactCommon/yoga/yoga/Yoga.cpp b/ReactCommon/yoga/yoga/Yoga.cpp index 6b91b7e17e4..9461bb3faba 100644 --- a/ReactCommon/yoga/yoga/Yoga.cpp +++ b/ReactCommon/yoga/yoga/Yoga.cpp @@ -2685,6 +2685,8 @@ static void YGNodelayoutImpl( "availableHeight is indefinite so heightMeasureMode must be " "YGMeasureModeUndefined"); + (performLayout ? layoutMarkerData.layouts : layoutMarkerData.measures) += 1; + // Set the resolved resolution in the node's layout. const YGDirection direction = node->resolveDirection(ownerDirection); node->setLayoutDirection(direction);