Resolve some differences between CSSNode and CSSNodeJNI

Reviewed By: lucasr

Differential Revision: D3960755

fbshipit-source-id: 3e13a9435208851a96a619c07625ef2a5402f5ec
This commit is contained in:
Emil Sjolander 2016-10-07 05:15:59 -07:00 committed by Facebook Github Bot
parent b6719b247d
commit d89f59d94a
2 changed files with 7 additions and 0 deletions

View File

@ -649,5 +649,6 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
layout.resetResult();
lineIndex = 0;
mLayoutState = LayoutState.DIRTY;
mMeasureFunction = null;
}
}

View File

@ -56,6 +56,9 @@ public class CSSNodeJNI implements CSSNodeAPI<CSSNodeJNI> {
@Override
public void reset() {
assertNativeInstance();
if (mParent != null || (mChildren != null && mChildren.size() > 0)) {
throw new IllegalStateException("You should not reset an attached CSSNode");
}
jni_CSSNodeFree(mNativePointer);
mNativePointer = 0;
@ -78,6 +81,9 @@ public class CSSNodeJNI implements CSSNodeAPI<CSSNodeJNI> {
@Override
public void addChildAt(CSSNodeJNI child, int i) {
assertNativeInstance();
if (child.mParent != null) {
throw new IllegalStateException("Child already has a parent, it must be removed first.");
}
mChildren.add(i, child);
child.mParent = this;