@@ -42,9 +42,14 @@ public static void setLogger(YogaLogger logger) {
4242 private long mNativePointer ;
4343 private Object mData ;
4444
45- private boolean mHasSetPadding = false ;
46- private boolean mHasSetMargin = false ;
47- private boolean mHasSetBorder = false ;
45+ /* Those flags needs be in sync with YGJNI.cpp */
46+ private final static int MARGIN = 1 ;
47+ private final static int PADDING = 2 ;
48+ private final static int BORDER = 4 ;
49+
50+ @ DoNotStrip
51+ private int mEdgeSetFlag = 0 ;
52+
4853 private boolean mHasSetPosition = false ;
4954
5055 @ DoNotStrip
@@ -113,16 +118,26 @@ protected void finalize() throws Throwable {
113118 private native void jni_YGNodeReset (long nativePointer );
114119 @ Override
115120 public void reset () {
116- mHasSetPadding = false ;
117- mHasSetMargin = false ;
118- mHasSetBorder = false ;
121+ mEdgeSetFlag = 0 ;
119122 mHasSetPosition = false ;
120123 mHasNewLayout = true ;
121124
122125 mWidth = YogaConstants .UNDEFINED ;
123126 mHeight = YogaConstants .UNDEFINED ;
124127 mTop = YogaConstants .UNDEFINED ;
125128 mLeft = YogaConstants .UNDEFINED ;
129+ mMarginLeft = 0 ;
130+ mMarginTop = 0 ;
131+ mMarginRight = 0 ;
132+ mMarginBottom = 0 ;
133+ mPaddingLeft = 0 ;
134+ mPaddingTop = 0 ;
135+ mPaddingRight = 0 ;
136+ mPaddingBottom = 0 ;
137+ mBorderLeft = 0 ;
138+ mBorderTop = 0 ;
139+ mBorderRight = 0 ;
140+ mBorderBottom = 0 ;
126141 mLayoutDirection = 0 ;
127142
128143 mMeasureFunction = null ;
@@ -382,7 +397,7 @@ public void setFlexBasisAuto() {
382397 private native Object jni_YGNodeStyleGetMargin (long nativePointer , int edge );
383398 @ Override
384399 public YogaValue getMargin (YogaEdge edge ) {
385- if (!mHasSetMargin ) {
400+ if (!(( mEdgeSetFlag & MARGIN ) == MARGIN ) ) {
386401 return YogaValue .UNDEFINED ;
387402 }
388403 return (YogaValue ) jni_YGNodeStyleGetMargin (mNativePointer , edge .intValue ());
@@ -391,28 +406,28 @@ public YogaValue getMargin(YogaEdge edge) {
391406 private native void jni_YGNodeStyleSetMargin (long nativePointer , int edge , float margin );
392407 @ Override
393408 public void setMargin (YogaEdge edge , float margin ) {
394- mHasSetMargin = true ;
409+ mEdgeSetFlag |= MARGIN ;
395410 jni_YGNodeStyleSetMargin (mNativePointer , edge .intValue (), margin );
396411 }
397412
398413 private native void jni_YGNodeStyleSetMarginPercent (long nativePointer , int edge , float percent );
399414 @ Override
400415 public void setMarginPercent (YogaEdge edge , float percent ) {
401- mHasSetMargin = true ;
416+ mEdgeSetFlag |= MARGIN ;
402417 jni_YGNodeStyleSetMarginPercent (mNativePointer , edge .intValue (), percent );
403418 }
404419
405420 private native void jni_YGNodeStyleSetMarginAuto (long nativePointer , int edge );
406421 @ Override
407422 public void setMarginAuto (YogaEdge edge ) {
408- mHasSetMargin = true ;
423+ mEdgeSetFlag |= MARGIN ;
409424 jni_YGNodeStyleSetMarginAuto (mNativePointer , edge .intValue ());
410425 }
411426
412427 private native Object jni_YGNodeStyleGetPadding (long nativePointer , int edge );
413428 @ Override
414429 public YogaValue getPadding (YogaEdge edge ) {
415- if (!mHasSetPadding ) {
430+ if (!(( mEdgeSetFlag & PADDING ) == PADDING ) ) {
416431 return YogaValue .UNDEFINED ;
417432 }
418433 return (YogaValue ) jni_YGNodeStyleGetPadding (mNativePointer , edge .intValue ());
@@ -421,21 +436,21 @@ public YogaValue getPadding(YogaEdge edge) {
421436 private native void jni_YGNodeStyleSetPadding (long nativePointer , int edge , float padding );
422437 @ Override
423438 public void setPadding (YogaEdge edge , float padding ) {
424- mHasSetPadding = true ;
439+ mEdgeSetFlag |= PADDING ;
425440 jni_YGNodeStyleSetPadding (mNativePointer , edge .intValue (), padding );
426441 }
427442
428443 private native void jni_YGNodeStyleSetPaddingPercent (long nativePointer , int edge , float percent );
429444 @ Override
430445 public void setPaddingPercent (YogaEdge edge , float percent ) {
431- mHasSetPadding = true ;
446+ mEdgeSetFlag |= PADDING ;
432447 jni_YGNodeStyleSetPaddingPercent (mNativePointer , edge .intValue (), percent );
433448 }
434449
435450 private native float jni_YGNodeStyleGetBorder (long nativePointer , int edge );
436451 @ Override
437452 public float getBorder (YogaEdge edge ) {
438- if (!mHasSetBorder ) {
453+ if (!(( mEdgeSetFlag & BORDER ) == BORDER ) ) {
439454 return YogaConstants .UNDEFINED ;
440455 }
441456 return jni_YGNodeStyleGetBorder (mNativePointer , edge .intValue ());
@@ -444,7 +459,7 @@ public float getBorder(YogaEdge edge) {
444459 private native void jni_YGNodeStyleSetBorder (long nativePointer , int edge , float border );
445460 @ Override
446461 public void setBorder (YogaEdge edge , float border ) {
447- mHasSetBorder = true ;
462+ mEdgeSetFlag |= BORDER ;
448463 jni_YGNodeStyleSetBorder (mNativePointer , edge .intValue (), border );
449464 }
450465
0 commit comments