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
This commit is contained in:
Valentin Shergin
2019-02-11 13:07:09 -08:00
committed by Facebook Github Bot
parent 64d6ea8b0d
commit 1a26f97eb0
22 changed files with 145 additions and 165 deletions
@@ -30,7 +30,8 @@ NS_ASSUME_NONNULL_BEGIN
/**
* Creates a component view with given component handle.
*/
- (UIView<RCTComponentViewProtocol> *)createComponentViewWithComponentHandle:(facebook::react::ComponentHandle)componentHandle;
- (UIView<RCTComponentViewProtocol> *)createComponentViewWithComponentHandle:
(facebook::react::ComponentHandle)componentHandle;
@end
@@ -10,19 +10,18 @@
#import <React/RCTAssert.h>
#import <react/core/ReactPrimitives.h>
#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<ComponentHandle, Class<RCTComponentViewProtocol>> _registry;
}
@@ -52,14 +51,17 @@ using namespace facebook::react;
_registry[componentHandle] = componentViewClass;
}
- (UIView<RCTComponentViewProtocol> *)createComponentViewWithComponentHandle:(facebook::react::ComponentHandle)componentHandle
- (UIView<RCTComponentViewProtocol> *)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];
}
@@ -7,11 +7,11 @@
#import <UIKit/UIKit.h>
#import <React/RCTPrimitives.h>
#import <react/core/LayoutMetrics.h>
#import <react/core/LocalData.h>
#import <react/core/Props.h>
#import <react/core/LayoutMetrics.h>
#import <react/events/EventEmitter.h>
#import <React/RCTPrimitives.h>
NS_ASSUME_NONNULL_BEGIN
@@ -34,23 +34,20 @@ NS_ASSUME_NONNULL_BEGIN
* component view.
* Receiver must add `childComponentView` as a subview.
*/
- (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView
index:(NSInteger)index;
- (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)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<RCTComponentViewProtocol> *)childComponentView
index:(NSInteger)index;
- (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)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.
@@ -7,9 +7,9 @@
#import <UIKit/UIKit.h>
#import <react/core/ReactPrimitives.h>
#import <React/RCTComponentViewFactory.h>
#import <React/RCTComponentViewProtocol.h>
#import <react/core/ReactPrimitives.h>
NS_ASSUME_NONNULL_BEGIN
@@ -26,7 +26,8 @@ NS_ASSUME_NONNULL_BEGIN
* for given `componentHandle` and with given `tag`.
* #RefuseSingleUse
*/
- (UIView<RCTComponentViewProtocol> *)dequeueComponentViewWithComponentHandle:(facebook::react::ComponentHandle)componentHandle
- (UIView<RCTComponentViewProtocol> *)dequeueComponentViewWithComponentHandle:
(facebook::react::ComponentHandle)componentHandle
tag:(ReactTag)tag;
/**
@@ -16,8 +16,8 @@ using namespace facebook::react;
#ifdef LEGACY_UIMANAGER_INTEGRATION_ENABLED
#import <React/RCTUIManager.h>
#import <React/RCTBridge+Private.h>
#import <React/RCTUIManager.h>
/**
* 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<RCTComponentViewProtocol> *componentView =
[self _dequeueComponentViewWithComponentHandle:componentHandle];
UIView<RCTComponentViewProtocol> *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<RCTComponentViewProtocol> *)componentViewByTag:(ReactTag)tag
@@ -158,7 +160,7 @@ const NSInteger RCTComponentViewRegistryRecyclePoolMaxSize = 1024;
{
RCTAssertMainQueue();
NSHashTable<UIView<RCTComponentViewProtocol> *> *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<UIView<RCTComponentViewProtocol> *> *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];
+4 -5
View File
@@ -7,11 +7,11 @@
#import <UIKit/UIKit.h>
#import <React/RCTMountingManagerDelegate.h>
#import <React/RCTPrimitives.h>
#import <react/core/ReactPrimitives.h>
#import <react/mounting/ShadowView.h>
#import <react/mounting/ShadowViewMutation.h>
#import <React/RCTPrimitives.h>
#import <React/RCTMountingManagerDelegate.h>
NS_ASSUME_NONNULL_BEGIN
@@ -22,7 +22,7 @@ NS_ASSUME_NONNULL_BEGIN
*/
@interface RCTMountingManager : NSObject
@property (nonatomic, weak) id <RCTMountingManagerDelegate> delegate;
@property (nonatomic, weak) id<RCTMountingManagerDelegate> 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.
+41 -41
View File
@@ -7,24 +7,24 @@
#import "RCTMountingManager.h"
#import <react/core/LayoutableShadowNode.h>
#import <react/debug/SystraceSection.h>
#import <React/RCTAssert.h>
#import <React/RCTUtils.h>
#import <react/core/LayoutableShadowNode.h>
#import <react/debug/SystraceSection.h>
#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<RCTMountItemProtocol> *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<RCTMountItemProtocol> alloc] initWithCapacity:mutations.size() * 2 /* ~ the worst case */];
mountItems =
[[NSMutableArray<RCTMountItemProtocol> 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<RCTMountItemProtocol> *)mountItems
rootTag:(ReactTag)rootTag
- (void)_performMountItems:(NSArray<RCTMountItemProtocol> *)mountItems rootTag:(ReactTag)rootTag
{
SystraceSection s("-[RCTMountingManager _performMountItems:rootTag:]");
RCTAssertMainQueue();
@@ -9,7 +9,6 @@
#import <React/RCTComponentViewProtocol.h>
NS_ASSUME_NONNULL_BEGIN
/**
@@ -17,14 +16,11 @@ NS_ASSUME_NONNULL_BEGIN
*/
@interface UIView (ComponentViewProtocol)
- (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView
index:(NSInteger)index;
- (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index;
- (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView
index:(NSInteger)index;
- (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)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;
@@ -14,21 +14,18 @@ using namespace facebook::react;
@implementation UIView (ComponentViewProtocol)
- (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView
index:(NSInteger)index
- (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
{
[self insertSubview:childComponentView atIndex:index];
}
- (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView
index:(NSInteger)index
- (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)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) {
+2 -4
View File
@@ -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
+7 -14
View File
@@ -12,9 +12,9 @@
#import <React/RCTAssert.h>
#import <React/RCTSurfaceDelegate.h>
#import <React/RCTSurfaceRootView.h>
#import <React/RCTSurfaceView.h>
#import <React/RCTSurfaceView+Internal.h>
#import <React/RCTSurfaceTouchHandler.h>
#import <React/RCTSurfaceView+Internal.h>
#import <React/RCTSurfaceView.h>
#import <React/RCTUIManagerUtils.h>
#import <React/RCTUtils.h>
@@ -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<std::mutex> 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
@@ -13,4 +13,3 @@
@interface RCTFabricSurfaceHostingProxyRootView : RCTSurfaceHostingProxyRootView
@end
@@ -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
@@ -13,4 +13,3 @@
@interface RCTFabricSurfaceHostingView : RCTSurfaceHostingView
@end
@@ -25,4 +25,3 @@
}
@end
+2 -4
View File
@@ -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;
+4 -2
View File
@@ -13,12 +13,14 @@
namespace facebook {
namespace react {
MainQueueExecutor &MainQueueExecutor::instance() {
MainQueueExecutor &MainQueueExecutor::instance()
{
static auto instance = folly::Indestructible<MainQueueExecutor>{};
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();
+5 -7
View File
@@ -5,10 +5,10 @@
#pragma once
#include <CoreFoundation/CoreFoundation.h>
#include <CoreFoundation/CFRunLoop.h>
#include <react/uimanager/primitives.h>
#include <CoreFoundation/CoreFoundation.h>
#include <react/events/EventBeat.h>
#include <react/uimanager/primitives.h>
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_;
+12 -11
View File
@@ -5,17 +5,16 @@
#import "MainRunLoopEventBeat.h"
#import <mutex>
#import <React/RCTUtils.h>
#import <mutex>
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).
+6 -8
View File
@@ -5,10 +5,10 @@
* LICENSE file in the root directory of this source tree.
*/
#include <CoreFoundation/CoreFoundation.h>
#include <CoreFoundation/CFRunLoop.h>
#include <react/uimanager/primitives.h>
#include <CoreFoundation/CoreFoundation.h>
#include <react/events/EventBeat.h>
#include <react/uimanager/primitives.h>
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<bool> isBusy_ {false};
mutable std::atomic<bool> isBusy_{false};
};
} // namespace react
+9 -10
View File
@@ -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<bool>(new bool {false}, [this](bool *wasExecuted) {
auto wasExecuted = std::shared_ptr<bool>(new bool{false}, [this](bool *wasExecuted) {
if (!*wasExecuted && failCallback_) {
failCallback_();
}
@@ -12,9 +12,9 @@
#include <react/components/view/ViewComponentDescriptor.h>
#include <react/components/view/ViewProps.h>
#include <react/components/view/ViewShadowNode.h>
#include <react/core/ComponentDescriptor.h>
#include <react/core/LayoutContext.h>
#include <react/core/ShadowNodeFragment.h>
#include <react/core/ComponentDescriptor.h>
#include <react/debug/DebugStringConvertible.h>
#include <react/debug/DebugStringConvertibleItem.h>