From 5d6ce0e4aea7e1d4e4d7aa64ac7ac82b5f49d824 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Fri, 6 Jan 2017 06:39:36 -0800 Subject: [PATCH] Rely on yoga to enforces precedence rules Reviewed By: javache Differential Revision: D4376526 fbshipit-source-id: b37e541f74674ce0c918cc4993943a972bc4dc87 --- React/Views/RCTShadowView.m | 51 +++++++------------------------------ 1 file changed, 9 insertions(+), 42 deletions(-) diff --git a/React/Views/RCTShadowView.m b/React/Views/RCTShadowView.m index 638271ed1..1ad9accf9 100644 --- a/React/Views/RCTShadowView.m +++ b/React/Views/RCTShadowView.m @@ -56,48 +56,15 @@ static void RCTPrint(YGNodeRef node) printf("%s(%zd), ", shadowView.viewName.UTF8String, shadowView.reactTag.integerValue); } -// Enforces precedence rules, e.g. marginLeft > marginHorizontal > margin. -#define DEFINE_PROCESS_META_PROPS(type) \ -static void RCTProcessMetaProps##type(const float metaProps[META_PROP_COUNT], YGNodeRef node) { \ - if (!YGFloatIsUndefined(metaProps[META_PROP_LEFT])) { \ - YGNodeStyleSet##type(node, YGEdgeStart, metaProps[META_PROP_LEFT]); \ - } else if (!YGFloatIsUndefined(metaProps[META_PROP_HORIZONTAL])) { \ - YGNodeStyleSet##type(node, YGEdgeStart, metaProps[META_PROP_HORIZONTAL]); \ - } else if (!YGFloatIsUndefined(metaProps[META_PROP_ALL])) { \ - YGNodeStyleSet##type(node, YGEdgeStart, metaProps[META_PROP_ALL]); \ - } else { \ - YGNodeStyleSet##type(node, YGEdgeStart, 0); \ - } \ - \ - if (!YGFloatIsUndefined(metaProps[META_PROP_RIGHT])) { \ - YGNodeStyleSet##type(node, YGEdgeEnd, metaProps[META_PROP_RIGHT]); \ - } else if (!YGFloatIsUndefined(metaProps[META_PROP_HORIZONTAL])) { \ - YGNodeStyleSet##type(node, YGEdgeEnd, metaProps[META_PROP_HORIZONTAL]); \ - } else if (!YGFloatIsUndefined(metaProps[META_PROP_ALL])) { \ - YGNodeStyleSet##type(node, YGEdgeEnd, metaProps[META_PROP_ALL]); \ - } else { \ - YGNodeStyleSet##type(node, YGEdgeEnd, 0); \ - } \ - \ - if (!YGFloatIsUndefined(metaProps[META_PROP_TOP])) { \ - YGNodeStyleSet##type(node, YGEdgeTop, metaProps[META_PROP_TOP]); \ - } else if (!YGFloatIsUndefined(metaProps[META_PROP_VERTICAL])) { \ - YGNodeStyleSet##type(node, YGEdgeTop, metaProps[META_PROP_VERTICAL]); \ - } else if (!YGFloatIsUndefined(metaProps[META_PROP_ALL])) { \ - YGNodeStyleSet##type(node, YGEdgeTop, metaProps[META_PROP_ALL]); \ - } else { \ - YGNodeStyleSet##type(node, YGEdgeTop, 0); \ - } \ - \ - if (!YGFloatIsUndefined(metaProps[META_PROP_BOTTOM])) { \ - YGNodeStyleSet##type(node, YGEdgeBottom, metaProps[META_PROP_BOTTOM]); \ - } else if (!YGFloatIsUndefined(metaProps[META_PROP_VERTICAL])) { \ - YGNodeStyleSet##type(node, YGEdgeBottom, metaProps[META_PROP_VERTICAL]); \ - } else if (!YGFloatIsUndefined(metaProps[META_PROP_ALL])) { \ - YGNodeStyleSet##type(node, YGEdgeBottom, metaProps[META_PROP_ALL]); \ - } else { \ - YGNodeStyleSet##type(node, YGEdgeBottom, 0); \ - } \ +#define DEFINE_PROCESS_META_PROPS(type) \ +static void RCTProcessMetaProps##type(const float metaProps[META_PROP_COUNT], YGNodeRef node) { \ + YGNodeStyleSet##type(node, YGEdgeStart, metaProps[META_PROP_LEFT]); \ + YGNodeStyleSet##type(node, YGEdgeEnd, metaProps[META_PROP_RIGHT]); \ + YGNodeStyleSet##type(node, YGEdgeTop, metaProps[META_PROP_TOP]); \ + YGNodeStyleSet##type(node, YGEdgeBottom, metaProps[META_PROP_BOTTOM]); \ + YGNodeStyleSet##type(node, YGEdgeHorizontal, metaProps[META_PROP_HORIZONTAL]); \ + YGNodeStyleSet##type(node, YGEdgeVertical, metaProps[META_PROP_VERTICAL]); \ + YGNodeStyleSet##type(node, YGEdgeAll, metaProps[META_PROP_ALL]); \ } DEFINE_PROCESS_META_PROPS(Padding);