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

View File

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

View File

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