Dont go down through JNI to figure out that no margin/padding/border/position was set
Summary: Many layout systems query the padding after calculation to as it is needs to be propagated to the underlying view system on the platform. However most nodes have no padding set on them so going 4-6 times through JNI layer to figure this out is a waste of time. Differential Revision: D4080909 fbshipit-source-id: 7eb1885c615191055aa21e3435c6fbc652b883ae
This commit is contained in:
committed by
Facebook Github Bot
parent
01c2ac3369
commit
d6d817c142
@@ -40,6 +40,11 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
|
||||
private long mNativePointer;
|
||||
private Object mData;
|
||||
|
||||
private boolean mHasSetPadding = false;
|
||||
private boolean mHasSetMargin = false;
|
||||
private boolean mHasSetBorder = false;
|
||||
private boolean mHasSetPosition = false;
|
||||
|
||||
private native long jni_CSSNodeNew();
|
||||
public CSSNode() {
|
||||
mNativePointer = jni_CSSNodeNew();
|
||||
@@ -63,6 +68,10 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
|
||||
private native void jni_CSSNodeReset(long nativePointer);
|
||||
@Override
|
||||
public void reset() {
|
||||
mHasSetPadding = false;
|
||||
mHasSetMargin = false;
|
||||
mHasSetBorder = false;
|
||||
mHasSetPosition = false;
|
||||
jni_CSSNodeReset(mNativePointer);
|
||||
}
|
||||
|
||||
@@ -304,48 +313,64 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
|
||||
private native float jni_CSSNodeStyleGetMargin(long nativePointer, int edge);
|
||||
@Override
|
||||
public float getMargin(int spacingType) {
|
||||
if (!mHasSetMargin) {
|
||||
return spacingType < Spacing.START ? 0 : CSSConstants.UNDEFINED;
|
||||
}
|
||||
return jni_CSSNodeStyleGetMargin(mNativePointer, spacingType);
|
||||
}
|
||||
|
||||
private native void jni_CSSNodeStyleSetMargin(long nativePointer, int edge, float margin);
|
||||
@Override
|
||||
public void setMargin(int spacingType, float margin) {
|
||||
mHasSetMargin = true;
|
||||
jni_CSSNodeStyleSetMargin(mNativePointer, spacingType, margin);
|
||||
}
|
||||
|
||||
private native float jni_CSSNodeStyleGetPadding(long nativePointer, int edge);
|
||||
@Override
|
||||
public float getPadding(int spacingType) {
|
||||
if (!mHasSetPadding) {
|
||||
return spacingType < Spacing.START ? 0 : CSSConstants.UNDEFINED;
|
||||
}
|
||||
return jni_CSSNodeStyleGetPadding(mNativePointer, spacingType);
|
||||
}
|
||||
|
||||
private native void jni_CSSNodeStyleSetPadding(long nativePointer, int edge, float padding);
|
||||
@Override
|
||||
public void setPadding(int spacingType, float padding) {
|
||||
mHasSetPadding = true;
|
||||
jni_CSSNodeStyleSetPadding(mNativePointer, spacingType, padding);
|
||||
}
|
||||
|
||||
private native float jni_CSSNodeStyleGetBorder(long nativePointer, int edge);
|
||||
@Override
|
||||
public float getBorder(int spacingType) {
|
||||
if (!mHasSetBorder) {
|
||||
return spacingType < Spacing.START ? 0 : CSSConstants.UNDEFINED;
|
||||
}
|
||||
return jni_CSSNodeStyleGetBorder(mNativePointer, spacingType);
|
||||
}
|
||||
|
||||
private native void jni_CSSNodeStyleSetBorder(long nativePointer, int edge, float border);
|
||||
@Override
|
||||
public void setBorder(int spacingType, float border) {
|
||||
mHasSetBorder = true;
|
||||
jni_CSSNodeStyleSetBorder(mNativePointer, spacingType, border);
|
||||
}
|
||||
|
||||
private native float jni_CSSNodeStyleGetPosition(long nativePointer, int edge);
|
||||
@Override
|
||||
public float getPosition(int spacingType) {
|
||||
if (!mHasSetPosition) {
|
||||
return CSSConstants.UNDEFINED;
|
||||
}
|
||||
return jni_CSSNodeStyleGetPosition(mNativePointer, spacingType);
|
||||
}
|
||||
|
||||
private native void jni_CSSNodeStyleSetPosition(long nativePointer, int edge, float position);
|
||||
@Override
|
||||
public void setPosition(int spacingType, float position) {
|
||||
mHasSetPosition = true;
|
||||
jni_CSSNodeStyleSetPosition(mNativePointer, spacingType, position);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user