Remove the use of YGUndefined for flex-basis
Summary: Remove the use of YGUndefined for default flex-basis value Reviewed By: emilsjolander Differential Revision: D7243924 fbshipit-source-id: 2bfaca1a5e3da40d5292a273cabf705f59c9d666
This commit is contained in:
committed by
Facebook Github Bot
parent
877c275a13
commit
d567885070
@@ -45,7 +45,7 @@ YGStyle::YGStyle()
|
|||||||
flex(YGFloatOptionalUndefined),
|
flex(YGFloatOptionalUndefined),
|
||||||
flexGrow(YGFloatOptionalUndefined),
|
flexGrow(YGFloatOptionalUndefined),
|
||||||
flexShrink(YGFloatOptionalUndefined),
|
flexShrink(YGFloatOptionalUndefined),
|
||||||
flexBasis(kYGValueAuto),
|
flexBasis({0, YGUnitAuto}),
|
||||||
margin(kYGDefaultEdgeValuesUnit),
|
margin(kYGDefaultEdgeValuesUnit),
|
||||||
position(kYGDefaultEdgeValuesUnit),
|
position(kYGDefaultEdgeValuesUnit),
|
||||||
padding(kYGDefaultEdgeValuesUnit),
|
padding(kYGDefaultEdgeValuesUnit),
|
||||||
|
@@ -800,7 +800,54 @@ void YGNodeStyleSetFlexShrink(const YGNodeRef node, const float flexShrink) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
YG_NODE_STYLE_PROPERTY_UNIT_AUTO_IMPL(YGValue, FlexBasis, flexBasis, flexBasis);
|
YGValue YGNodeStyleGetFlexBasis(const YGNodeRef node) {
|
||||||
|
YGValue flexBasis = node->getStyle().flexBasis;
|
||||||
|
if (flexBasis.unit == YGUnitUndefined || flexBasis.unit == YGUnitAuto) {
|
||||||
|
// TODO(T26792433): Get rid off the use of YGUndefined at client side
|
||||||
|
flexBasis.value = YGUndefined;
|
||||||
|
}
|
||||||
|
return flexBasis;
|
||||||
|
}
|
||||||
|
|
||||||
|
void YGNodeStyleSetFlexBasis(const YGNodeRef node, const float flexBasis) {
|
||||||
|
YGValue value = {
|
||||||
|
.value = YGFloatSanitize(flexBasis),
|
||||||
|
.unit = YGFloatIsUndefined(flexBasis) ? YGUnitUndefined : YGUnitPoint,
|
||||||
|
};
|
||||||
|
if ((node->getStyle().flexBasis.value != value.value &&
|
||||||
|
value.unit != YGUnitUndefined) ||
|
||||||
|
node->getStyle().flexBasis.unit != value.unit) {
|
||||||
|
YGStyle style = node->getStyle();
|
||||||
|
style.flexBasis = value;
|
||||||
|
node->setStyle(style);
|
||||||
|
node->markDirtyAndPropogate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void YGNodeStyleSetFlexBasisPercent(
|
||||||
|
const YGNodeRef node,
|
||||||
|
const float flexBasisPercent) {
|
||||||
|
if (node->getStyle().flexBasis.value != flexBasisPercent ||
|
||||||
|
node->getStyle().flexBasis.unit != YGUnitPercent) {
|
||||||
|
YGStyle style = node->getStyle();
|
||||||
|
style.flexBasis.value = YGFloatSanitize(flexBasisPercent);
|
||||||
|
style.flexBasis.unit =
|
||||||
|
YGFloatIsUndefined(flexBasisPercent) ? YGUnitAuto : YGUnitPercent;
|
||||||
|
node->setStyle(style);
|
||||||
|
node->markDirtyAndPropogate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void YGNodeStyleSetFlexBasisAuto(const YGNodeRef node) {
|
||||||
|
if (node->getStyle().flexBasis.unit != YGUnitAuto) {
|
||||||
|
YGStyle style = node->getStyle();
|
||||||
|
style.flexBasis.value = 0;
|
||||||
|
style.flexBasis.unit = YGUnitAuto;
|
||||||
|
node->setStyle(style);
|
||||||
|
node->markDirtyAndPropogate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
YG_NODE_STYLE_EDGE_PROPERTY_UNIT_IMPL(YGValue, Position, position, position);
|
YG_NODE_STYLE_EDGE_PROPERTY_UNIT_IMPL(YGValue, Position, position, position);
|
||||||
YG_NODE_STYLE_EDGE_PROPERTY_UNIT_IMPL(YGValue, Margin, margin, margin);
|
YG_NODE_STYLE_EDGE_PROPERTY_UNIT_IMPL(YGValue, Margin, margin, margin);
|
||||||
YG_NODE_STYLE_EDGE_PROPERTY_UNIT_AUTO_IMPL(YGValue, Margin, margin);
|
YG_NODE_STYLE_EDGE_PROPERTY_UNIT_AUTO_IMPL(YGValue, Margin, margin);
|
||||||
|
Reference in New Issue
Block a user