Always return undefined value if nothing is set
Summary: This reflects a check to native code where style values will always return the value that was set on them and default to undefined. Reviewed By: astreet Differential Revision: D4531779 fbshipit-source-id: 97a789e70dcf0fb5174e2039991e7a2b27f45f01
This commit is contained in:
committed by
Facebook Github Bot
parent
6ceb4af2d4
commit
168ae4099d
@@ -382,7 +382,7 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
|
|||||||
@Override
|
@Override
|
||||||
public YogaValue getMargin(YogaEdge edge) {
|
public YogaValue getMargin(YogaEdge edge) {
|
||||||
if (!mHasSetMargin) {
|
if (!mHasSetMargin) {
|
||||||
return edge.intValue() < YogaEdge.START.intValue() ? YogaValue.ZERO : YogaValue.UNDEFINED;
|
return YogaValue.UNDEFINED;
|
||||||
}
|
}
|
||||||
return (YogaValue) jni_YGNodeStyleGetMargin(mNativePointer, edge.intValue());
|
return (YogaValue) jni_YGNodeStyleGetMargin(mNativePointer, edge.intValue());
|
||||||
}
|
}
|
||||||
@@ -405,7 +405,7 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
|
|||||||
@Override
|
@Override
|
||||||
public YogaValue getPadding(YogaEdge edge) {
|
public YogaValue getPadding(YogaEdge edge) {
|
||||||
if (!mHasSetPadding) {
|
if (!mHasSetPadding) {
|
||||||
return edge.intValue() < YogaEdge.START.intValue() ? YogaValue.ZERO : YogaValue.UNDEFINED;
|
return YogaValue.UNDEFINED;
|
||||||
}
|
}
|
||||||
return (YogaValue) jni_YGNodeStyleGetPadding(mNativePointer, edge.intValue());
|
return (YogaValue) jni_YGNodeStyleGetPadding(mNativePointer, edge.intValue());
|
||||||
}
|
}
|
||||||
@@ -428,7 +428,7 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
|
|||||||
@Override
|
@Override
|
||||||
public float getBorder(YogaEdge edge) {
|
public float getBorder(YogaEdge edge) {
|
||||||
if (!mHasSetBorder) {
|
if (!mHasSetBorder) {
|
||||||
return edge.intValue() < YogaEdge.START.intValue() ? 0 : YogaConstants.UNDEFINED;
|
return YogaConstants.UNDEFINED;
|
||||||
}
|
}
|
||||||
return jni_YGNodeStyleGetBorder(mNativePointer, edge.intValue());
|
return jni_YGNodeStyleGetBorder(mNativePointer, edge.intValue());
|
||||||
}
|
}
|
||||||
|
@@ -230,4 +230,16 @@ public class YogaNodeTest {
|
|||||||
assertEquals(5, (int) node.getLayoutPadding(YogaEdge.TOP));
|
assertEquals(5, (int) node.getLayoutPadding(YogaEdge.TOP));
|
||||||
assertEquals(5, (int) node.getLayoutPadding(YogaEdge.BOTTOM));
|
assertEquals(5, (int) node.getLayoutPadding(YogaEdge.BOTTOM));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDefaultEdgeValues() {
|
||||||
|
final YogaNode node = new YogaNode();
|
||||||
|
|
||||||
|
for (YogaEdge edge : YogaEdge.values()) {
|
||||||
|
assertEquals(YogaUnit.UNDEFINED, node.getMargin(edge).unit);
|
||||||
|
assertEquals(YogaUnit.UNDEFINED, node.getPadding(edge).unit);
|
||||||
|
assertEquals(YogaUnit.UNDEFINED, node.getPosition(edge).unit);
|
||||||
|
assertTrue(YogaConstants.isUndefined(node.getBorder(edge)));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user