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

@@ -32,7 +32,7 @@ TEST_F(ConfigCloningTest, uses_values_provided_by_cloning_callback) {
config->setCloneNodeCallback(cloneNode);
YGNode node{}, owner{};
auto clone = config->cloneNode(&node, &owner, 0);
auto clone = config->cloneNode(&node, &owner, 0, nullptr);
ASSERT_EQ(clone, &clonedNode);
}
@@ -43,12 +43,21 @@ TEST_F(
config->setCloneNodeCallback(doNotClone);
YGNode node{}, owner{};
auto clone = config->cloneNode(&node, &owner, 0);
auto clone = config->cloneNode(&node, &owner, 0, nullptr);
ASSERT_NE(clone, nullptr);
YGNodeFree(clone);
}
TEST_F(ConfigCloningTest, can_clone_with_context) {
config->setCloneNodeCallback([](YGNodeRef, YGNodeRef, int, void* context) {
return (YGNodeRef) context;
});
YGNode node{}, owner{}, clone{};
ASSERT_EQ(config->cloneNode(&node, &owner, 0, &clone), &clone);
}
void ConfigCloningTest::SetUp() {
config = {YGConfigNew(), YGConfigFree};
}