From ca79e6cf30751bd111b95435ea546da3d88f9aab Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Thu, 4 Aug 2016 08:19:59 -0700 Subject: [PATCH] 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 --- .../com/facebook/react/flat/FlatARTSurfaceViewManager.java | 6 +++--- .../main/java/com/facebook/react/flat/FlatShadowNode.java | 3 ++- .../java/com/facebook/react/flat/NativeViewWrapper.java | 5 +++-- .../src/main/java/com/facebook/react/flat/RCTText.java | 6 +++--- .../src/main/java/com/facebook/react/flat/RCTTextInput.java | 6 +++--- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/flat/FlatARTSurfaceViewManager.java b/ReactAndroid/src/main/java/com/facebook/react/flat/FlatARTSurfaceViewManager.java index f05ad7bd7..2c1eec28a 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/flat/FlatARTSurfaceViewManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/flat/FlatARTSurfaceViewManager.java @@ -12,7 +12,7 @@ package com.facebook.react.flat; import android.graphics.Bitmap; import com.facebook.csslayout.CSSMeasureMode; -import com.facebook.csslayout.CSSNode; +import com.facebook.csslayout.CSSNodeAPI; import com.facebook.csslayout.MeasureOutput; import com.facebook.react.uimanager.BaseViewManager; 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 CSSNode.MeasureFunction MEASURE_FUNCTION = new CSSNode.MeasureFunction() { + private static final CSSNodeAPI.MeasureFunction MEASURE_FUNCTION = new CSSNodeAPI.MeasureFunction() { @Override public void measure( - CSSNode node, + CSSNodeAPI node, float width, CSSMeasureMode widthMode, float height, diff --git a/ReactAndroid/src/main/java/com/facebook/react/flat/FlatShadowNode.java b/ReactAndroid/src/main/java/com/facebook/react/flat/FlatShadowNode.java index 2dc0ff76e..25457424f 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/flat/FlatShadowNode.java +++ b/ReactAndroid/src/main/java/com/facebook/react/flat/FlatShadowNode.java @@ -14,6 +14,7 @@ import javax.annotation.Nullable; import android.graphics.Rect; import com.facebook.csslayout.CSSNode; +import com.facebook.csslayout.CSSNodeAPI; import com.facebook.infer.annotation.Assertions; import com.facebook.react.uimanager.LayoutShadowNode; import com.facebook.react.uimanager.OnLayoutEvent; @@ -227,7 +228,7 @@ import com.facebook.react.views.view.ReactClippingViewGroupHelper; } @Override - protected void markUpdated() { + public void markUpdated() { super.markUpdated(); mIsUpdated = true; invalidate(); diff --git a/ReactAndroid/src/main/java/com/facebook/react/flat/NativeViewWrapper.java b/ReactAndroid/src/main/java/com/facebook/react/flat/NativeViewWrapper.java index 08cf9db06..05b4b8154 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/flat/NativeViewWrapper.java +++ b/ReactAndroid/src/main/java/com/facebook/react/flat/NativeViewWrapper.java @@ -12,6 +12,7 @@ package com.facebook.react.flat; import javax.annotation.Nullable; import com.facebook.csslayout.CSSNode; +import com.facebook.csslayout.CSSNodeAPI; import com.facebook.react.uimanager.ReactStylesDiffMap; import com.facebook.react.uimanager.ReactShadowNode; import com.facebook.react.uimanager.ThemedReactContext; @@ -27,9 +28,9 @@ import com.facebook.react.uimanager.ViewManager; /* package */ NativeViewWrapper(ViewManager viewManager) { ReactShadowNode reactShadowNode = viewManager.createShadowNodeInstance(); - if (reactShadowNode instanceof CSSNode.MeasureFunction) { + if (reactShadowNode instanceof CSSNodeAPI.MeasureFunction) { mReactShadowNode = reactShadowNode; - setMeasureFunction((CSSNode.MeasureFunction) reactShadowNode); + setMeasureFunction((CSSNodeAPI.MeasureFunction) reactShadowNode); } else { mReactShadowNode = null; } diff --git a/ReactAndroid/src/main/java/com/facebook/react/flat/RCTText.java b/ReactAndroid/src/main/java/com/facebook/react/flat/RCTText.java index 99bf0e2a8..ef9411033 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/flat/RCTText.java +++ b/ReactAndroid/src/main/java/com/facebook/react/flat/RCTText.java @@ -16,7 +16,7 @@ import android.text.Layout; import android.text.TextUtils; import com.facebook.csslayout.CSSMeasureMode; -import com.facebook.csslayout.CSSNode; +import com.facebook.csslayout.CSSNodeAPI; import com.facebook.csslayout.MeasureOutput; import com.facebook.csslayout.Spacing; 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. * 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 // using a single instance. @@ -68,7 +68,7 @@ import com.facebook.textcachewarmer.DefaultTextLayoutCacheWarmer; @Override public void measure( - CSSNode node, + CSSNodeAPI node, float width, CSSMeasureMode widthMode, float height, diff --git a/ReactAndroid/src/main/java/com/facebook/react/flat/RCTTextInput.java b/ReactAndroid/src/main/java/com/facebook/react/flat/RCTTextInput.java index 1f56312bc..00b232a7f 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/flat/RCTTextInput.java +++ b/ReactAndroid/src/main/java/com/facebook/react/flat/RCTTextInput.java @@ -17,7 +17,7 @@ import android.view.ViewGroup; import android.widget.EditText; import com.facebook.csslayout.CSSMeasureMode; -import com.facebook.csslayout.CSSNode; +import com.facebook.csslayout.CSSNodeAPI; import com.facebook.csslayout.MeasureOutput; import com.facebook.csslayout.Spacing; 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.UNSET; -public class RCTTextInput extends RCTVirtualText implements AndroidView, CSSNode.MeasureFunction { +public class RCTTextInput extends RCTVirtualText implements AndroidView, CSSNodeAPI.MeasureFunction { @Nullable private String mText; private int mJsEventCount = UNSET; @@ -73,7 +73,7 @@ public class RCTTextInput extends RCTVirtualText implements AndroidView, CSSNode @Override public void measure( - CSSNode node, + CSSNodeAPI node, float width, CSSMeasureMode widthMode, float height,