Add the ability to attach data to a java CSSNode

Summary: The C version already has this ability via the same name 'context'. This can be used to attach arbitrary data about your view hierarchy to a CSSNode. Previously this could only be done in java via subclassing CSSNode.

Reviewed By: lucasr

Differential Revision: D3662065

fbshipit-source-id: 560a768092f17381e99b349d08bd4a8b365541be
This commit is contained in:
Emil Sjolander
2016-08-04 08:20:07 -07:00
committed by Facebook Github Bot 9
parent b32d384337
commit 9278ff462e
3 changed files with 24 additions and 0 deletions

View File

@@ -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;
}
}