From 9c2caaac3e0a0f932ff67e4e80f90b6c5626b56f Mon Sep 17 00:00:00 2001 From: Sreejith Krishnan R Date: Wed, 23 Aug 2017 02:16:34 -0700 Subject: [PATCH] Expose method to set custom baseline function Summary: I was trying to typeset mathematical equations in react native. When typesetting fractions, baseline of the fraction must be aligned with the baseline of others. The baseline of fraction will vary based on size of numerator and denominator. ![image](https://user-images.githubusercontent.com/31202232/29577330-a22b45ee-8788-11e7-9cc5-04a72bcc1180.png) In yoga, we can set custom baseline function using `YogaNode.setBaselineFunction` method. If this method is exposed in `ReactShadowNode` class, it will be easy to create custom native UI modules which requires setting custom baseline. Closes https://github.com/facebook/react-native/pull/15605 Differential Revision: D5686876 Pulled By: shergin fbshipit-source-id: 34d797a7ea27d5c1b9f6b9c36e469cdca3883aec --- .../java/com/facebook/react/uimanager/ReactShadowNode.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactShadowNode.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactShadowNode.java index a3ce58bf3..4357e9157 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactShadowNode.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactShadowNode.java @@ -22,6 +22,7 @@ import com.facebook.yoga.YogaConstants; import com.facebook.yoga.YogaDirection; import com.facebook.yoga.YogaFlexDirection; import com.facebook.yoga.YogaJustify; +import com.facebook.yoga.YogaBaselineFunction; import com.facebook.yoga.YogaMeasureFunction; import com.facebook.yoga.YogaNode; import com.facebook.yoga.YogaOverflow; @@ -782,6 +783,10 @@ public class ReactShadowNode { mShouldNotifyOnLayout = shouldNotifyOnLayout; } + public void setBaselineFunction(YogaBaselineFunction baselineFunction) { + mYogaNode.setBaselineFunction(baselineFunction); + } + public void setMeasureFunction(YogaMeasureFunction measureFunction) { if ((measureFunction == null ^ mYogaNode.isMeasureDefined()) && getChildCount() != 0) {