Permalink
Browse files

Fix border width precedence issue

  • Loading branch information...
a2 committed Jul 30, 2015
1 parent 90b80e3 commit f2b3057a7cb350b8c41e240ca4188d1518730235
Showing with 14 additions and 13 deletions.
  1. +12 −12 React/Views/RCTShadowView.m
  2. +2 −1 React/Views/RCTView.m
@@ -39,8 +39,10 @@ @implementation RCTShadowView
NSMutableArray *_reactSubviews;
BOOL _recomputePadding;
BOOL _recomputeMargin;
BOOL _recomputeBorder;
float _paddingMetaProps[META_PROP_COUNT];
float _marginMetaProps[META_PROP_COUNT];
float _borderMetaProps[META_PROP_COUNT];
}
@synthesize reactTag = _reactTag;
@@ -247,6 +249,7 @@ - (instancetype)init
for (int ii = 0; ii < META_PROP_COUNT; ii++) {
_paddingMetaProps[ii] = CSS_UNDEFINED;
_marginMetaProps[ii] = CSS_UNDEFINED;
_borderMetaProps[ii] = CSS_UNDEFINED;
}
_newView = YES;
@@ -449,27 +452,20 @@ - (UIEdgeInsets)paddingAsInsets
#define RCT_BORDER_PROPERTY(prop, metaProp) \
- (void)setBorder##prop##Width:(CGFloat)value \
{ \
_cssNode->style.border[CSS_##metaProp] = value; \
[self dirtyLayout]; \
_borderMetaProps[META_PROP_##metaProp] = value; \
_recomputeBorder = YES; \
} \
- (CGFloat)border##prop##Width \
{ \
return _cssNode->style.border[META_PROP_##metaProp]; \
return _borderMetaProps[META_PROP_##metaProp]; \
}
RCT_BORDER_PROPERTY(, ALL)
RCT_BORDER_PROPERTY(Top, TOP)
RCT_BORDER_PROPERTY(Left, LEFT)
RCT_BORDER_PROPERTY(Bottom, BOTTOM)
RCT_BORDER_PROPERTY(Right, RIGHT)
- (void)setBorderWidth:(CGFloat)value
{
for (int i = 0; i < 4; i++) {
_cssNode->style.border[i] = value;
}
[self dirtyLayout];
}
// Dimensions
#define RCT_DIMENSIONS_PROPERTY(setProp, getProp, cssProp) \
@@ -562,12 +558,16 @@ - (void)updateLayout
if (_recomputeMargin) {
RCTProcessMetaProps(_marginMetaProps, _cssNode->style.margin);
}
if (_recomputePadding || _recomputeMargin) {
if (_recomputeBorder) {
RCTProcessMetaProps(_borderMetaProps, _cssNode->style.border);
}
if (_recomputePadding || _recomputeMargin || _recomputeBorder) {
[self dirtyLayout];
}
[self fillCSSNode:_cssNode];
_recomputeMargin = NO;
_recomputePadding = NO;
_recomputeBorder = NO;
}
@end
View
@@ -523,7 +523,7 @@ - (void)displayLayer:(CALayer *)layer
_backgroundColor.CGColor,
self.clipsToBounds);
const CGRect contentsCenter = ({
CGRect contentsCenter = ({
CGSize size = image.size;
UIEdgeInsets insets = image.capInsets;
CGRectMake(
@@ -540,6 +540,7 @@ - (void)displayLayer:(CALayer *)layer
[image drawInRect:(CGRect){CGPointZero, size}];
image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
contentsCenter = CGRectMake(0, 0, 1, 1);
}
layer.backgroundColor = NULL;

0 comments on commit f2b3057

Please sign in to comment.