not setting flags when setting margin, padding, border and position on yoga node
Summary: We are now not setting flags when we set style inputs margin, padding, border and position on yoga node. Reviewed By: davidaurelio Differential Revision: D14224000 fbshipit-source-id: deef4c1ab1a60fbc4909183bc2aa59fa23939d43
This commit is contained in:
committed by
Facebook Github Bot
parent
15668aceb6
commit
8b8d9a05b7
@@ -36,10 +36,6 @@ public class YogaNodeJNI extends YogaNode {
|
||||
private static final int PADDING = 2;
|
||||
private static final int BORDER = 4;
|
||||
|
||||
@DoNotStrip
|
||||
private int mEdgeSetFlag = 0;
|
||||
|
||||
private boolean mHasSetPosition = false;
|
||||
private final boolean mAvoidGlobalJNIRefs;
|
||||
|
||||
@DoNotStrip
|
||||
@@ -120,8 +116,6 @@ public class YogaNodeJNI extends YogaNode {
|
||||
|
||||
private static native void jni_YGNodeReset(long nativePointer);
|
||||
public void reset() {
|
||||
mEdgeSetFlag = 0;
|
||||
mHasSetPosition = false;
|
||||
mHasNewLayout = true;
|
||||
|
||||
mWidth = YogaConstants.UNDEFINED;
|
||||
@@ -429,81 +423,61 @@ public class YogaNodeJNI extends YogaNode {
|
||||
|
||||
private static native Object jni_YGNodeStyleGetMargin(long nativePointer, int edge);
|
||||
public YogaValue getMargin(YogaEdge edge) {
|
||||
if (!((mEdgeSetFlag & MARGIN) == MARGIN)) {
|
||||
return YogaValue.UNDEFINED;
|
||||
}
|
||||
return (YogaValue) jni_YGNodeStyleGetMargin(mNativePointer, edge.intValue());
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeStyleSetMargin(long nativePointer, int edge, float margin);
|
||||
public void setMargin(YogaEdge edge, float margin) {
|
||||
mEdgeSetFlag |= MARGIN;
|
||||
jni_YGNodeStyleSetMargin(mNativePointer, edge.intValue(), margin);
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeStyleSetMarginPercent(long nativePointer, int edge, float percent);
|
||||
public void setMarginPercent(YogaEdge edge, float percent) {
|
||||
mEdgeSetFlag |= MARGIN;
|
||||
jni_YGNodeStyleSetMarginPercent(mNativePointer, edge.intValue(), percent);
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeStyleSetMarginAuto(long nativePointer, int edge);
|
||||
public void setMarginAuto(YogaEdge edge) {
|
||||
mEdgeSetFlag |= MARGIN;
|
||||
jni_YGNodeStyleSetMarginAuto(mNativePointer, edge.intValue());
|
||||
}
|
||||
|
||||
private static native Object jni_YGNodeStyleGetPadding(long nativePointer, int edge);
|
||||
public YogaValue getPadding(YogaEdge edge) {
|
||||
if (!((mEdgeSetFlag & PADDING) == PADDING)) {
|
||||
return YogaValue.UNDEFINED;
|
||||
}
|
||||
return (YogaValue) jni_YGNodeStyleGetPadding(mNativePointer, edge.intValue());
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeStyleSetPadding(long nativePointer, int edge, float padding);
|
||||
public void setPadding(YogaEdge edge, float padding) {
|
||||
mEdgeSetFlag |= PADDING;
|
||||
jni_YGNodeStyleSetPadding(mNativePointer, edge.intValue(), padding);
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeStyleSetPaddingPercent(long nativePointer, int edge, float percent);
|
||||
public void setPaddingPercent(YogaEdge edge, float percent) {
|
||||
mEdgeSetFlag |= PADDING;
|
||||
jni_YGNodeStyleSetPaddingPercent(mNativePointer, edge.intValue(), percent);
|
||||
}
|
||||
|
||||
private static native float jni_YGNodeStyleGetBorder(long nativePointer, int edge);
|
||||
public float getBorder(YogaEdge edge) {
|
||||
if (!((mEdgeSetFlag & BORDER) == BORDER)) {
|
||||
return YogaConstants.UNDEFINED;
|
||||
}
|
||||
return jni_YGNodeStyleGetBorder(mNativePointer, edge.intValue());
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeStyleSetBorder(long nativePointer, int edge, float border);
|
||||
public void setBorder(YogaEdge edge, float border) {
|
||||
mEdgeSetFlag |= BORDER;
|
||||
jni_YGNodeStyleSetBorder(mNativePointer, edge.intValue(), border);
|
||||
}
|
||||
|
||||
private static native Object jni_YGNodeStyleGetPosition(long nativePointer, int edge);
|
||||
public YogaValue getPosition(YogaEdge edge) {
|
||||
if (!mHasSetPosition) {
|
||||
return YogaValue.UNDEFINED;
|
||||
}
|
||||
return (YogaValue) jni_YGNodeStyleGetPosition(mNativePointer, edge.intValue());
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeStyleSetPosition(long nativePointer, int edge, float position);
|
||||
public void setPosition(YogaEdge edge, float position) {
|
||||
mHasSetPosition = true;
|
||||
jni_YGNodeStyleSetPosition(mNativePointer, edge.intValue(), position);
|
||||
}
|
||||
|
||||
private static native void jni_YGNodeStyleSetPositionPercent(long nativePointer, int edge, float percent);
|
||||
public void setPositionPercent(YogaEdge edge, float percent) {
|
||||
mHasSetPosition = true;
|
||||
jni_YGNodeStyleSetPositionPercent(mNativePointer, edge.intValue(), percent);
|
||||
}
|
||||
|
||||
|
@@ -129,20 +129,11 @@ static void YGTransferLayoutOutputsRecursive(
|
||||
static auto borderBottomField =
|
||||
obj->getClass()->getField<jfloat>("mBorderBottom");
|
||||
|
||||
static auto edgeSetFlagField =
|
||||
obj->getClass()->getField<jint>("mEdgeSetFlag");
|
||||
static auto hasNewLayoutField =
|
||||
obj->getClass()->getField<jboolean>("mHasNewLayout");
|
||||
static auto doesLegacyStretchBehaviour = obj->getClass()->getField<jboolean>(
|
||||
"mDoesLegacyStretchFlagAffectsLayout");
|
||||
|
||||
/* Those flags needs be in sync with YogaNode.java */
|
||||
const int MARGIN = 1;
|
||||
const int PADDING = 2;
|
||||
const int BORDER = 4;
|
||||
|
||||
int hasEdgeSetFlag = (int) obj->getFieldValue(edgeSetFlagField);
|
||||
|
||||
obj->setFieldValue(widthField, YGNodeLayoutGetWidth(root));
|
||||
obj->setFieldValue(heightField, YGNodeLayoutGetHeight(root));
|
||||
obj->setFieldValue(leftField, YGNodeLayoutGetLeft(root));
|
||||
@@ -151,36 +142,27 @@ static void YGTransferLayoutOutputsRecursive(
|
||||
doesLegacyStretchBehaviour,
|
||||
YGNodeLayoutGetDidLegacyStretchFlagAffectLayout(root));
|
||||
|
||||
if ((hasEdgeSetFlag & MARGIN) == MARGIN) {
|
||||
obj->setFieldValue(
|
||||
marginLeftField, YGNodeLayoutGetMargin(root, YGEdgeLeft));
|
||||
obj->setFieldValue(marginTopField, YGNodeLayoutGetMargin(root, YGEdgeTop));
|
||||
obj->setFieldValue(
|
||||
marginRightField, YGNodeLayoutGetMargin(root, YGEdgeRight));
|
||||
obj->setFieldValue(
|
||||
marginBottomField, YGNodeLayoutGetMargin(root, YGEdgeBottom));
|
||||
}
|
||||
obj->setFieldValue(marginLeftField, YGNodeLayoutGetMargin(root, YGEdgeLeft));
|
||||
obj->setFieldValue(marginTopField, YGNodeLayoutGetMargin(root, YGEdgeTop));
|
||||
obj->setFieldValue(
|
||||
marginRightField, YGNodeLayoutGetMargin(root, YGEdgeRight));
|
||||
obj->setFieldValue(
|
||||
marginBottomField, YGNodeLayoutGetMargin(root, YGEdgeBottom));
|
||||
|
||||
if ((hasEdgeSetFlag & PADDING) == PADDING) {
|
||||
obj->setFieldValue(
|
||||
paddingLeftField, YGNodeLayoutGetPadding(root, YGEdgeLeft));
|
||||
obj->setFieldValue(
|
||||
paddingTopField, YGNodeLayoutGetPadding(root, YGEdgeTop));
|
||||
obj->setFieldValue(
|
||||
paddingRightField, YGNodeLayoutGetPadding(root, YGEdgeRight));
|
||||
obj->setFieldValue(
|
||||
paddingBottomField, YGNodeLayoutGetPadding(root, YGEdgeBottom));
|
||||
}
|
||||
obj->setFieldValue(
|
||||
paddingLeftField, YGNodeLayoutGetPadding(root, YGEdgeLeft));
|
||||
obj->setFieldValue(paddingTopField, YGNodeLayoutGetPadding(root, YGEdgeTop));
|
||||
obj->setFieldValue(
|
||||
paddingRightField, YGNodeLayoutGetPadding(root, YGEdgeRight));
|
||||
obj->setFieldValue(
|
||||
paddingBottomField, YGNodeLayoutGetPadding(root, YGEdgeBottom));
|
||||
|
||||
if ((hasEdgeSetFlag & BORDER) == BORDER) {
|
||||
obj->setFieldValue(
|
||||
borderLeftField, YGNodeLayoutGetBorder(root, YGEdgeLeft));
|
||||
obj->setFieldValue(borderTopField, YGNodeLayoutGetBorder(root, YGEdgeTop));
|
||||
obj->setFieldValue(
|
||||
borderRightField, YGNodeLayoutGetBorder(root, YGEdgeRight));
|
||||
obj->setFieldValue(
|
||||
borderBottomField, YGNodeLayoutGetBorder(root, YGEdgeBottom));
|
||||
}
|
||||
obj->setFieldValue(borderLeftField, YGNodeLayoutGetBorder(root, YGEdgeLeft));
|
||||
obj->setFieldValue(borderTopField, YGNodeLayoutGetBorder(root, YGEdgeTop));
|
||||
obj->setFieldValue(
|
||||
borderRightField, YGNodeLayoutGetBorder(root, YGEdgeRight));
|
||||
obj->setFieldValue(
|
||||
borderBottomField, YGNodeLayoutGetBorder(root, YGEdgeBottom));
|
||||
|
||||
obj->setFieldValue<jboolean>(hasNewLayoutField, true);
|
||||
YGTransferLayoutDirection(root, obj);
|
||||
|
Reference in New Issue
Block a user