From 844cafd8836e54c00df6563565fd20802419abfe Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Thu, 27 Oct 2016 10:52:12 -0700 Subject: [PATCH] Set layout outputs on java object from C Reviewed By: lexs Differential Revision: D4077968 fbshipit-source-id: bce86ba610cd5ae36cfb45d78b2609c63a14cfa3 --- .../java/com/facebook/csslayout/CSSNode.java | 40 ++++++++++++------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/csslayout/CSSNode.java b/ReactAndroid/src/main/java/com/facebook/csslayout/CSSNode.java index 103784f44..f07ad7de9 100644 --- a/ReactAndroid/src/main/java/com/facebook/csslayout/CSSNode.java +++ b/ReactAndroid/src/main/java/com/facebook/csslayout/CSSNode.java @@ -45,6 +45,17 @@ public class CSSNode implements CSSNodeAPI { private boolean mHasSetBorder = false; private boolean mHasSetPosition = false; + @DoNotStrip + private float mWidth = CSSConstants.UNDEFINED; + @DoNotStrip + private float mHeight = CSSConstants.UNDEFINED; + @DoNotStrip + private float mTop = CSSConstants.UNDEFINED; + @DoNotStrip + private float mLeft = CSSConstants.UNDEFINED; + @DoNotStrip + private int mLayoutDirection = 0; + private native long jni_CSSNodeNew(); public CSSNode() { mNativePointer = jni_CSSNodeNew(); @@ -73,6 +84,12 @@ public class CSSNode implements CSSNodeAPI { mHasSetBorder = false; mHasSetPosition = false; + mWidth = CSSConstants.UNDEFINED; + mHeight = CSSConstants.UNDEFINED; + mTop = CSSConstants.UNDEFINED; + mLeft = CSSConstants.UNDEFINED; + mLayoutDirection = 0; + mMeasureFunction = null; mData = null; @@ -176,12 +193,6 @@ public class CSSNode implements CSSNodeAPI { jni_CSSNodeStyleSetDirection(mNativePointer, direction.ordinal()); } - private native int jni_CSSNodeLayoutGetDirection(long nativePointer); - @Override - public CSSDirection getLayoutDirection() { - return CSSDirection.values()[jni_CSSNodeLayoutGetDirection(mNativePointer)]; - } - private native int jni_CSSNodeStyleGetFlexDirection(long nativePointer); @Override public CSSFlexDirection getFlexDirection() { @@ -450,28 +461,29 @@ public class CSSNode implements CSSNodeAPI { jni_CSSNodeStyleSetMaxHeight(mNativePointer, maxheight); } - private native float jni_CSSNodeLayoutGetLeft(long nativePointer); @Override public float getLayoutX() { - return jni_CSSNodeLayoutGetLeft(mNativePointer); + return mLeft; } - private native float jni_CSSNodeLayoutGetTop(long nativePointer); @Override public float getLayoutY() { - return jni_CSSNodeLayoutGetTop(mNativePointer); + return mTop; } - private native float jni_CSSNodeLayoutGetWidth(long nativePointer); @Override public float getLayoutWidth() { - return jni_CSSNodeLayoutGetWidth(mNativePointer); + return mWidth; } - private native float jni_CSSNodeLayoutGetHeight(long nativePointer); @Override public float getLayoutHeight() { - return jni_CSSNodeLayoutGetHeight(mNativePointer); + return mHeight; + } + + @Override + public CSSDirection getLayoutDirection() { + return CSSDirection.values()[mLayoutDirection]; } private native void jni_CSSNodeSetHasMeasureFunc(long nativePointer, boolean hasMeasureFunc);