From 05f41931e22fd6fe849876646802c07f4cbd1b69 Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Tue, 10 Apr 2018 16:36:56 -0700 Subject: [PATCH] Fabric: Fixed YogaLayoutableShadowNode::yogaNodeCloneCallbackConnector Summary: YogaLayoutableShadowNode::yogaNodeCloneCallbackConnector recently was disabled because of change in Yoga (D7339832). This diff brings is back. Reviewed By: mdvacca Differential Revision: D7526417 fbshipit-source-id: 5369d641bf1e118132cf742d2d243bf426c0ffdb --- .../fabric/view/yoga/YogaLayoutableShadowNode.cpp | 11 ++++------- .../fabric/view/yoga/YogaLayoutableShadowNode.h | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/ReactCommon/fabric/view/yoga/YogaLayoutableShadowNode.cpp b/ReactCommon/fabric/view/yoga/YogaLayoutableShadowNode.cpp index e2aa05f84..62c803b2f 100644 --- a/ReactCommon/fabric/view/yoga/YogaLayoutableShadowNode.cpp +++ b/ReactCommon/fabric/view/yoga/YogaLayoutableShadowNode.cpp @@ -23,9 +23,8 @@ SharedYogaConfig YogaLayoutableShadowNode::suitableYogaConfig() { static SharedYogaConfig sharedYogaConfig; if (!sharedYogaConfig) { - sharedYogaConfig = std::make_shared(YGConfig({ - // .cloneNodeCallback = YogaLayoutableShadowNode::yogaNodeCloneCallbackConnector - })); + sharedYogaConfig = std::shared_ptr(YGConfigNew()); + sharedYogaConfig->cloneNodeCallback = YogaLayoutableShadowNode::yogaNodeCloneCallbackConnector; } return sharedYogaConfig; @@ -169,7 +168,7 @@ SharedDebugStringConvertibleList YogaLayoutableShadowNode::getDebugProps() const #pragma mark - Yoga Connectors -void YogaLayoutableShadowNode::yogaNodeCloneCallbackConnector(YGNode *oldYogaNode, YGNode *newYogaNode, YGNode *parentYogaNode, int childIndex) { +YGNode *YogaLayoutableShadowNode::yogaNodeCloneCallbackConnector(YGNode *oldYogaNode, YGNode *parentYogaNode, int childIndex) { // We have only raw pointer to the parent shadow node, but that's enough for now. YogaLayoutableShadowNode *parentShadowNodeRawPtr = (YogaLayoutableShadowNode *)parentYogaNode->getContext(); assert(parentShadowNodeRawPtr); @@ -198,9 +197,7 @@ void YogaLayoutableShadowNode::yogaNodeCloneCallbackConnector(YGNode *oldYogaNod std::dynamic_pointer_cast(parentShadowNodeRawPtr->cloneAndReplaceChild(oldShadowNode)); assert(newShadowNode); - // And finally, we have to replace underline yoga node with the new one provided by Yoga. - newYogaNode->setContext((void *)newShadowNode.get()); - newShadowNode->yogaNode_ = std::shared_ptr(newYogaNode); + return newShadowNode->yogaNode_.get(); } void YogaLayoutableShadowNode::setYogaNodeChildrenBasedOnShadowNodeChildren(YGNode &yogaNode, const SharedShadowNodeSharedList &children) { diff --git a/ReactCommon/fabric/view/yoga/YogaLayoutableShadowNode.h b/ReactCommon/fabric/view/yoga/YogaLayoutableShadowNode.h index e07acc859..15f25cdf4 100644 --- a/ReactCommon/fabric/view/yoga/YogaLayoutableShadowNode.h +++ b/ReactCommon/fabric/view/yoga/YogaLayoutableShadowNode.h @@ -85,7 +85,7 @@ private: static SharedYogaConfig suitableYogaConfig(); static void setYogaNodeChildrenBasedOnShadowNodeChildren(YGNode &yogaNode, const SharedShadowNodeSharedList &children); - static void yogaNodeCloneCallbackConnector(YGNode *oldYogaNode, YGNode *newYogaNode, YGNode *parentYogaNode, int childIndex); + static YGNode *yogaNodeCloneCallbackConnector(YGNode *oldYogaNode, YGNode *parentYogaNode, int childIndex); }; } // namespace react