From f4def0062cc2f1e07c5f16c1b9af6c15a2fca050 Mon Sep 17 00:00:00 2001 From: David Aurelio Date: Thu, 24 Jan 2019 06:28:01 -0800 Subject: [PATCH] Delete functionality for shared childen Summary: @public Removes `YGNodeInsertSharedChild` / `addSharedChildAt`. This functionality is unused, and can cause memory leaks. Reviewed By: SidharthGuglani Differential Revision: D13711105 fbshipit-source-id: 86206c05393b3f1a497e6b046006f94ead88c6ce --- .../main/java/com/facebook/yoga/YogaNode.java | 20 ++++--------------- .../jni/first-party/yogajni/jni/YGJNI.cpp | 9 --------- ReactCommon/yoga/yoga/Yoga.cpp | 14 ------------- ReactCommon/yoga/yoga/Yoga.h | 10 ---------- 4 files changed, 4 insertions(+), 49 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/yoga/YogaNode.java b/ReactAndroid/src/main/java/com/facebook/yoga/YogaNode.java index 7dd2694745f..a8168cf1f42 100644 --- a/ReactAndroid/src/main/java/com/facebook/yoga/YogaNode.java +++ b/ReactAndroid/src/main/java/com/facebook/yoga/YogaNode.java @@ -1,9 +1,8 @@ -/* - * Copyright (c) Facebook, Inc. - * - * This source code is licensed under the MIT license found in the LICENSE - * file in the root directory of this source tree. +/** + * Copyright (c) Facebook, Inc. and its affiliates. * + * This source code is licensed under the MIT license found in the LICENSE + * file in the root directory of this source tree. */ package com.facebook.yoga; @@ -174,17 +173,6 @@ public class YogaNode implements Cloneable { jni_YGNodeInsertChild(mNativePointer, child.mNativePointer, i); } - private static native void jni_YGNodeInsertSharedChild(long nativePointer, long childPointer, int index); - - public void addSharedChildAt(YogaNode child, int i) { - if (mChildren == null) { - mChildren = new ArrayList<>(4); - } - mChildren.add(i, child); - child.mOwner = null; - jni_YGNodeInsertSharedChild(mNativePointer, child.mNativePointer, i); - } - private static native void jni_YGNodeSetIsReferenceBaseline(long nativePointer, boolean isReferenceBaseline); public void setIsReferenceBaseline(boolean isReferenceBaseline) { diff --git a/ReactAndroid/src/main/jni/first-party/yogajni/jni/YGJNI.cpp b/ReactAndroid/src/main/jni/first-party/yogajni/jni/YGJNI.cpp index ea0d9d07f56..915876b5ad6 100644 --- a/ReactAndroid/src/main/jni/first-party/yogajni/jni/YGJNI.cpp +++ b/ReactAndroid/src/main/jni/first-party/yogajni/jni/YGJNI.cpp @@ -359,14 +359,6 @@ void jni_YGNodeInsertChild( _jlong2YGNodeRef(nativePointer), _jlong2YGNodeRef(childPointer), index); } -void jni_YGNodeInsertSharedChild( - jlong nativePointer, - jlong childPointer, - jint index) { - YGNodeInsertSharedChild( - _jlong2YGNodeRef(nativePointer), _jlong2YGNodeRef(childPointer), index); -} - void jni_YGNodeRemoveChild(jlong nativePointer, jlong childPointer) { YGNodeRemoveChild( _jlong2YGNodeRef(nativePointer), _jlong2YGNodeRef(childPointer)); @@ -672,7 +664,6 @@ jint JNI_OnLoad(JavaVM* vm, void*) { YGMakeCriticalNativeMethod(jni_YGNodeReset), YGMakeCriticalNativeMethod(jni_YGNodeClearChildren), YGMakeCriticalNativeMethod(jni_YGNodeInsertChild), - YGMakeCriticalNativeMethod(jni_YGNodeInsertSharedChild), YGMakeCriticalNativeMethod(jni_YGNodeRemoveChild), YGMakeCriticalNativeMethod(jni_YGNodeSetIsReferenceBaseline), YGMakeCriticalNativeMethod(jni_YGNodeIsReferenceBaseline), diff --git a/ReactCommon/yoga/yoga/Yoga.cpp b/ReactCommon/yoga/yoga/Yoga.cpp index 38287e76fc9..357e137b895 100644 --- a/ReactCommon/yoga/yoga/Yoga.cpp +++ b/ReactCommon/yoga/yoga/Yoga.cpp @@ -402,20 +402,6 @@ void YGNodeInsertChild( node->markDirtyAndPropogate(); } -void YGNodeInsertSharedChild( - const YGNodeRef node, - const YGNodeRef child, - const uint32_t index) { - YGAssertWithNode( - node, - node->getMeasure() == nullptr, - "Cannot add child: Nodes with measure functions cannot have children."); - - node->insertChild(child, index); - child->setOwner(nullptr); - node->markDirtyAndPropogate(); -} - void YGNodeRemoveChild(const YGNodeRef owner, const YGNodeRef excludedChild) { // This algorithm is a forked variant from cloneChildrenIfNeeded in YGNode // that excludes a child. diff --git a/ReactCommon/yoga/yoga/Yoga.h b/ReactCommon/yoga/yoga/Yoga.h index afb4c9be51b..b15f8bb28d0 100644 --- a/ReactCommon/yoga/yoga/Yoga.h +++ b/ReactCommon/yoga/yoga/Yoga.h @@ -69,16 +69,6 @@ WIN_EXPORT void YGNodeInsertChild( const YGNodeRef child, const uint32_t index); -// This function inserts the child YGNodeRef as a children of the node received -// by parameter and set the Owner of the child object to null. This function is -// expected to be called when using Yoga in persistent mode in order to share a -// YGNodeRef object as a child of two different Yoga trees. The child YGNodeRef -// is expected to be referenced from its original owner and from a clone of its -// original owner. -WIN_EXPORT void YGNodeInsertSharedChild( - const YGNodeRef node, - const YGNodeRef child, - const uint32_t index); 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);