From c981db0146fcead7ac7ef76e4d0ac2321d2b3058 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20W=C3=B6hrl?= Date: Sun, 15 Oct 2017 20:55:58 +0200 Subject: [PATCH] transfer current layout before calling basline function do not reset newLayoutFlag on baseline transfer --- java/jni/YGJNI.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/java/jni/YGJNI.cpp b/java/jni/YGJNI.cpp index 69cbb38115..cddb80ecd1 100644 --- a/java/jni/YGJNI.cpp +++ b/java/jni/YGJNI.cpp @@ -42,7 +42,7 @@ static void YGTransferLayoutDirection(YGNodeRef node, alias_ref javaNod javaNode->setFieldValue(layoutDirectionField, static_cast(YGNodeLayoutGetDirection(node))); } -static void YGTransferLayoutOutputsRecursive(YGNodeRef root) { +static void YGTransferLayoutOutputsRecursiveImpl(YGNodeRef root, bool transferAndResetNewLayoutFlag) { if (root->getHasNewLayout()) { if (auto obj = YGNodeJobject(root)->lockLocal()) { static auto widthField = obj->getClass()->getField("mWidth"); @@ -111,9 +111,11 @@ static void YGTransferLayoutOutputsRecursive(YGNodeRef root) { obj->setFieldValue(borderBottomField, YGNodeLayoutGetBorder(root, YGEdgeBottom)); } - obj->setFieldValue(hasNewLayoutField, true); YGTransferLayoutDirection(root, obj); - root->setHasNewLayout(false); + if(transferAndResetNewLayoutFlag){ + obj->setFieldValue(hasNewLayoutField, true); + root->setHasNewLayout(false); + } for (uint32_t i = 0; i < YGNodeGetChildCount(root); i++) { YGTransferLayoutOutputsRecursive(YGNodeGetChild(root, i)); @@ -124,6 +126,14 @@ static void YGTransferLayoutOutputsRecursive(YGNodeRef root) { } } +static void YGTransferLayoutOutputsRecursive(YGNodeRef root) { + YGTransferLayoutOutputsRecursiveImpl(root, true); +} + +static void YGTransferLayoutOutputsRecursiveForBaseline(YGNodeRef root) { + YGTransferLayoutOutputsRecursiveImpl(root, false); +} + static void YGPrint(YGNodeRef node) { if (auto obj = YGNodeJobject(node)->lockLocal()) { cout << obj->toString() << endl; @@ -136,6 +146,7 @@ static float YGJNIBaselineFunc(YGNodeRef node, float width, float height) { if (auto obj = YGNodeJobject(node)->lockLocal()) { static auto baselineFunc = findClassStatic("com/facebook/yoga/YogaNode") ->getMethod("baseline"); + YGTransferLayoutOutputsRecursiveForBaseline(obj); return baselineFunc(obj, width, height); } else { return height;