Remove the usage of YGUndefined in the default values of Border in YGStyle
Summary: Remove the usage of YGUndefined in the default values of Border in YGStyle. In the getter of Border function, YGUndefined is used just to keep it logically consistent. The proper solution would be to change the api in `Yoga.h` to accept `YGFloatOptional`, but that would require to change lot of the code in client of this library. Will make a separate diff for that. Reviewed By: emilsjolander Differential Revision: D7195115 fbshipit-source-id: e635cf55ac94d8a90caef6cafce281579da2cbfc
This commit is contained in:
committed by
Facebook Github Bot
parent
c75adb0671
commit
47ad3f63cf
@@ -760,7 +760,35 @@ 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_AUTO_IMPL(YGValue, Margin, margin);
|
||||
YG_NODE_STYLE_EDGE_PROPERTY_UNIT_IMPL(YGValue, Padding, padding, padding);
|
||||
YG_NODE_STYLE_EDGE_PROPERTY_IMPL(float, Border, border, border);
|
||||
|
||||
// TODO: Change the API to accept YGFloatOptional.
|
||||
void YGNodeStyleSetBorder(
|
||||
const YGNodeRef node,
|
||||
const YGEdge edge,
|
||||
const float border) {
|
||||
YGValue value = {
|
||||
.value = YGFloatSanitize(border),
|
||||
.unit = YGFloatIsUndefined(border) ? YGUnitUndefined : YGUnitPoint,
|
||||
};
|
||||
if ((node->getStyle().border[edge].value != value.value &&
|
||||
value.unit != YGUnitUndefined) ||
|
||||
node->getStyle().border[edge].unit != value.unit) {
|
||||
YGStyle style = node->getStyle();
|
||||
style.border[edge] = value;
|
||||
node->setStyle(style);
|
||||
node->markDirtyAndPropogate();
|
||||
}
|
||||
}
|
||||
|
||||
float YGNodeStyleGetBorder(const YGNodeRef node, const YGEdge edge) {
|
||||
if (node->getStyle().border[edge].unit == YGUnitUndefined) {
|
||||
// TODO: Rather than returning YGUndefined, change the api to return
|
||||
// YGFloatOptional.
|
||||
return YGUndefined;
|
||||
}
|
||||
|
||||
return node->getStyle().border[edge].value;
|
||||
}
|
||||
|
||||
YG_NODE_STYLE_PROPERTY_UNIT_AUTO_IMPL(YGValue, Width, width, dimensions[YGDimensionWidth]);
|
||||
YG_NODE_STYLE_PROPERTY_UNIT_AUTO_IMPL(YGValue, Height, height, dimensions[YGDimensionHeight]);
|
||||
|
Reference in New Issue
Block a user