diff --git a/ReactCommon/fabric/core/layout/LayoutableShadowNode.cpp b/ReactCommon/fabric/core/layout/LayoutableShadowNode.cpp index 3e2b4a0e8..a1fd9623f 100644 --- a/ReactCommon/fabric/core/layout/LayoutableShadowNode.cpp +++ b/ReactCommon/fabric/core/layout/LayoutableShadowNode.cpp @@ -10,6 +10,8 @@ #include #include #include +#include +#include namespace facebook { namespace react { @@ -94,5 +96,40 @@ void LayoutableShadowNode::layoutChildren(LayoutContext layoutContext) { // Default implementation does nothing. } +SharedDebugStringConvertibleList LayoutableShadowNode::getDebugProps() const { + SharedDebugStringConvertibleList list = {}; + + if (getHasNewLayout()) { + list.push_back(std::make_shared("hasNewLayout")); + } + + if (!getIsLayoutClean()) { + list.push_back(std::make_shared("dirty")); + } + + LayoutMetrics layoutMetrics = getLayoutMetrics(); + LayoutMetrics defaultLayoutMetrics = LayoutMetrics(); + + list.push_back(std::make_shared("frame", stringFromRect(layoutMetrics.frame))); + + if (layoutMetrics.borderWidth != defaultLayoutMetrics.borderWidth) { + list.push_back(std::make_shared("borderWidth", stringFromEdgeInsets(layoutMetrics.borderWidth))); + } + + if (layoutMetrics.contentInsets != defaultLayoutMetrics.contentInsets) { + list.push_back(std::make_shared("contentInsets", stringFromEdgeInsets(layoutMetrics.contentInsets))); + } + + if (layoutMetrics.displayType == DisplayType::None) { + list.push_back(std::make_shared("hidden")); + } + + if (layoutMetrics.layoutDirection == LayoutDirection::RightToLeft) { + list.push_back(std::make_shared("rtl")); + } + + return list; +} + } // namespace react } // namespace facebook diff --git a/ReactCommon/fabric/core/layout/LayoutableShadowNode.h b/ReactCommon/fabric/core/layout/LayoutableShadowNode.h index d1c9ce1d6..d66449877 100644 --- a/ReactCommon/fabric/core/layout/LayoutableShadowNode.h +++ b/ReactCommon/fabric/core/layout/LayoutableShadowNode.h @@ -13,6 +13,7 @@ #include #include +#include namespace facebook { namespace react { @@ -102,6 +103,10 @@ protected: */ virtual bool setLayoutMetrics(LayoutMetrics layoutMetrics); +#pragma mark - DebugStringConvertible + + SharedDebugStringConvertibleList getDebugProps() const; + private: LayoutMetrics layoutMetrics_ {}; bool hasNewLayout_ {false}; diff --git a/ReactCommon/fabric/view/ConcreteViewShadowNode.h b/ReactCommon/fabric/view/ConcreteViewShadowNode.h index 320fbb0d4..a6994fe3e 100644 --- a/ReactCommon/fabric/view/ConcreteViewShadowNode.h +++ b/ReactCommon/fabric/view/ConcreteViewShadowNode.h @@ -138,7 +138,7 @@ public: auto basePropsList = ShadowNode::getDebugProps(); std::move(basePropsList.begin(), basePropsList.end(), std::back_inserter(list)); - list.push_back(std::make_shared("layout", "", YogaLayoutableShadowNode::getDebugProps())); + list.push_back(std::make_shared("layout", "", LayoutableShadowNode::getDebugProps())); return list; } diff --git a/ReactCommon/fabric/view/yoga/YogaLayoutableShadowNode.cpp b/ReactCommon/fabric/view/yoga/YogaLayoutableShadowNode.cpp index 2851fa4d9..2b6a6e233 100644 --- a/ReactCommon/fabric/view/yoga/YogaLayoutableShadowNode.cpp +++ b/ReactCommon/fabric/view/yoga/YogaLayoutableShadowNode.cpp @@ -130,42 +130,6 @@ void YogaLayoutableShadowNode::layoutChildren(LayoutContext layoutContext) { } } -#pragma mark - DebugStringConvertible - -SharedDebugStringConvertibleList YogaLayoutableShadowNode::getDebugProps() const { - // TODO: Move to the base class and return `layoutMetrics` instead. - - SharedDebugStringConvertibleList list = {}; - - if (getHasNewLayout()) { - list.push_back(std::make_shared("hasNewLayout")); - } - - YGLayout defaultYogaLayout = YGLayout(); - defaultYogaLayout.direction = YGDirectionLTR; - YGLayout currentYogaLayout = std::const_pointer_cast(yogaNode_)->getLayout(); - -#define YOGA_LAYOUT_PROPS_ADD_TO_SET(stringName, propertyName, accessor, convertor) \ - { \ - auto currentValueString = convertor(currentYogaLayout.propertyName accessor); \ - auto defaultValueString = convertor(defaultYogaLayout.propertyName accessor); \ - if (currentValueString != defaultValueString) { \ - list.push_back(std::make_shared(#stringName, currentValueString)); \ - } \ - } - - YOGA_LAYOUT_PROPS_ADD_TO_SET(position, position, , stringFromYogaPosition) - YOGA_LAYOUT_PROPS_ADD_TO_SET(dimensions, dimensions, , stringFromYogaDimensions) - YOGA_LAYOUT_PROPS_ADD_TO_SET(margin, margin, , stringFromYogaEdges) - YOGA_LAYOUT_PROPS_ADD_TO_SET(border, border, , stringFromYogaEdges) - YOGA_LAYOUT_PROPS_ADD_TO_SET(padding, padding, , stringFromYogaEdges) - YOGA_LAYOUT_PROPS_ADD_TO_SET(direction, direction, , stringFromYogaStyleDirection) - - return list; -} - -#pragma mark - Helpers - #pragma mark - Yoga Connectors YGNode *YogaLayoutableShadowNode::yogaNodeCloneCallbackConnector(YGNode *oldYogaNode, YGNode *parentYogaNode, int childIndex) { diff --git a/ReactCommon/fabric/view/yoga/YogaLayoutableShadowNode.h b/ReactCommon/fabric/view/yoga/YogaLayoutableShadowNode.h index 15f25cdf4..8b367e5e9 100644 --- a/ReactCommon/fabric/view/yoga/YogaLayoutableShadowNode.h +++ b/ReactCommon/fabric/view/yoga/YogaLayoutableShadowNode.h @@ -76,10 +76,6 @@ public: void layoutChildren(LayoutContext layoutContext) override; -#pragma mark - DebugStringConvertible - - SharedDebugStringConvertibleList getDebugProps() const override; - private: mutable SharedYogaNode yogaNode_;