Change the type of flexGrow to YGFloatOptional
Summary: Change the type of flexGrow to YGFloatOptional Reviewed By: emilsjolander Differential Revision: D7215355 fbshipit-source-id: 1298ee332551d44e4d070169a1e4103d005c4f43
This commit is contained in:
committed by
Facebook Github Bot
parent
2232d7603a
commit
8aadae8ce4
@@ -592,8 +592,8 @@ float YGNode::resolveFlexGrow() {
|
|||||||
if (parent_ == nullptr) {
|
if (parent_ == nullptr) {
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
if (!YGFloatIsUndefined(style_.flexGrow)) {
|
if (!style_.flexGrow.isUndefined) {
|
||||||
return style_.flexGrow;
|
return style_.flexGrow.value;
|
||||||
}
|
}
|
||||||
if (!style_.flex.isUndefined && style_.flex.value > 0.0f) {
|
if (!style_.flex.isUndefined && style_.flex.value > 0.0f) {
|
||||||
return style_.flex.value;
|
return style_.flex.value;
|
||||||
|
@@ -161,7 +161,7 @@ void YGNodeToString(
|
|||||||
appendFormatedString(
|
appendFormatedString(
|
||||||
str, "align-self: %s; ", YGAlignToString(node->getStyle().alignSelf));
|
str, "align-self: %s; ", YGAlignToString(node->getStyle().alignSelf));
|
||||||
}
|
}
|
||||||
appendFloatIfNotUndefined(str, "flex-grow", node->getStyle().flexGrow);
|
appendFloatOptionalIfDefined(str, "flex-grow", node->getStyle().flexGrow);
|
||||||
appendFloatIfNotUndefined(str, "flex-shrink", node->getStyle().flexShrink);
|
appendFloatIfNotUndefined(str, "flex-shrink", node->getStyle().flexShrink);
|
||||||
appendNumberIfNotAuto(str, "flex-basis", node->getStyle().flexBasis);
|
appendNumberIfNotAuto(str, "flex-basis", node->getStyle().flexBasis);
|
||||||
appendFloatOptionalIfDefined(str, "flex", node->getStyle().flex);
|
appendFloatOptionalIfDefined(str, "flex", node->getStyle().flex);
|
||||||
|
@@ -43,7 +43,7 @@ YGStyle::YGStyle()
|
|||||||
overflow(YGOverflowVisible),
|
overflow(YGOverflowVisible),
|
||||||
display(YGDisplayFlex),
|
display(YGDisplayFlex),
|
||||||
flex(YGFloatOptionalUndefined),
|
flex(YGFloatOptionalUndefined),
|
||||||
flexGrow(YGUndefined),
|
flexGrow(YGFloatOptionalUndefined),
|
||||||
flexShrink(YGUndefined),
|
flexShrink(YGUndefined),
|
||||||
flexBasis(kYGValueAuto),
|
flexBasis(kYGValueAuto),
|
||||||
margin(kYGDefaultEdgeValuesUnit),
|
margin(kYGDefaultEdgeValuesUnit),
|
||||||
@@ -79,9 +79,11 @@ bool YGStyle::operator==(const YGStyle& style) {
|
|||||||
areNonFloatValuesEqual && flex.value == style.flex.value;
|
areNonFloatValuesEqual && flex.value == style.flex.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(YGFloatIsUndefined(flexGrow) && YGFloatIsUndefined(style.flexGrow))) {
|
areNonFloatValuesEqual = areNonFloatValuesEqual &&
|
||||||
|
flexGrow.isUndefined == style.flexGrow.isUndefined;
|
||||||
|
if (areNonFloatValuesEqual && !flexGrow.isUndefined) {
|
||||||
areNonFloatValuesEqual =
|
areNonFloatValuesEqual =
|
||||||
areNonFloatValuesEqual && flexGrow == style.flexGrow;
|
areNonFloatValuesEqual && flexGrow.value == style.flexGrow.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(YGFloatIsUndefined(flexShrink) &&
|
if (!(YGFloatIsUndefined(flexShrink) &&
|
||||||
|
@@ -21,7 +21,7 @@ struct YGStyle {
|
|||||||
YGOverflow overflow;
|
YGOverflow overflow;
|
||||||
YGDisplay display;
|
YGDisplay display;
|
||||||
YGFloatOptional flex;
|
YGFloatOptional flex;
|
||||||
float flexGrow;
|
YGFloatOptional flexGrow;
|
||||||
float flexShrink;
|
float flexShrink;
|
||||||
YGValue flexBasis;
|
YGValue flexBasis;
|
||||||
std::array<YGValue, YGEdgeCount> margin;
|
std::array<YGValue, YGEdgeCount> margin;
|
||||||
|
@@ -511,9 +511,9 @@ void YGNodeCopyStyle(const YGNodeRef dstNode, const YGNodeRef srcNode) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
float YGNodeStyleGetFlexGrow(const YGNodeRef node) {
|
float YGNodeStyleGetFlexGrow(const YGNodeRef node) {
|
||||||
return YGFloatIsUndefined(node->getStyle().flexGrow)
|
return node->getStyle().flexGrow.isUndefined
|
||||||
? kDefaultFlexGrow
|
? kDefaultFlexGrow
|
||||||
: node->getStyle().flexGrow;
|
: node->getStyle().flexGrow.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
float YGNodeStyleGetFlexShrink(const YGNodeRef node) {
|
float YGNodeStyleGetFlexShrink(const YGNodeRef node) {
|
||||||
@@ -772,7 +772,21 @@ float YGNodeStyleGetFlex(const YGNodeRef node) {
|
|||||||
: node->getStyle().flex.value;
|
: node->getStyle().flex.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
YG_NODE_STYLE_PROPERTY_SETTER_IMPL(float, FlexGrow, flexGrow, flexGrow);
|
// TODO(T26792433): Change the API to accept YGFloatOptional.
|
||||||
|
void YGNodeStyleSetFlexGrow(const YGNodeRef node, const float flexGrow) {
|
||||||
|
if (!YGFloatOptionalFloatEquals(node->getStyle().flexGrow, flexGrow)) {
|
||||||
|
YGStyle style = node->getStyle();
|
||||||
|
if (YGFloatIsUndefined(flexGrow)) {
|
||||||
|
style.flexGrow = {true, 0};
|
||||||
|
} else {
|
||||||
|
style.flexGrow = {false, flexGrow};
|
||||||
|
}
|
||||||
|
node->setStyle(style);
|
||||||
|
node->markDirtyAndPropogate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// YG_NODE_STYLE_PROPERTY_SETTER_IMPL(float, FlexGrow, flexGrow, flexGrow);
|
||||||
YG_NODE_STYLE_PROPERTY_SETTER_IMPL(float, FlexShrink, flexShrink, flexShrink);
|
YG_NODE_STYLE_PROPERTY_SETTER_IMPL(float, FlexShrink, flexShrink, flexShrink);
|
||||||
YG_NODE_STYLE_PROPERTY_UNIT_AUTO_IMPL(YGValue, FlexBasis, flexBasis, flexBasis);
|
YG_NODE_STYLE_PROPERTY_UNIT_AUTO_IMPL(YGValue, FlexBasis, flexBasis, flexBasis);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user