mirror of
https://github.com/status-im/react-native.git
synced 2025-02-25 15:45:32 +00:00
Add [RCTShadowView isCSSLeaf] for skipping css tree of children
Summary: RCTShadowText currently overrides a couple methods from RCTShadowView to reset the count of the cssNode children to 0. This diff instead moves that logic into RCTShadowView behind a configurable flag making it easier to reason about. Reviewed By: javache Differential Revision: D3586434 fbshipit-source-id: 4389a8119dc49e3fc4357174c87c0c69287ae385
This commit is contained in:
parent
102577565a
commit
0587c85094
@ -81,6 +81,11 @@ static css_dim_t RCTMeasure(void *context, float width, css_measure_mode_t width
|
||||
return [[superDescription substringToIndex:superDescription.length - 1] stringByAppendingFormat:@"; text: %@>", [self attributedString].string];
|
||||
}
|
||||
|
||||
- (BOOL)isCSSLeafNode
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)contentSizeMultiplierDidChange:(NSNotification *)note
|
||||
{
|
||||
[self dirtyLayout];
|
||||
@ -443,18 +448,6 @@ static css_dim_t RCTMeasure(void *context, float width, css_measure_mode_t width
|
||||
}
|
||||
}
|
||||
|
||||
- (void)insertReactSubview:(RCTShadowView *)subview atIndex:(NSInteger)atIndex
|
||||
{
|
||||
[super insertReactSubview:subview atIndex:atIndex];
|
||||
self.cssNode->children_count = 0;
|
||||
}
|
||||
|
||||
- (void)removeReactSubview:(RCTShadowView *)subview
|
||||
{
|
||||
[super removeReactSubview:subview];
|
||||
self.cssNode->children_count = 0;
|
||||
}
|
||||
|
||||
- (void)setBackgroundColor:(UIColor *)backgroundColor
|
||||
{
|
||||
super.backgroundColor = backgroundColor;
|
||||
|
@ -189,6 +189,13 @@ typedef void (^RCTApplierBlock)(NSDictionary<NSNumber *, UIView *> *viewRegistry
|
||||
- (void)dirtyLayout NS_REQUIRES_SUPER;
|
||||
- (BOOL)isLayoutDirty;
|
||||
|
||||
/**
|
||||
* Return whether or not this node acts as a leaf node in the eyes of CSSLayout. For example
|
||||
* RCTShadowText has children which it does not want CSSLayout to lay out so in the eyes of
|
||||
* CSSLayout it is a leaf node.
|
||||
*/
|
||||
- (BOOL)isCSSLeafNode;
|
||||
|
||||
- (void)dirtyPropagation NS_REQUIRES_SUPER;
|
||||
- (BOOL)isPropagationDirty;
|
||||
|
||||
|
@ -320,6 +320,11 @@ static void RCTProcessMetaProps(const float metaProps[META_PROP_COUNT], float st
|
||||
return _layoutLifecycle != RCTUpdateLifecycleComputed;
|
||||
}
|
||||
|
||||
- (BOOL)isCSSLeafNode
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void)dirtyPropagation
|
||||
{
|
||||
if (_propagationLifecycle != RCTUpdateLifecycleDirtied) {
|
||||
@ -354,7 +359,7 @@ static void RCTProcessMetaProps(const float metaProps[META_PROP_COUNT], float st
|
||||
- (void)insertReactSubview:(RCTShadowView *)subview atIndex:(NSInteger)atIndex
|
||||
{
|
||||
[_reactSubviews insertObject:subview atIndex:atIndex];
|
||||
_cssNode->children_count = (int)_reactSubviews.count;
|
||||
_cssNode->children_count = [self isCSSLeafNode] ? 0 : (int)_reactSubviews.count;
|
||||
subview->_superview = self;
|
||||
_didUpdateSubviews = YES;
|
||||
[self dirtyText];
|
||||
@ -370,7 +375,7 @@ static void RCTProcessMetaProps(const float metaProps[META_PROP_COUNT], float st
|
||||
_didUpdateSubviews = YES;
|
||||
subview->_superview = nil;
|
||||
[_reactSubviews removeObject:subview];
|
||||
_cssNode->children_count = (int)_reactSubviews.count;
|
||||
_cssNode->children_count = [self isCSSLeafNode] ? 0 : (int)_reactSubviews.count;
|
||||
}
|
||||
|
||||
- (NSArray<RCTShadowView *> *)reactSubviews
|
||||
|
Loading…
x
Reference in New Issue
Block a user