Add support for context-aware cloning functions

Summary:
@public

Context-aware cloning functions are an internal Yoga feature that will be used for Yoga’s JNI code.

It will be possible to specify a context when calculating layout, which will be passed on to cloning functions. This will be a private feature.

Reviewed By: SidharthGuglani

Differential Revision: D14149470

fbshipit-source-id: 1d11106e65f9d872d10f191763da001f8d158a61
This commit is contained in:
David Aurelio
2019-02-20 11:52:38 -08:00
committed by Facebook Github Bot
parent b1c749075d
commit 2156de5fb5
6 changed files with 57 additions and 18 deletions

View File

@@ -1789,13 +1789,16 @@ static bool YGNodeFixedSizeSetMeasuredDimensions(
return false;
}
static void YGZeroOutLayoutRecursivly(const YGNodeRef node) {
static void YGZeroOutLayoutRecursivly(
const YGNodeRef node,
void* layoutContext) {
node->getLayout() = {};
node->setLayoutDimension(0, 0);
node->setLayoutDimension(0, 1);
node->setHasNewLayout(true);
node->iterChildrenAfterCloningIfNeeded(YGZeroOutLayoutRecursivly);
node->iterChildrenAfterCloningIfNeeded(
YGZeroOutLayoutRecursivly, layoutContext);
}
static float YGNodeCalculateAvailableInnerDim(
@@ -1877,7 +1880,7 @@ static float YGNodeComputeFlexBasisForChildren(
for (auto child : children) {
child->resolveDimension();
if (child->getStyle().display == YGDisplayNone) {
YGZeroOutLayoutRecursivly(child);
YGZeroOutLayoutRecursivly(child, layoutContext);
child->setHasNewLayout(true);
child->setDirty(false);
continue;
@@ -2751,7 +2754,7 @@ static void YGNodelayoutImpl(
// At this point we know we're going to perform work. Ensure that each child
// has a mutable copy.
node->cloneChildrenIfNeeded();
node->cloneChildrenIfNeeded(layoutContext);
// Reset layout flags, as they could have changed.
node->setLayoutHadOverflow(false);