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