Skip to content

Commit 7449658

Browse files
Emil SjolanderFacebook Github Bot
authored andcommitted
Absolute positioned items should apear inside padding but outside border
Reviewed By: gkassabli Differential Revision: D4153332 fbshipit-source-id: 251e29e02018a433f60349b78c03feb121512797
1 parent a4a02f6 commit 7449658

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

React/CSSLayout/CSSLayout.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,12 +1115,14 @@ static void absoluteLayoutChild(const CSSNodeRef node,
11151115
if (isTrailingPosDefined(child, mainAxis) && !isLeadingPosDefined(child, mainAxis)) {
11161116
child->layout.position[leading[mainAxis]] = node->layout.measuredDimensions[dim[mainAxis]] -
11171117
child->layout.measuredDimensions[dim[mainAxis]] -
1118+
getTrailingBorder(node, mainAxis) -
11181119
getTrailingPosition(child, mainAxis);
11191120
}
11201121

11211122
if (isTrailingPosDefined(child, crossAxis) && !isLeadingPosDefined(child, crossAxis)) {
11221123
child->layout.position[leading[crossAxis]] = node->layout.measuredDimensions[dim[crossAxis]] -
11231124
child->layout.measuredDimensions[dim[crossAxis]] -
1125+
getTrailingBorder(node, crossAxis) -
11241126
getTrailingPosition(child, crossAxis);
11251127
}
11261128
}
@@ -1830,16 +1832,14 @@ static void layoutNodeImpl(const CSSNodeRef node,
18301832
getLeadingMargin(child, mainAxis);
18311833
}
18321834
} else {
1833-
if (performLayout) {
1834-
// If the child is position absolute (without top/left) or relative,
1835-
// we put it at the current accumulated offset.
1836-
child->layout.position[pos[mainAxis]] += mainDim;
1837-
}
1838-
18391835
// Now that we placed the element, we need to update the variables.
18401836
// We need to do that only for relative elements. Absolute elements
18411837
// do not take part in that phase.
18421838
if (child->style.positionType == CSSPositionTypeRelative) {
1839+
if (performLayout) {
1840+
child->layout.position[pos[mainAxis]] += mainDim;
1841+
}
1842+
18431843
if (canSkipFlex) {
18441844
// If we skipped the flex step, then we can't rely on the
18451845
// measuredDims because
@@ -1857,6 +1857,8 @@ static void layoutNodeImpl(const CSSNodeRef node,
18571857
// can only be one element in that cross dimension.
18581858
crossDim = fmaxf(crossDim, getDimWithMargin(child, crossAxis));
18591859
}
1860+
} else if (performLayout) {
1861+
child->layout.position[pos[mainAxis]] += getLeadingBorder(node, mainAxis) + leadingMainDim;
18601862
}
18611863
}
18621864
}
@@ -1901,7 +1903,7 @@ static void layoutNodeImpl(const CSSNodeRef node,
19011903
getLeadingMargin(child, crossAxis);
19021904
} else {
19031905
child->layout.position[pos[crossAxis]] =
1904-
leadingPaddingAndBorderCross + getLeadingMargin(child, crossAxis);
1906+
getLeadingBorder(node, crossAxis) + getLeadingMargin(child, crossAxis);
19051907
}
19061908
} else {
19071909
float leadingCrossDim = leadingPaddingAndBorderCross;

0 commit comments

Comments
 (0)