Skip to content

Commit

Permalink
Fix assertion preventing YGNodeLayoutGet* with YGEdgeEnd
Browse files Browse the repository at this point in the history
Summary:
Expected to be able to call `YGNodeLayoutGetMargin(node, YGEdgeEnd)`, but instead, the program aborts with `"Cannot get layout properties of multi-edge shorthands"`.

This bug seems to incorrectly prevent properties from YGEdgeEnd for all Layout properties.
Closes facebook/yoga#632

Differential Revision: D6408060

Pulled By: emilsjolander

fbshipit-source-id: 4ab3b2ffb2f1bb6fd3a27f780caf0123abcdb230
  • Loading branch information
justjake authored and facebook-github-bot committed Nov 27, 2017
1 parent d5b5951 commit a383b8c
Showing 1 changed file with 24 additions and 23 deletions.
47 changes: 24 additions & 23 deletions ReactCommon/yoga/yoga/Yoga.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -657,29 +657,30 @@ static inline const YGValue *YGNodeResolveFlexBasisPtr(const YGNodeRef node) {
return node->layout.instanceName; \
}

#define YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(type, name, instanceName) \
type YGNodeLayoutGet##name(const YGNodeRef node, const YGEdge edge) { \
YGAssertWithNode(node, \
edge < YGEdgeEnd, \
"Cannot get layout properties of multi-edge shorthands"); \
\
if (edge == YGEdgeLeft) { \
if (node->layout.direction == YGDirectionRTL) { \
return node->layout.instanceName[YGEdgeEnd]; \
} else { \
return node->layout.instanceName[YGEdgeStart]; \
} \
} \
\
if (edge == YGEdgeRight) { \
if (node->layout.direction == YGDirectionRTL) { \
return node->layout.instanceName[YGEdgeStart]; \
} else { \
return node->layout.instanceName[YGEdgeEnd]; \
} \
} \
\
return node->layout.instanceName[edge]; \
#define YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(type, name, instanceName) \
type YGNodeLayoutGet##name(const YGNodeRef node, const YGEdge edge) { \
YGAssertWithNode( \
node, \
edge <= YGEdgeEnd, \
"Cannot get layout properties of multi-edge shorthands"); \
\
if (edge == YGEdgeLeft) { \
if (node->layout.direction == YGDirectionRTL) { \
return node->layout.instanceName[YGEdgeEnd]; \
} else { \
return node->layout.instanceName[YGEdgeStart]; \
} \
} \
\
if (edge == YGEdgeRight) { \
if (node->layout.direction == YGDirectionRTL) { \
return node->layout.instanceName[YGEdgeStart]; \
} else { \
return node->layout.instanceName[YGEdgeEnd]; \
} \
} \
\
return node->layout.instanceName[edge]; \
}

YG_NODE_PROPERTY_IMPL(void *, Context, context, context);
Expand Down

0 comments on commit a383b8c

Please sign in to comment.