Moved isLeadingPos defined as a method on YGNode
Reviewed By: emilsjolander Differential Revision: D6682956 fbshipit-source-id: 31c60e0eae906e1434a6969f3cd786fcaf9097a5
This commit is contained in:
parent
00f1a37b2c
commit
98a74b0a2b
|
@ -35,18 +35,6 @@ inline float YGResolveValue(const YGValue value, const float parentSize) {
|
|||
return YGUndefined;
|
||||
}
|
||||
|
||||
inline bool YGNodeIsLeadingPosDefined(
|
||||
const YGNodeRef node,
|
||||
const YGFlexDirection axis) {
|
||||
return (YGFlexDirectionIsRow(axis) &&
|
||||
YGComputedEdgeValue(
|
||||
node->getStyle().position, YGEdgeStart, &YGValueUndefined)
|
||||
->unit != YGUnitUndefined) ||
|
||||
YGComputedEdgeValue(
|
||||
node->getStyle().position, leading[axis], &YGValueUndefined)
|
||||
->unit != YGUnitUndefined;
|
||||
}
|
||||
|
||||
inline bool YGFlexDirectionIsColumn(const YGFlexDirection flexDirection) {
|
||||
return flexDirection == YGFlexDirectionColumn ||
|
||||
flexDirection == YGFlexDirectionColumnReverse;
|
||||
|
|
|
@ -102,6 +102,14 @@ float YGNode::getLeadingPosition(
|
|||
: YGResolveValue(*leadingPosition, axisSize);
|
||||
}
|
||||
|
||||
bool YGNode::isLeadingPositionDefined(const YGFlexDirection axis) {
|
||||
return (YGFlexDirectionIsRow(axis) &&
|
||||
YGComputedEdgeValue(style_.position, YGEdgeStart, &YGValueUndefined)
|
||||
->unit != YGUnitUndefined) ||
|
||||
YGComputedEdgeValue(style_.position, leading[axis], &YGValueUndefined)
|
||||
->unit != YGUnitUndefined;
|
||||
}
|
||||
|
||||
// Setters
|
||||
|
||||
void YGNode::setContext(void* context) {
|
||||
|
|
|
@ -77,6 +77,7 @@ struct YGNode {
|
|||
std::array<YGValue, 2> getResolvedDimensions() const;
|
||||
YGValue getResolvedDimension(int index);
|
||||
float getLeadingPosition(const YGFlexDirection axis, const float axisSize);
|
||||
bool isLeadingPositionDefined(const YGFlexDirection axis);
|
||||
|
||||
// Setters
|
||||
|
||||
|
|
|
@ -1088,7 +1088,7 @@ static void YGNodeSetChildTrailingPosition(const YGNodeRef node,
|
|||
static float YGNodeRelativePosition(const YGNodeRef node,
|
||||
const YGFlexDirection axis,
|
||||
const float axisSize) {
|
||||
return YGNodeIsLeadingPosDefined(node, axis)
|
||||
return node->isLeadingPositionDefined(axis)
|
||||
? node->getLeadingPosition(axis, axisSize)
|
||||
: -YGNodeTrailingPosition(node, axis, axisSize);
|
||||
}
|
||||
|
@ -1341,7 +1341,7 @@ static void YGNodeAbsoluteLayoutChild(const YGNodeRef node,
|
|||
// If the child doesn't have a specified width, compute the width based
|
||||
// on the left/right
|
||||
// offsets if they're defined.
|
||||
if (YGNodeIsLeadingPosDefined(child, YGFlexDirectionRow) &&
|
||||
if (child->isLeadingPositionDefined(YGFlexDirectionRow) &&
|
||||
YGNodeIsTrailingPosDefined(child, YGFlexDirectionRow)) {
|
||||
childWidth = node->getLayout().measuredDimensions[YGDimensionWidth] -
|
||||
(YGNodeLeadingBorder(node, YGFlexDirectionRow) +
|
||||
|
@ -1360,7 +1360,7 @@ static void YGNodeAbsoluteLayoutChild(const YGNodeRef node,
|
|||
// If the child doesn't have a specified height, compute the height
|
||||
// based on the top/bottom
|
||||
// offsets if they're defined.
|
||||
if (YGNodeIsLeadingPosDefined(child, YGFlexDirectionColumn) &&
|
||||
if (child->isLeadingPositionDefined(YGFlexDirectionColumn) &&
|
||||
YGNodeIsTrailingPosDefined(child, YGFlexDirectionColumn)) {
|
||||
childHeight = node->getLayout().measuredDimensions[YGDimensionHeight] -
|
||||
(YGNodeLeadingBorder(node, YGFlexDirectionColumn) +
|
||||
|
@ -1430,7 +1430,8 @@ static void YGNodeAbsoluteLayoutChild(const YGNodeRef node,
|
|||
"abs-layout",
|
||||
config);
|
||||
|
||||
if (YGNodeIsTrailingPosDefined(child, mainAxis) && !YGNodeIsLeadingPosDefined(child, mainAxis)) {
|
||||
if (YGNodeIsTrailingPosDefined(child, mainAxis) &&
|
||||
!child->isLeadingPositionDefined(mainAxis)) {
|
||||
child->setLayoutPosition(
|
||||
node->getLayout().measuredDimensions[dim[mainAxis]] -
|
||||
child->getLayout().measuredDimensions[dim[mainAxis]] -
|
||||
|
@ -1440,7 +1441,7 @@ static void YGNodeAbsoluteLayoutChild(const YGNodeRef node,
|
|||
child, mainAxis, isMainAxisRow ? width : height),
|
||||
leading[mainAxis]);
|
||||
} else if (
|
||||
!YGNodeIsLeadingPosDefined(child, mainAxis) &&
|
||||
!child->isLeadingPositionDefined(mainAxis) &&
|
||||
node->getStyle().justifyContent == YGJustifyCenter) {
|
||||
child->setLayoutPosition(
|
||||
(node->getLayout().measuredDimensions[dim[mainAxis]] -
|
||||
|
@ -1448,7 +1449,7 @@ static void YGNodeAbsoluteLayoutChild(const YGNodeRef node,
|
|||
2.0f,
|
||||
leading[mainAxis]);
|
||||
} else if (
|
||||
!YGNodeIsLeadingPosDefined(child, mainAxis) &&
|
||||
!child->isLeadingPositionDefined(mainAxis) &&
|
||||
node->getStyle().justifyContent == YGJustifyFlexEnd) {
|
||||
child->setLayoutPosition(
|
||||
(node->getLayout().measuredDimensions[dim[mainAxis]] -
|
||||
|
@ -1457,7 +1458,7 @@ static void YGNodeAbsoluteLayoutChild(const YGNodeRef node,
|
|||
}
|
||||
|
||||
if (YGNodeIsTrailingPosDefined(child, crossAxis) &&
|
||||
!YGNodeIsLeadingPosDefined(child, crossAxis)) {
|
||||
!child->isLeadingPositionDefined(crossAxis)) {
|
||||
child->setLayoutPosition(
|
||||
node->getLayout().measuredDimensions[dim[crossAxis]] -
|
||||
child->getLayout().measuredDimensions[dim[crossAxis]] -
|
||||
|
@ -1467,15 +1468,16 @@ static void YGNodeAbsoluteLayoutChild(const YGNodeRef node,
|
|||
child, crossAxis, isMainAxisRow ? height : width),
|
||||
leading[crossAxis]);
|
||||
|
||||
} else if (!YGNodeIsLeadingPosDefined(child, crossAxis) &&
|
||||
YGNodeAlignItem(node, child) == YGAlignCenter) {
|
||||
} else if (
|
||||
!child->isLeadingPositionDefined(crossAxis) &&
|
||||
YGNodeAlignItem(node, child) == YGAlignCenter) {
|
||||
child->setLayoutPosition(
|
||||
(node->getLayout().measuredDimensions[dim[crossAxis]] -
|
||||
child->getLayout().measuredDimensions[dim[crossAxis]]) /
|
||||
2.0f,
|
||||
leading[crossAxis]);
|
||||
} else if (
|
||||
!YGNodeIsLeadingPosDefined(child, crossAxis) &&
|
||||
!child->isLeadingPositionDefined(crossAxis) &&
|
||||
((YGNodeAlignItem(node, child) == YGAlignFlexEnd) ^
|
||||
(node->getStyle().flexWrap == YGWrapWrapReverse))) {
|
||||
child->setLayoutPosition(
|
||||
|
@ -2498,7 +2500,7 @@ static void YGNodelayoutImpl(const YGNodeRef node,
|
|||
continue;
|
||||
}
|
||||
if (child->getStyle().positionType == YGPositionTypeAbsolute &&
|
||||
YGNodeIsLeadingPosDefined(child, mainAxis)) {
|
||||
child->isLeadingPositionDefined(mainAxis)) {
|
||||
if (performLayout) {
|
||||
// In case the child is position absolute and has left/top being
|
||||
// defined, we override the position to whatever the user said
|
||||
|
@ -2593,7 +2595,8 @@ static void YGNodelayoutImpl(const YGNodeRef node,
|
|||
// top/left/bottom/right
|
||||
// set, override all the previously computed positions to set it
|
||||
// correctly.
|
||||
const bool isChildLeadingPosDefined = YGNodeIsLeadingPosDefined(child, crossAxis);
|
||||
const bool isChildLeadingPosDefined =
|
||||
child->isLeadingPositionDefined(crossAxis);
|
||||
if (isChildLeadingPosDefined) {
|
||||
child->setLayoutPosition(
|
||||
child->getLeadingPosition(crossAxis, availableInnerCrossDim) +
|
||||
|
|
Loading…
Reference in New Issue