Add the ability to attach data to a java CSSNode
Reviewed By: lucasr Differential Revision: D3662065 fbshipit-source-id: 560a768092f17381e99b349d08bd4a8b365541be
This commit is contained in:
parent
44e7a88620
commit
e0fc8c0ea0
|
@ -63,6 +63,7 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
|
|||
private @Nullable MeasureFunction mMeasureFunction = null;
|
||||
private LayoutState mLayoutState = LayoutState.DIRTY;
|
||||
private boolean mIsTextNode = false;
|
||||
private Object mData;
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
|
@ -621,6 +622,16 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setData(Object data) {
|
||||
mData = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getData() {
|
||||
return mData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets this instance to its default state. This method is meant to be used when
|
||||
* recycling {@link CSSNode} instances.
|
||||
|
|
|
@ -88,6 +88,8 @@ public interface CSSNodeAPI<CSSNodeType extends CSSNodeAPI> {
|
|||
void setDefaultPadding(int spacingType, float padding);
|
||||
CSSOverflow getOverflow();
|
||||
void setOverflow(CSSOverflow overflow);
|
||||
void setData(Object data);
|
||||
Object getData();
|
||||
void init();
|
||||
void reset();
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ public class CSSNodeJNI implements CSSNodeAPI<CSSNodeJNI> {
|
|||
private List<CSSNodeJNI> mChildren;
|
||||
private MeasureFunction mMeasureFunction;
|
||||
private int mNativePointer;
|
||||
private Object mData;
|
||||
|
||||
private void assertNativeInstance() {
|
||||
if (mNativePointer == 0) {
|
||||
|
@ -718,4 +719,14 @@ public class CSSNodeJNI implements CSSNodeAPI<CSSNodeJNI> {
|
|||
public boolean valuesEqual(float f1, float f2) {
|
||||
return FloatUtil.floatsEqual(f1, f2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setData(Object data) {
|
||||
mData = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getData() {
|
||||
return mData;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue