From a05e05fafbeb777d71b7c4dcb14e19fcfe0191ae Mon Sep 17 00:00:00 2001 From: Nick Lockwood Date: Thu, 9 Jun 2016 09:48:56 -0700 Subject: [PATCH] Converted zIndex to integers Summary: Converted the zIndex property on iOS to NSInteger instead of double. This is consistent with the CSS spec, and helps to simplify the Android implementation. Reviewed By: javache Differential Revision: D3411491 fbshipit-source-id: 902ebc29aac39a65f7e8707a28607655f9f5052c --- React/Views/RCTShadowView.h | 2 +- React/Views/RCTShadowView.m | 2 +- React/Views/RCTView.h | 2 +- React/Views/RCTViewManager.m | 4 ++-- React/Views/UIView+React.h | 2 +- React/Views/UIView+React.m | 6 +++--- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/React/Views/RCTShadowView.h b/React/Views/RCTShadowView.h index d32ba1365..2c78a3f24 100644 --- a/React/Views/RCTShadowView.h +++ b/React/Views/RCTShadowView.h @@ -132,7 +132,7 @@ typedef void (^RCTApplierBlock)(NSDictionary *viewRegistry /** * z-index, used to override sibling order in the view */ -@property (nonatomic, assign) double zIndex; +@property (nonatomic, assign) NSInteger zIndex; /** * Calculate property changes that need to be propagated to the view. diff --git a/React/Views/RCTShadowView.m b/React/Views/RCTShadowView.m index b518929dd..c7b3e3b05 100644 --- a/React/Views/RCTShadowView.m +++ b/React/Views/RCTShadowView.m @@ -610,7 +610,7 @@ RCT_STYLE_PROPERTY(FlexWrap, flexWrap, flex_wrap, css_wrap_type_t) [self dirtyPropagation]; } -- (void)setZIndex:(double)zIndex +- (void)setZIndex:(NSInteger)zIndex { _zIndex = zIndex; if (_superview) { diff --git a/React/Views/RCTView.h b/React/Views/RCTView.h index ea17f568a..96c0b4182 100644 --- a/React/Views/RCTView.h +++ b/React/Views/RCTView.h @@ -46,7 +46,7 @@ * inherited from UIView+React, but we override it here to reduce the boxing * and associated object overheads. */ -@property (nonatomic, assign) double reactZIndex; +@property (nonatomic, assign) NSInteger reactZIndex; /** * This is an optimization used to improve performance diff --git a/React/Views/RCTViewManager.m b/React/Views/RCTViewManager.m index c54e726c3..e23dfc802 100644 --- a/React/Views/RCTViewManager.m +++ b/React/Views/RCTViewManager.m @@ -246,7 +246,7 @@ RCT_VIEW_BORDER_RADIUS_PROPERTY(TopRight) RCT_VIEW_BORDER_RADIUS_PROPERTY(BottomLeft) RCT_VIEW_BORDER_RADIUS_PROPERTY(BottomRight) -RCT_REMAP_VIEW_PROPERTY(zIndex, reactZIndex, double) +RCT_REMAP_VIEW_PROPERTY(zIndex, reactZIndex, NSInteger) #pragma mark - ShadowView properties @@ -292,6 +292,6 @@ RCT_EXPORT_SHADOW_PROPERTY(position, css_position_type_t) RCT_EXPORT_SHADOW_PROPERTY(onLayout, RCTDirectEventBlock) -RCT_EXPORT_SHADOW_PROPERTY(zIndex, double) +RCT_EXPORT_SHADOW_PROPERTY(zIndex, NSInteger) @end diff --git a/React/Views/UIView+React.h b/React/Views/UIView+React.h index 61484740b..600a0b347 100644 --- a/React/Views/UIView+React.h +++ b/React/Views/UIView+React.h @@ -28,7 +28,7 @@ /** * z-index, used to override sibling order in didUpdateReactSubviews. */ -@property (nonatomic, assign) double reactZIndex; +@property (nonatomic, assign) NSInteger reactZIndex; /** * The reactSubviews array, sorted by zIndex. This value is cached and diff --git a/React/Views/UIView+React.m b/React/Views/UIView+React.m index 7004493d8..d637e7efa 100644 --- a/React/Views/UIView+React.m +++ b/React/Views/UIView+React.m @@ -87,12 +87,12 @@ [subview removeFromSuperview]; } -- (double)reactZIndex +- (NSInteger)reactZIndex { - return [objc_getAssociatedObject(self, _cmd) doubleValue]; + return [objc_getAssociatedObject(self, _cmd) integerValue]; } -- (void)setReactZIndex:(double)reactZIndex +- (void)setReactZIndex:(NSInteger)reactZIndex { objc_setAssociatedObject(self, @selector(reactZIndex), @(reactZIndex), OBJC_ASSOCIATION_RETAIN_NONATOMIC); }