Change the type of flexShrink to YGFloatOptional
Summary: Change the type of flexShrink to YGFloatOptional Reviewed By: emilsjolander Differential Revision: D7232171 fbshipit-source-id: 3111119d3d74a7035c01132bff61b30cf44e120a
This commit is contained in:
committed by
Facebook Github Bot
parent
8aadae8ce4
commit
877c275a13
@@ -605,8 +605,8 @@ float YGNode::resolveFlexShrink() {
|
|||||||
if (parent_ == nullptr) {
|
if (parent_ == nullptr) {
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
if (!YGFloatIsUndefined(style_.flexShrink)) {
|
if (!style_.flexShrink.isUndefined) {
|
||||||
return style_.flexShrink;
|
return style_.flexShrink.value;
|
||||||
}
|
}
|
||||||
if (!config_->useWebDefaults && !style_.flex.isUndefined &&
|
if (!config_->useWebDefaults && !style_.flex.isUndefined &&
|
||||||
style_.flex.value < 0.0f) {
|
style_.flex.value < 0.0f) {
|
||||||
|
@@ -48,13 +48,6 @@ static void appendFloatOptionalIfDefined(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
appendFloatIfNotUndefined(string* base, const string key, const float num) {
|
|
||||||
if (!YGFloatIsUndefined(num)) {
|
|
||||||
appendFormatedString(base, "%s: %g; ", key.c_str(), num);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void appendNumberIfNotUndefined(
|
static void appendNumberIfNotUndefined(
|
||||||
string* base,
|
string* base,
|
||||||
const string key,
|
const string key,
|
||||||
@@ -162,7 +155,8 @@ void YGNodeToString(
|
|||||||
str, "align-self: %s; ", YGAlignToString(node->getStyle().alignSelf));
|
str, "align-self: %s; ", YGAlignToString(node->getStyle().alignSelf));
|
||||||
}
|
}
|
||||||
appendFloatOptionalIfDefined(str, "flex-grow", node->getStyle().flexGrow);
|
appendFloatOptionalIfDefined(str, "flex-grow", node->getStyle().flexGrow);
|
||||||
appendFloatIfNotUndefined(str, "flex-shrink", node->getStyle().flexShrink);
|
appendFloatOptionalIfDefined(
|
||||||
|
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);
|
||||||
|
|
||||||
|
@@ -44,7 +44,7 @@ YGStyle::YGStyle()
|
|||||||
display(YGDisplayFlex),
|
display(YGDisplayFlex),
|
||||||
flex(YGFloatOptionalUndefined),
|
flex(YGFloatOptionalUndefined),
|
||||||
flexGrow(YGFloatOptionalUndefined),
|
flexGrow(YGFloatOptionalUndefined),
|
||||||
flexShrink(YGUndefined),
|
flexShrink(YGFloatOptionalUndefined),
|
||||||
flexBasis(kYGValueAuto),
|
flexBasis(kYGValueAuto),
|
||||||
margin(kYGDefaultEdgeValuesUnit),
|
margin(kYGDefaultEdgeValuesUnit),
|
||||||
position(kYGDefaultEdgeValuesUnit),
|
position(kYGDefaultEdgeValuesUnit),
|
||||||
@@ -86,10 +86,11 @@ bool YGStyle::operator==(const YGStyle& style) {
|
|||||||
areNonFloatValuesEqual && flexGrow.value == style.flexGrow.value;
|
areNonFloatValuesEqual && flexGrow.value == style.flexGrow.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(YGFloatIsUndefined(flexShrink) &&
|
areNonFloatValuesEqual = areNonFloatValuesEqual &&
|
||||||
YGFloatIsUndefined(style.flexShrink))) {
|
flexShrink.isUndefined == style.flexShrink.isUndefined;
|
||||||
|
if (areNonFloatValuesEqual && !style.flexShrink.isUndefined) {
|
||||||
areNonFloatValuesEqual =
|
areNonFloatValuesEqual =
|
||||||
areNonFloatValuesEqual && flexShrink == style.flexShrink;
|
areNonFloatValuesEqual && flexShrink.value == style.flexShrink.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(YGFloatIsUndefined(aspectRatio) &&
|
if (!(YGFloatIsUndefined(aspectRatio) &&
|
||||||
|
@@ -22,7 +22,7 @@ struct YGStyle {
|
|||||||
YGDisplay display;
|
YGDisplay display;
|
||||||
YGFloatOptional flex;
|
YGFloatOptional flex;
|
||||||
YGFloatOptional flexGrow;
|
YGFloatOptional flexGrow;
|
||||||
float flexShrink;
|
YGFloatOptional flexShrink;
|
||||||
YGValue flexBasis;
|
YGValue flexBasis;
|
||||||
std::array<YGValue, YGEdgeCount> margin;
|
std::array<YGValue, YGEdgeCount> margin;
|
||||||
std::array<YGValue, YGEdgeCount> position;
|
std::array<YGValue, YGEdgeCount> position;
|
||||||
|
@@ -517,10 +517,10 @@ float YGNodeStyleGetFlexGrow(const YGNodeRef node) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
float YGNodeStyleGetFlexShrink(const YGNodeRef node) {
|
float YGNodeStyleGetFlexShrink(const YGNodeRef node) {
|
||||||
return YGFloatIsUndefined(node->getStyle().flexShrink)
|
return node->getStyle().flexShrink.isUndefined
|
||||||
? (node->getConfig()->useWebDefaults ? kWebDefaultFlexShrink
|
? (node->getConfig()->useWebDefaults ? kWebDefaultFlexShrink
|
||||||
: kDefaultFlexShrink)
|
: kDefaultFlexShrink)
|
||||||
: node->getStyle().flexShrink;
|
: node->getStyle().flexShrink.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define YG_NODE_STYLE_PROPERTY_SETTER_IMPL( \
|
#define YG_NODE_STYLE_PROPERTY_SETTER_IMPL( \
|
||||||
@@ -786,10 +786,21 @@ void YGNodeStyleSetFlexGrow(const YGNodeRef node, const float flexGrow) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// YG_NODE_STYLE_PROPERTY_SETTER_IMPL(float, FlexGrow, flexGrow, flexGrow);
|
// TODO(T26792433): Change the API to accept YGFloatOptional.
|
||||||
YG_NODE_STYLE_PROPERTY_SETTER_IMPL(float, FlexShrink, flexShrink, flexShrink);
|
void YGNodeStyleSetFlexShrink(const YGNodeRef node, const float flexShrink) {
|
||||||
YG_NODE_STYLE_PROPERTY_UNIT_AUTO_IMPL(YGValue, FlexBasis, flexBasis, flexBasis);
|
if (!YGFloatOptionalFloatEquals(node->getStyle().flexShrink, flexShrink)) {
|
||||||
|
YGStyle style = node->getStyle();
|
||||||
|
if (YGFloatIsUndefined(flexShrink)) {
|
||||||
|
style.flexGrow = {true, 0};
|
||||||
|
} else {
|
||||||
|
style.flexShrink = {false, flexShrink};
|
||||||
|
}
|
||||||
|
node->setStyle(style);
|
||||||
|
node->markDirtyAndPropogate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
YG_NODE_STYLE_PROPERTY_UNIT_AUTO_IMPL(YGValue, FlexBasis, flexBasis, flexBasis);
|
||||||
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