Extend Yoga to be able clone Yoga Node with new children
Summary: This diff includes the following changes: 1 ) I extended the Java implementation of YogaNode to be able to get a full copy of a YogaNode object without copying the List of children of the original YogaNode. In other words, the new copy of the YogaNode will have the same data of the original YogaNode, but with an empty list of children. 2 ) We created a new method in Yoga.cpp called YGNodeInsertSharedChild. This new method is going to be used by Fabric in order to temporarily share a YogaNode between two "Yoga Trees" (the "current Yoga" tree and a partial "clone of the current Yoga tree"). We exposed this new functionality in the java implementation of Yoga (method addSharedChildAt) I'm including sebmarkbage for more context. Reviewed By: emilsjolander Differential Revision: D7245421 fbshipit-source-id: 72578c8261f29e4a12fc6c72a91f2f891cd58d48
This commit is contained in:
committed by
Facebook Github Bot
parent
f0edefdbb7
commit
5e3ffb39a2
25
yoga/Yoga.h
25
yoga/Yoga.h
@@ -62,9 +62,8 @@ typedef int (*YGLogger)(const YGConfigRef config,
|
||||
YGLogLevel level,
|
||||
const char *format,
|
||||
va_list args);
|
||||
typedef YGNodeRef (*YGCloneNodeFunc)(YGNodeRef oldNode,
|
||||
YGNodeRef parent,
|
||||
int childIndex);
|
||||
typedef YGNodeRef (
|
||||
*YGCloneNodeFunc)(YGNodeRef oldNode, YGNodeRef owner, int childIndex);
|
||||
|
||||
// YGNode
|
||||
WIN_EXPORT YGNodeRef YGNodeNew(void);
|
||||
@@ -78,12 +77,26 @@ WIN_EXPORT int32_t YGNodeGetInstanceCount(void);
|
||||
WIN_EXPORT void YGNodeInsertChild(const YGNodeRef node,
|
||||
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);
|
||||
WIN_EXPORT YGNodeRef YGNodeGetOwner(const YGNodeRef node);
|
||||
WIN_EXPORT uint32_t YGNodeGetChildCount(const YGNodeRef node);
|
||||
WIN_EXPORT void YGNodeSetChildren(YGNodeRef const parent, const YGNodeRef children[], const uint32_t count);
|
||||
WIN_EXPORT void YGNodeSetChildren(
|
||||
YGNodeRef const owner,
|
||||
const YGNodeRef children[],
|
||||
const uint32_t count);
|
||||
|
||||
WIN_EXPORT void YGNodeCalculateLayout(const YGNodeRef node,
|
||||
const float availableWidth,
|
||||
@@ -307,6 +320,8 @@ YG_EXTERN_C_END
|
||||
// Calls f on each node in the tree including the given node argument.
|
||||
extern void YGTraversePreOrder(YGNodeRef const node, std::function<void(YGNodeRef node)>&& f);
|
||||
|
||||
extern void YGNodeSetChildren(YGNodeRef const parent, const std::vector<YGNodeRef> &children);
|
||||
extern void YGNodeSetChildren(
|
||||
YGNodeRef const owner,
|
||||
const std::vector<YGNodeRef>& children);
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user