Permalink
Browse files

s/CGFloat/float in RCTShadowView

Reviewed By: emilsjolander

Differential Revision: D4081788

fbshipit-source-id: 91da6af0fff1317ff4661572e8e7c1cc5594f810
  • Loading branch information...
javache authored and Facebook Github Bot committed Oct 26, 2016
1 parent 4ea359a commit 82911a8204da6b87e40ea808aa93c11056d43dc8
Showing with 88 additions and 87 deletions.
  1. +33 −32 React/Views/RCTShadowView.h
  2. +13 −13 React/Views/RCTShadowView.m
  3. +42 −42 React/Views/RCTViewManager.m
@@ -72,18 +72,18 @@ typedef void (^RCTApplierBlock)(NSDictionary<NSNumber *, UIView *> *viewRegistry
* Position and dimensions.
* Defaults to { 0, 0, NAN, NAN }.
*/
-@property (nonatomic, assign) CGFloat top;
-@property (nonatomic, assign) CGFloat left;
-@property (nonatomic, assign) CGFloat bottom;
-@property (nonatomic, assign) CGFloat right;
+@property (nonatomic, assign) float top;
+@property (nonatomic, assign) float left;
+@property (nonatomic, assign) float bottom;
+@property (nonatomic, assign) float right;
-@property (nonatomic, assign) CGFloat width;
-@property (nonatomic, assign) CGFloat height;
+@property (nonatomic, assign) float width;
+@property (nonatomic, assign) float height;
-@property (nonatomic, assign) CGFloat minWidth;
-@property (nonatomic, assign) CGFloat maxWidth;
-@property (nonatomic, assign) CGFloat minHeight;
-@property (nonatomic, assign) CGFloat maxHeight;
+@property (nonatomic, assign) float minWidth;
+@property (nonatomic, assign) float maxWidth;
+@property (nonatomic, assign) float minHeight;
+@property (nonatomic, assign) float maxHeight;
@property (nonatomic, assign) CGRect frame;
@@ -99,33 +99,33 @@ typedef void (^RCTApplierBlock)(NSDictionary<NSNumber *, UIView *> *viewRegistry
/**
* Border. Defaults to { 0, 0, 0, 0 }.
*/
-@property (nonatomic, assign) CGFloat borderWidth;
-@property (nonatomic, assign) CGFloat borderTopWidth;
-@property (nonatomic, assign) CGFloat borderLeftWidth;
-@property (nonatomic, assign) CGFloat borderBottomWidth;
-@property (nonatomic, assign) CGFloat borderRightWidth;
+@property (nonatomic, assign) float borderWidth;
+@property (nonatomic, assign) float borderTopWidth;
+@property (nonatomic, assign) float borderLeftWidth;
+@property (nonatomic, assign) float borderBottomWidth;
+@property (nonatomic, assign) float borderRightWidth;
/**
* Margin. Defaults to { 0, 0, 0, 0 }.
*/
-@property (nonatomic, assign) CGFloat margin;
-@property (nonatomic, assign) CGFloat marginVertical;
-@property (nonatomic, assign) CGFloat marginHorizontal;
-@property (nonatomic, assign) CGFloat marginTop;
-@property (nonatomic, assign) CGFloat marginLeft;
-@property (nonatomic, assign) CGFloat marginBottom;
-@property (nonatomic, assign) CGFloat marginRight;
+@property (nonatomic, assign) float margin;
+@property (nonatomic, assign) float marginVertical;
+@property (nonatomic, assign) float marginHorizontal;
+@property (nonatomic, assign) float marginTop;
+@property (nonatomic, assign) float marginLeft;
+@property (nonatomic, assign) float marginBottom;
+@property (nonatomic, assign) float marginRight;
/**
* Padding. Defaults to { 0, 0, 0, 0 }.
*/
-@property (nonatomic, assign) CGFloat padding;
-@property (nonatomic, assign) CGFloat paddingVertical;
-@property (nonatomic, assign) CGFloat paddingHorizontal;
-@property (nonatomic, assign) CGFloat paddingTop;
-@property (nonatomic, assign) CGFloat paddingLeft;
-@property (nonatomic, assign) CGFloat paddingBottom;
-@property (nonatomic, assign) CGFloat paddingRight;
+@property (nonatomic, assign) float padding;
+@property (nonatomic, assign) float paddingVertical;
+@property (nonatomic, assign) float paddingHorizontal;
+@property (nonatomic, assign) float paddingTop;
+@property (nonatomic, assign) float paddingLeft;
+@property (nonatomic, assign) float paddingBottom;
+@property (nonatomic, assign) float paddingRight;
- (UIEdgeInsets)paddingAsInsets;
@@ -138,9 +138,10 @@ typedef void (^RCTApplierBlock)(NSDictionary<NSNumber *, UIView *> *viewRegistry
@property (nonatomic, assign) CSSAlign alignItems;
@property (nonatomic, assign) CSSPositionType position;
@property (nonatomic, assign) CSSWrapType flexWrap;
-@property (nonatomic, assign) CGFloat flexGrow;
-@property (nonatomic, assign) CGFloat flexShrink;
-@property (nonatomic, assign) CGFloat flexBasis;
+
+@property (nonatomic, assign) float flexGrow;
+@property (nonatomic, assign) float flexShrink;
+@property (nonatomic, assign) float flexBasis;
- (void)setFlex:(float)flex;
@@ -440,12 +440,12 @@ - (NSString *)recursiveDescription
// Margin
#define RCT_MARGIN_PROPERTY(prop, metaProp) \
-- (void)setMargin##prop:(CGFloat)value \
+- (void)setMargin##prop:(float)value \
{ \
_marginMetaProps[META_PROP_##metaProp] = value; \
_recomputeMargin = YES; \
} \
-- (CGFloat)margin##prop \
+- (float)margin##prop \
{ \
return _marginMetaProps[META_PROP_##metaProp]; \
}
@@ -461,12 +461,12 @@ - (CGFloat)margin##prop \
// Padding
#define RCT_PADDING_PROPERTY(prop, metaProp) \
-- (void)setPadding##prop:(CGFloat)value \
+- (void)setPadding##prop:(float)value \
{ \
_paddingMetaProps[META_PROP_##metaProp] = value; \
_recomputePadding = YES; \
} \
-- (CGFloat)padding##prop \
+- (float)padding##prop \
{ \
return _paddingMetaProps[META_PROP_##metaProp]; \
}
@@ -509,12 +509,12 @@ - (UIEdgeInsets)paddingAsInsets
// Border
#define RCT_BORDER_PROPERTY(prop, metaProp) \
-- (void)setBorder##prop##Width:(CGFloat)value \
+- (void)setBorder##prop##Width:(float)value \
{ \
_borderMetaProps[META_PROP_##metaProp] = value; \
_recomputeBorder = YES; \
} \
-- (CGFloat)border##prop##Width \
+- (float)border##prop##Width \
{ \
return _borderMetaProps[META_PROP_##metaProp]; \
}
@@ -529,12 +529,12 @@ - (CGFloat)border##prop##Width \
#define RCT_DIMENSION_PROPERTY(setProp, getProp, cssProp) \
-- (void)set##setProp:(CGFloat)value \
+- (void)set##setProp:(float)value \
{ \
CSSNodeStyleSet##cssProp(_cssNode, value); \
[self dirtyText]; \
} \
-- (CGFloat)getProp \
+- (float)getProp \
{ \
return CSSNodeStyleGet##cssProp(_cssNode); \
}
@@ -549,12 +549,12 @@ - (CGFloat)getProp \
// Position
#define RCT_POSITION_PROPERTY(setProp, getProp, edge) \
-- (void)set##setProp:(CGFloat)value \
+- (void)set##setProp:(float)value \
{ \
CSSNodeStyleSetPosition(_cssNode, edge, value); \
[self dirtyText]; \
} \
-- (CGFloat)getProp \
+- (float)getProp \
{ \
return CSSNodeStyleGetPosition(_cssNode, edge); \
}
@@ -630,9 +630,9 @@ - (type)getProp \
return CSSNodeStyleGet##cssProp(_cssNode); \
}
-RCT_STYLE_PROPERTY(FlexGrow, flexGrow, FlexGrow, CGFloat)
-RCT_STYLE_PROPERTY(FlexShrink, flexShrink, FlexShrink, CGFloat)
-RCT_STYLE_PROPERTY(FlexBasis, flexBasis, FlexBasis, CGFloat)
+RCT_STYLE_PROPERTY(FlexGrow, flexGrow, FlexGrow, float)
+RCT_STYLE_PROPERTY(FlexShrink, flexShrink, FlexShrink, float)
+RCT_STYLE_PROPERTY(FlexBasis, flexBasis, FlexBasis, float)
RCT_STYLE_PROPERTY(FlexDirection, flexDirection, FlexDirection, CSSFlexDirection)
RCT_STYLE_PROPERTY(JustifyContent, justifyContent, JustifyContent, CSSJustify)
RCT_STYLE_PROPERTY(AlignSelf, alignSelf, AlignSelf, CSSAlign)
@@ -193,7 +193,7 @@ - (RCTViewManagerUIBlock)uiBlockToAmendWithShadowViewRegistry:(__unused NSDictio
view.layer.borderColor = json ? [RCTConvert CGColor:json] : defaultView.layer.borderColor;
}
}
-RCT_CUSTOM_VIEW_PROPERTY(borderWidth, CGFloat, RCTView)
+RCT_CUSTOM_VIEW_PROPERTY(borderWidth, float, RCTView)
{
if ([view respondsToSelector:@selector(setBorderWidth:)]) {
view.borderWidth = json ? [RCTConvert CGFloat:json] : defaultView.borderWidth;
@@ -222,10 +222,10 @@ - (RCTViewManagerUIBlock)uiBlockToAmendWithShadowViewRegistry:(__unused NSDictio
RCT_EXPORT_VIEW_PROPERTY(onMagicTap, RCTDirectEventBlock)
#define RCT_VIEW_BORDER_PROPERTY(SIDE) \
-RCT_CUSTOM_VIEW_PROPERTY(border##SIDE##Width, CGFloat, RCTView) \
+RCT_CUSTOM_VIEW_PROPERTY(border##SIDE##Width, float, RCTView) \
{ \
if ([view respondsToSelector:@selector(setBorder##SIDE##Width:)]) { \
- view.border##SIDE##Width = json ? [RCTConvert CGFloat:json] : defaultView.border##SIDE##Width; \
+ view.border##SIDE##Width = json ? [RCTConvert float:json] : defaultView.border##SIDE##Width; \
} \
} \
RCT_CUSTOM_VIEW_PROPERTY(border##SIDE##Color, UIColor, RCTView) \
@@ -259,45 +259,45 @@ - (RCTViewManagerUIBlock)uiBlockToAmendWithShadowViewRegistry:(__unused NSDictio
RCT_EXPORT_SHADOW_PROPERTY(backgroundColor, UIColor)
-RCT_EXPORT_SHADOW_PROPERTY(top, CGFloat)
-RCT_EXPORT_SHADOW_PROPERTY(right, CGFloat)
-RCT_EXPORT_SHADOW_PROPERTY(bottom, CGFloat)
-RCT_EXPORT_SHADOW_PROPERTY(left, CGFloat);
-
-RCT_EXPORT_SHADOW_PROPERTY(width, CGFloat)
-RCT_EXPORT_SHADOW_PROPERTY(height, CGFloat)
-
-RCT_EXPORT_SHADOW_PROPERTY(minWidth, CGFloat)
-RCT_EXPORT_SHADOW_PROPERTY(maxWidth, CGFloat)
-RCT_EXPORT_SHADOW_PROPERTY(minHeight, CGFloat)
-RCT_EXPORT_SHADOW_PROPERTY(maxHeight, CGFloat)
-
-RCT_EXPORT_SHADOW_PROPERTY(borderTopWidth, CGFloat)
-RCT_EXPORT_SHADOW_PROPERTY(borderRightWidth, CGFloat)
-RCT_EXPORT_SHADOW_PROPERTY(borderBottomWidth, CGFloat)
-RCT_EXPORT_SHADOW_PROPERTY(borderLeftWidth, CGFloat)
-RCT_EXPORT_SHADOW_PROPERTY(borderWidth, CGFloat)
-
-RCT_EXPORT_SHADOW_PROPERTY(marginTop, CGFloat)
-RCT_EXPORT_SHADOW_PROPERTY(marginRight, CGFloat)
-RCT_EXPORT_SHADOW_PROPERTY(marginBottom, CGFloat)
-RCT_EXPORT_SHADOW_PROPERTY(marginLeft, CGFloat)
-RCT_EXPORT_SHADOW_PROPERTY(marginVertical, CGFloat)
-RCT_EXPORT_SHADOW_PROPERTY(marginHorizontal, CGFloat)
-RCT_EXPORT_SHADOW_PROPERTY(margin, CGFloat)
-
-RCT_EXPORT_SHADOW_PROPERTY(paddingTop, CGFloat)
-RCT_EXPORT_SHADOW_PROPERTY(paddingRight, CGFloat)
-RCT_EXPORT_SHADOW_PROPERTY(paddingBottom, CGFloat)
-RCT_EXPORT_SHADOW_PROPERTY(paddingLeft, CGFloat)
-RCT_EXPORT_SHADOW_PROPERTY(paddingVertical, CGFloat)
-RCT_EXPORT_SHADOW_PROPERTY(paddingHorizontal, CGFloat)
-RCT_EXPORT_SHADOW_PROPERTY(padding, CGFloat)
-
-RCT_EXPORT_SHADOW_PROPERTY(flex, CGFloat)
-RCT_EXPORT_SHADOW_PROPERTY(flexGrow, CGFloat)
-RCT_EXPORT_SHADOW_PROPERTY(flexShrink, CGFloat)
-RCT_EXPORT_SHADOW_PROPERTY(flexBasis, CGFloat)
+RCT_EXPORT_SHADOW_PROPERTY(top, float)
+RCT_EXPORT_SHADOW_PROPERTY(right, float)
+RCT_EXPORT_SHADOW_PROPERTY(bottom, float)
+RCT_EXPORT_SHADOW_PROPERTY(left, float);
+
+RCT_EXPORT_SHADOW_PROPERTY(width, float)
+RCT_EXPORT_SHADOW_PROPERTY(height, float)
+
+RCT_EXPORT_SHADOW_PROPERTY(minWidth, float)
+RCT_EXPORT_SHADOW_PROPERTY(maxWidth, float)
+RCT_EXPORT_SHADOW_PROPERTY(minHeight, float)
+RCT_EXPORT_SHADOW_PROPERTY(maxHeight, float)
+
+RCT_EXPORT_SHADOW_PROPERTY(borderTopWidth, float)
+RCT_EXPORT_SHADOW_PROPERTY(borderRightWidth, float)
+RCT_EXPORT_SHADOW_PROPERTY(borderBottomWidth, float)
+RCT_EXPORT_SHADOW_PROPERTY(borderLeftWidth, float)
+RCT_EXPORT_SHADOW_PROPERTY(borderWidth, float)
+
+RCT_EXPORT_SHADOW_PROPERTY(marginTop, float)
+RCT_EXPORT_SHADOW_PROPERTY(marginRight, float)
+RCT_EXPORT_SHADOW_PROPERTY(marginBottom, float)
+RCT_EXPORT_SHADOW_PROPERTY(marginLeft, float)
+RCT_EXPORT_SHADOW_PROPERTY(marginVertical, float)
+RCT_EXPORT_SHADOW_PROPERTY(marginHorizontal, float)
+RCT_EXPORT_SHADOW_PROPERTY(margin, float)
+
+RCT_EXPORT_SHADOW_PROPERTY(paddingTop, float)
+RCT_EXPORT_SHADOW_PROPERTY(paddingRight, float)
+RCT_EXPORT_SHADOW_PROPERTY(paddingBottom, float)
+RCT_EXPORT_SHADOW_PROPERTY(paddingLeft, float)
+RCT_EXPORT_SHADOW_PROPERTY(paddingVertical, float)
+RCT_EXPORT_SHADOW_PROPERTY(paddingHorizontal, float)
+RCT_EXPORT_SHADOW_PROPERTY(padding, float)
+
+RCT_EXPORT_SHADOW_PROPERTY(flex, float)
+RCT_EXPORT_SHADOW_PROPERTY(flexGrow, float)
+RCT_EXPORT_SHADOW_PROPERTY(flexShrink, float)
+RCT_EXPORT_SHADOW_PROPERTY(flexBasis, float)
RCT_EXPORT_SHADOW_PROPERTY(flexDirection, CSSFlexDirection)
RCT_EXPORT_SHADOW_PROPERTY(flexWrap, CSSWrapType)
RCT_EXPORT_SHADOW_PROPERTY(justifyContent, CSSJustify)

2 comments on commit 82911a8

@pvinis

This comment has been minimized.

Show comment
Hide comment
@pvinis

pvinis Nov 11, 2016

Contributor

why was that done?

Contributor

pvinis replied Nov 11, 2016

why was that done?

@javache

This comment has been minimized.

Show comment
Hide comment
@javache

javache Nov 18, 2016

Member

Since css-layout internally only use floats, we should convert to the right type correctly. (CGFloat is double on 64-bit iOS device, and float on 32-bit devices, so there's some conversion cost.

Member

javache replied Nov 18, 2016

Since css-layout internally only use floats, we should convert to the right type correctly. (CGFloat is double on 64-bit iOS device, and float on 32-bit devices, so there's some conversion cost.

Please sign in to comment.