Expose method to set custom baseline function

Summary:
<!--
Thank you for sending the PR! We appreciate you spending the time to work on these changes.

Help us understand your motivation by explaining why you decided to make this change.

You can learn more about contributing to React Native here: http://facebook.github.io/react-native/docs/contributing.html

Happy contributing!

-->

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
This commit is contained in:
Sreejith Krishnan R 2017-08-23 02:16:34 -07:00 committed by Facebook Github Bot
parent ad4aee7519
commit 9c2caaac3e
1 changed files with 5 additions and 0 deletions

View File

@ -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) {