mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Summary: ## Changelog: [Internal] - While merging a Contributor PR in D43816768, I got curious whether such things as detecting/fixing typos could be automated. There is a tool called [typos](https://github.com/crate-ci/typos), which, as it turns out, works very well on source code files. The amount of false positives was minimal, most of the suggestions were valid ones. And the total amount of typos found and fixed was **more than 300**, which is... quite a bit :) ### Methodology * Run `typos` separately on `ReactCommon`, `Libraries`, `React`, `ReactAndroid` and `scripts` folders inside `packages/react-native`, e.g.: ``` $ typos -w --config ~/tmp/_typos.toml ~/fbsource/xplat/js/react-native-github/packages/react-native/ReactAndroid ``` Contents of the `_typos.toml` config file: ``` [default.extend-words] collapsable = "collapsable" NDK = "NDK" inout = "inout" ``` (yeah, it really didn't like the "collapsable" word, for some reason ;)) * Inspect all the changes manually and revert false positives (as mentioned, their amount was minimal) Note that most of the changes are inside things like comments and error messages, however there are a few among identifier name fixes (`typos` is actually quite smart at understanding naming conventions in code) - I kept the suggestions in cases that are local and not part of a public API. There are also misspelled file name changes in a couple of cases. Reviewed By: NickGerleman Differential Revision: D44172494 fbshipit-source-id: 86e27edbbb99e09135e3cdd5d7cea8ffeb8307f4
108 lines
2.8 KiB
Objective-C
108 lines
2.8 KiB
Objective-C
/*
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#import "RCTRootContentView.h"
|
|
|
|
#import "RCTBridge.h"
|
|
#import "RCTPerformanceLogger.h"
|
|
#import "RCTRootView.h"
|
|
#import "RCTRootViewInternal.h"
|
|
#import "RCTTouchHandler.h"
|
|
#import "RCTUIManager.h"
|
|
#import "UIView+React.h"
|
|
|
|
@implementation RCTRootContentView
|
|
|
|
- (instancetype)initWithFrame:(CGRect)frame
|
|
bridge:(RCTBridge *)bridge
|
|
reactTag:(NSNumber *)reactTag
|
|
sizeFlexibility:(RCTRootViewSizeFlexibility)sizeFlexibility
|
|
{
|
|
if ((self = [super initWithFrame:frame])) {
|
|
_bridge = bridge;
|
|
self.reactTag = reactTag;
|
|
_sizeFlexibility = sizeFlexibility;
|
|
_touchHandler = [[RCTTouchHandler alloc] initWithBridge:_bridge];
|
|
[_touchHandler attachToView:self];
|
|
[_bridge.uiManager registerRootView:self];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
RCT_NOT_IMPLEMENTED(-(instancetype)initWithFrame : (CGRect)frame)
|
|
RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder : (nonnull NSCoder *)aDecoder)
|
|
|
|
- (void)layoutSubviews
|
|
{
|
|
[super layoutSubviews];
|
|
[self updateAvailableSize];
|
|
}
|
|
|
|
- (void)insertReactSubview:(UIView *)subview atIndex:(NSInteger)atIndex
|
|
{
|
|
[super insertReactSubview:subview atIndex:atIndex];
|
|
[_bridge.performanceLogger markStopForTag:RCTPLTTI];
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
if (!self->_contentHasAppeared) {
|
|
self->_contentHasAppeared = YES;
|
|
[[NSNotificationCenter defaultCenter] postNotificationName:RCTContentDidAppearNotification object:self.superview];
|
|
}
|
|
});
|
|
}
|
|
|
|
- (void)setSizeFlexibility:(RCTRootViewSizeFlexibility)sizeFlexibility
|
|
{
|
|
if (_sizeFlexibility == sizeFlexibility) {
|
|
return;
|
|
}
|
|
|
|
_sizeFlexibility = sizeFlexibility;
|
|
[self setNeedsLayout];
|
|
}
|
|
|
|
- (CGSize)availableSize
|
|
{
|
|
CGSize size = self.bounds.size;
|
|
return CGSizeMake(
|
|
_sizeFlexibility & RCTRootViewSizeFlexibilityWidth ? INFINITY : size.width,
|
|
_sizeFlexibility & RCTRootViewSizeFlexibilityHeight ? INFINITY : size.height);
|
|
}
|
|
|
|
- (void)updateAvailableSize
|
|
{
|
|
if (!self.reactTag || !_bridge.isValid) {
|
|
return;
|
|
}
|
|
|
|
[_bridge.uiManager setAvailableSize:self.availableSize forRootView:self];
|
|
}
|
|
|
|
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
|
|
{
|
|
// The root content view itself should never receive touches
|
|
UIView *hitView = [super hitTest:point withEvent:event];
|
|
if (_passThroughTouches && hitView == self) {
|
|
return nil;
|
|
}
|
|
return hitView;
|
|
}
|
|
|
|
- (void)invalidate
|
|
{
|
|
if (self.userInteractionEnabled) {
|
|
self.userInteractionEnabled = NO;
|
|
[(RCTRootView *)self.superview contentViewInvalidated];
|
|
|
|
[_bridge enqueueJSCall:@"AppRegistry"
|
|
method:@"unmountApplicationComponentAtRootTag"
|
|
args:@[ self.reactTag ]
|
|
completion:NULL];
|
|
}
|
|
}
|
|
|
|
@end
|