Fix assertion preventing YGNodeLayoutGet* with YGEdgeEnd

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 https://github.com/facebook/yoga/pull/632

Differential Revision: D6408060

Pulled By: emilsjolander

fbshipit-source-id: 4ab3b2ffb2f1bb6fd3a27f780caf0123abcdb230
This commit is contained in:
Jake Teton-Landis 2017-11-27 02:54:59 -08:00 committed by Facebook Github Bot
parent d5b59517c2
commit a383b8ca05

View File

@ -657,29 +657,30 @@ static inline const YGValue *YGNodeResolveFlexBasisPtr(const YGNodeRef node) {
return node->layout.instanceName; \ return node->layout.instanceName; \
} }
#define YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(type, name, instanceName) \ #define YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(type, name, instanceName) \
type YGNodeLayoutGet##name(const YGNodeRef node, const YGEdge edge) { \ type YGNodeLayoutGet##name(const YGNodeRef node, const YGEdge edge) { \
YGAssertWithNode(node, \ YGAssertWithNode( \
edge < YGEdgeEnd, \ node, \
"Cannot get layout properties of multi-edge shorthands"); \ edge <= YGEdgeEnd, \
\ "Cannot get layout properties of multi-edge shorthands"); \
if (edge == YGEdgeLeft) { \ \
if (node->layout.direction == YGDirectionRTL) { \ if (edge == YGEdgeLeft) { \
return node->layout.instanceName[YGEdgeEnd]; \ if (node->layout.direction == YGDirectionRTL) { \
} else { \ return node->layout.instanceName[YGEdgeEnd]; \
return node->layout.instanceName[YGEdgeStart]; \ } else { \
} \ return node->layout.instanceName[YGEdgeStart]; \
} \ } \
\ } \
if (edge == YGEdgeRight) { \ \
if (node->layout.direction == YGDirectionRTL) { \ if (edge == YGEdgeRight) { \
return node->layout.instanceName[YGEdgeStart]; \ if (node->layout.direction == YGDirectionRTL) { \
} else { \ return node->layout.instanceName[YGEdgeStart]; \
return node->layout.instanceName[YGEdgeEnd]; \ } else { \
} \ return node->layout.instanceName[YGEdgeEnd]; \
} \ } \
\ } \
return node->layout.instanceName[edge]; \ \
return node->layout.instanceName[edge]; \
} }
YG_NODE_PROPERTY_IMPL(void *, Context, context, context); YG_NODE_PROPERTY_IMPL(void *, Context, context, context);