mirror of
https://github.com/status-im/react-native.git
synced 2025-01-15 03:56:03 +00:00
Move leading border function as a method on YGNode
Reviewed By: emilsjolander Differential Revision: D6711523 fbshipit-source-id: 76e90083a9dd0728dc9557cc3b0a1f431f3afd5d
This commit is contained in:
parent
2b27f1aa19
commit
210ae5b95a
@ -596,3 +596,15 @@ bool YGNode::isNodeFlexible() {
|
|||||||
(style_.positionType == YGPositionTypeRelative) &&
|
(style_.positionType == YGPositionTypeRelative) &&
|
||||||
(resolveFlexGrow() != 0 || resolveFlexShrink() != 0));
|
(resolveFlexGrow() != 0 || resolveFlexShrink() != 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float YGNode::getLeadingBorder(const YGFlexDirection axis) {
|
||||||
|
if (YGFlexDirectionIsRow(axis) &&
|
||||||
|
style_.border[YGEdgeStart].unit != YGUnitUndefined &&
|
||||||
|
style_.border[YGEdgeStart].value >= 0.0f) {
|
||||||
|
return style_.border[YGEdgeStart].value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return fmaxf(
|
||||||
|
YGComputedEdgeValue(style_.border, leading[axis], &YGValueZero)->value,
|
||||||
|
0.0f);
|
||||||
|
}
|
||||||
|
@ -85,6 +85,7 @@ struct YGNode {
|
|||||||
float getTrailingPosition(const YGFlexDirection axis, const float axisSize);
|
float getTrailingPosition(const YGFlexDirection axis, const float axisSize);
|
||||||
float getLeadingMargin(const YGFlexDirection axis, const float widthSize);
|
float getLeadingMargin(const YGFlexDirection axis, const float widthSize);
|
||||||
float getTrailingMargin(const YGFlexDirection axis, const float widthSize);
|
float getTrailingMargin(const YGFlexDirection axis, const float widthSize);
|
||||||
|
float getLeadingBorder(const YGFlexDirection flexDirection);
|
||||||
// Setters
|
// Setters
|
||||||
|
|
||||||
void setContext(void* context);
|
void setContext(void* context);
|
||||||
|
@ -797,21 +797,6 @@ static float YGNodeTrailingPadding(const YGNodeRef node,
|
|||||||
0.0f);
|
0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
static float YGNodeLeadingBorder(
|
|
||||||
const YGNodeRef node,
|
|
||||||
const YGFlexDirection axis) {
|
|
||||||
if (YGFlexDirectionIsRow(axis) &&
|
|
||||||
node->getStyle().border[YGEdgeStart].unit != YGUnitUndefined &&
|
|
||||||
node->getStyle().border[YGEdgeStart].value >= 0.0f) {
|
|
||||||
return node->getStyle().border[YGEdgeStart].value;
|
|
||||||
}
|
|
||||||
|
|
||||||
return fmaxf(
|
|
||||||
YGComputedEdgeValue(node->getStyle().border, leading[axis], &YGValueZero)
|
|
||||||
->value,
|
|
||||||
0.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
static float YGNodeTrailingBorder(
|
static float YGNodeTrailingBorder(
|
||||||
const YGNodeRef node,
|
const YGNodeRef node,
|
||||||
const YGFlexDirection axis) {
|
const YGFlexDirection axis) {
|
||||||
@ -832,7 +817,7 @@ static inline float YGNodeLeadingPaddingAndBorder(
|
|||||||
const YGFlexDirection axis,
|
const YGFlexDirection axis,
|
||||||
const float widthSize) {
|
const float widthSize) {
|
||||||
return YGNodeLeadingPadding(node, axis, widthSize) +
|
return YGNodeLeadingPadding(node, axis, widthSize) +
|
||||||
YGNodeLeadingBorder(node, axis);
|
node->getLeadingBorder(axis);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline float YGNodeTrailingPaddingAndBorder(const YGNodeRef node,
|
static inline float YGNodeTrailingPaddingAndBorder(const YGNodeRef node,
|
||||||
@ -1235,7 +1220,7 @@ static void YGNodeAbsoluteLayoutChild(const YGNodeRef node,
|
|||||||
if (child->isLeadingPositionDefined(YGFlexDirectionRow) &&
|
if (child->isLeadingPositionDefined(YGFlexDirectionRow) &&
|
||||||
child->isTrailingPosDefined(YGFlexDirectionRow)) {
|
child->isTrailingPosDefined(YGFlexDirectionRow)) {
|
||||||
childWidth = node->getLayout().measuredDimensions[YGDimensionWidth] -
|
childWidth = node->getLayout().measuredDimensions[YGDimensionWidth] -
|
||||||
(YGNodeLeadingBorder(node, YGFlexDirectionRow) +
|
(node->getLeadingBorder(YGFlexDirectionRow) +
|
||||||
YGNodeTrailingBorder(node, YGFlexDirectionRow)) -
|
YGNodeTrailingBorder(node, YGFlexDirectionRow)) -
|
||||||
(child->getLeadingPosition(YGFlexDirectionRow, width) +
|
(child->getLeadingPosition(YGFlexDirectionRow, width) +
|
||||||
child->getTrailingPosition(YGFlexDirectionRow, width));
|
child->getTrailingPosition(YGFlexDirectionRow, width));
|
||||||
@ -1254,7 +1239,7 @@ static void YGNodeAbsoluteLayoutChild(const YGNodeRef node,
|
|||||||
if (child->isLeadingPositionDefined(YGFlexDirectionColumn) &&
|
if (child->isLeadingPositionDefined(YGFlexDirectionColumn) &&
|
||||||
child->isTrailingPosDefined(YGFlexDirectionColumn)) {
|
child->isTrailingPosDefined(YGFlexDirectionColumn)) {
|
||||||
childHeight = node->getLayout().measuredDimensions[YGDimensionHeight] -
|
childHeight = node->getLayout().measuredDimensions[YGDimensionHeight] -
|
||||||
(YGNodeLeadingBorder(node, YGFlexDirectionColumn) +
|
(node->getLeadingBorder(YGFlexDirectionColumn) +
|
||||||
YGNodeTrailingBorder(node, YGFlexDirectionColumn)) -
|
YGNodeTrailingBorder(node, YGFlexDirectionColumn)) -
|
||||||
(child->getLeadingPosition(YGFlexDirectionColumn, height) +
|
(child->getLeadingPosition(YGFlexDirectionColumn, height) +
|
||||||
child->getTrailingPosition(YGFlexDirectionColumn, height));
|
child->getTrailingPosition(YGFlexDirectionColumn, height));
|
||||||
@ -1789,12 +1774,10 @@ static void YGNodelayoutImpl(const YGNodeRef node,
|
|||||||
node->setLayoutMargin(
|
node->setLayoutMargin(
|
||||||
node->getTrailingMargin(flexColumnDirection, parentWidth), YGEdgeBottom);
|
node->getTrailingMargin(flexColumnDirection, parentWidth), YGEdgeBottom);
|
||||||
|
|
||||||
node->setLayoutBorder(
|
node->setLayoutBorder(node->getLeadingBorder(flexRowDirection), YGEdgeStart);
|
||||||
YGNodeLeadingBorder(node, flexRowDirection), YGEdgeStart);
|
|
||||||
node->setLayoutBorder(
|
node->setLayoutBorder(
|
||||||
YGNodeTrailingBorder(node, flexRowDirection), YGEdgeEnd);
|
YGNodeTrailingBorder(node, flexRowDirection), YGEdgeEnd);
|
||||||
node->setLayoutBorder(
|
node->setLayoutBorder(node->getLeadingBorder(flexColumnDirection), YGEdgeTop);
|
||||||
YGNodeLeadingBorder(node, flexColumnDirection), YGEdgeTop);
|
|
||||||
node->setLayoutBorder(
|
node->setLayoutBorder(
|
||||||
YGNodeTrailingBorder(node, flexColumnDirection), YGEdgeBottom);
|
YGNodeTrailingBorder(node, flexColumnDirection), YGEdgeBottom);
|
||||||
|
|
||||||
@ -2459,7 +2442,7 @@ static void YGNodelayoutImpl(const YGNodeRef node,
|
|||||||
// (and margin/border).
|
// (and margin/border).
|
||||||
child->setLayoutPosition(
|
child->setLayoutPosition(
|
||||||
child->getLeadingPosition(mainAxis, availableInnerMainDim) +
|
child->getLeadingPosition(mainAxis, availableInnerMainDim) +
|
||||||
YGNodeLeadingBorder(node, mainAxis) +
|
node->getLeadingBorder(mainAxis) +
|
||||||
child->getLeadingMargin(mainAxis, availableInnerWidth),
|
child->getLeadingMargin(mainAxis, availableInnerWidth),
|
||||||
pos[mainAxis]);
|
pos[mainAxis]);
|
||||||
}
|
}
|
||||||
@ -2501,7 +2484,7 @@ static void YGNodelayoutImpl(const YGNodeRef node,
|
|||||||
} else if (performLayout) {
|
} else if (performLayout) {
|
||||||
child->setLayoutPosition(
|
child->setLayoutPosition(
|
||||||
child->getLayout().position[pos[mainAxis]] +
|
child->getLayout().position[pos[mainAxis]] +
|
||||||
YGNodeLeadingBorder(node, mainAxis) + leadingMainDim,
|
node->getLeadingBorder(mainAxis) + leadingMainDim,
|
||||||
pos[mainAxis]);
|
pos[mainAxis]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2552,7 +2535,7 @@ static void YGNodelayoutImpl(const YGNodeRef node,
|
|||||||
if (isChildLeadingPosDefined) {
|
if (isChildLeadingPosDefined) {
|
||||||
child->setLayoutPosition(
|
child->setLayoutPosition(
|
||||||
child->getLeadingPosition(crossAxis, availableInnerCrossDim) +
|
child->getLeadingPosition(crossAxis, availableInnerCrossDim) +
|
||||||
YGNodeLeadingBorder(node, crossAxis) +
|
node->getLeadingBorder(crossAxis) +
|
||||||
child->getLeadingMargin(crossAxis, availableInnerWidth),
|
child->getLeadingMargin(crossAxis, availableInnerWidth),
|
||||||
pos[crossAxis]);
|
pos[crossAxis]);
|
||||||
}
|
}
|
||||||
@ -2560,7 +2543,7 @@ static void YGNodelayoutImpl(const YGNodeRef node,
|
|||||||
if (!isChildLeadingPosDefined ||
|
if (!isChildLeadingPosDefined ||
|
||||||
YGFloatIsUndefined(child->getLayout().position[pos[crossAxis]])) {
|
YGFloatIsUndefined(child->getLayout().position[pos[crossAxis]])) {
|
||||||
child->setLayoutPosition(
|
child->setLayoutPosition(
|
||||||
YGNodeLeadingBorder(node, crossAxis) +
|
node->getLeadingBorder(crossAxis) +
|
||||||
child->getLeadingMargin(crossAxis, availableInnerWidth),
|
child->getLeadingMargin(crossAxis, availableInnerWidth),
|
||||||
pos[crossAxis]);
|
pos[crossAxis]);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user