From c3c5c3cbce24a31f73ae6339e377ee76ca6401ad Mon Sep 17 00:00:00 2001 From: Vince Mi Date: Mon, 11 Jun 2018 04:07:38 -0700 Subject: [PATCH] Add back deprecated getParent methods for non-breaking API change (#775) Summary: I'm not totally sure what I'm doing so if this needs changes let me know. Closes https://github.com/facebook/yoga/pull/775 Reviewed By: emilsjolander Differential Revision: D8331892 Pulled By: passy fbshipit-source-id: eb1023e666322d2472e4081fd4a4e72a7b43d049 --- ReactAndroid/src/main/java/com/facebook/yoga/YogaNode.java | 5 ++--- ReactCommon/yoga/yoga/YGNode.cpp | 4 ++++ ReactCommon/yoga/yoga/YGNode.h | 2 ++ ReactCommon/yoga/yoga/Yoga.cpp | 4 ++++ ReactCommon/yoga/yoga/Yoga.h | 1 + 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/yoga/YogaNode.java b/ReactAndroid/src/main/java/com/facebook/yoga/YogaNode.java index fdb5b4be5017c1..90caf8f81e0131 100644 --- a/ReactAndroid/src/main/java/com/facebook/yoga/YogaNode.java +++ b/ReactAndroid/src/main/java/com/facebook/yoga/YogaNode.java @@ -234,15 +234,14 @@ public YogaNode removeChildAt(int i) { * {@link YogaNode} is shared between two or more YogaTrees. */ @Nullable - public - YogaNode getOwner() { + public YogaNode getOwner() { return mOwner; } /** @deprecated Use #getOwner() instead. This will be removed in the next version. */ @Deprecated @Nullable - YogaNode getParent() { + public YogaNode getParent() { return getOwner(); } diff --git a/ReactCommon/yoga/yoga/YGNode.cpp b/ReactCommon/yoga/yoga/YGNode.cpp index 64a47d356a373f..16f9e4d0092eca 100644 --- a/ReactCommon/yoga/yoga/YGNode.cpp +++ b/ReactCommon/yoga/yoga/YGNode.cpp @@ -53,6 +53,10 @@ YGNodeRef YGNode::getOwner() const { return owner_; } +YGNodeRef YGNode::getParent() const { + return getOwner(); +} + YGVector YGNode::getChildren() const { return children_; } diff --git a/ReactCommon/yoga/yoga/YGNode.h b/ReactCommon/yoga/yoga/YGNode.h index 96541a575eeb20..e3562bb605299b 100644 --- a/ReactCommon/yoga/yoga/YGNode.h +++ b/ReactCommon/yoga/yoga/YGNode.h @@ -78,6 +78,8 @@ struct YGNode { // to one YogaTree or nullptr when the YGNode is shared between two or more // YogaTrees. YGNodeRef getOwner() const; + // Deprecated, use getOwner() instead. + YGNodeRef getParent() const; YGVector getChildren() const; uint32_t getChildrenCount() const; YGNodeRef getChild(uint32_t index) const; diff --git a/ReactCommon/yoga/yoga/Yoga.cpp b/ReactCommon/yoga/yoga/Yoga.cpp index a927ef556c4734..c6a8ffd2ea1e48 100644 --- a/ReactCommon/yoga/yoga/Yoga.cpp +++ b/ReactCommon/yoga/yoga/Yoga.cpp @@ -535,6 +535,10 @@ YGNodeRef YGNodeGetOwner(const YGNodeRef node) { return node->getOwner(); } +YGNodeRef YGNodeGetParent(const YGNodeRef node) { + return node->getOwner(); +} + void YGNodeMarkDirty(const YGNodeRef node) { YGAssertWithNode( node, diff --git a/ReactCommon/yoga/yoga/Yoga.h b/ReactCommon/yoga/yoga/Yoga.h index 25eb0eb6f5a821..a9fc89d7df4d2c 100644 --- a/ReactCommon/yoga/yoga/Yoga.h +++ b/ReactCommon/yoga/yoga/Yoga.h @@ -92,6 +92,7 @@ WIN_EXPORT void YGNodeRemoveChild(const YGNodeRef node, const YGNodeRef child); WIN_EXPORT void YGNodeRemoveAllChildren(const YGNodeRef node); WIN_EXPORT YGNodeRef YGNodeGetChild(const YGNodeRef node, const uint32_t index); WIN_EXPORT YGNodeRef YGNodeGetOwner(const YGNodeRef node); +WIN_EXPORT YGNodeRef YGNodeGetParent(const YGNodeRef node); WIN_EXPORT uint32_t YGNodeGetChildCount(const YGNodeRef node); WIN_EXPORT void YGNodeSetChildren( YGNodeRef const owner,