diff --git a/packages/react-native/ReactCommon/yoga/yoga/Yoga.cpp b/packages/react-native/ReactCommon/yoga/yoga/Yoga.cpp index f144c1508ba848..47169bbfc50277 100644 --- a/packages/react-native/ReactCommon/yoga/yoga/Yoga.cpp +++ b/packages/react-native/ReactCommon/yoga/yoga/Yoga.cpp @@ -801,11 +801,8 @@ YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(float, Border, border) YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(float, Padding, padding) #ifdef DEBUG -void YGNodePrint(const YGNodeConstRef nodeRef, const YGPrintOptions options) { - const auto node = resolveRef(nodeRef); - std::string str; - yoga::nodeToString(str, node, options, 0); - yoga::log(node, LogLevel::Debug, str.c_str()); +void YGNodePrint(const YGNodeConstRef node, const YGPrintOptions options) { + yoga::print(resolveRef(node), scopedEnum(options)); } #endif diff --git a/packages/react-native/ReactCommon/yoga/yoga/algorithm/CalculateLayout.cpp b/packages/react-native/ReactCommon/yoga/yoga/algorithm/CalculateLayout.cpp index a7c21d081f73a3..ebe2510a90e52b 100644 --- a/packages/react-native/ReactCommon/yoga/yoga/algorithm/CalculateLayout.cpp +++ b/packages/react-native/ReactCommon/yoga/yoga/algorithm/CalculateLayout.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -2737,9 +2738,9 @@ void calculateLayout( #ifdef DEBUG if (node->getConfig()->shouldPrintTree()) { - YGNodePrint( + yoga::print( node, - (YGPrintOptions)(YGPrintOptionsLayout | YGPrintOptionsChildren | YGPrintOptionsStyle)); + PrintOptions::Layout | PrintOptions::Children | PrintOptions::Style); } #endif } diff --git a/packages/react-native/ReactCommon/yoga/yoga/debug/NodeToString.cpp b/packages/react-native/ReactCommon/yoga/yoga/debug/NodeToString.cpp index 787ec976e46bee..8b60c5fdd4f4a4 100644 --- a/packages/react-native/ReactCommon/yoga/yoga/debug/NodeToString.cpp +++ b/packages/react-native/ReactCommon/yoga/yoga/debug/NodeToString.cpp @@ -11,6 +11,7 @@ #include +#include #include #include @@ -118,12 +119,12 @@ static void appendEdgeIfNotUndefined( void nodeToString( std::string& str, const yoga::Node* node, - YGPrintOptions options, + PrintOptions options, uint32_t level) { indent(str, level); appendFormattedString(str, "
getLayout().dimensions[YGDimensionWidth]); @@ -136,7 +137,7 @@ void nodeToString( appendFormattedString(str, "\" "); } - if (options & YGPrintOptionsStyle) { + if ((options & PrintOptions::Style) == PrintOptions::Style) { appendFormattedString(str, "style=\""); const auto& style = node->getStyle(); if (style.flexDirection() != yoga::Node{}.getStyle().flexDirection()) { @@ -228,7 +229,8 @@ void nodeToString( appendFormattedString(str, ">"); const size_t childCount = node->getChildCount(); - if (options & YGPrintOptionsChildren && childCount > 0) { + if ((options & PrintOptions::Children) == PrintOptions::Children && + childCount > 0) { for (size_t i = 0; i < childCount; i++) { appendFormattedString(str, "\n"); nodeToString(str, node->getChild(i), options, level + 1); @@ -239,5 +241,11 @@ void nodeToString( appendFormattedString(str, "
"); } +void print(const yoga::Node* node, PrintOptions options) { + std::string str; + yoga::nodeToString(str, node, options, 0); + yoga::log(node, LogLevel::Debug, str.c_str()); +} + } // namespace facebook::yoga #endif diff --git a/packages/react-native/ReactCommon/yoga/yoga/debug/NodeToString.h b/packages/react-native/ReactCommon/yoga/yoga/debug/NodeToString.h index 07f5941ab23dba..268d5ac927d044 100644 --- a/packages/react-native/ReactCommon/yoga/yoga/debug/NodeToString.h +++ b/packages/react-native/ReactCommon/yoga/yoga/debug/NodeToString.h @@ -11,7 +11,7 @@ #include -#include +#include #include namespace facebook::yoga { @@ -19,9 +19,11 @@ namespace facebook::yoga { void nodeToString( std::string& str, const yoga::Node* node, - YGPrintOptions options, + PrintOptions options, uint32_t level); +void print(const yoga::Node* node, PrintOptions options); + } // namespace facebook::yoga #endif