Feature auto margin

Summary:
Even so I know there are some opinions against ```margin: 0 auto``` it's still part of the spec: https://www.w3.org/TR/css-flexbox-1/#auto-margins and pretty usefull if you have to position via ```justify-content```.

This PR adds an implementation for that.

It adds an additonal ```YGUnitAuto``` and margins got ```YGNodeStyleSetMarginAuto``` functions as well.
Closes https://github.com/facebook/yoga/pull/357

Reviewed By: astreet

Differential Revision: D4501142

Pulled By: emilsjolander

fbshipit-source-id: 86519f8632496f46e78a7c9dbc5b21e212e3e0c7
This commit is contained in:
Lukas Wöhrl
2017-02-14 14:26:09 -08:00
committed by Facebook Github Bot
parent 8a91c0a0e5
commit 1146013e9e
29 changed files with 3353 additions and 56 deletions

View File

@@ -15,6 +15,8 @@ function toValueJava(value) {
function toMethodName(value) {
if (value.indexOf('%') >= 0){
return 'Percent';
} else if(value.indexOf('AUTO') >= 0) {
return 'Auto';
}
return '';
}
@@ -136,6 +138,8 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, {
YGDisplayFlex:{value:'YogaDisplay.FLEX'},
YGDisplayNone:{value:'YogaDisplay.NONE'},
YGAuto:{value:'YogaConstants.AUTO'},
YGWrapNoWrap:{value:'YogaWrap.NO_WRAP'},
YGWrapWrap:{value:'YogaWrap.WRAP'},
@@ -218,7 +222,14 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, {
}},
YGNodeStyleSetMargin:{value:function(nodeName, edge, value) {
this.push(nodeName + '.setMargin' + toMethodName(value) + '(' + edge + ', ' + toValueJava(value) + 'f);');
var valueStr = toValueJava(value);
if (valueStr != 'YogaConstants.AUTO') {
valueStr = ', ' + valueStr + 'f';
} else {
valueStr = '';
}
this.push(nodeName + '.setMargin' + toMethodName(value) + '(' + edge + valueStr + ');');
}},
YGNodeStyleSetMaxHeight:{value:function(nodeName, value) {