From 1a26f97eb0f5b7dc89d97ba6efd02ce06e75e477 Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Mon, 11 Feb 2019 12:22:32 -0800 Subject: [PATCH] Clang-format for all files in Fabric folder Summary: Trivial. If you have troubles with rebasing on top of this revision, run this on your diff: $ find */*.h */*.mm */*.cpp */*.m -exec clang-format -style=file -i {} \; Reviewed By: JoshuaGross Differential Revision: D14018903 fbshipit-source-id: fd0ce2da0e11954e683385402738c701045e727c --- .../Fabric/Mounting/RCTComponentViewFactory.h | 3 +- .../Mounting/RCTComponentViewFactory.mm | 18 ++-- .../Mounting/RCTComponentViewProtocol.h | 13 ++- .../Mounting/RCTComponentViewRegistry.h | 5 +- .../Mounting/RCTComponentViewRegistry.mm | 28 ++++--- React/Fabric/Mounting/RCTMountingManager.h | 9 +- React/Fabric/Mounting/RCTMountingManager.mm | 82 +++++++++---------- .../Mounting/UIView+ComponentViewProtocol.h | 10 +-- .../Mounting/UIView+ComponentViewProtocol.mm | 22 ++--- React/Fabric/Surface/RCTFabricSurface.h | 6 +- React/Fabric/Surface/RCTFabricSurface.mm | 21 ++--- .../RCTFabricSurfaceHostingProxyRootView.h | 1 - .../RCTFabricSurfaceHostingProxyRootView.mm | 8 +- .../Surface/RCTFabricSurfaceHostingView.h | 1 - .../Surface/RCTFabricSurfaceHostingView.mm | 1 - React/Fabric/Utils/MainQueueExecutor.h | 6 +- React/Fabric/Utils/MainQueueExecutor.mm | 6 +- React/Fabric/Utils/MainRunLoopEventBeat.h | 12 ++- React/Fabric/Utils/MainRunLoopEventBeat.mm | 23 +++--- React/Fabric/Utils/RuntimeEventBeat.h | 14 ++-- React/Fabric/Utils/RuntimeEventBeat.mm | 19 ++--- .../fabric/uimanager/UITemplateProcessor.cpp | 2 +- 22 files changed, 145 insertions(+), 165 deletions(-) diff --git a/React/Fabric/Mounting/RCTComponentViewFactory.h b/React/Fabric/Mounting/RCTComponentViewFactory.h index 1aed476a1ad..535734aace9 100644 --- a/React/Fabric/Mounting/RCTComponentViewFactory.h +++ b/React/Fabric/Mounting/RCTComponentViewFactory.h @@ -30,7 +30,8 @@ NS_ASSUME_NONNULL_BEGIN /** * Creates a component view with given component handle. */ -- (UIView *)createComponentViewWithComponentHandle:(facebook::react::ComponentHandle)componentHandle; +- (UIView *)createComponentViewWithComponentHandle: + (facebook::react::ComponentHandle)componentHandle; @end diff --git a/React/Fabric/Mounting/RCTComponentViewFactory.mm b/React/Fabric/Mounting/RCTComponentViewFactory.mm index 6b160f713f9..06606d5c8e3 100644 --- a/React/Fabric/Mounting/RCTComponentViewFactory.mm +++ b/React/Fabric/Mounting/RCTComponentViewFactory.mm @@ -10,19 +10,18 @@ #import #import -#import "RCTViewComponentView.h" +#import "RCTActivityIndicatorViewComponentView.h" #import "RCTImageComponentView.h" -#import "RCTScrollViewComponentView.h" #import "RCTParagraphComponentView.h" #import "RCTRootComponentView.h" -#import "RCTActivityIndicatorViewComponentView.h" +#import "RCTScrollViewComponentView.h" #import "RCTSliderComponentView.h" #import "RCTSwitchComponentView.h" +#import "RCTViewComponentView.h" using namespace facebook::react; -@implementation RCTComponentViewFactory -{ +@implementation RCTComponentViewFactory { std::unordered_map> _registry; } @@ -52,14 +51,17 @@ using namespace facebook::react; _registry[componentHandle] = componentViewClass; } -- (UIView *)createComponentViewWithComponentHandle:(facebook::react::ComponentHandle)componentHandle +- (UIView *)createComponentViewWithComponentHandle: + (facebook::react::ComponentHandle)componentHandle { RCTAssertMainQueue(); auto iterator = _registry.find(componentHandle); RCTAssert( - iterator != _registry.end(), - @"ComponentView with componentHandle `%lli` (`%s`) not found.", componentHandle, (char *)componentHandle); + iterator != _registry.end(), + @"ComponentView with componentHandle `%lli` (`%s`) not found.", + componentHandle, + (char *)componentHandle); Class componentViewClass = iterator->second; return [[componentViewClass alloc] init]; } diff --git a/React/Fabric/Mounting/RCTComponentViewProtocol.h b/React/Fabric/Mounting/RCTComponentViewProtocol.h index 5a5b7e3023e..116f6ef4295 100644 --- a/React/Fabric/Mounting/RCTComponentViewProtocol.h +++ b/React/Fabric/Mounting/RCTComponentViewProtocol.h @@ -7,11 +7,11 @@ #import +#import +#import #import #import -#import #import -#import NS_ASSUME_NONNULL_BEGIN @@ -34,23 +34,20 @@ NS_ASSUME_NONNULL_BEGIN * component view. * Receiver must add `childComponentView` as a subview. */ -- (void)mountChildComponentView:(UIView *)childComponentView - index:(NSInteger)index; +- (void)mountChildComponentView:(UIView *)childComponentView index:(NSInteger)index; /* * Called for unmounting (detaching) a child component view from `self` * component view. * Receiver must remove `childComponentView` as a subview. */ -- (void)unmountChildComponentView:(UIView *)childComponentView - index:(NSInteger)index; +- (void)unmountChildComponentView:(UIView *)childComponentView index:(NSInteger)index; /* * Called for updating component's props. * Receiver must update native view props accordingly changed props. */ -- (void)updateProps:(facebook::react::SharedProps)props - oldProps:(facebook::react::SharedProps)oldProps; +- (void)updateProps:(facebook::react::SharedProps)props oldProps:(facebook::react::SharedProps)oldProps; /* * Called for updating component's local data. diff --git a/React/Fabric/Mounting/RCTComponentViewRegistry.h b/React/Fabric/Mounting/RCTComponentViewRegistry.h index 127c1e5c7e1..a85308002f6 100644 --- a/React/Fabric/Mounting/RCTComponentViewRegistry.h +++ b/React/Fabric/Mounting/RCTComponentViewRegistry.h @@ -7,9 +7,9 @@ #import -#import #import #import +#import NS_ASSUME_NONNULL_BEGIN @@ -26,7 +26,8 @@ NS_ASSUME_NONNULL_BEGIN * for given `componentHandle` and with given `tag`. * #RefuseSingleUse */ -- (UIView *)dequeueComponentViewWithComponentHandle:(facebook::react::ComponentHandle)componentHandle +- (UIView *)dequeueComponentViewWithComponentHandle: + (facebook::react::ComponentHandle)componentHandle tag:(ReactTag)tag; /** diff --git a/React/Fabric/Mounting/RCTComponentViewRegistry.mm b/React/Fabric/Mounting/RCTComponentViewRegistry.mm index deab9e4b525..8f4e881d4cb 100644 --- a/React/Fabric/Mounting/RCTComponentViewRegistry.mm +++ b/React/Fabric/Mounting/RCTComponentViewRegistry.mm @@ -16,8 +16,8 @@ using namespace facebook::react; #ifdef LEGACY_UIMANAGER_INTEGRATION_ENABLED -#import #import +#import /** * Warning: This is a total hack and temporary solution. @@ -78,11 +78,11 @@ const NSInteger RCTComponentViewRegistryRecyclePoolMaxSize = 1024; if (self = [super init]) { _registry = [NSMapTable mapTableWithKeyOptions:NSPointerFunctionsIntegerPersonality | NSPointerFunctionsOpaqueMemory valueOptions:NSPointerFunctionsObjectPersonality]; - _recyclePool = [NSMapTable mapTableWithKeyOptions:NSPointerFunctionsOpaquePersonality | NSPointerFunctionsOpaqueMemory - valueOptions:NSPointerFunctionsObjectPersonality]; + _recyclePool = + [NSMapTable mapTableWithKeyOptions:NSPointerFunctionsOpaquePersonality | NSPointerFunctionsOpaqueMemory + valueOptions:NSPointerFunctionsObjectPersonality]; _componentViewFactory = [RCTComponentViewFactory standardComponentViewFactory]; - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleApplicationDidReceiveMemoryWarningNotification) name:UIApplicationDidReceiveMemoryWarningNotification @@ -102,11 +102,11 @@ const NSInteger RCTComponentViewRegistryRecyclePoolMaxSize = 1024; { RCTAssertMainQueue(); - RCTAssert(![_registry objectForKey:(__bridge id)(void *)tag], - @"RCTComponentViewRegistry: Attempt to dequeue already registered component."); + RCTAssert( + ![_registry objectForKey:(__bridge id)(void *)tag], + @"RCTComponentViewRegistry: Attempt to dequeue already registered component."); - UIView *componentView = - [self _dequeueComponentViewWithComponentHandle:componentHandle]; + UIView *componentView = [self _dequeueComponentViewWithComponentHandle:componentHandle]; componentView.tag = tag; [_registry setObject:componentView forKey:(__bridge id)(void *)tag]; @@ -123,8 +123,9 @@ const NSInteger RCTComponentViewRegistryRecyclePoolMaxSize = 1024; { RCTAssertMainQueue(); - RCTAssert([_registry objectForKey:(__bridge id)(void *)tag], - @"RCTComponentViewRegistry: Attempt to enqueue unregistered component."); + RCTAssert( + [_registry objectForKey:(__bridge id)(void *)tag], + @"RCTComponentViewRegistry: Attempt to enqueue unregistered component."); #ifdef LEGACY_UIMANAGER_INTEGRATION_ENABLED [RCTUIManager unregisterView:componentView]; @@ -139,7 +140,8 @@ const NSInteger RCTComponentViewRegistryRecyclePoolMaxSize = 1024; { RCTAssertMainQueue(); [self _enqueueComponentViewWithComponentHandle:componentHandle - componentView:[self.componentViewFactory createComponentViewWithComponentHandle:componentHandle]]; + componentView:[self.componentViewFactory + createComponentViewWithComponentHandle:componentHandle]]; } - (UIView *)componentViewByTag:(ReactTag)tag @@ -158,7 +160,7 @@ const NSInteger RCTComponentViewRegistryRecyclePoolMaxSize = 1024; { RCTAssertMainQueue(); NSHashTable *> *componentViews = - [_recyclePool objectForKey:(__bridge id)(void *)componentHandle]; + [_recyclePool objectForKey:(__bridge id)(void *)componentHandle]; if (!componentViews || componentViews.count == 0) { return [self.componentViewFactory createComponentViewWithComponentHandle:componentHandle]; } @@ -175,7 +177,7 @@ const NSInteger RCTComponentViewRegistryRecyclePoolMaxSize = 1024; [componentView prepareForRecycle]; NSHashTable *> *componentViews = - [_recyclePool objectForKey:(__bridge id)(void *)componentHandle]; + [_recyclePool objectForKey:(__bridge id)(void *)componentHandle]; if (!componentViews) { componentViews = [NSHashTable hashTableWithOptions:NSPointerFunctionsObjectPersonality]; [_recyclePool setObject:componentViews forKey:(__bridge id)(void *)componentHandle]; diff --git a/React/Fabric/Mounting/RCTMountingManager.h b/React/Fabric/Mounting/RCTMountingManager.h index 9d3a3e11d0a..d4a64da800e 100644 --- a/React/Fabric/Mounting/RCTMountingManager.h +++ b/React/Fabric/Mounting/RCTMountingManager.h @@ -7,11 +7,11 @@ #import +#import +#import #import #import #import -#import -#import NS_ASSUME_NONNULL_BEGIN @@ -22,7 +22,7 @@ NS_ASSUME_NONNULL_BEGIN */ @interface RCTMountingManager : NSObject -@property (nonatomic, weak) id delegate; +@property (nonatomic, weak) id delegate; @property (nonatomic, strong) RCTComponentViewRegistry *componentViewRegistry; /** @@ -30,8 +30,7 @@ NS_ASSUME_NONNULL_BEGIN * The order of mutation tnstructions matters. * Can be called from any thread. */ -- (void)performTransactionWithMutations:(facebook::react::ShadowViewMutationList)mutations - rootTag:(ReactTag)rootTag; +- (void)performTransactionWithMutations:(facebook::react::ShadowViewMutationList)mutations rootTag:(ReactTag)rootTag; /** * Suggests preliminary creation of a component view of given type. diff --git a/React/Fabric/Mounting/RCTMountingManager.mm b/React/Fabric/Mounting/RCTMountingManager.mm index 7a1b4831f6d..105f39919ec 100644 --- a/React/Fabric/Mounting/RCTMountingManager.mm +++ b/React/Fabric/Mounting/RCTMountingManager.mm @@ -7,24 +7,24 @@ #import "RCTMountingManager.h" -#import -#import #import #import +#import +#import #import "RCTComponentViewProtocol.h" #import "RCTComponentViewRegistry.h" #import "RCTMountItemProtocol.h" -#import "RCTCreateMountItem.h" #import "RCTConversions.h" +#import "RCTCreateMountItem.h" #import "RCTDeleteMountItem.h" #import "RCTInsertMountItem.h" #import "RCTRemoveMountItem.h" -#import "RCTUpdatePropsMountItem.h" #import "RCTUpdateEventEmitterMountItem.h" -#import "RCTUpdateLocalDataMountItem.h" #import "RCTUpdateLayoutMetricsMountItem.h" +#import "RCTUpdateLocalDataMountItem.h" +#import "RCTUpdatePropsMountItem.h" using namespace facebook::react; @@ -39,8 +39,7 @@ using namespace facebook::react; return self; } -- (void)performTransactionWithMutations:(facebook::react::ShadowViewMutationList)mutations - rootTag:(ReactTag)rootTag +- (void)performTransactionWithMutations:(facebook::react::ShadowViewMutationList)mutations rootTag:(ReactTag)rootTag { NSMutableArray *mountItems; @@ -48,22 +47,23 @@ using namespace facebook::react; // This section is measured separately from `_performMountItems:rootTag:` because that can be asynchronous. SystraceSection s("-[RCTMountingManager performTransactionWithMutations:rootTag:]"); - mountItems = [[NSMutableArray alloc] initWithCapacity:mutations.size() * 2 /* ~ the worst case */]; + mountItems = + [[NSMutableArray alloc] initWithCapacity:mutations.size() * 2 /* ~ the worst case */]; for (const auto &mutation : mutations) { switch (mutation.type) { case ShadowViewMutation::Create: { RCTCreateMountItem *mountItem = - [[RCTCreateMountItem alloc] initWithComponentHandle:mutation.newChildShadowView.componentHandle - tag:mutation.newChildShadowView.tag]; + [[RCTCreateMountItem alloc] initWithComponentHandle:mutation.newChildShadowView.componentHandle + tag:mutation.newChildShadowView.tag]; [mountItems addObject:mountItem]; break; } case ShadowViewMutation::Delete: { RCTDeleteMountItem *mountItem = - [[RCTDeleteMountItem alloc] initWithComponentHandle:mutation.oldChildShadowView.componentHandle - tag:mutation.oldChildShadowView.tag]; + [[RCTDeleteMountItem alloc] initWithComponentHandle:mutation.oldChildShadowView.componentHandle + tag:mutation.oldChildShadowView.tag]; [mountItems addObject:mountItem]; break; } @@ -75,38 +75,39 @@ using namespace facebook::react; newProps:mutation.newChildShadowView.props]]; // EventEmitter - [mountItems addObject:[[RCTUpdateEventEmitterMountItem alloc] initWithTag:mutation.newChildShadowView.tag - eventEmitter:mutation.newChildShadowView.eventEmitter]]; + [mountItems + addObject:[[RCTUpdateEventEmitterMountItem alloc] initWithTag:mutation.newChildShadowView.tag + eventEmitter:mutation.newChildShadowView.eventEmitter]]; // LocalData if (mutation.newChildShadowView.localData) { - [mountItems addObject:[[RCTUpdateLocalDataMountItem alloc] initWithTag:mutation.newChildShadowView.tag - oldLocalData:nullptr - newLocalData:mutation.newChildShadowView.localData]]; + [mountItems + addObject:[[RCTUpdateLocalDataMountItem alloc] initWithTag:mutation.newChildShadowView.tag + oldLocalData:nullptr + newLocalData:mutation.newChildShadowView.localData]]; } // Layout if (mutation.newChildShadowView.layoutMetrics != EmptyLayoutMetrics) { - [mountItems addObject:[[RCTUpdateLayoutMetricsMountItem alloc] initWithTag:mutation.newChildShadowView.tag - oldLayoutMetrics:{} - newLayoutMetrics:mutation.newChildShadowView.layoutMetrics]]; + [mountItems addObject:[[RCTUpdateLayoutMetricsMountItem alloc] + initWithTag:mutation.newChildShadowView.tag + oldLayoutMetrics:{} + newLayoutMetrics:mutation.newChildShadowView.layoutMetrics]]; } // Insertion - RCTInsertMountItem *mountItem = - [[RCTInsertMountItem alloc] initWithChildTag:mutation.newChildShadowView.tag - parentTag:mutation.parentShadowView.tag - index:mutation.index]; + RCTInsertMountItem *mountItem = [[RCTInsertMountItem alloc] initWithChildTag:mutation.newChildShadowView.tag + parentTag:mutation.parentShadowView.tag + index:mutation.index]; [mountItems addObject:mountItem]; break; } case ShadowViewMutation::Remove: { - RCTRemoveMountItem *mountItem = - [[RCTRemoveMountItem alloc] initWithChildTag:mutation.oldChildShadowView.tag - parentTag:mutation.parentShadowView.tag - index:mutation.index]; + RCTRemoveMountItem *mountItem = [[RCTRemoveMountItem alloc] initWithChildTag:mutation.oldChildShadowView.tag + parentTag:mutation.parentShadowView.tag + index:mutation.index]; [mountItems addObject:mountItem]; break; } @@ -118,35 +119,35 @@ using namespace facebook::react; // Props if (oldChildShadowView.props != newChildShadowView.props) { RCTUpdatePropsMountItem *mountItem = - [[RCTUpdatePropsMountItem alloc] initWithTag:mutation.oldChildShadowView.tag - oldProps:mutation.oldChildShadowView.props - newProps:mutation.newChildShadowView.props]; + [[RCTUpdatePropsMountItem alloc] initWithTag:mutation.oldChildShadowView.tag + oldProps:mutation.oldChildShadowView.props + newProps:mutation.newChildShadowView.props]; [mountItems addObject:mountItem]; } // EventEmitter if (oldChildShadowView.eventEmitter != newChildShadowView.eventEmitter) { RCTUpdateEventEmitterMountItem *mountItem = - [[RCTUpdateEventEmitterMountItem alloc] initWithTag:mutation.oldChildShadowView.tag - eventEmitter:mutation.oldChildShadowView.eventEmitter]; + [[RCTUpdateEventEmitterMountItem alloc] initWithTag:mutation.oldChildShadowView.tag + eventEmitter:mutation.oldChildShadowView.eventEmitter]; [mountItems addObject:mountItem]; } // LocalData if (oldChildShadowView.localData != newChildShadowView.localData) { RCTUpdateLocalDataMountItem *mountItem = - [[RCTUpdateLocalDataMountItem alloc] initWithTag:newChildShadowView.tag - oldLocalData:oldChildShadowView.localData - newLocalData:newChildShadowView.localData]; + [[RCTUpdateLocalDataMountItem alloc] initWithTag:newChildShadowView.tag + oldLocalData:oldChildShadowView.localData + newLocalData:newChildShadowView.localData]; [mountItems addObject:mountItem]; } // Layout if (oldChildShadowView.layoutMetrics != newChildShadowView.layoutMetrics) { RCTUpdateLayoutMetricsMountItem *mountItem = - [[RCTUpdateLayoutMetricsMountItem alloc] initWithTag:mutation.oldChildShadowView.tag - oldLayoutMetrics:oldChildShadowView.layoutMetrics - newLayoutMetrics:newChildShadowView.layoutMetrics]; + [[RCTUpdateLayoutMetricsMountItem alloc] initWithTag:mutation.oldChildShadowView.tag + oldLayoutMetrics:oldChildShadowView.layoutMetrics + newLayoutMetrics:newChildShadowView.layoutMetrics]; [mountItems addObject:mountItem]; } @@ -161,8 +162,7 @@ using namespace facebook::react; }); } -- (void)_performMountItems:(NSArray *)mountItems - rootTag:(ReactTag)rootTag +- (void)_performMountItems:(NSArray *)mountItems rootTag:(ReactTag)rootTag { SystraceSection s("-[RCTMountingManager _performMountItems:rootTag:]"); RCTAssertMainQueue(); diff --git a/React/Fabric/Mounting/UIView+ComponentViewProtocol.h b/React/Fabric/Mounting/UIView+ComponentViewProtocol.h index 6c630782aa1..b30cff79fb6 100644 --- a/React/Fabric/Mounting/UIView+ComponentViewProtocol.h +++ b/React/Fabric/Mounting/UIView+ComponentViewProtocol.h @@ -9,7 +9,6 @@ #import - NS_ASSUME_NONNULL_BEGIN /** @@ -17,14 +16,11 @@ NS_ASSUME_NONNULL_BEGIN */ @interface UIView (ComponentViewProtocol) -- (void)mountChildComponentView:(UIView *)childComponentView - index:(NSInteger)index; +- (void)mountChildComponentView:(UIView *)childComponentView index:(NSInteger)index; -- (void)unmountChildComponentView:(UIView *)childComponentView - index:(NSInteger)index; +- (void)unmountChildComponentView:(UIView *)childComponentView index:(NSInteger)index; -- (void)updateProps:(facebook::react::SharedProps)props - oldProps:(facebook::react::SharedProps)oldProps; +- (void)updateProps:(facebook::react::SharedProps)props oldProps:(facebook::react::SharedProps)oldProps; - (void)updateEventEmitter:(facebook::react::SharedEventEmitter)eventEmitter; diff --git a/React/Fabric/Mounting/UIView+ComponentViewProtocol.mm b/React/Fabric/Mounting/UIView+ComponentViewProtocol.mm index e60f393a1a5..14fe9d9528a 100644 --- a/React/Fabric/Mounting/UIView+ComponentViewProtocol.mm +++ b/React/Fabric/Mounting/UIView+ComponentViewProtocol.mm @@ -14,21 +14,18 @@ using namespace facebook::react; @implementation UIView (ComponentViewProtocol) -- (void)mountChildComponentView:(UIView *)childComponentView - index:(NSInteger)index +- (void)mountChildComponentView:(UIView *)childComponentView index:(NSInteger)index { [self insertSubview:childComponentView atIndex:index]; } -- (void)unmountChildComponentView:(UIView *)childComponentView - index:(NSInteger)index +- (void)unmountChildComponentView:(UIView *)childComponentView index:(NSInteger)index { RCTAssert(childComponentView.superview == self, @"Attempt to unmount improperly mounted component view."); [childComponentView removeFromSuperview]; } -- (void)updateProps:(SharedProps)props - oldProps:(SharedProps)oldProps +- (void)updateProps:(SharedProps)props oldProps:(SharedProps)oldProps { // Default implementation does nothing. } @@ -38,24 +35,21 @@ using namespace facebook::react; // Default implementation does nothing. } -- (void)updateLocalData:(SharedLocalData)localData - oldLocalData:(SharedLocalData)oldLocalData +- (void)updateLocalData:(SharedLocalData)localData oldLocalData:(SharedLocalData)oldLocalData { // Default implementation does nothing. } -- (void)updateLayoutMetrics:(LayoutMetrics)layoutMetrics - oldLayoutMetrics:(LayoutMetrics)oldLayoutMetrics +- (void)updateLayoutMetrics:(LayoutMetrics)layoutMetrics oldLayoutMetrics:(LayoutMetrics)oldLayoutMetrics { if (layoutMetrics.frame != oldLayoutMetrics.frame) { self.frame = RCTCGRectFromRect(layoutMetrics.frame); } if (layoutMetrics.layoutDirection != oldLayoutMetrics.layoutDirection) { - self.semanticContentAttribute = - layoutMetrics.layoutDirection == LayoutDirection::RightToLeft ? - UISemanticContentAttributeForceRightToLeft : - UISemanticContentAttributeForceLeftToRight; + self.semanticContentAttribute = layoutMetrics.layoutDirection == LayoutDirection::RightToLeft + ? UISemanticContentAttributeForceRightToLeft + : UISemanticContentAttributeForceLeftToRight; } if (layoutMetrics.displayType != oldLayoutMetrics.displayType) { diff --git a/React/Fabric/Surface/RCTFabricSurface.h b/React/Fabric/Surface/RCTFabricSurface.h index 41ca6e58973..cbc2cf25936 100644 --- a/React/Fabric/Surface/RCTFabricSurface.h +++ b/React/Fabric/Surface/RCTFabricSurface.h @@ -84,8 +84,7 @@ NS_ASSUME_NONNULL_BEGIN /** * Sets `minimumSize` and `maximumSize` layout constraints for the Surface. */ -- (void)setMinimumSize:(CGSize)minimumSize - maximumSize:(CGSize)maximumSize; +- (void)setMinimumSize:(CGSize)minimumSize maximumSize:(CGSize)maximumSize; /** * Previously set `minimumSize` layout constraint. @@ -110,8 +109,7 @@ NS_ASSUME_NONNULL_BEGIN * Measures the Surface with given constraints. * This method does not cause any side effects on the surface object. */ -- (CGSize)sizeThatFitsMinimumSize:(CGSize)minimumSize - maximumSize:(CGSize)maximumSize; +- (CGSize)sizeThatFitsMinimumSize:(CGSize)minimumSize maximumSize:(CGSize)maximumSize; /** * Return the current size of the root view based on (but not clamp by) current diff --git a/React/Fabric/Surface/RCTFabricSurface.mm b/React/Fabric/Surface/RCTFabricSurface.mm index f5f55cf8ed6..044139fbe85 100644 --- a/React/Fabric/Surface/RCTFabricSurface.mm +++ b/React/Fabric/Surface/RCTFabricSurface.mm @@ -12,9 +12,9 @@ #import #import #import -#import -#import #import +#import +#import #import #import @@ -189,12 +189,9 @@ #pragma mark - Layout -- (CGSize)sizeThatFitsMinimumSize:(CGSize)minimumSize - maximumSize:(CGSize)maximumSize +- (CGSize)sizeThatFitsMinimumSize:(CGSize)minimumSize maximumSize:(CGSize)maximumSize { - return [_surfacePresenter sizeThatFitsMinimumSize:minimumSize - maximumSize:maximumSize - surface:self]; + return [_surfacePresenter sizeThatFitsMinimumSize:minimumSize maximumSize:maximumSize surface:self]; } #pragma mark - Size Constraints @@ -204,13 +201,11 @@ [self setMinimumSize:size maximumSize:size]; } -- (void)setMinimumSize:(CGSize)minimumSize - maximumSize:(CGSize)maximumSize +- (void)setMinimumSize:(CGSize)minimumSize maximumSize:(CGSize)maximumSize { { std::lock_guard lock(_mutex); - if (CGSizeEqualToSize(minimumSize, _minimumSize) && - CGSizeEqualToSize(maximumSize, _maximumSize)) { + if (CGSizeEqualToSize(minimumSize, _minimumSize) && CGSizeEqualToSize(maximumSize, _maximumSize)) { return; } @@ -218,9 +213,7 @@ _minimumSize = minimumSize; } - [_surfacePresenter setMinimumSize:minimumSize - maximumSize:maximumSize - surface:self]; + [_surfacePresenter setMinimumSize:minimumSize maximumSize:maximumSize surface:self]; } - (CGSize)minimumSize diff --git a/React/Fabric/Surface/RCTFabricSurfaceHostingProxyRootView.h b/React/Fabric/Surface/RCTFabricSurfaceHostingProxyRootView.h index 53260fcf902..bd653909cea 100644 --- a/React/Fabric/Surface/RCTFabricSurfaceHostingProxyRootView.h +++ b/React/Fabric/Surface/RCTFabricSurfaceHostingProxyRootView.h @@ -13,4 +13,3 @@ @interface RCTFabricSurfaceHostingProxyRootView : RCTSurfaceHostingProxyRootView @end - diff --git a/React/Fabric/Surface/RCTFabricSurfaceHostingProxyRootView.mm b/React/Fabric/Surface/RCTFabricSurfaceHostingProxyRootView.mm index 115c7e2e03d..ac76e023ba4 100644 --- a/React/Fabric/Surface/RCTFabricSurfaceHostingProxyRootView.mm +++ b/React/Fabric/Surface/RCTFabricSurfaceHostingProxyRootView.mm @@ -11,9 +11,13 @@ @implementation RCTFabricSurfaceHostingProxyRootView -+ (RCTSurface *)createSurfaceWithBridge:(RCTBridge *)bridge moduleName:(NSString *)moduleName initialProperties:(NSDictionary *)initialProperties ++ (RCTSurface *)createSurfaceWithBridge:(RCTBridge *)bridge + moduleName:(NSString *)moduleName + initialProperties:(NSDictionary *)initialProperties { - return (RCTSurface *)[[RCTFabricSurface alloc] initWithBridge:bridge moduleName:moduleName initialProperties:initialProperties]; + return (RCTSurface *)[[RCTFabricSurface alloc] initWithBridge:bridge + moduleName:moduleName + initialProperties:initialProperties]; } @end diff --git a/React/Fabric/Surface/RCTFabricSurfaceHostingView.h b/React/Fabric/Surface/RCTFabricSurfaceHostingView.h index 8dbe3086944..76de83ea5ea 100644 --- a/React/Fabric/Surface/RCTFabricSurfaceHostingView.h +++ b/React/Fabric/Surface/RCTFabricSurfaceHostingView.h @@ -13,4 +13,3 @@ @interface RCTFabricSurfaceHostingView : RCTSurfaceHostingView @end - diff --git a/React/Fabric/Surface/RCTFabricSurfaceHostingView.mm b/React/Fabric/Surface/RCTFabricSurfaceHostingView.mm index fb07a87a996..ebc21df8c1a 100644 --- a/React/Fabric/Surface/RCTFabricSurfaceHostingView.mm +++ b/React/Fabric/Surface/RCTFabricSurfaceHostingView.mm @@ -25,4 +25,3 @@ } @end - diff --git a/React/Fabric/Utils/MainQueueExecutor.h b/React/Fabric/Utils/MainQueueExecutor.h index fabd81e895a..5864e58e8e6 100644 --- a/React/Fabric/Utils/MainQueueExecutor.h +++ b/React/Fabric/Utils/MainQueueExecutor.h @@ -10,10 +10,8 @@ namespace facebook { namespace react { -class MainQueueExecutor: - public folly::Executor { - -public: +class MainQueueExecutor : public folly::Executor { + public: static MainQueueExecutor &instance(); void add(folly::Func function) override; diff --git a/React/Fabric/Utils/MainQueueExecutor.mm b/React/Fabric/Utils/MainQueueExecutor.mm index 5cc411b3d7d..55749261d15 100644 --- a/React/Fabric/Utils/MainQueueExecutor.mm +++ b/React/Fabric/Utils/MainQueueExecutor.mm @@ -13,12 +13,14 @@ namespace facebook { namespace react { -MainQueueExecutor &MainQueueExecutor::instance() { +MainQueueExecutor &MainQueueExecutor::instance() +{ static auto instance = folly::Indestructible{}; return *instance; } -void MainQueueExecutor::add(folly::Func function) { +void MainQueueExecutor::add(folly::Func function) +{ __block folly::Func blockFunction = std::move(function); dispatch_async(dispatch_get_main_queue(), ^{ blockFunction(); diff --git a/React/Fabric/Utils/MainRunLoopEventBeat.h b/React/Fabric/Utils/MainRunLoopEventBeat.h index 30f9941e49a..eb7c94694fb 100644 --- a/React/Fabric/Utils/MainRunLoopEventBeat.h +++ b/React/Fabric/Utils/MainRunLoopEventBeat.h @@ -5,10 +5,10 @@ #pragma once -#include #include -#include +#include #include +#include namespace facebook { namespace react { @@ -17,16 +17,14 @@ namespace react { * Event beat associated with main run loop cycle. * The callback is always called on the main thread. */ -class MainRunLoopEventBeat final: - public EventBeat { - -public: +class MainRunLoopEventBeat final : public EventBeat { + public: MainRunLoopEventBeat(RuntimeExecutor runtimeExecutor); ~MainRunLoopEventBeat(); void induce() const override; -private: + private: void lockExecutorAndBeat() const; const RuntimeExecutor runtimeExecutor_; diff --git a/React/Fabric/Utils/MainRunLoopEventBeat.mm b/React/Fabric/Utils/MainRunLoopEventBeat.mm index d3bf8d553c5..1585e28a2a5 100644 --- a/React/Fabric/Utils/MainRunLoopEventBeat.mm +++ b/React/Fabric/Utils/MainRunLoopEventBeat.mm @@ -5,17 +5,16 @@ #import "MainRunLoopEventBeat.h" -#import #import +#import namespace facebook { namespace react { -MainRunLoopEventBeat::MainRunLoopEventBeat(RuntimeExecutor runtimeExecutor): - runtimeExecutor_(std::move(runtimeExecutor)) { - - mainRunLoopObserver_ = - CFRunLoopObserverCreateWithHandler( +MainRunLoopEventBeat::MainRunLoopEventBeat(RuntimeExecutor runtimeExecutor) + : runtimeExecutor_(std::move(runtimeExecutor)) +{ + mainRunLoopObserver_ = CFRunLoopObserverCreateWithHandler( NULL /* allocator */, kCFRunLoopBeforeWaiting /* activities */, true /* repeats */, @@ -26,20 +25,21 @@ MainRunLoopEventBeat::MainRunLoopEventBeat(RuntimeExecutor runtimeExecutor): } this->lockExecutorAndBeat(); - } - ); + }); assert(mainRunLoopObserver_); CFRunLoopAddObserver(CFRunLoopGetMain(), mainRunLoopObserver_, kCFRunLoopCommonModes); } -MainRunLoopEventBeat::~MainRunLoopEventBeat() { +MainRunLoopEventBeat::~MainRunLoopEventBeat() +{ CFRunLoopRemoveObserver(CFRunLoopGetMain(), mainRunLoopObserver_, kCFRunLoopCommonModes); CFRelease(mainRunLoopObserver_); } -void MainRunLoopEventBeat::induce() const { +void MainRunLoopEventBeat::induce() const +{ if (!this->isRequested_) { return; } @@ -49,7 +49,8 @@ void MainRunLoopEventBeat::induce() const { }); } -void MainRunLoopEventBeat::lockExecutorAndBeat() const { +void MainRunLoopEventBeat::lockExecutorAndBeat() const +{ // Note: We need the third mutex to get back to the main thread before // the lambda is finished (because all mutexes are allocated on the stack). diff --git a/React/Fabric/Utils/RuntimeEventBeat.h b/React/Fabric/Utils/RuntimeEventBeat.h index 1cb20e10ba0..ed7055a374a 100644 --- a/React/Fabric/Utils/RuntimeEventBeat.h +++ b/React/Fabric/Utils/RuntimeEventBeat.h @@ -5,10 +5,10 @@ * LICENSE file in the root directory of this source tree. */ -#include #include -#include +#include #include +#include namespace facebook { namespace react { @@ -18,19 +18,17 @@ namespace react { * The beat is called on `RuntimeExecutor`'s thread induced by the main thread * event loop. */ -class RuntimeEventBeat: - public EventBeat { - -public: +class RuntimeEventBeat : public EventBeat { + public: RuntimeEventBeat(RuntimeExecutor runtimeExecutor); ~RuntimeEventBeat(); void induce() const override; -private: + private: const RuntimeExecutor runtimeExecutor_; CFRunLoopObserverRef mainRunLoopObserver_; - mutable std::atomic isBusy_ {false}; + mutable std::atomic isBusy_{false}; }; } // namespace react diff --git a/React/Fabric/Utils/RuntimeEventBeat.mm b/React/Fabric/Utils/RuntimeEventBeat.mm index 042fe8ed16f..6b05f2c6094 100644 --- a/React/Fabric/Utils/RuntimeEventBeat.mm +++ b/React/Fabric/Utils/RuntimeEventBeat.mm @@ -10,11 +10,9 @@ namespace facebook { namespace react { -RuntimeEventBeat::RuntimeEventBeat(RuntimeExecutor runtimeExecutor): - runtimeExecutor_(std::move(runtimeExecutor)) { - - mainRunLoopObserver_ = - CFRunLoopObserverCreateWithHandler( +RuntimeEventBeat::RuntimeEventBeat(RuntimeExecutor runtimeExecutor) : runtimeExecutor_(std::move(runtimeExecutor)) +{ + mainRunLoopObserver_ = CFRunLoopObserverCreateWithHandler( NULL /* allocator */, kCFRunLoopBeforeWaiting /* activities */, true /* repeats */, @@ -23,20 +21,21 @@ RuntimeEventBeat::RuntimeEventBeat(RuntimeExecutor runtimeExecutor): // Note: We only `induce` beat here; actual beat will be performed on // a different thread. this->induce(); - } - ); + }); assert(mainRunLoopObserver_); CFRunLoopAddObserver(CFRunLoopGetMain(), mainRunLoopObserver_, kCFRunLoopCommonModes); } -RuntimeEventBeat::~RuntimeEventBeat() { +RuntimeEventBeat::~RuntimeEventBeat() +{ CFRunLoopRemoveObserver(CFRunLoopGetMain(), mainRunLoopObserver_, kCFRunLoopCommonModes); CFRelease(mainRunLoopObserver_); } -void RuntimeEventBeat::induce() const { +void RuntimeEventBeat::induce() const +{ if (!isRequested_ || isBusy_) { return; } @@ -49,7 +48,7 @@ void RuntimeEventBeat::induce() const { // This trick is quite expensive due to deallocation and messing with atomic // counters. Seems we need this only for making hot-reloading mechanism // thread-safe. Hence, let's leave it to be DEBUG-only for now. - auto wasExecuted = std::shared_ptr(new bool {false}, [this](bool *wasExecuted) { + auto wasExecuted = std::shared_ptr(new bool{false}, [this](bool *wasExecuted) { if (!*wasExecuted && failCallback_) { failCallback_(); } diff --git a/ReactCommon/fabric/uimanager/UITemplateProcessor.cpp b/ReactCommon/fabric/uimanager/UITemplateProcessor.cpp index ce1a4f5cb8d..4a245fa252a 100644 --- a/ReactCommon/fabric/uimanager/UITemplateProcessor.cpp +++ b/ReactCommon/fabric/uimanager/UITemplateProcessor.cpp @@ -12,9 +12,9 @@ #include #include #include +#include #include #include -#include #include #include