Moved getTrailingPosition function as a method on YGNode
Reviewed By: emilsjolander Differential Revision: D6683205 fbshipit-source-id: d30003d90d634c644d92c833e58165b073d4d13e
This commit is contained in:
parent
040197a485
commit
b709ff4f13
|
@ -102,6 +102,25 @@ float YGNode::getLeadingPosition(
|
||||||
: YGResolveValue(*leadingPosition, axisSize);
|
: YGResolveValue(*leadingPosition, axisSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float YGNode::getTrailingPosition(
|
||||||
|
const YGFlexDirection axis,
|
||||||
|
const float axisSize) {
|
||||||
|
if (YGFlexDirectionIsRow(axis)) {
|
||||||
|
const YGValue* trailingPosition =
|
||||||
|
YGComputedEdgeValue(style_.position, YGEdgeEnd, &YGValueUndefined);
|
||||||
|
if (trailingPosition->unit != YGUnitUndefined) {
|
||||||
|
return YGResolveValue(*trailingPosition, axisSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const YGValue* trailingPosition =
|
||||||
|
YGComputedEdgeValue(style_.position, trailing[axis], &YGValueUndefined);
|
||||||
|
|
||||||
|
return trailingPosition->unit == YGUnitUndefined
|
||||||
|
? 0.0f
|
||||||
|
: YGResolveValue(*trailingPosition, axisSize);
|
||||||
|
}
|
||||||
|
|
||||||
bool YGNode::isLeadingPositionDefined(const YGFlexDirection axis) {
|
bool YGNode::isLeadingPositionDefined(const YGFlexDirection axis) {
|
||||||
return (YGFlexDirectionIsRow(axis) &&
|
return (YGFlexDirectionIsRow(axis) &&
|
||||||
YGComputedEdgeValue(style_.position, YGEdgeStart, &YGValueUndefined)
|
YGComputedEdgeValue(style_.position, YGEdgeStart, &YGValueUndefined)
|
||||||
|
|
|
@ -79,6 +79,7 @@ struct YGNode {
|
||||||
float getLeadingPosition(const YGFlexDirection axis, const float axisSize);
|
float getLeadingPosition(const YGFlexDirection axis, const float axisSize);
|
||||||
bool isLeadingPositionDefined(const YGFlexDirection axis);
|
bool isLeadingPositionDefined(const YGFlexDirection axis);
|
||||||
bool isTrailingPosDefined(const YGFlexDirection axis);
|
bool isTrailingPosDefined(const YGFlexDirection axis);
|
||||||
|
float getTrailingPosition(const YGFlexDirection axis, const float axisSize);
|
||||||
|
|
||||||
// Setters
|
// Setters
|
||||||
|
|
||||||
|
|
|
@ -999,25 +999,6 @@ static inline bool YGNodeIsLayoutDimDefined(const YGNodeRef node, const YGFlexDi
|
||||||
return !YGFloatIsUndefined(value) && value >= 0.0f;
|
return !YGFloatIsUndefined(value) && value >= 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
static float YGNodeTrailingPosition(const YGNodeRef node,
|
|
||||||
const YGFlexDirection axis,
|
|
||||||
const float axisSize) {
|
|
||||||
if (YGFlexDirectionIsRow(axis)) {
|
|
||||||
const YGValue* trailingPosition = YGComputedEdgeValue(
|
|
||||||
node->getStyle().position, YGEdgeEnd, &YGValueUndefined);
|
|
||||||
if (trailingPosition->unit != YGUnitUndefined) {
|
|
||||||
return YGResolveValue(*trailingPosition, axisSize);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const YGValue* trailingPosition = YGComputedEdgeValue(
|
|
||||||
node->getStyle().position, trailing[axis], &YGValueUndefined);
|
|
||||||
|
|
||||||
return trailingPosition->unit == YGUnitUndefined
|
|
||||||
? 0.0f
|
|
||||||
: YGResolveValue(*trailingPosition, axisSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
static float YGNodeBoundAxisWithinMinAndMax(const YGNodeRef node,
|
static float YGNodeBoundAxisWithinMinAndMax(const YGNodeRef node,
|
||||||
const YGFlexDirection axis,
|
const YGFlexDirection axis,
|
||||||
const float value,
|
const float value,
|
||||||
|
@ -1079,7 +1060,7 @@ static float YGNodeRelativePosition(const YGNodeRef node,
|
||||||
const float axisSize) {
|
const float axisSize) {
|
||||||
return node->isLeadingPositionDefined(axis)
|
return node->isLeadingPositionDefined(axis)
|
||||||
? node->getLeadingPosition(axis, axisSize)
|
? node->getLeadingPosition(axis, axisSize)
|
||||||
: -YGNodeTrailingPosition(node, axis, axisSize);
|
: -node->getTrailingPosition(axis, axisSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void YGConstrainMaxSizeForMode(const YGNodeRef node,
|
static void YGConstrainMaxSizeForMode(const YGNodeRef node,
|
||||||
|
@ -1336,7 +1317,7 @@ static void YGNodeAbsoluteLayoutChild(const YGNodeRef node,
|
||||||
(YGNodeLeadingBorder(node, YGFlexDirectionRow) +
|
(YGNodeLeadingBorder(node, YGFlexDirectionRow) +
|
||||||
YGNodeTrailingBorder(node, YGFlexDirectionRow)) -
|
YGNodeTrailingBorder(node, YGFlexDirectionRow)) -
|
||||||
(child->getLeadingPosition(YGFlexDirectionRow, width) +
|
(child->getLeadingPosition(YGFlexDirectionRow, width) +
|
||||||
YGNodeTrailingPosition(child, YGFlexDirectionRow, width));
|
child->getTrailingPosition(YGFlexDirectionRow, width));
|
||||||
childWidth = YGNodeBoundAxis(child, YGFlexDirectionRow, childWidth, width, width);
|
childWidth = YGNodeBoundAxis(child, YGFlexDirectionRow, childWidth, width, width);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1355,7 +1336,7 @@ static void YGNodeAbsoluteLayoutChild(const YGNodeRef node,
|
||||||
(YGNodeLeadingBorder(node, YGFlexDirectionColumn) +
|
(YGNodeLeadingBorder(node, YGFlexDirectionColumn) +
|
||||||
YGNodeTrailingBorder(node, YGFlexDirectionColumn)) -
|
YGNodeTrailingBorder(node, YGFlexDirectionColumn)) -
|
||||||
(child->getLeadingPosition(YGFlexDirectionColumn, height) +
|
(child->getLeadingPosition(YGFlexDirectionColumn, height) +
|
||||||
YGNodeTrailingPosition(child, YGFlexDirectionColumn, height));
|
child->getTrailingPosition(YGFlexDirectionColumn, height));
|
||||||
childHeight = YGNodeBoundAxis(child, YGFlexDirectionColumn, childHeight, height, width);
|
childHeight = YGNodeBoundAxis(child, YGFlexDirectionColumn, childHeight, height, width);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1426,8 +1407,8 @@ static void YGNodeAbsoluteLayoutChild(const YGNodeRef node,
|
||||||
child->getLayout().measuredDimensions[dim[mainAxis]] -
|
child->getLayout().measuredDimensions[dim[mainAxis]] -
|
||||||
YGNodeTrailingBorder(node, mainAxis) -
|
YGNodeTrailingBorder(node, mainAxis) -
|
||||||
YGNodeTrailingMargin(child, mainAxis, width) -
|
YGNodeTrailingMargin(child, mainAxis, width) -
|
||||||
YGNodeTrailingPosition(
|
child->getTrailingPosition(
|
||||||
child, mainAxis, isMainAxisRow ? width : height),
|
mainAxis, isMainAxisRow ? width : height),
|
||||||
leading[mainAxis]);
|
leading[mainAxis]);
|
||||||
} else if (
|
} else if (
|
||||||
!child->isLeadingPositionDefined(mainAxis) &&
|
!child->isLeadingPositionDefined(mainAxis) &&
|
||||||
|
@ -1453,8 +1434,8 @@ static void YGNodeAbsoluteLayoutChild(const YGNodeRef node,
|
||||||
child->getLayout().measuredDimensions[dim[crossAxis]] -
|
child->getLayout().measuredDimensions[dim[crossAxis]] -
|
||||||
YGNodeTrailingBorder(node, crossAxis) -
|
YGNodeTrailingBorder(node, crossAxis) -
|
||||||
YGNodeTrailingMargin(child, crossAxis, width) -
|
YGNodeTrailingMargin(child, crossAxis, width) -
|
||||||
YGNodeTrailingPosition(
|
child->getTrailingPosition(
|
||||||
child, crossAxis, isMainAxisRow ? height : width),
|
crossAxis, isMainAxisRow ? height : width),
|
||||||
leading[crossAxis]);
|
leading[crossAxis]);
|
||||||
|
|
||||||
} else if (
|
} else if (
|
||||||
|
|
Loading…
Reference in New Issue