Move node cloning to YGConfig

Summary:
@public

Encapsulates node cloning within `YGConfig`.
This is necessary for allowing for context-aware cloning functions, which will ultimately allow for removal of weak global JNI references.

Reviewed By: shergin

Differential Revision: D14132608

fbshipit-source-id: 0dec114c8e172b1e34a4b7fd146c43f13c151ade
This commit is contained in:
David Aurelio
2019-02-20 11:52:38 -08:00
committed by Facebook Github Bot
parent 2643b96589
commit 367a93de88
5 changed files with 82 additions and 20 deletions

View File

@@ -19,6 +19,7 @@ struct YGConfig {
va_list args);
private:
YGCloneNodeFunc cloneNodeCallback_ = nullptr;
union {
LogWithContextFn withContext;
YGLogger noContext;
@@ -31,7 +32,6 @@ public:
bool shouldDiffLayoutWithoutLegacyStretchBehaviour = false;
bool printTree = false;
float pointScaleFactor = 1.0f;
YGCloneNodeFunc cloneNodeCallback = nullptr;
std::array<bool, facebook::yoga::enums::count<YGExperimentalFeature>()>
experimentalFeatures = {};
void* context = nullptr;
@@ -50,4 +50,9 @@ public:
void setLogger(std::nullptr_t) {
setLogger(YGLogger{nullptr});
}
YGNodeRef cloneNode(YGNodeRef node, YGNodeRef owner, int childIndex);
void setCloneNodeCallback(YGCloneNodeFunc cloneNode) {
cloneNodeCallback_ = cloneNode;
}
};