Add jni bindings
Summary: Add jni bindings for csslayout. First step in many of removing LayoutEngine.java and performing all layout in native. Reviewed By: lucasr Differential Revision: D3648793
This commit is contained in:
parent
0c9afec7dc
commit
ca79e6cf30
|
@ -12,7 +12,7 @@ package com.facebook.react.flat;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
|
|
||||||
import com.facebook.csslayout.CSSMeasureMode;
|
import com.facebook.csslayout.CSSMeasureMode;
|
||||||
import com.facebook.csslayout.CSSNode;
|
import com.facebook.csslayout.CSSNodeAPI;
|
||||||
import com.facebook.csslayout.MeasureOutput;
|
import com.facebook.csslayout.MeasureOutput;
|
||||||
import com.facebook.react.uimanager.BaseViewManager;
|
import com.facebook.react.uimanager.BaseViewManager;
|
||||||
import com.facebook.react.uimanager.ThemedReactContext;
|
import com.facebook.react.uimanager.ThemedReactContext;
|
||||||
|
@ -23,10 +23,10 @@ import com.facebook.react.views.art.ARTSurfaceView;
|
||||||
|
|
||||||
private static final String REACT_CLASS = "ARTSurfaceView";
|
private static final String REACT_CLASS = "ARTSurfaceView";
|
||||||
|
|
||||||
private static final CSSNode.MeasureFunction MEASURE_FUNCTION = new CSSNode.MeasureFunction() {
|
private static final CSSNodeAPI.MeasureFunction MEASURE_FUNCTION = new CSSNodeAPI.MeasureFunction() {
|
||||||
@Override
|
@Override
|
||||||
public void measure(
|
public void measure(
|
||||||
CSSNode node,
|
CSSNodeAPI node,
|
||||||
float width,
|
float width,
|
||||||
CSSMeasureMode widthMode,
|
CSSMeasureMode widthMode,
|
||||||
float height,
|
float height,
|
||||||
|
|
|
@ -14,6 +14,7 @@ import javax.annotation.Nullable;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
|
|
||||||
import com.facebook.csslayout.CSSNode;
|
import com.facebook.csslayout.CSSNode;
|
||||||
|
import com.facebook.csslayout.CSSNodeAPI;
|
||||||
import com.facebook.infer.annotation.Assertions;
|
import com.facebook.infer.annotation.Assertions;
|
||||||
import com.facebook.react.uimanager.LayoutShadowNode;
|
import com.facebook.react.uimanager.LayoutShadowNode;
|
||||||
import com.facebook.react.uimanager.OnLayoutEvent;
|
import com.facebook.react.uimanager.OnLayoutEvent;
|
||||||
|
@ -227,7 +228,7 @@ import com.facebook.react.views.view.ReactClippingViewGroupHelper;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void markUpdated() {
|
public void markUpdated() {
|
||||||
super.markUpdated();
|
super.markUpdated();
|
||||||
mIsUpdated = true;
|
mIsUpdated = true;
|
||||||
invalidate();
|
invalidate();
|
||||||
|
|
|
@ -12,6 +12,7 @@ package com.facebook.react.flat;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.facebook.csslayout.CSSNode;
|
import com.facebook.csslayout.CSSNode;
|
||||||
|
import com.facebook.csslayout.CSSNodeAPI;
|
||||||
import com.facebook.react.uimanager.ReactStylesDiffMap;
|
import com.facebook.react.uimanager.ReactStylesDiffMap;
|
||||||
import com.facebook.react.uimanager.ReactShadowNode;
|
import com.facebook.react.uimanager.ReactShadowNode;
|
||||||
import com.facebook.react.uimanager.ThemedReactContext;
|
import com.facebook.react.uimanager.ThemedReactContext;
|
||||||
|
@ -27,9 +28,9 @@ import com.facebook.react.uimanager.ViewManager;
|
||||||
|
|
||||||
/* package */ NativeViewWrapper(ViewManager viewManager) {
|
/* package */ NativeViewWrapper(ViewManager viewManager) {
|
||||||
ReactShadowNode reactShadowNode = viewManager.createShadowNodeInstance();
|
ReactShadowNode reactShadowNode = viewManager.createShadowNodeInstance();
|
||||||
if (reactShadowNode instanceof CSSNode.MeasureFunction) {
|
if (reactShadowNode instanceof CSSNodeAPI.MeasureFunction) {
|
||||||
mReactShadowNode = reactShadowNode;
|
mReactShadowNode = reactShadowNode;
|
||||||
setMeasureFunction((CSSNode.MeasureFunction) reactShadowNode);
|
setMeasureFunction((CSSNodeAPI.MeasureFunction) reactShadowNode);
|
||||||
} else {
|
} else {
|
||||||
mReactShadowNode = null;
|
mReactShadowNode = null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ import android.text.Layout;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import com.facebook.csslayout.CSSMeasureMode;
|
import com.facebook.csslayout.CSSMeasureMode;
|
||||||
import com.facebook.csslayout.CSSNode;
|
import com.facebook.csslayout.CSSNodeAPI;
|
||||||
import com.facebook.csslayout.MeasureOutput;
|
import com.facebook.csslayout.MeasureOutput;
|
||||||
import com.facebook.csslayout.Spacing;
|
import com.facebook.csslayout.Spacing;
|
||||||
import com.facebook.fbui.widget.text.layoutbuilder.TextLayoutBuilder;
|
import com.facebook.fbui.widget.text.layoutbuilder.TextLayoutBuilder;
|
||||||
|
@ -34,7 +34,7 @@ import com.facebook.textcachewarmer.DefaultTextLayoutCacheWarmer;
|
||||||
* a) RCTText is not a virtual node, and can be measured and laid out.
|
* a) RCTText is not a virtual node, and can be measured and laid out.
|
||||||
* b) when no font size is specified, a font size of ViewDefaults#FONT_SIZE_SP is assumed.
|
* b) when no font size is specified, a font size of ViewDefaults#FONT_SIZE_SP is assumed.
|
||||||
*/
|
*/
|
||||||
/* package */ final class RCTText extends RCTVirtualText implements CSSNode.MeasureFunction {
|
/* package */ final class RCTText extends RCTVirtualText implements CSSNodeAPI.MeasureFunction {
|
||||||
|
|
||||||
// We set every value we use every time we use the layout builder, so we can get away with only
|
// We set every value we use every time we use the layout builder, so we can get away with only
|
||||||
// using a single instance.
|
// using a single instance.
|
||||||
|
@ -68,7 +68,7 @@ import com.facebook.textcachewarmer.DefaultTextLayoutCacheWarmer;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void measure(
|
public void measure(
|
||||||
CSSNode node,
|
CSSNodeAPI node,
|
||||||
float width,
|
float width,
|
||||||
CSSMeasureMode widthMode,
|
CSSMeasureMode widthMode,
|
||||||
float height,
|
float height,
|
||||||
|
|
|
@ -17,7 +17,7 @@ import android.view.ViewGroup;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
|
||||||
import com.facebook.csslayout.CSSMeasureMode;
|
import com.facebook.csslayout.CSSMeasureMode;
|
||||||
import com.facebook.csslayout.CSSNode;
|
import com.facebook.csslayout.CSSNodeAPI;
|
||||||
import com.facebook.csslayout.MeasureOutput;
|
import com.facebook.csslayout.MeasureOutput;
|
||||||
import com.facebook.csslayout.Spacing;
|
import com.facebook.csslayout.Spacing;
|
||||||
import com.facebook.infer.annotation.Assertions;
|
import com.facebook.infer.annotation.Assertions;
|
||||||
|
@ -33,7 +33,7 @@ import com.facebook.react.views.view.MeasureUtil;
|
||||||
import static com.facebook.react.views.text.ReactTextShadowNode.PROP_TEXT;
|
import static com.facebook.react.views.text.ReactTextShadowNode.PROP_TEXT;
|
||||||
import static com.facebook.react.views.text.ReactTextShadowNode.UNSET;
|
import static com.facebook.react.views.text.ReactTextShadowNode.UNSET;
|
||||||
|
|
||||||
public class RCTTextInput extends RCTVirtualText implements AndroidView, CSSNode.MeasureFunction {
|
public class RCTTextInput extends RCTVirtualText implements AndroidView, CSSNodeAPI.MeasureFunction {
|
||||||
|
|
||||||
@Nullable private String mText;
|
@Nullable private String mText;
|
||||||
private int mJsEventCount = UNSET;
|
private int mJsEventCount = UNSET;
|
||||||
|
@ -73,7 +73,7 @@ public class RCTTextInput extends RCTVirtualText implements AndroidView, CSSNode
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void measure(
|
public void measure(
|
||||||
CSSNode node,
|
CSSNodeAPI node,
|
||||||
float width,
|
float width,
|
||||||
CSSMeasureMode widthMode,
|
CSSMeasureMode widthMode,
|
||||||
float height,
|
float height,
|
||||||
|
|
Loading…
Reference in New Issue