Fix position on root node with RTL direction

Summary:
If the root node has a position and we have a RTL layout, that position must be like LTR direction. See #477.
Closes https://github.com/facebook/yoga/pull/502

Differential Revision: D4867144

Pulled By: emilsjolander

fbshipit-source-id: b5ad3d87e7054090da12d7665a3d1abe8496a548
This commit is contained in:
Lukas Wöhrl 2017-04-11 13:00:02 -07:00 committed by Facebook Github Bot
parent 7da07fa9f3
commit f7fe9a6219
1 changed files with 6 additions and 2 deletions

View File

@ -1324,8 +1324,12 @@ static void YGNodeSetPosition(const YGNodeRef node,
const float mainSize,
const float crossSize,
const float parentWidth) {
const YGFlexDirection mainAxis = YGResolveFlexDirection(node->style.flexDirection, direction);
const YGFlexDirection crossAxis = YGFlexDirectionCross(mainAxis, direction);
/* Root nodes should be always layouted as LTR, so we don't return negative values. */
const YGDirection directionRespectingRoot = node->parent != NULL ? direction : YGDirectionLTR;
const YGFlexDirection mainAxis =
YGResolveFlexDirection(node->style.flexDirection, directionRespectingRoot);
const YGFlexDirection crossAxis = YGFlexDirectionCross(mainAxis, directionRespectingRoot);
const float relativePositionMain = YGNodeRelativePosition(node, mainAxis, mainSize);
const float relativePositionCross = YGNodeRelativePosition(node, crossAxis, crossSize);