From 053d9e92a5b31523df4e8e60a7f0717cd97406de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Norte?= Date: Wed, 29 Jan 2025 07:06:07 -0800 Subject: [PATCH] Print nativeID in debug props for Props (#49017) Summary: Changelog: [internal] The debug string for props doesn't log `nativeID` so we can't access it in Fantom. This fixes that to simply future tests. Reviewed By: javache Differential Revision: D68779903 --- .../components/view/YogaStylableProps.cpp | 449 +++++++++--------- .../ReactCommon/react/renderer/core/Props.cpp | 9 + .../ReactCommon/react/renderer/core/Props.h | 13 + 3 files changed, 249 insertions(+), 222 deletions(-) diff --git a/packages/react-native/ReactCommon/react/renderer/components/view/YogaStylableProps.cpp b/packages/react-native/ReactCommon/react/renderer/components/view/YogaStylableProps.cpp index 28c4cdaa276cd4..1e194393ec7b39 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/view/YogaStylableProps.cpp +++ b/packages/react-native/ReactCommon/react/renderer/components/view/YogaStylableProps.cpp @@ -556,228 +556,233 @@ void YogaStylableProps::setProp( #if RN_DEBUG_STRING_CONVERTIBLE SharedDebugStringConvertibleList YogaStylableProps::getDebugProps() const { const auto defaultYogaStyle = yoga::Style{}; - return { - debugStringConvertibleItem( - "direction", yogaStyle.direction(), defaultYogaStyle.direction()), - debugStringConvertibleItem( - "flexDirection", - yogaStyle.flexDirection(), - defaultYogaStyle.flexDirection()), - debugStringConvertibleItem( - "justifyContent", - yogaStyle.justifyContent(), - defaultYogaStyle.justifyContent()), - debugStringConvertibleItem( - "alignContent", - yogaStyle.alignContent(), - defaultYogaStyle.alignContent()), - debugStringConvertibleItem( - "alignItems", yogaStyle.alignItems(), defaultYogaStyle.alignItems()), - debugStringConvertibleItem( - "alignSelf", yogaStyle.alignSelf(), defaultYogaStyle.alignSelf()), - debugStringConvertibleItem( - "positionType", - yogaStyle.positionType(), - defaultYogaStyle.positionType()), - debugStringConvertibleItem( - "flexWrap", yogaStyle.flexWrap(), defaultYogaStyle.flexWrap()), - debugStringConvertibleItem( - "overflow", yogaStyle.overflow(), defaultYogaStyle.overflow()), - debugStringConvertibleItem( - "display", yogaStyle.display(), defaultYogaStyle.display()), - debugStringConvertibleItem( - "flex", yogaStyle.flex(), defaultYogaStyle.flex()), - debugStringConvertibleItem( - "flexGrow", yogaStyle.flexGrow(), defaultYogaStyle.flexGrow()), - debugStringConvertibleItem( - "rowGap", - yogaStyle.gap(yoga::Gutter::Row), - defaultYogaStyle.gap(yoga::Gutter::Row)), - debugStringConvertibleItem( - "columnGap", - yogaStyle.gap(yoga::Gutter::Column), - defaultYogaStyle.gap(yoga::Gutter::Column)), - debugStringConvertibleItem( - "gap", - yogaStyle.gap(yoga::Gutter::All), - defaultYogaStyle.gap(yoga::Gutter::All)), - debugStringConvertibleItem( - "flexShrink", yogaStyle.flexShrink(), defaultYogaStyle.flexShrink()), - debugStringConvertibleItem( - "flexBasis", yogaStyle.flexBasis(), defaultYogaStyle.flexBasis()), - debugStringConvertibleItem( - "marginLeft", - yogaStyle.margin(yoga::Edge::Left), - defaultYogaStyle.margin(yoga::Edge::Left)), - debugStringConvertibleItem( - "marginTop", - yogaStyle.margin(yoga::Edge::Top), - defaultYogaStyle.margin(yoga::Edge::Top)), - debugStringConvertibleItem( - "marginRight", - yogaStyle.margin(yoga::Edge::Right), - defaultYogaStyle.margin(yoga::Edge::Right)), - debugStringConvertibleItem( - "marginBottom", - yogaStyle.margin(yoga::Edge::Bottom), - defaultYogaStyle.margin(yoga::Edge::Bottom)), - debugStringConvertibleItem( - "marginStart", - yogaStyle.margin(yoga::Edge::Start), - defaultYogaStyle.margin(yoga::Edge::Start)), - debugStringConvertibleItem( - "marginEnd", - yogaStyle.margin(yoga::Edge::End), - defaultYogaStyle.margin(yoga::Edge::End)), - debugStringConvertibleItem( - "marginHorizontal", - yogaStyle.margin(yoga::Edge::Horizontal), - defaultYogaStyle.margin(yoga::Edge::Horizontal)), - debugStringConvertibleItem( - "marginVertical", - yogaStyle.margin(yoga::Edge::Vertical), - defaultYogaStyle.margin(yoga::Edge::Vertical)), - debugStringConvertibleItem( - "margin", - yogaStyle.margin(yoga::Edge::All), - defaultYogaStyle.margin(yoga::Edge::All)), - debugStringConvertibleItem( - "left", - yogaStyle.position(yoga::Edge::Left), - defaultYogaStyle.position(yoga::Edge::Left)), - debugStringConvertibleItem( - "top", - yogaStyle.position(yoga::Edge::Top), - defaultYogaStyle.position(yoga::Edge::Top)), - debugStringConvertibleItem( - "right", - yogaStyle.position(yoga::Edge::Right), - defaultYogaStyle.position(yoga::Edge::Right)), - debugStringConvertibleItem( - "bottom", - yogaStyle.position(yoga::Edge::Bottom), - defaultYogaStyle.position(yoga::Edge::Bottom)), - debugStringConvertibleItem( - "start", - yogaStyle.position(yoga::Edge::Start), - defaultYogaStyle.position(yoga::Edge::Start)), - debugStringConvertibleItem( - "end", - yogaStyle.position(yoga::Edge::End), - defaultYogaStyle.position(yoga::Edge::End)), - debugStringConvertibleItem( - "inseInline", - yogaStyle.position(yoga::Edge::Horizontal), - defaultYogaStyle.position(yoga::Edge::Horizontal)), - debugStringConvertibleItem( - "insetBlock", - yogaStyle.position(yoga::Edge::Vertical), - defaultYogaStyle.position(yoga::Edge::Vertical)), - debugStringConvertibleItem( - "inset", - yogaStyle.position(yoga::Edge::All), - defaultYogaStyle.position(yoga::Edge::All)), - debugStringConvertibleItem( - "paddingLeft", - yogaStyle.padding(yoga::Edge::Left), - defaultYogaStyle.padding(yoga::Edge::Left)), - debugStringConvertibleItem( - "paddingTop", - yogaStyle.padding(yoga::Edge::Top), - defaultYogaStyle.padding(yoga::Edge::Top)), - debugStringConvertibleItem( - "paddingRight", - yogaStyle.padding(yoga::Edge::Right), - defaultYogaStyle.padding(yoga::Edge::Right)), - debugStringConvertibleItem( - "paddingBottom", - yogaStyle.padding(yoga::Edge::Bottom), - defaultYogaStyle.padding(yoga::Edge::Bottom)), - debugStringConvertibleItem( - "paddingStart", - yogaStyle.padding(yoga::Edge::Start), - defaultYogaStyle.padding(yoga::Edge::Start)), - debugStringConvertibleItem( - "paddingEnd", - yogaStyle.padding(yoga::Edge::End), - defaultYogaStyle.padding(yoga::Edge::End)), - debugStringConvertibleItem( - "paddingHorizontal", - yogaStyle.padding(yoga::Edge::Horizontal), - defaultYogaStyle.padding(yoga::Edge::Horizontal)), - debugStringConvertibleItem( - "paddingVertical", - yogaStyle.padding(yoga::Edge::Vertical), - defaultYogaStyle.padding(yoga::Edge::Vertical)), - debugStringConvertibleItem( - "padding", - yogaStyle.padding(yoga::Edge::All), - defaultYogaStyle.padding(yoga::Edge::All)), - debugStringConvertibleItem( - "borderLeftWidth", - yogaStyle.border(yoga::Edge::Left), - defaultYogaStyle.border(yoga::Edge::Left)), - debugStringConvertibleItem( - "borderTopWidth", - yogaStyle.border(yoga::Edge::Top), - defaultYogaStyle.border(yoga::Edge::Top)), - debugStringConvertibleItem( - "borderRightWidth", - yogaStyle.border(yoga::Edge::Right), - defaultYogaStyle.border(yoga::Edge::Right)), - debugStringConvertibleItem( - "borderBottomWidth", - yogaStyle.border(yoga::Edge::Bottom), - defaultYogaStyle.border(yoga::Edge::Bottom)), - debugStringConvertibleItem( - "borderStartWidth", - yogaStyle.border(yoga::Edge::Start), - defaultYogaStyle.border(yoga::Edge::Start)), - debugStringConvertibleItem( - "borderEndWidth", - yogaStyle.border(yoga::Edge::End), - defaultYogaStyle.border(yoga::Edge::End)), - debugStringConvertibleItem( - "borderHorizontalWidth", - yogaStyle.border(yoga::Edge::Horizontal), - defaultYogaStyle.border(yoga::Edge::Horizontal)), - debugStringConvertibleItem( - "borderVerticalWidth", - yogaStyle.border(yoga::Edge::Vertical), - defaultYogaStyle.border(yoga::Edge::Vertical)), - debugStringConvertibleItem( - "bordeWidth", - yogaStyle.border(yoga::Edge::All), - defaultYogaStyle.border(yoga::Edge::All)), - debugStringConvertibleItem( - "width", - yogaStyle.dimension(yoga::Dimension::Width), - defaultYogaStyle.dimension(yoga::Dimension::Width)), - debugStringConvertibleItem( - "height", - yogaStyle.dimension(yoga::Dimension::Height), - defaultYogaStyle.dimension(yoga::Dimension::Height)), - debugStringConvertibleItem( - "minWidth", - yogaStyle.minDimension(yoga::Dimension::Width), - defaultYogaStyle.minDimension(yoga::Dimension::Width)), - debugStringConvertibleItem( - "minHeight", - yogaStyle.minDimension(yoga::Dimension::Height), - defaultYogaStyle.minDimension(yoga::Dimension::Height)), - debugStringConvertibleItem( - "maxWidth", - yogaStyle.maxDimension(yoga::Dimension::Width), - defaultYogaStyle.maxDimension(yoga::Dimension::Width)), - debugStringConvertibleItem( - "maxHeight", - yogaStyle.maxDimension(yoga::Dimension::Height), - defaultYogaStyle.maxDimension(yoga::Dimension::Height)), - debugStringConvertibleItem( - "aspectRatio", - yogaStyle.aspectRatio(), - defaultYogaStyle.aspectRatio()), - }; + return Props::getDebugProps() + + SharedDebugStringConvertibleList{ + debugStringConvertibleItem( + "direction", yogaStyle.direction(), defaultYogaStyle.direction()), + debugStringConvertibleItem( + "flexDirection", + yogaStyle.flexDirection(), + defaultYogaStyle.flexDirection()), + debugStringConvertibleItem( + "justifyContent", + yogaStyle.justifyContent(), + defaultYogaStyle.justifyContent()), + debugStringConvertibleItem( + "alignContent", + yogaStyle.alignContent(), + defaultYogaStyle.alignContent()), + debugStringConvertibleItem( + "alignItems", + yogaStyle.alignItems(), + defaultYogaStyle.alignItems()), + debugStringConvertibleItem( + "alignSelf", yogaStyle.alignSelf(), defaultYogaStyle.alignSelf()), + debugStringConvertibleItem( + "positionType", + yogaStyle.positionType(), + defaultYogaStyle.positionType()), + debugStringConvertibleItem( + "flexWrap", yogaStyle.flexWrap(), defaultYogaStyle.flexWrap()), + debugStringConvertibleItem( + "overflow", yogaStyle.overflow(), defaultYogaStyle.overflow()), + debugStringConvertibleItem( + "display", yogaStyle.display(), defaultYogaStyle.display()), + debugStringConvertibleItem( + "flex", yogaStyle.flex(), defaultYogaStyle.flex()), + debugStringConvertibleItem( + "flexGrow", yogaStyle.flexGrow(), defaultYogaStyle.flexGrow()), + debugStringConvertibleItem( + "rowGap", + yogaStyle.gap(yoga::Gutter::Row), + defaultYogaStyle.gap(yoga::Gutter::Row)), + debugStringConvertibleItem( + "columnGap", + yogaStyle.gap(yoga::Gutter::Column), + defaultYogaStyle.gap(yoga::Gutter::Column)), + debugStringConvertibleItem( + "gap", + yogaStyle.gap(yoga::Gutter::All), + defaultYogaStyle.gap(yoga::Gutter::All)), + debugStringConvertibleItem( + "flexShrink", + yogaStyle.flexShrink(), + defaultYogaStyle.flexShrink()), + debugStringConvertibleItem( + "flexBasis", yogaStyle.flexBasis(), defaultYogaStyle.flexBasis()), + debugStringConvertibleItem( + "marginLeft", + yogaStyle.margin(yoga::Edge::Left), + defaultYogaStyle.margin(yoga::Edge::Left)), + debugStringConvertibleItem( + "marginTop", + yogaStyle.margin(yoga::Edge::Top), + defaultYogaStyle.margin(yoga::Edge::Top)), + debugStringConvertibleItem( + "marginRight", + yogaStyle.margin(yoga::Edge::Right), + defaultYogaStyle.margin(yoga::Edge::Right)), + debugStringConvertibleItem( + "marginBottom", + yogaStyle.margin(yoga::Edge::Bottom), + defaultYogaStyle.margin(yoga::Edge::Bottom)), + debugStringConvertibleItem( + "marginStart", + yogaStyle.margin(yoga::Edge::Start), + defaultYogaStyle.margin(yoga::Edge::Start)), + debugStringConvertibleItem( + "marginEnd", + yogaStyle.margin(yoga::Edge::End), + defaultYogaStyle.margin(yoga::Edge::End)), + debugStringConvertibleItem( + "marginHorizontal", + yogaStyle.margin(yoga::Edge::Horizontal), + defaultYogaStyle.margin(yoga::Edge::Horizontal)), + debugStringConvertibleItem( + "marginVertical", + yogaStyle.margin(yoga::Edge::Vertical), + defaultYogaStyle.margin(yoga::Edge::Vertical)), + debugStringConvertibleItem( + "margin", + yogaStyle.margin(yoga::Edge::All), + defaultYogaStyle.margin(yoga::Edge::All)), + debugStringConvertibleItem( + "left", + yogaStyle.position(yoga::Edge::Left), + defaultYogaStyle.position(yoga::Edge::Left)), + debugStringConvertibleItem( + "top", + yogaStyle.position(yoga::Edge::Top), + defaultYogaStyle.position(yoga::Edge::Top)), + debugStringConvertibleItem( + "right", + yogaStyle.position(yoga::Edge::Right), + defaultYogaStyle.position(yoga::Edge::Right)), + debugStringConvertibleItem( + "bottom", + yogaStyle.position(yoga::Edge::Bottom), + defaultYogaStyle.position(yoga::Edge::Bottom)), + debugStringConvertibleItem( + "start", + yogaStyle.position(yoga::Edge::Start), + defaultYogaStyle.position(yoga::Edge::Start)), + debugStringConvertibleItem( + "end", + yogaStyle.position(yoga::Edge::End), + defaultYogaStyle.position(yoga::Edge::End)), + debugStringConvertibleItem( + "inseInline", + yogaStyle.position(yoga::Edge::Horizontal), + defaultYogaStyle.position(yoga::Edge::Horizontal)), + debugStringConvertibleItem( + "insetBlock", + yogaStyle.position(yoga::Edge::Vertical), + defaultYogaStyle.position(yoga::Edge::Vertical)), + debugStringConvertibleItem( + "inset", + yogaStyle.position(yoga::Edge::All), + defaultYogaStyle.position(yoga::Edge::All)), + debugStringConvertibleItem( + "paddingLeft", + yogaStyle.padding(yoga::Edge::Left), + defaultYogaStyle.padding(yoga::Edge::Left)), + debugStringConvertibleItem( + "paddingTop", + yogaStyle.padding(yoga::Edge::Top), + defaultYogaStyle.padding(yoga::Edge::Top)), + debugStringConvertibleItem( + "paddingRight", + yogaStyle.padding(yoga::Edge::Right), + defaultYogaStyle.padding(yoga::Edge::Right)), + debugStringConvertibleItem( + "paddingBottom", + yogaStyle.padding(yoga::Edge::Bottom), + defaultYogaStyle.padding(yoga::Edge::Bottom)), + debugStringConvertibleItem( + "paddingStart", + yogaStyle.padding(yoga::Edge::Start), + defaultYogaStyle.padding(yoga::Edge::Start)), + debugStringConvertibleItem( + "paddingEnd", + yogaStyle.padding(yoga::Edge::End), + defaultYogaStyle.padding(yoga::Edge::End)), + debugStringConvertibleItem( + "paddingHorizontal", + yogaStyle.padding(yoga::Edge::Horizontal), + defaultYogaStyle.padding(yoga::Edge::Horizontal)), + debugStringConvertibleItem( + "paddingVertical", + yogaStyle.padding(yoga::Edge::Vertical), + defaultYogaStyle.padding(yoga::Edge::Vertical)), + debugStringConvertibleItem( + "padding", + yogaStyle.padding(yoga::Edge::All), + defaultYogaStyle.padding(yoga::Edge::All)), + debugStringConvertibleItem( + "borderLeftWidth", + yogaStyle.border(yoga::Edge::Left), + defaultYogaStyle.border(yoga::Edge::Left)), + debugStringConvertibleItem( + "borderTopWidth", + yogaStyle.border(yoga::Edge::Top), + defaultYogaStyle.border(yoga::Edge::Top)), + debugStringConvertibleItem( + "borderRightWidth", + yogaStyle.border(yoga::Edge::Right), + defaultYogaStyle.border(yoga::Edge::Right)), + debugStringConvertibleItem( + "borderBottomWidth", + yogaStyle.border(yoga::Edge::Bottom), + defaultYogaStyle.border(yoga::Edge::Bottom)), + debugStringConvertibleItem( + "borderStartWidth", + yogaStyle.border(yoga::Edge::Start), + defaultYogaStyle.border(yoga::Edge::Start)), + debugStringConvertibleItem( + "borderEndWidth", + yogaStyle.border(yoga::Edge::End), + defaultYogaStyle.border(yoga::Edge::End)), + debugStringConvertibleItem( + "borderHorizontalWidth", + yogaStyle.border(yoga::Edge::Horizontal), + defaultYogaStyle.border(yoga::Edge::Horizontal)), + debugStringConvertibleItem( + "borderVerticalWidth", + yogaStyle.border(yoga::Edge::Vertical), + defaultYogaStyle.border(yoga::Edge::Vertical)), + debugStringConvertibleItem( + "bordeWidth", + yogaStyle.border(yoga::Edge::All), + defaultYogaStyle.border(yoga::Edge::All)), + debugStringConvertibleItem( + "width", + yogaStyle.dimension(yoga::Dimension::Width), + defaultYogaStyle.dimension(yoga::Dimension::Width)), + debugStringConvertibleItem( + "height", + yogaStyle.dimension(yoga::Dimension::Height), + defaultYogaStyle.dimension(yoga::Dimension::Height)), + debugStringConvertibleItem( + "minWidth", + yogaStyle.minDimension(yoga::Dimension::Width), + defaultYogaStyle.minDimension(yoga::Dimension::Width)), + debugStringConvertibleItem( + "minHeight", + yogaStyle.minDimension(yoga::Dimension::Height), + defaultYogaStyle.minDimension(yoga::Dimension::Height)), + debugStringConvertibleItem( + "maxWidth", + yogaStyle.maxDimension(yoga::Dimension::Width), + defaultYogaStyle.maxDimension(yoga::Dimension::Width)), + debugStringConvertibleItem( + "maxHeight", + yogaStyle.maxDimension(yoga::Dimension::Height), + defaultYogaStyle.maxDimension(yoga::Dimension::Height)), + debugStringConvertibleItem( + "aspectRatio", + yogaStyle.aspectRatio(), + defaultYogaStyle.aspectRatio()), + }; } #endif diff --git a/packages/react-native/ReactCommon/react/renderer/core/Props.cpp b/packages/react-native/ReactCommon/react/renderer/core/Props.cpp index a8bd7079d47289..bdd0f76825ea6d 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/Props.cpp +++ b/packages/react-native/ReactCommon/react/renderer/core/Props.cpp @@ -10,6 +10,7 @@ #include #include +#include #include "DynamicPropsUtilities.h" namespace facebook::react { @@ -56,4 +57,12 @@ void Props::setProp( } } +#pragma mark - DebugStringConvertible + +#if RN_DEBUG_STRING_CONVERTIBLE +SharedDebugStringConvertibleList Props::getDebugProps() const { + return {debugStringConvertibleItem("nativeID", nativeId)}; +} +#endif + } // namespace facebook::react diff --git a/packages/react-native/ReactCommon/react/renderer/core/Props.h b/packages/react-native/ReactCommon/react/renderer/core/Props.h index 0905361fbc4cf7..b2c66b025100ce 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/Props.h +++ b/packages/react-native/ReactCommon/react/renderer/core/Props.h @@ -35,7 +35,12 @@ class Props : public virtual Sealable, public virtual DebugStringConvertible { const RawProps& rawProps, const std::function& filterObjectKeys = nullptr); + +#if RN_DEBUG_STRING_CONVERTIBLE + virtual ~Props() override = default; +#else virtual ~Props() = default; +#endif Props(const Props& other) = delete; Props& operator=(const Props& other) = delete; @@ -65,6 +70,14 @@ class Props : public virtual Sealable, public virtual DebugStringConvertible { return folly::dynamic::object(); } +#endif + +#if RN_DEBUG_STRING_CONVERTIBLE + +#pragma mark - DebugStringConvertible (Partial) + + SharedDebugStringConvertibleList getDebugProps() const override; + #endif protected: