mirror of
https://github.com/status-im/react-native.git
synced 2025-01-27 01:40:08 +00:00
Demolishing of background color propagation infra
Summary: As it was mentioned in previous diffs, we are removing this because it overcomplicates rendering layer and provides (almost) no benefits (and cannot be implemented 100% accurate way). Reviewed By: mmmulani Differential Revision: D6582560 fbshipit-source-id: 0778db96a45dd8e2520268d5d00792677cb01a20
This commit is contained in:
parent
d89901fa60
commit
2679f3efb6
@ -24,6 +24,7 @@ extern NSString *const RCTReactTagAttributeName;
|
||||
@interface RCTShadowText : RCTShadowView
|
||||
|
||||
@property (nonatomic, strong) UIColor *color;
|
||||
@property (nonatomic, strong) UIColor *backgroundColor;
|
||||
@property (nonatomic, copy) NSString *fontFamily;
|
||||
@property (nonatomic, assign) CGFloat fontSize;
|
||||
@property (nonatomic, copy) NSString *fontWeight;
|
||||
|
@ -620,12 +620,6 @@ static YGSize RCTMeasure(YGNodeRef node, float width, YGMeasureMode widthMode, f
|
||||
return requiredSize;
|
||||
}
|
||||
|
||||
- (void)setBackgroundColor:(UIColor *)backgroundColor
|
||||
{
|
||||
super.backgroundColor = backgroundColor;
|
||||
[self dirtyText];
|
||||
}
|
||||
|
||||
#define RCT_TEXT_PROPERTY(setProp, ivar, type) \
|
||||
- (void)set##setProp:(type)value; \
|
||||
{ \
|
||||
|
@ -58,6 +58,7 @@ RCT_EXPORT_MODULE()
|
||||
#pragma mark - Shadow properties
|
||||
|
||||
RCT_EXPORT_SHADOW_PROPERTY(color, UIColor)
|
||||
RCT_EXPORT_SHADOW_PROPERTY(backgroundColor, UIColor)
|
||||
RCT_EXPORT_SHADOW_PROPERTY(fontFamily, NSString)
|
||||
RCT_EXPORT_SHADOW_PROPERTY(fontSize, CGFloat)
|
||||
RCT_EXPORT_SHADOW_PROPERTY(fontWeight, NSString)
|
||||
|
@ -18,9 +18,6 @@
|
||||
#import "UIView+React.h"
|
||||
|
||||
@implementation RCTRootContentView
|
||||
{
|
||||
UIColor *_backgroundColor;
|
||||
}
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
bridge:(RCTBridge *)bridge
|
||||
@ -34,7 +31,6 @@
|
||||
_touchHandler = [[RCTTouchHandler alloc] initWithBridge:_bridge];
|
||||
[_touchHandler attachToView:self];
|
||||
[_bridge.uiManager registerRootView:self];
|
||||
self.layer.backgroundColor = NULL;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@ -89,19 +85,6 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder:(nonnull NSCoder *)aDecoder)
|
||||
[_bridge.uiManager setAvailableSize:self.availableSize forRootView:self];
|
||||
}
|
||||
|
||||
- (void)setBackgroundColor:(UIColor *)backgroundColor
|
||||
{
|
||||
_backgroundColor = backgroundColor;
|
||||
if (self.reactTag && _bridge.isValid) {
|
||||
[_bridge.uiManager setBackgroundColor:backgroundColor forView:self];
|
||||
}
|
||||
}
|
||||
|
||||
- (UIColor *)backgroundColor
|
||||
{
|
||||
return _backgroundColor;
|
||||
}
|
||||
|
||||
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
|
||||
{
|
||||
// The root content view itself should never receive touches
|
||||
|
@ -133,12 +133,6 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder)
|
||||
}
|
||||
#endif
|
||||
|
||||
- (void)setBackgroundColor:(UIColor *)backgroundColor
|
||||
{
|
||||
super.backgroundColor = backgroundColor;
|
||||
_contentView.backgroundColor = backgroundColor;
|
||||
}
|
||||
|
||||
#pragma mark - passThroughTouches
|
||||
|
||||
- (BOOL)passThroughTouches
|
||||
@ -282,7 +276,6 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder)
|
||||
sizeFlexiblity:_sizeFlexibility];
|
||||
[self runApplication:bridge];
|
||||
|
||||
_contentView.backgroundColor = self.backgroundColor;
|
||||
_contentView.passThroughTouches = _passThroughTouches;
|
||||
[self insertSubview:_contentView atIndex:0];
|
||||
|
||||
|
@ -88,13 +88,6 @@ RCT_EXTERN NSString *const RCTUIManagerWillUpdateViewsDueToContentSizeMultiplier
|
||||
*/
|
||||
- (void)setIntrinsicContentSize:(CGSize)intrinsicContentSize forView:(UIView *)view;
|
||||
|
||||
/**
|
||||
* Update the background color of a view. The source of truth for
|
||||
* backgroundColor is the shadow view, so if to update backgroundColor from
|
||||
* native code you will need to call this method.
|
||||
*/
|
||||
- (void)setBackgroundColor:(UIColor *)color forView:(UIView *)view;
|
||||
|
||||
/**
|
||||
* Sets up layout animation which will perform on next layout pass.
|
||||
* The animation will affect only one next layout pass.
|
||||
|
@ -298,7 +298,6 @@ static NSDictionary *deviceOrientationEventBody(UIDeviceOrientation orientation)
|
||||
RCTRootShadowView *shadowView = [RCTRootShadowView new];
|
||||
shadowView.availableSize = availableSize;
|
||||
shadowView.reactTag = reactTag;
|
||||
shadowView.backgroundColor = rootView.backgroundColor;
|
||||
shadowView.viewName = NSStringFromClass([rootView class]);
|
||||
self->_shadowViewRegistry[shadowView.reactTag] = shadowView;
|
||||
[self->_rootViewTags addObject:reactTag];
|
||||
@ -417,20 +416,6 @@ static NSDictionary *deviceOrientationEventBody(UIDeviceOrientation orientation)
|
||||
} forTag:view.reactTag];
|
||||
}
|
||||
|
||||
- (void)setBackgroundColor:(UIColor *)color forView:(UIView *)view
|
||||
{
|
||||
RCTAssertMainQueue();
|
||||
[self _executeBlockWithShadowView:^(RCTShadowView *shadowView) {
|
||||
if (!self->_viewRegistry) {
|
||||
return;
|
||||
}
|
||||
|
||||
shadowView.backgroundColor = color;
|
||||
[self _amendPendingUIBlocksWithStylePropagationUpdateForShadowView:shadowView];
|
||||
[self flushUIBlocksWithCompletion:^{}];
|
||||
} forTag:view.reactTag];
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters views from registries
|
||||
*/
|
||||
@ -969,11 +954,6 @@ RCT_EXPORT_METHOD(createView:(nonnull NSNumber *)reactTag
|
||||
shadowView.rootView = (RCTRootShadowView *)rootView;
|
||||
}
|
||||
|
||||
// Shadow view is the source of truth for background color this is a little
|
||||
// bit counter-intuitive if people try to set background color when setting up
|
||||
// the view, but it's the only way that makes sense given our threading model
|
||||
UIColor *backgroundColor = shadowView.backgroundColor;
|
||||
|
||||
// Dispatch view creation directly to the main thread instead of adding to
|
||||
// UIBlocks array. This way, it doesn't get deferred until after layout.
|
||||
__weak RCTUIManager *weakManager = self;
|
||||
@ -984,11 +964,7 @@ RCT_EXPORT_METHOD(createView:(nonnull NSNumber *)reactTag
|
||||
}
|
||||
UIView *view = [componentData createViewWithTag:reactTag];
|
||||
if (view) {
|
||||
[componentData setProps:props forView:view]; // Must be done before bgColor to prevent wrong default
|
||||
if ([view respondsToSelector:@selector(setBackgroundColor:)]) {
|
||||
((UIView *)view).backgroundColor = backgroundColor;
|
||||
}
|
||||
|
||||
[componentData setProps:props forView:view];
|
||||
uiManager->_viewRegistry[reactTag] = view;
|
||||
|
||||
#if RCT_DEV
|
||||
|
@ -55,7 +55,6 @@ typedef void (^RCTApplierBlock)(NSDictionary<NSNumber *, UIView *> *viewRegistry
|
||||
@property (nonatomic, weak, readonly) RCTShadowView *superview;
|
||||
@property (nonatomic, assign, readonly) YGNodeRef yogaNode;
|
||||
@property (nonatomic, copy) NSString *viewName;
|
||||
@property (nonatomic, strong) UIColor *backgroundColor; // Used to propagate to children
|
||||
@property (nonatomic, copy) RCTDirectEventBlock onLayout;
|
||||
|
||||
/**
|
||||
|
@ -19,8 +19,6 @@
|
||||
typedef void (^RCTActionBlock)(RCTShadowView *shadowViewSelf, id value);
|
||||
typedef void (^RCTResetActionBlock)(RCTShadowView *shadowViewSelf);
|
||||
|
||||
static NSString *const RCTBackgroundColorProp = @"backgroundColor";
|
||||
|
||||
typedef NS_ENUM(unsigned int, meta_prop_t) {
|
||||
META_PROP_LEFT,
|
||||
META_PROP_TOP,
|
||||
@ -278,26 +276,6 @@ static void RCTProcessMetaPropsBorder(const YGValue metaProps[META_PROP_COUNT],
|
||||
}];
|
||||
}
|
||||
|
||||
if (!_backgroundColor) {
|
||||
UIColor *parentBackgroundColor = parentProperties[RCTBackgroundColorProp];
|
||||
if (parentBackgroundColor) {
|
||||
[applierBlocks addObject:^(NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
||||
UIView *view = viewRegistry[self->_reactTag];
|
||||
[view reactSetInheritedBackgroundColor:parentBackgroundColor];
|
||||
}];
|
||||
}
|
||||
} else {
|
||||
// Update parent properties for children
|
||||
NSMutableDictionary<NSString *, id> *properties = [NSMutableDictionary dictionaryWithDictionary:parentProperties];
|
||||
CGFloat alpha = CGColorGetAlpha(_backgroundColor.CGColor);
|
||||
if (alpha < 1.0) {
|
||||
// If bg is non-opaque, don't propagate further
|
||||
properties[RCTBackgroundColorProp] = [UIColor clearColor];
|
||||
} else {
|
||||
properties[RCTBackgroundColorProp] = _backgroundColor;
|
||||
}
|
||||
return properties;
|
||||
}
|
||||
return parentProperties;
|
||||
}
|
||||
|
||||
@ -786,12 +764,6 @@ RCT_STYLE_PROPERTY(Display, display, Display, YGDisplay)
|
||||
RCT_STYLE_PROPERTY(Direction, direction, Direction, YGDirection)
|
||||
RCT_STYLE_PROPERTY(AspectRatio, aspectRatio, AspectRatio, float)
|
||||
|
||||
- (void)setBackgroundColor:(UIColor *)color
|
||||
{
|
||||
_backgroundColor = color;
|
||||
[self dirtyPropagation];
|
||||
}
|
||||
|
||||
- (void)didUpdateReactSubviews
|
||||
{
|
||||
// Does nothing by default
|
||||
|
@ -273,8 +273,6 @@ RCT_REMAP_VIEW_PROPERTY(zIndex, reactZIndex, NSInteger)
|
||||
|
||||
#pragma mark - ShadowView properties
|
||||
|
||||
RCT_EXPORT_SHADOW_PROPERTY(backgroundColor, UIColor)
|
||||
|
||||
RCT_EXPORT_SHADOW_PROPERTY(top, YGValue)
|
||||
RCT_EXPORT_SHADOW_PROPERTY(right, YGValue)
|
||||
RCT_EXPORT_SHADOW_PROPERTY(start, YGValue)
|
||||
|
@ -66,11 +66,6 @@
|
||||
*/
|
||||
- (void)reactSetFrame:(CGRect)frame;
|
||||
|
||||
/**
|
||||
* Used to improve performance when compositing views with translucent content.
|
||||
*/
|
||||
- (void)reactSetInheritedBackgroundColor:(UIColor *)inheritedBackgroundColor;
|
||||
|
||||
/**
|
||||
* This method finds and returns the containing view controller for the view.
|
||||
*/
|
||||
|
@ -193,11 +193,6 @@
|
||||
self.bounds = bounds;
|
||||
}
|
||||
|
||||
- (void)reactSetInheritedBackgroundColor:(__unused UIColor *)inheritedBackgroundColor
|
||||
{
|
||||
// Does nothing by default
|
||||
}
|
||||
|
||||
- (UIViewController *)reactViewController
|
||||
{
|
||||
id responder = [self nextResponder];
|
||||
|
Loading…
x
Reference in New Issue
Block a user