Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Absolute positioned items should apear inside padding but outside border
Reviewed By: gkassabli

Differential Revision: D4153332

fbshipit-source-id: 251e29e02018a433f60349b78c03feb121512797
  • Loading branch information
Emil Sjolander authored and Facebook Github Bot committed Nov 9, 2016
1 parent a4a02f6 commit 7449658
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions React/CSSLayout/CSSLayout.c
Expand Up @@ -1115,12 +1115,14 @@ static void absoluteLayoutChild(const CSSNodeRef node,
if (isTrailingPosDefined(child, mainAxis) && !isLeadingPosDefined(child, mainAxis)) {
child->layout.position[leading[mainAxis]] = node->layout.measuredDimensions[dim[mainAxis]] -
child->layout.measuredDimensions[dim[mainAxis]] -
getTrailingBorder(node, mainAxis) -
getTrailingPosition(child, mainAxis);
}

if (isTrailingPosDefined(child, crossAxis) && !isLeadingPosDefined(child, crossAxis)) {
child->layout.position[leading[crossAxis]] = node->layout.measuredDimensions[dim[crossAxis]] -
child->layout.measuredDimensions[dim[crossAxis]] -
getTrailingBorder(node, crossAxis) -
getTrailingPosition(child, crossAxis);
}
}
Expand Down Expand Up @@ -1830,16 +1832,14 @@ static void layoutNodeImpl(const CSSNodeRef node,
getLeadingMargin(child, mainAxis);
}
} else {
if (performLayout) {
// If the child is position absolute (without top/left) or relative,
// we put it at the current accumulated offset.
child->layout.position[pos[mainAxis]] += mainDim;
}

// Now that we placed the element, we need to update the variables.
// We need to do that only for relative elements. Absolute elements
// do not take part in that phase.
if (child->style.positionType == CSSPositionTypeRelative) {
if (performLayout) {
child->layout.position[pos[mainAxis]] += mainDim;
}

if (canSkipFlex) {
// If we skipped the flex step, then we can't rely on the
// measuredDims because
Expand All @@ -1857,6 +1857,8 @@ static void layoutNodeImpl(const CSSNodeRef node,
// can only be one element in that cross dimension.
crossDim = fmaxf(crossDim, getDimWithMargin(child, crossAxis));
}
} else if (performLayout) {
child->layout.position[pos[mainAxis]] += getLeadingBorder(node, mainAxis) + leadingMainDim;
}
}
}
Expand Down Expand Up @@ -1901,7 +1903,7 @@ static void layoutNodeImpl(const CSSNodeRef node,
getLeadingMargin(child, crossAxis);
} else {
child->layout.position[pos[crossAxis]] =
leadingPaddingAndBorderCross + getLeadingMargin(child, crossAxis);
getLeadingBorder(node, crossAxis) + getLeadingMargin(child, crossAxis);
}
} else {
float leadingCrossDim = leadingPaddingAndBorderCross;
Expand Down

1 comment on commit 7449658

@brentvatne
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in commit message: s/padding/margin

Please sign in to comment.