Fixed types of getLeadingPaddingAndBorder and getTrailingPaddingAndBorder to YGFloatOptional

Reviewed By: emilsjolander

Differential Revision: D7339998

fbshipit-source-id: aa24335c2db1cd895b9711214b72195add718c32
This commit is contained in:
Pritesh Nandgaonkar 2018-04-04 07:55:37 -07:00 committed by Facebook Github Bot
parent ee0d621d2a
commit fe3a9d4013
3 changed files with 29 additions and 28 deletions

View File

@ -627,7 +627,7 @@ bool YGNode::isNodeFlexible() {
(resolveFlexGrow() != 0 || resolveFlexShrink() != 0));
}
float YGNode::getLeadingBorder(const YGFlexDirection axis) const {
float YGNode::getLeadingBorder(const YGFlexDirection& axis) const {
if (YGFlexDirectionIsRow(axis) &&
style_.border[YGEdgeStart].unit != YGUnitUndefined &&
!YGFloatIsUndefined(style_.border[YGEdgeStart].value) &&
@ -640,7 +640,7 @@ float YGNode::getLeadingBorder(const YGFlexDirection axis) const {
return YGFloatMax(computedEdgeValue, 0.0f);
}
float YGNode::getTrailingBorder(const YGFlexDirection flexDirection) const {
float YGNode::getTrailingBorder(const YGFlexDirection& flexDirection) const {
if (YGFlexDirectionIsRow(flexDirection) &&
style_.border[YGEdgeEnd].unit != YGUnitUndefined &&
!YGFloatIsUndefined(style_.border[YGEdgeEnd].value) &&
@ -688,18 +688,18 @@ YGFloatOptional YGNode::getTrailingPadding(
return YGFloatOptionalMax(resolvedValue, YGFloatOptional(0.0f));
}
float YGNode::getLeadingPaddingAndBorder(
const YGFlexDirection axis,
const float widthSize) const {
return YGUnwrapFloatOptional(getLeadingPadding(axis, widthSize)) +
getLeadingBorder(axis);
YGFloatOptional YGNode::getLeadingPaddingAndBorder(
const YGFlexDirection& axis,
const float& widthSize) const {
return getLeadingPadding(axis, widthSize) +
YGFloatOptional(getLeadingBorder(axis));
}
float YGNode::getTrailingPaddingAndBorder(
const YGFlexDirection axis,
const float widthSize) const {
return YGUnwrapFloatOptional(getTrailingPadding(axis, widthSize)) +
getTrailingBorder(axis);
YGFloatOptional YGNode::getTrailingPaddingAndBorder(
const YGFlexDirection& axis,
const float& widthSize) const {
return getTrailingPadding(axis, widthSize) +
YGFloatOptional(getTrailingBorder(axis));
}
bool YGNode::didUseLegacyFlag() {

View File

@ -91,20 +91,20 @@ struct YGNode {
float getTrailingPosition(const YGFlexDirection axis, const float axisSize) const;
float getLeadingMargin(const YGFlexDirection axis, const float widthSize) const;
float getTrailingMargin(const YGFlexDirection axis, const float widthSize) const;
float getLeadingBorder(const YGFlexDirection flexDirection) const;
float getTrailingBorder(const YGFlexDirection flexDirection) const;
float getLeadingBorder(const YGFlexDirection& flexDirection) const;
float getTrailingBorder(const YGFlexDirection& flexDirection) const;
YGFloatOptional getLeadingPadding(
const YGFlexDirection& axis,
const float& widthSize) const;
YGFloatOptional getTrailingPadding(
const YGFlexDirection& axis,
const float& widthSize) const;
float getLeadingPaddingAndBorder(
const YGFlexDirection axis,
const float widthSize) const;
float getTrailingPaddingAndBorder(
const YGFlexDirection axis,
const float widthSize) const;
YGFloatOptional getLeadingPaddingAndBorder(
const YGFlexDirection& axis,
const float& widthSize) const;
YGFloatOptional getTrailingPaddingAndBorder(
const YGFlexDirection& axis,
const float& widthSize) const;
float getMarginForAxis(const YGFlexDirection axis, const float widthSize) const;
// Setters

View File

@ -1014,8 +1014,9 @@ static const std::array<YGDimension, 4> dim = {
static inline float YGNodePaddingAndBorderForAxis(const YGNodeRef node,
const YGFlexDirection axis,
const float widthSize) {
return node->getLeadingPaddingAndBorder(axis, widthSize) +
node->getTrailingPaddingAndBorder(axis, widthSize);
return YGUnwrapFloatOptional(
node->getLeadingPaddingAndBorder(axis, widthSize) +
node->getTrailingPaddingAndBorder(axis, widthSize));
}
static inline YGAlign YGNodeAlignItem(const YGNodeRef node, const YGNodeRef child) {
@ -2357,8 +2358,8 @@ static void YGJustifyMainAxis(
}
}
const float leadingPaddingAndBorderMain =
node->getLeadingPaddingAndBorder(mainAxis, ownerWidth);
const float leadingPaddingAndBorderMain = YGUnwrapFloatOptional(
node->getLeadingPaddingAndBorder(mainAxis, ownerWidth));
collectedFlexItemsValues.mainDim =
leadingPaddingAndBorderMain + leadingMainDim;
collectedFlexItemsValues.crossDim = 0;
@ -2438,8 +2439,8 @@ static void YGJustifyMainAxis(
}
}
}
collectedFlexItemsValues.mainDim +=
node->getTrailingPaddingAndBorder(mainAxis, ownerWidth);
collectedFlexItemsValues.mainDim += YGUnwrapFloatOptional(
node->getTrailingPaddingAndBorder(mainAxis, ownerWidth));
}
//
@ -2639,8 +2640,8 @@ static void YGNodelayoutImpl(const YGNodeRef node,
const float mainAxisownerSize = isMainAxisRow ? ownerWidth : ownerHeight;
const float crossAxisownerSize = isMainAxisRow ? ownerHeight : ownerWidth;
const float leadingPaddingAndBorderCross =
node->getLeadingPaddingAndBorder(crossAxis, ownerWidth);
const float leadingPaddingAndBorderCross = YGUnwrapFloatOptional(
node->getLeadingPaddingAndBorder(crossAxis, ownerWidth));
const float paddingAndBorderAxisMain = YGNodePaddingAndBorderForAxis(node, mainAxis, ownerWidth);
const float paddingAndBorderAxisCross =
YGNodePaddingAndBorderForAxis(node, crossAxis, ownerWidth);