Apply clang-format update fixes

Reviewed By: igorsugak

Differential Revision: D25861683

fbshipit-source-id: 616afca13ae64c76421053ce49286035e0687e36
This commit is contained in:
Andres Suarez 2021-01-09 22:09:03 -08:00 коммит произвёл Facebook GitHub Bot
Родитель e3a05c9e3e
Коммит 0f4f917663
65 изменённых файлов: 570 добавлений и 500 удалений

Просмотреть файл

@ -154,13 +154,12 @@ RCT_EXTERN NSString *RCTFormatStackTrace(NSArray<NSDictionary<NSString *, id> *>
*/
#if DEBUG
#define RCTAssertThread(thread, format...) \
_Pragma("clang diagnostic push") _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") RCTAssert( \
[(id)thread isKindOfClass:[NSString class]] \
? [RCTCurrentThreadName() isEqualToString:(NSString *)thread] \
: [(id)thread isKindOfClass:[NSThread class]] ? [NSThread currentThread] == (NSThread *)thread \
: dispatch_get_current_queue() == (dispatch_queue_t)thread, \
format); \
#define RCTAssertThread(thread, format...) \
_Pragma("clang diagnostic push") _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") RCTAssert( \
[(id)thread isKindOfClass:[NSString class]] ? [RCTCurrentThreadName() isEqualToString:(NSString *)thread] \
: [(id)thread isKindOfClass:[NSThread class]] ? [NSThread currentThread] == (NSThread *)thread \
: dispatch_get_current_queue() == (dispatch_queue_t)thread, \
format); \
_Pragma("clang diagnostic pop")
#else

Просмотреть файл

@ -167,8 +167,12 @@ id RCTJSONClean(id object)
static dispatch_once_t onceToken;
static NSSet<Class> *validLeafTypes;
dispatch_once(&onceToken, ^{
validLeafTypes =
[[NSSet alloc] initWithArray:@ [[NSString class], [NSMutableString class], [NSNumber class], [NSNull class], ]];
validLeafTypes = [[NSSet alloc] initWithArray:@[
[NSString class],
[NSMutableString class],
[NSNumber class],
[NSNull class],
]];
});
if ([validLeafTypes containsObject:[object classForCoder]]) {

Просмотреть файл

@ -96,16 +96,17 @@ RCT_EXPORT_METHOD(showActionSheetWithOptions
UIColor *tintColor = [RCTConvert UIColor:options.tintColor() ? @(*options.tintColor()) : nil];
if (controller == nil) {
RCTLogError(@"Tried to display action sheet but there is no application window. options: %@", @{
@"title" : title,
@"message" : message,
@"options" : buttons,
@"cancelButtonIndex" : @(cancelButtonIndex),
@"destructiveButtonIndices" : destructiveButtonIndices,
@"anchor" : anchor,
@"tintColor" : tintColor,
@"disabledButtonIndices" : disabledButtonIndices,
});
RCTLogError(
@"Tried to display action sheet but there is no application window. options: %@", @{
@"title" : title,
@"message" : message,
@"options" : buttons,
@"cancelButtonIndex" : @(cancelButtonIndex),
@"destructiveButtonIndices" : destructiveButtonIndices,
@"anchor" : anchor,
@"tintColor" : tintColor,
@"disabledButtonIndices" : disabledButtonIndices,
});
return;
}

Просмотреть файл

@ -318,9 +318,9 @@ RCT_EXPORT_MODULE()
if (devSettings.isLiveReloadAvailable) {
[items addObject:[RCTDevMenuItem
buttonItemWithTitleBlock:^NSString * {
return devSettings.isDebuggingRemotely
? @"Systrace Unavailable"
: devSettings.isProfilingEnabled ? @"Stop Systrace" : @"Start Systrace";
return devSettings.isDebuggingRemotely ? @"Systrace Unavailable"
: devSettings.isProfilingEnabled ? @"Stop Systrace"
: @"Start Systrace";
}
handler:^{
if (devSettings.isDebuggingRemotely) {

Просмотреть файл

@ -160,11 +160,12 @@ using namespace facebook::react;
reusingView:(UILabel *)label
{
if (!label) {
label = [[UILabel alloc] initWithFrame:(CGRect){CGPointZero,
{
[pickerView rowSizeForComponent:component].width,
[pickerView rowSizeForComponent:component].height,
}}];
label = [[UILabel alloc] initWithFrame:(CGRect){
CGPointZero,
{
[pickerView rowSizeForComponent:component].width,
[pickerView rowSizeForComponent:component].height,
}}];
}
NSMutableDictionary<NSAttributedStringKey, id> *attributes = [_textAttributes mutableCopy];
// Color can be passed in from <Picker style={}/> or from <Picker.Item color={}/>

Просмотреть файл

@ -224,9 +224,9 @@
// Pick snap point based on direction and proximity
CGFloat fractionalIndex = (targetContentOffsetAlongAxis + alignmentOffset) / snapToIntervalF;
NSInteger snapIndex = velocityAlongAxis > 0.0
? ceil(fractionalIndex)
: velocityAlongAxis < 0.0 ? floor(fractionalIndex) : round(fractionalIndex);
NSInteger snapIndex = velocityAlongAxis > 0.0 ? ceil(fractionalIndex)
: velocityAlongAxis < 0.0 ? floor(fractionalIndex)
: round(fractionalIndex);
CGFloat newTargetContentOffset = (snapIndex * snapToIntervalF) - alignmentOffset;
// Set new targetContentOffset

Просмотреть файл

@ -74,8 +74,9 @@ using namespace facebook::react;
+ (std::vector<facebook::react::ComponentDescriptorProvider>)supplementalComponentDescriptorProviders
{
return {concreteComponentDescriptorProvider<RawTextComponentDescriptor>(),
concreteComponentDescriptorProvider<TextComponentDescriptor>()};
return {
concreteComponentDescriptorProvider<RawTextComponentDescriptor>(),
concreteComponentDescriptorProvider<TextComponentDescriptor>()};
}
- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps

Просмотреть файл

@ -174,10 +174,11 @@ using namespace facebook::react;
// `hitSlop`
if (oldViewProps.hitSlop != newViewProps.hitSlop) {
self.hitTestEdgeInsets = {-newViewProps.hitSlop.top,
-newViewProps.hitSlop.left,
-newViewProps.hitSlop.bottom,
-newViewProps.hitSlop.right};
self.hitTestEdgeInsets = {
-newViewProps.hitSlop.top,
-newViewProps.hitSlop.left,
-newViewProps.hitSlop.bottom,
-newViewProps.hitSlop.right};
}
// `overflow`
@ -372,18 +373,20 @@ using namespace facebook::react;
static RCTCornerRadii RCTCornerRadiiFromBorderRadii(BorderRadii borderRadii)
{
return RCTCornerRadii{.topLeft = (CGFloat)borderRadii.topLeft,
.topRight = (CGFloat)borderRadii.topRight,
.bottomLeft = (CGFloat)borderRadii.bottomLeft,
.bottomRight = (CGFloat)borderRadii.bottomRight};
return RCTCornerRadii{
.topLeft = (CGFloat)borderRadii.topLeft,
.topRight = (CGFloat)borderRadii.topRight,
.bottomLeft = (CGFloat)borderRadii.bottomLeft,
.bottomRight = (CGFloat)borderRadii.bottomRight};
}
static RCTBorderColors RCTCreateRCTBorderColorsFromBorderColors(BorderColors borderColors)
{
return RCTBorderColors{.top = RCTCreateCGColorRefFromSharedColor(borderColors.top),
.left = RCTCreateCGColorRefFromSharedColor(borderColors.left),
.bottom = RCTCreateCGColorRefFromSharedColor(borderColors.bottom),
.right = RCTCreateCGColorRefFromSharedColor(borderColors.right)};
return RCTBorderColors{
.top = RCTCreateCGColorRefFromSharedColor(borderColors.top),
.left = RCTCreateCGColorRefFromSharedColor(borderColors.left),
.bottom = RCTCreateCGColorRefFromSharedColor(borderColors.bottom),
.right = RCTCreateCGColorRefFromSharedColor(borderColors.right)};
}
static void RCTReleaseRCTBorderColors(RCTBorderColors borderColors)
@ -491,9 +494,9 @@ static RCTBorderStyle RCTBorderStyleFromBorderStyle(BorderStyle borderStyle)
} else {
CGSize imageSize = image.size;
UIEdgeInsets imageCapInsets = image.capInsets;
CGRect contentsCenter =
CGRect{CGPoint{imageCapInsets.left / imageSize.width, imageCapInsets.top / imageSize.height},
CGSize{(CGFloat)1.0 / imageSize.width, (CGFloat)1.0 / imageSize.height}};
CGRect contentsCenter = CGRect{
CGPoint{imageCapInsets.left / imageSize.width, imageCapInsets.top / imageSize.height},
CGSize{(CGFloat)1.0 / imageSize.width, (CGFloat)1.0 / imageSize.height}};
_borderLayer.contents = (id)image.CGImage;
_borderLayer.contentsScale = image.scale;

Просмотреть файл

@ -146,22 +146,23 @@ inline UIAccessibilityTraits RCTUIAccessibilityTraitsFromAccessibilityTraits(
inline CATransform3D RCTCATransform3DFromTransformMatrix(const facebook::react::Transform &transformMatrix)
{
return {(CGFloat)transformMatrix.matrix[0],
(CGFloat)transformMatrix.matrix[1],
(CGFloat)transformMatrix.matrix[2],
(CGFloat)transformMatrix.matrix[3],
(CGFloat)transformMatrix.matrix[4],
(CGFloat)transformMatrix.matrix[5],
(CGFloat)transformMatrix.matrix[6],
(CGFloat)transformMatrix.matrix[7],
(CGFloat)transformMatrix.matrix[8],
(CGFloat)transformMatrix.matrix[9],
(CGFloat)transformMatrix.matrix[10],
(CGFloat)transformMatrix.matrix[11],
(CGFloat)transformMatrix.matrix[12],
(CGFloat)transformMatrix.matrix[13],
(CGFloat)transformMatrix.matrix[14],
(CGFloat)transformMatrix.matrix[15]};
return {
(CGFloat)transformMatrix.matrix[0],
(CGFloat)transformMatrix.matrix[1],
(CGFloat)transformMatrix.matrix[2],
(CGFloat)transformMatrix.matrix[3],
(CGFloat)transformMatrix.matrix[4],
(CGFloat)transformMatrix.matrix[5],
(CGFloat)transformMatrix.matrix[6],
(CGFloat)transformMatrix.matrix[7],
(CGFloat)transformMatrix.matrix[8],
(CGFloat)transformMatrix.matrix[9],
(CGFloat)transformMatrix.matrix[10],
(CGFloat)transformMatrix.matrix[11],
(CGFloat)transformMatrix.matrix[12],
(CGFloat)transformMatrix.matrix[13],
(CGFloat)transformMatrix.matrix[14],
(CGFloat)transformMatrix.matrix[15]};
}
inline facebook::react::Point RCTPointFromCGPoint(const CGPoint &point)

Просмотреть файл

@ -89,8 +89,8 @@ class LayoutAnimationDelegateProxy : public LayoutAnimationStatusDelegate, publi
[scheduler onAllAnimationsComplete];
}
void activityDidChange(RunLoopObserver::Delegate const *delegate, RunLoopObserver::Activity activity) const
noexcept override
void activityDidChange(RunLoopObserver::Delegate const *delegate, RunLoopObserver::Activity activity)
const noexcept override
{
RCTScheduler *scheduler = (__bridge RCTScheduler *)scheduler_;
[scheduler animationTick];

Просмотреть файл

@ -51,11 +51,12 @@ static inline LayoutConstraints RCTGetLayoutConstraintsForSize(CGSize minimumSiz
static inline LayoutContext RCTGetLayoutContext(CGPoint viewportOffset)
{
return {.pointScaleFactor = RCTScreenScale(),
.swapLeftAndRightInRTL =
[[RCTI18nUtil sharedInstance] isRTL] && [[RCTI18nUtil sharedInstance] doLeftAndRightSwapInRTL],
.fontSizeMultiplier = RCTFontSizeMultiplier(),
.viewportOffset = RCTPointFromCGPoint(viewportOffset)};
return {
.pointScaleFactor = RCTScreenScale(),
.swapLeftAndRightInRTL =
[[RCTI18nUtil sharedInstance] isRTL] && [[RCTI18nUtil sharedInstance] doLeftAndRightSwapInRTL],
.fontSizeMultiplier = RCTFontSizeMultiplier(),
.viewportOffset = RCTPointFromCGPoint(viewportOffset)};
}
static dispatch_queue_t RCTGetBackgroundQueue()

Просмотреть файл

@ -555,11 +555,12 @@ static NSDictionary *deviceOrientationEventBody(UIDeviceOrientation orientation)
for (RCTShadowView *shadowView in affectedShadowViews) {
reactTags[index] = shadowView.reactTag;
RCTLayoutMetrics layoutMetrics = shadowView.layoutMetrics;
frameDataArray[index++] = (RCTFrameData){layoutMetrics.frame,
layoutMetrics.layoutDirection,
shadowView.isNewView,
shadowView.superview.isNewView,
layoutMetrics.displayType};
frameDataArray[index++] = (RCTFrameData){
layoutMetrics.frame,
layoutMetrics.layoutDirection,
shadowView.isNewView,
shadowView.superview.isNewView,
layoutMetrics.displayType};
}
}

Просмотреть файл

@ -469,14 +469,15 @@ void RCTProfileInit(RCTBridge *bridge)
NSArray *orderedThreads =
@[ @"JS async", @"RCTPerformanceLogger", @"com.facebook.react.JavaScript", @(RCTUIManagerQueueName), @"main" ];
[orderedThreads enumerateObjectsUsingBlock:^(NSString *thread, NSUInteger idx, __unused BOOL *stop) {
RCTProfileAddEvent(kProfileTraceEvents,
@"ph"
: @"M", // metadata event
@"name"
: @"thread_sort_index", @"tid"
: thread, @"args"
:
@{@"sort_index" : @(-1000 + (NSInteger)idx)});
RCTProfileAddEvent(
kProfileTraceEvents,
@"ph"
: @"M", // metadata event
@"name"
: @"thread_sort_index", @"tid"
: thread, @"args"
:
@{@"sort_index" : @(-1000 + (NSInteger)idx)});
}];
});

Просмотреть файл

@ -33,22 +33,23 @@ BOOL RCTBorderColorsAreEqual(RCTBorderColors borderColors)
RCTCornerInsets RCTGetCornerInsets(RCTCornerRadii cornerRadii, UIEdgeInsets edgeInsets)
{
return (RCTCornerInsets){{
MAX(0, cornerRadii.topLeft - edgeInsets.left),
MAX(0, cornerRadii.topLeft - edgeInsets.top),
},
{
MAX(0, cornerRadii.topRight - edgeInsets.right),
MAX(0, cornerRadii.topRight - edgeInsets.top),
},
{
MAX(0, cornerRadii.bottomLeft - edgeInsets.left),
MAX(0, cornerRadii.bottomLeft - edgeInsets.bottom),
},
{
MAX(0, cornerRadii.bottomRight - edgeInsets.right),
MAX(0, cornerRadii.bottomRight - edgeInsets.bottom),
}};
return (RCTCornerInsets){
{
MAX(0, cornerRadii.topLeft - edgeInsets.left),
MAX(0, cornerRadii.topLeft - edgeInsets.top),
},
{
MAX(0, cornerRadii.topRight - edgeInsets.right),
MAX(0, cornerRadii.topRight - edgeInsets.top),
},
{
MAX(0, cornerRadii.bottomLeft - edgeInsets.left),
MAX(0, cornerRadii.bottomLeft - edgeInsets.bottom),
},
{
MAX(0, cornerRadii.bottomRight - edgeInsets.right),
MAX(0, cornerRadii.bottomRight - edgeInsets.bottom),
}};
}
static UIEdgeInsets RCTRoundInsetsToPixel(UIEdgeInsets edgeInsets)
@ -206,11 +207,11 @@ static UIImage *RCTGetSolidBorderImage(
(borderInsets.top + cornerInsets.topRight.height + borderInsets.bottom + cornerInsets.bottomLeft.height <=
viewSize.height);
UIEdgeInsets edgeInsets =
(UIEdgeInsets){borderInsets.top + MAX(cornerInsets.topLeft.height, cornerInsets.topRight.height),
borderInsets.left + MAX(cornerInsets.topLeft.width, cornerInsets.bottomLeft.width),
borderInsets.bottom + MAX(cornerInsets.bottomLeft.height, cornerInsets.bottomRight.height),
borderInsets.right + MAX(cornerInsets.bottomRight.width, cornerInsets.topRight.width)};
UIEdgeInsets edgeInsets = (UIEdgeInsets){
borderInsets.top + MAX(cornerInsets.topLeft.height, cornerInsets.topRight.height),
borderInsets.left + MAX(cornerInsets.topLeft.width, cornerInsets.bottomLeft.width),
borderInsets.bottom + MAX(cornerInsets.bottomLeft.height, cornerInsets.bottomRight.height),
borderInsets.right + MAX(cornerInsets.bottomRight.width, cornerInsets.topRight.width)};
if (hasCornerRadii) {
// Asymmetrical edgeInsets cause strange artifacting on iOS 10 and earlier.
@ -271,8 +272,9 @@ static UIImage *RCTGetSolidBorderImage(
if (cornerInsets.bottomLeft.width > 0 && cornerInsets.bottomLeft.height > 0) {
CGPoint points[2];
RCTEllipseGetIntersectionsWithLine(
(CGRect){{bottomLeft.x, bottomLeft.y - 2 * cornerInsets.bottomLeft.height},
{2 * cornerInsets.bottomLeft.width, 2 * cornerInsets.bottomLeft.height}},
(CGRect){
{bottomLeft.x, bottomLeft.y - 2 * cornerInsets.bottomLeft.height},
{2 * cornerInsets.bottomLeft.width, 2 * cornerInsets.bottomLeft.height}},
(CGPoint){0, size.height},
bottomLeft,
points);
@ -285,8 +287,9 @@ static UIImage *RCTGetSolidBorderImage(
if (cornerInsets.topRight.width > 0 && cornerInsets.topRight.height > 0) {
CGPoint points[2];
RCTEllipseGetIntersectionsWithLine(
(CGRect){{topRight.x - 2 * cornerInsets.topRight.width, topRight.y},
{2 * cornerInsets.topRight.width, 2 * cornerInsets.topRight.height}},
(CGRect){
{topRight.x - 2 * cornerInsets.topRight.width, topRight.y},
{2 * cornerInsets.topRight.width, 2 * cornerInsets.topRight.height}},
(CGPoint){size.width, 0},
topRight,
points);

Просмотреть файл

@ -15,8 +15,8 @@ RCT_CONVERTER(CLLocationDistance, CLLocationDistance, doubleValue);
+ (CLLocationCoordinate2D)CLLocationCoordinate2D:(id)json
{
json = [self NSDictionary:json];
return (CLLocationCoordinate2D){[self CLLocationDegrees:json[@"latitude"]],
[self CLLocationDegrees:json[@"longitude"]]};
return (CLLocationCoordinate2D){
[self CLLocationDegrees:json[@"latitude"]], [self CLLocationDegrees:json[@"longitude"]]};
}
@end

Просмотреть файл

@ -14,27 +14,31 @@ RCTLayoutMetrics RCTLayoutMetricsFromYogaNode(YGNodeRef yogaNode)
{
RCTLayoutMetrics layoutMetrics;
CGRect frame = (CGRect){(CGPoint){RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetLeft(yogaNode)),
RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetTop(yogaNode))},
(CGSize){RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetWidth(yogaNode)),
RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetHeight(yogaNode))}};
CGRect frame = (CGRect){
(CGPoint){
RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetLeft(yogaNode)),
RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetTop(yogaNode))},
(CGSize){
RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetWidth(yogaNode)),
RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetHeight(yogaNode))}};
UIEdgeInsets padding =
(UIEdgeInsets){RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetPadding(yogaNode, YGEdgeTop)),
RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetPadding(yogaNode, YGEdgeLeft)),
RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetPadding(yogaNode, YGEdgeBottom)),
RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetPadding(yogaNode, YGEdgeRight))};
UIEdgeInsets padding = (UIEdgeInsets){
RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetPadding(yogaNode, YGEdgeTop)),
RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetPadding(yogaNode, YGEdgeLeft)),
RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetPadding(yogaNode, YGEdgeBottom)),
RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetPadding(yogaNode, YGEdgeRight))};
UIEdgeInsets borderWidth =
(UIEdgeInsets){RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetBorder(yogaNode, YGEdgeTop)),
RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetBorder(yogaNode, YGEdgeLeft)),
RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetBorder(yogaNode, YGEdgeBottom)),
RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetBorder(yogaNode, YGEdgeRight))};
UIEdgeInsets borderWidth = (UIEdgeInsets){
RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetBorder(yogaNode, YGEdgeTop)),
RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetBorder(yogaNode, YGEdgeLeft)),
RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetBorder(yogaNode, YGEdgeBottom)),
RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetBorder(yogaNode, YGEdgeRight))};
UIEdgeInsets compoundInsets = (UIEdgeInsets){borderWidth.top + padding.top,
borderWidth.left + padding.left,
borderWidth.bottom + padding.bottom,
borderWidth.right + padding.right};
UIEdgeInsets compoundInsets = (UIEdgeInsets){
borderWidth.top + padding.top,
borderWidth.left + padding.left,
borderWidth.bottom + padding.bottom,
borderWidth.right + padding.right};
CGRect bounds = (CGRect){CGPointZero, frame.size};
CGRect contentFrame = UIEdgeInsetsInsetRect(bounds, compoundInsets);

Просмотреть файл

@ -82,11 +82,12 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder : (NSCoder *)aDecoder)
reusingView:(UILabel *)label
{
if (!label) {
label = [[UILabel alloc] initWithFrame:(CGRect){CGPointZero,
{
[pickerView rowSizeForComponent:component].width,
[pickerView rowSizeForComponent:component].height,
}}];
label = [[UILabel alloc] initWithFrame:(CGRect){
CGPointZero,
{
[pickerView rowSizeForComponent:component].width,
[pickerView rowSizeForComponent:component].height,
}}];
}
label.font = _font;

Просмотреть файл

@ -18,19 +18,21 @@
- (UIEdgeInsets)paddingAsInsets
{
YGNodeRef yogaNode = self.yogaNode;
return (UIEdgeInsets){RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetPadding(yogaNode, YGEdgeTop)),
RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetPadding(yogaNode, YGEdgeLeft)),
RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetPadding(yogaNode, YGEdgeBottom)),
RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetPadding(yogaNode, YGEdgeRight))};
return (UIEdgeInsets){
RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetPadding(yogaNode, YGEdgeTop)),
RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetPadding(yogaNode, YGEdgeLeft)),
RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetPadding(yogaNode, YGEdgeBottom)),
RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetPadding(yogaNode, YGEdgeRight))};
}
- (UIEdgeInsets)borderAsInsets
{
YGNodeRef yogaNode = self.yogaNode;
return (UIEdgeInsets){RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetBorder(yogaNode, YGEdgeTop)),
RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetBorder(yogaNode, YGEdgeLeft)),
RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetBorder(yogaNode, YGEdgeBottom)),
RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetBorder(yogaNode, YGEdgeRight))};
return (UIEdgeInsets){
RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetBorder(yogaNode, YGEdgeTop)),
RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetBorder(yogaNode, YGEdgeLeft)),
RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetBorder(yogaNode, YGEdgeBottom)),
RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetBorder(yogaNode, YGEdgeRight))};
}
- (UIEdgeInsets)compoundInsets
@ -38,10 +40,11 @@
UIEdgeInsets borderAsInsets = self.borderAsInsets;
UIEdgeInsets paddingAsInsets = self.paddingAsInsets;
return (UIEdgeInsets){borderAsInsets.top + paddingAsInsets.top,
borderAsInsets.left + paddingAsInsets.left,
borderAsInsets.bottom + paddingAsInsets.bottom,
borderAsInsets.right + paddingAsInsets.right};
return (UIEdgeInsets){
borderAsInsets.top + paddingAsInsets.top,
borderAsInsets.left + paddingAsInsets.left,
borderAsInsets.bottom + paddingAsInsets.bottom,
borderAsInsets.right + paddingAsInsets.right};
}
- (CGSize)availableSize

Просмотреть файл

@ -267,8 +267,9 @@ static void RCTProcessMetaPropsBorder(const YGValue metaProps[META_PROP_COUNT],
{
YGNodeRef yogaNode = _yogaNode;
CGSize oldMinimumSize = (CGSize){RCTCoreGraphicsFloatFromYogaValue(YGNodeStyleGetMinWidth(yogaNode), 0.0),
RCTCoreGraphicsFloatFromYogaValue(YGNodeStyleGetMinHeight(yogaNode), 0.0)};
CGSize oldMinimumSize = (CGSize){
RCTCoreGraphicsFloatFromYogaValue(YGNodeStyleGetMinWidth(yogaNode), 0.0),
RCTCoreGraphicsFloatFromYogaValue(YGNodeStyleGetMinHeight(yogaNode), 0.0)};
if (!CGSizeEqualToSize(oldMinimumSize, minimumSize)) {
YGNodeStyleSetMinWidth(yogaNode, RCTYogaFloatFromCoreGraphicsFloat(minimumSize.width));

Просмотреть файл

@ -714,9 +714,9 @@ RCT_SCROLL_EVENT_HANDLER(scrollViewDidScrollToTop, onScrollToTop)
// Pick snap point based on direction and proximity
CGFloat fractionalIndex = (targetContentOffsetAlongAxis + alignmentOffset) / snapToIntervalF;
NSInteger snapIndex = velocityAlongAxis > 0.0
? ceil(fractionalIndex)
: velocityAlongAxis < 0.0 ? floor(fractionalIndex) : round(fractionalIndex);
NSInteger snapIndex = velocityAlongAxis > 0.0 ? ceil(fractionalIndex)
: velocityAlongAxis < 0.0 ? floor(fractionalIndex)
: round(fractionalIndex);
CGFloat newTargetContentOffset = (snapIndex * snapToIntervalF) - alignmentOffset;
// Set new targetContentOffset

Просмотреть файл

@ -204,7 +204,7 @@ static inline RefPtr<T> adoptRef(T *ptr) {
}
template <typename T, typename... Args>
static inline RefPtr<T> createNew(Args &&... arguments) {
static inline RefPtr<T> createNew(Args &&...arguments) {
return RefPtr<T>::adoptRef(new T(std::forward<Args>(arguments)...));
}

Просмотреть файл

@ -21,7 +21,7 @@ class StaticInitialized {
constexpr StaticInitialized() : m_instance(nullptr) {}
template <typename... Args>
void initialize(Args &&... arguments) {
void initialize(Args &&...arguments) {
FBASSERT(!m_instance);
m_instance = new T(std::forward<Args>(arguments)...);
}

Просмотреть файл

@ -14,7 +14,7 @@ namespace xplat {
namespace detail {
template <typename R, typename M, typename... T>
R jsArg1(const folly::dynamic &arg, M asFoo, const T &... desc) {
R jsArg1(const folly::dynamic &arg, M asFoo, const T &...desc) {
try {
return (arg.*asFoo)();
} catch (const folly::TypeError &ex) {
@ -35,7 +35,7 @@ template <typename R, typename... T>
R jsArg(
const folly::dynamic &arg,
R (folly::dynamic::*asFoo)() const,
const T &... desc) {
const T &...desc) {
return detail::jsArg1<R>(arg, asFoo, desc...);
}
@ -43,7 +43,7 @@ template <typename R, typename... T>
R jsArg(
const folly::dynamic &arg,
R (folly::dynamic::*asFoo)() const &,
const T &... desc) {
const T &...desc) {
return detail::jsArg1<R>(arg, asFoo, desc...);
}

Просмотреть файл

@ -39,12 +39,12 @@ template <typename R, typename... T>
R jsArg(
const folly::dynamic &arg,
R (folly::dynamic::*asFoo)() const,
const T &... desc);
const T &...desc);
template <typename R, typename... T>
R jsArg(
const folly::dynamic &arg,
R (folly::dynamic::*asFoo)() const &,
const T &... desc);
const T &...desc);
// This is like jsArg, but a operates on a dynamic representing an array of
// arguments. The argument n is used both to index the array and build the

Просмотреть файл

@ -29,7 +29,7 @@ struct ConcreteSystraceSection {
template <typename... ConvertsToStringPiece>
explicit ConcreteSystraceSection(
const char *name,
ConvertsToStringPiece &&... args)
ConvertsToStringPiece &&...args)
: m_section(TRACE_TAG_REACT_CXX_BRIDGE, name, args...) {}
private:
@ -42,7 +42,7 @@ struct DummySystraceSection {
template <typename... ConvertsToStringPiece>
explicit DummySystraceSection(
__unused const char *name,
__unused ConvertsToStringPiece &&... args) {}
__unused ConvertsToStringPiece &&...args) {}
};
using SystraceSection = DummySystraceSection;
#endif

Просмотреть файл

@ -299,9 +299,10 @@ void InspectorState::Running::pushPendingEval(
std::shared_ptr<folly::Promise<debugger::EvalResult>> promise,
folly::Function<void(const facebook::hermes::debugger::EvalResult &)>
resultTransformer) {
PendingEval pendingEval{debugger::Command::eval(src, frameIndex),
promise,
std::move(resultTransformer)};
PendingEval pendingEval{
debugger::Command::eval(src, frameIndex),
promise,
std::move(resultTransformer)};
pendingEvals_.emplace(std::move(pendingEval));
@ -476,9 +477,10 @@ void InspectorState::Paused::pushPendingEval(
return;
}
PendingEval pendingEval{debugger::Command::eval(src, frameIndex),
promise,
std::move(resultTransformer)};
PendingEval pendingEval{
debugger::Command::eval(src, frameIndex),
promise,
std::move(resultTransformer)};
pendingEvals_.emplace(std::move(pendingEval));
hasPendingWork_.notify_one();
}

Просмотреть файл

@ -156,8 +156,8 @@ static void sendResponse(const std::string &str) {
static std::string readScriptSource(const char *path) {
std::ifstream stream(path);
return std::string{std::istreambuf_iterator<char>(stream),
std::istreambuf_iterator<char>()};
return std::string{
std::istreambuf_iterator<char>(stream), std::istreambuf_iterator<char>()};
}
static std::string getUrl(const char *path) {
@ -228,9 +228,10 @@ static void runScript(const std::string &scriptSource, const std::string &url) {
int main(int argc, char **argv) {
const char *shortOpts = "l:h";
const option longOpts[] = {{"log", 1, nullptr, 'l'},
{"help", 0, nullptr, 'h'},
{nullptr, 0, nullptr, 0}};
const option longOpts[] = {
{"log", 1, nullptr, 'l'},
{"help", 0, nullptr, 'h'},
{nullptr, 0, nullptr, 0}};
while (true) {
int opt = getopt_long(argc, argv, shortOpts, longOpts, nullptr);

Просмотреть файл

@ -6,6 +6,7 @@
*/
#include <jsi/test/testlib.h>
#include <gtest/gtest.h>
#include <jsi/decorator.h>
#include <jsi/jsi.h>

Просмотреть файл

@ -119,12 +119,12 @@ void LayoutAnimationDriver::animationMutationsForFrame(
// Copy so that if something else mutates the inflight animations, it
// won't change this mutation after this point.
auto mutation =
ShadowViewMutation{finalMutationForKeyFrame.type,
finalMutationForKeyFrame.parentShadowView,
keyframe.viewPrev,
finalMutationForKeyFrame.newChildShadowView,
finalMutationForKeyFrame.index};
auto mutation = ShadowViewMutation{
finalMutationForKeyFrame.type,
finalMutationForKeyFrame.parentShadowView,
keyframe.viewPrev,
finalMutationForKeyFrame.newChildShadowView,
finalMutationForKeyFrame.index};
assert(mutation.oldChildShadowView.tag != 0);
assert(
mutation.newChildShadowView.tag != 0 ||
@ -136,11 +136,12 @@ void LayoutAnimationDriver::animationMutationsForFrame(
// mounting layer is the same as the one on the ShadowTree. This is
// mostly to make the MountingCoordinator StubViewTree assertions
// pass.
auto mutation = ShadowViewMutation{ShadowViewMutation::Type::Update,
keyframe.parentView,
keyframe.viewPrev,
keyframe.viewEnd,
-1};
auto mutation = ShadowViewMutation{
ShadowViewMutation::Type::Update,
keyframe.parentView,
keyframe.viewPrev,
keyframe.viewEnd,
-1};
assert(mutation.oldChildShadowView.tag != 0);
assert(mutation.newChildShadowView.tag != 0);
mutationsList.push_back(mutation);

Просмотреть файл

@ -119,12 +119,13 @@ static better::optional<AnimationConfig> parseAnimationConfig(
double defaultDuration,
bool parsePropertyType) {
if (config.empty() || !config.isObject()) {
return AnimationConfig{AnimationType::Linear,
AnimationProperty::NotApplicable,
defaultDuration,
0,
0,
0};
return AnimationConfig{
AnimationType::Linear,
AnimationProperty::NotApplicable,
defaultDuration,
0,
0,
0};
}
auto const typeIt = config.find("type");
@ -219,12 +220,13 @@ static better::optional<AnimationConfig> parseAnimationConfig(
}
}
return better::optional<AnimationConfig>(AnimationConfig{*animationType,
animationProperty,
duration,
delay,
springDamping,
initialVelocity});
return better::optional<AnimationConfig>(AnimationConfig{
*animationType,
animationProperty,
duration,
delay,
springDamping,
initialVelocity});
}
// Parse animation config from JS
@ -291,14 +293,14 @@ void LayoutAnimationKeyFrameManager::uiManagerDidConfigureNextLayoutAnimation(
if (layoutAnimationConfig) {
std::lock_guard<std::mutex> lock(currentAnimationMutex_);
currentAnimation_ = better::optional<LayoutAnimation>{
LayoutAnimation{-1,
0,
false,
*layoutAnimationConfig,
successCallback,
failureCallback,
{}}};
currentAnimation_ = better::optional<LayoutAnimation>{LayoutAnimation{
-1,
0,
false,
*layoutAnimationConfig,
successCallback,
failureCallback,
{}}};
} else {
LOG(ERROR) << "Parsing LayoutAnimationConfig failed: "
<< (folly::dynamic)config;
@ -372,8 +374,9 @@ LayoutAnimationKeyFrameManager::calculateAnimationProgress(
} else if (mutationConfig.animationType == AnimationType::EaseInEaseOut) {
// This is a combination of accelerate+decelerate.
// The animation starts and ends slowly, and speeds up in the middle.
return {linearTimeProgression,
cos((linearTimeProgression + 1.0) * PI) / 2 + 0.5};
return {
linearTimeProgression,
cos((linearTimeProgression + 1.0) * PI) / 2 + 0.5};
} else if (mutationConfig.animationType == AnimationType::Spring) {
// Using mSpringDamping in this equation is not really the exact
// mathematical springDamping, but a good approximation We need to replace
@ -926,13 +929,13 @@ LayoutAnimationKeyFrameManager::pullTransaction(
mutationConfig.animationType != AnimationType::None;
if (wasInsertedTagRemoved && haveConfiguration) {
movesToAnimate.push_back(
AnimationKeyFrame{{},
AnimationConfigurationType::Update,
mutation.newChildShadowView.tag,
mutation.parentShadowView,
movedIt->second.oldChildShadowView,
mutation.newChildShadowView});
movesToAnimate.push_back(AnimationKeyFrame{
{},
AnimationConfigurationType::Update,
mutation.newChildShadowView.tag,
mutation.parentShadowView,
movedIt->second.oldChildShadowView,
mutation.newChildShadowView});
}
// Creates and inserts should also be executed immediately.
@ -1019,14 +1022,15 @@ LayoutAnimationKeyFrameManager::pullTransaction(
viewStart.props = props;
}
keyFrame = AnimationKeyFrame{{},
AnimationConfigurationType::Create,
tag,
parent,
viewStart,
viewFinal,
baselineShadowView,
0};
keyFrame = AnimationKeyFrame{
{},
AnimationConfigurationType::Create,
tag,
parent,
viewStart,
viewFinal,
baselineShadowView,
0};
} else if (mutation.type == ShadowViewMutation::Type::Delete) {
if (mutationConfig.animationProperty ==
AnimationProperty::Opacity &&
@ -1221,12 +1225,12 @@ LayoutAnimationKeyFrameManager::pullTransaction(
if (keyFrame.finalMutationForKeyFrame.hasValue()) {
auto &finalMutation = *keyFrame.finalMutationForKeyFrame;
auto mutationInstruction =
ShadowViewMutation{finalMutation.type,
finalMutation.parentShadowView,
keyFrame.viewPrev,
finalMutation.newChildShadowView,
finalMutation.index};
auto mutationInstruction = ShadowViewMutation{
finalMutation.type,
finalMutation.parentShadowView,
keyFrame.viewPrev,
finalMutation.newChildShadowView,
finalMutation.index};
PrintMutationInstruction(
"Queueing up final mutation instruction - update:",
mutationInstruction);
@ -1409,11 +1413,12 @@ LayoutAnimationKeyFrameManager::pullTransaction(
for (auto const &keyFrame : conflictingAnimations) {
if (keyFrame.finalMutationForKeyFrame.hasValue()) {
auto &finalMutation = (*keyFrame.finalMutationForKeyFrame);
auto mutation = ShadowViewMutation{finalMutation.type,
finalMutation.parentShadowView,
keyFrame.viewPrev,
finalMutation.newChildShadowView,
finalMutation.index};
auto mutation = ShadowViewMutation{
finalMutation.type,
finalMutation.parentShadowView,
keyFrame.viewPrev,
finalMutation.newChildShadowView,
finalMutation.index};
PrintMutationInstruction(
"No Animation: Queueing up final conflicting mutation instruction",
mutation);

Просмотреть файл

@ -63,10 +63,11 @@ ComponentDescriptorProvider concreteComponentDescriptorProvider() {
std::is_base_of<ComponentDescriptor, ComponentDescriptorT>::value,
"ComponentDescriptorT must be a descendant of ComponentDescriptor");
return {ComponentDescriptorT::ConcreteShadowNode::Handle(),
ComponentDescriptorT::ConcreteShadowNode::Name(),
nullptr,
&concreteComponentDescriptorConstructor<ComponentDescriptorT>};
return {
ComponentDescriptorT::ConcreteShadowNode::Handle(),
ComponentDescriptorT::ConcreteShadowNode::Name(),
nullptr,
&concreteComponentDescriptorConstructor<ComponentDescriptorT>};
}
} // namespace react

Просмотреть файл

@ -35,10 +35,10 @@ void ImageShadowNode::updateStateIfNeeded() {
return;
}
auto state =
ImageState{imageSource,
imageManager_->requestImage(imageSource, getSurfaceId()),
getConcreteProps().blurRadius};
auto state = ImageState{
imageSource,
imageManager_->requestImage(imageSource, getSurfaceId()),
getConcreteProps().blurRadius};
setStateData(std::move(state));
}

Просмотреть файл

@ -32,8 +32,9 @@ class ModalHostViewState final {
ModalHostViewState(
ModalHostViewState const &previousState,
folly::dynamic data)
: screenSize(Size{(Float)data["screenWidth"].getDouble(),
(Float)data["screenHeight"].getDouble()}){};
: screenSize(Size{
(Float)data["screenWidth"].getDouble(),
(Float)data["screenHeight"].getDouble()}){};
#endif
const Size screenSize{};

Просмотреть файл

@ -30,8 +30,9 @@ class ScrollViewState final {
#ifdef ANDROID
ScrollViewState() = default;
ScrollViewState(ScrollViewState const &previousState, folly::dynamic data)
: contentOffset({(Float)data["contentOffsetLeft"].getDouble(),
(Float)data["contentOffsetTop"].getDouble()}),
: contentOffset(
{(Float)data["contentOffsetLeft"].getDouble(),
(Float)data["contentOffsetTop"].getDouble()}),
contentBoundingRect({}){};
folly::dynamic getDynamic() const {

Просмотреть файл

@ -43,14 +43,15 @@ class SliderShadowNode final : public ConcreteViewShadowNode<
ShadowNodeFamilyFragment const &familyFragment,
ComponentDescriptor const &componentDescriptor) {
auto imageSource = ImageSource{ImageSource::Type::Invalid};
return {imageSource,
{imageSource, nullptr},
imageSource,
{imageSource, nullptr},
imageSource,
{imageSource, nullptr},
imageSource,
{imageSource, nullptr}};
return {
imageSource,
{imageSource, nullptr},
imageSource,
{imageSource, nullptr},
imageSource,
{imageSource, nullptr},
imageSource,
{imageSource, nullptr}};
}
#pragma mark - LayoutableShadowNode

Просмотреть файл

@ -112,9 +112,10 @@ void ParagraphShadowNode::updateStateIfNeeded(Content const &content) {
return;
}
setStateData(ParagraphState{content.attributedString,
content.paragraphAttributes,
textLayoutManager_});
setStateData(ParagraphState{
content.attributedString,
content.paragraphAttributes,
textLayoutManager_});
}
#pragma mark - LayoutableShadowNode

Просмотреть файл

@ -155,17 +155,18 @@ void AndroidTextInputShadowNode::updateStateIfNeeded() {
// current attributedString unchanged, and pass in zero for the "event count"
// so no changes are applied There's no way to prevent a state update from
// flowing to Java, so we just ensure it's a noop in those cases.
setStateData(AndroidTextInputState{newEventCount,
newAttributedString,
reactTreeAttributedString,
getConcreteProps().paragraphAttributes,
defaultTextAttributes,
ShadowView(*this),
textLayoutManager_,
state.defaultThemePaddingStart,
state.defaultThemePaddingEnd,
state.defaultThemePaddingTop,
state.defaultThemePaddingBottom});
setStateData(AndroidTextInputState{
newEventCount,
newAttributedString,
reactTreeAttributedString,
getConcreteProps().paragraphAttributes,
defaultTextAttributes,
ShadowView(*this),
textLayoutManager_,
state.defaultThemePaddingStart,
state.defaultThemePaddingEnd,
state.defaultThemePaddingTop,
state.defaultThemePaddingBottom});
}
#pragma mark - LayoutableShadowNode

Просмотреть файл

@ -451,9 +451,10 @@ YGNode *YogaLayoutableShadowNode::yogaNodeCloneCallbackConnector(
auto oldNode =
static_cast<YogaLayoutableShadowNode *>(oldYogaNode->getContext());
auto clonedNode = oldNode->clone({ShadowNodeFragment::propsPlaceholder(),
ShadowNodeFragment::childrenPlaceholder(),
oldNode->getState()});
auto clonedNode = oldNode->clone(
{ShadowNodeFragment::propsPlaceholder(),
ShadowNodeFragment::childrenPlaceholder(),
oldNode->getState()});
parentNode->replaceChild(*oldNode, clonedNode, childIndex);
return &static_cast<YogaLayoutableShadowNode &>(*clonedNode).yogaNode_;
}
@ -471,8 +472,9 @@ YGSize YogaLayoutableShadowNode::yogaNodeMeasureCallbackConnector(
static_cast<YogaLayoutableShadowNode *>(yogaNode->getContext());
auto minimumSize = Size{0, 0};
auto maximumSize = Size{std::numeric_limits<Float>::infinity(),
std::numeric_limits<Float>::infinity()};
auto maximumSize = Size{
std::numeric_limits<Float>::infinity(),
std::numeric_limits<Float>::infinity()};
switch (widthMode) {
case YGMeasureModeUndefined:
@ -501,8 +503,8 @@ YGSize YogaLayoutableShadowNode::yogaNodeMeasureCallbackConnector(
auto size = shadowNodeRawPtr->measureContent(
threadLocalLayoutContext, {minimumSize, maximumSize});
return YGSize{yogaFloatFromFloat(size.width),
yogaFloatFromFloat(size.height)};
return YGSize{
yogaFloatFromFloat(size.width), yogaFloatFromFloat(size.height)};
}
#ifdef RN_DEBUG_YOGA_LOGGER

Просмотреть файл

@ -117,11 +117,13 @@ inline better::optional<Float> optionalFloatFromYogaValue(
inline LayoutMetrics layoutMetricsFromYogaNode(YGNode &yogaNode) {
auto layoutMetrics = LayoutMetrics{};
layoutMetrics.frame =
Rect{Point{floatFromYogaFloat(YGNodeLayoutGetLeft(&yogaNode)),
floatFromYogaFloat(YGNodeLayoutGetTop(&yogaNode))},
Size{floatFromYogaFloat(YGNodeLayoutGetWidth(&yogaNode)),
floatFromYogaFloat(YGNodeLayoutGetHeight(&yogaNode))}};
layoutMetrics.frame = Rect{
Point{
floatFromYogaFloat(YGNodeLayoutGetLeft(&yogaNode)),
floatFromYogaFloat(YGNodeLayoutGetTop(&yogaNode))},
Size{
floatFromYogaFloat(YGNodeLayoutGetWidth(&yogaNode)),
floatFromYogaFloat(YGNodeLayoutGetHeight(&yogaNode))}};
layoutMetrics.borderWidth = EdgeInsets{
floatFromYogaFloat(YGNodeLayoutGetBorder(&yogaNode, YGEdgeLeft)),

Просмотреть файл

@ -208,9 +208,10 @@ TEST_F(YogaDirtyFlagTest, updatingStateForScrollViewMistNotDirtyYogaNode) {
oldShadowNode.getFamily(),
std::make_shared<ScrollViewState>(state));
return oldShadowNode.clone({ShadowNodeFragment::propsPlaceholder(),
ShadowNodeFragment::childrenPlaceholder(),
newState});
return oldShadowNode.clone(
{ShadowNodeFragment::propsPlaceholder(),
ShadowNodeFragment::childrenPlaceholder(),
newState});
});
EXPECT_FALSE(

Просмотреть файл

@ -21,8 +21,9 @@ namespace react {
*/
struct LayoutConstraints {
Size minimumSize{0, 0};
Size maximumSize{std::numeric_limits<Float>::infinity(),
std::numeric_limits<Float>::infinity()};
Size maximumSize{
std::numeric_limits<Float>::infinity(),
std::numeric_limits<Float>::infinity()};
LayoutDirection layoutDirection{LayoutDirection::Undefined};
/*

Просмотреть файл

@ -28,8 +28,9 @@ struct LayoutMetrics {
Rect getContentFrame() const {
return Rect{
Point{contentInsets.left, contentInsets.top},
Size{frame.size.width - contentInsets.left - contentInsets.right,
frame.size.height - contentInsets.top - contentInsets.bottom}};
Size{
frame.size.width - contentInsets.left - contentInsets.right,
frame.size.height - contentInsets.top - contentInsets.bottom}};
}
bool operator==(const LayoutMetrics &rhs) const {

Просмотреть файл

@ -15,8 +15,8 @@
namespace facebook {
namespace react {
void RawPropsKey::render(char *buffer, RawPropsPropNameLength *length) const
noexcept {
void RawPropsKey::render(char *buffer, RawPropsPropNameLength *length)
const noexcept {
*length = 0;
// Prefix

Просмотреть файл

@ -64,8 +64,8 @@ class RawPropsParser final {
/*
* To be used by `RawProps` only.
*/
RawValue const *at(RawProps const &rawProps, RawPropsKey const &key) const
noexcept;
RawValue const *at(RawProps const &rawProps, RawPropsKey const &key)
const noexcept;
mutable better::small_vector<RawPropsKey, kNumberOfPropsPerComponentSoftCap>
keys_{};

Просмотреть файл

@ -29,7 +29,7 @@ struct ConcreteSystraceSection {
template <typename... ConvertsToStringPiece>
explicit ConcreteSystraceSection(
const char *name,
ConvertsToStringPiece &&... args)
ConvertsToStringPiece &&...args)
: m_section(TRACE_TAG_REACT_CXX_BRIDGE, name, args...) {}
private:
@ -42,7 +42,7 @@ struct DummySystraceSection {
template <typename... ConvertsToStringPiece>
explicit DummySystraceSection(
const char *name,
ConvertsToStringPiece &&... args) {}
ConvertsToStringPiece &&...args) {}
};
using SystraceSection = DummySystraceSection;
#endif

Просмотреть файл

@ -45,9 +45,10 @@ ShadowNode::Unshared ComponentBuilder::build(
*family, elementFragment.stateCallback());
constShadowNode = componentDescriptor.cloneShadowNode(
*constShadowNode,
ShadowNodeFragment{ShadowNodeFragment::propsPlaceholder(),
ShadowNodeFragment::childrenPlaceholder(),
newState});
ShadowNodeFragment{
ShadowNodeFragment::propsPlaceholder(),
ShadowNodeFragment::childrenPlaceholder(),
newState});
}
auto shadowNode = std::const_pointer_cast<ShadowNode>(constShadowNode);

Просмотреть файл

@ -94,9 +94,10 @@ struct Rect {
rightBottomPoint.y = std::max(rightBottomPoint.y, c.y);
rightBottomPoint.y = std::max(rightBottomPoint.y, d.y);
return {leftTopPoint,
{rightBottomPoint.x - leftTopPoint.x,
rightBottomPoint.y - leftTopPoint.y}};
return {
leftTopPoint,
{rightBottomPoint.x - leftTopPoint.x,
rightBottomPoint.y - leftTopPoint.y}};
}
};

Просмотреть файл

@ -57,8 +57,8 @@ namespace std {
template <typename T>
struct hash<facebook::react::RectangleCorners<T>> {
size_t operator()(facebook::react::RectangleCorners<T> const &corners) const
noexcept {
size_t operator()(
facebook::react::RectangleCorners<T> const &corners) const noexcept {
return folly::hash::hash_combine(
0,
corners.topLeft,

Просмотреть файл

@ -45,20 +45,22 @@ template <typename T>
RectangleEdges<T> operator+(
RectangleEdges<T> const &lhs,
RectangleEdges<T> const &rhs) noexcept {
return RectangleEdges<T>{lhs.left + rhs.left,
lhs.top + rhs.top,
lhs.right + rhs.right,
lhs.bottom + rhs.bottom};
return RectangleEdges<T>{
lhs.left + rhs.left,
lhs.top + rhs.top,
lhs.right + rhs.right,
lhs.bottom + rhs.bottom};
}
template <typename T>
RectangleEdges<T> operator-(
RectangleEdges<T> const &lhs,
RectangleEdges<T> const &rhs) noexcept {
return RectangleEdges<T>{lhs.left - rhs.left,
lhs.top - rhs.top,
lhs.right - rhs.right,
lhs.bottom - rhs.bottom};
return RectangleEdges<T>{
lhs.left - rhs.left,
lhs.top - rhs.top,
lhs.right - rhs.right,
lhs.bottom - rhs.bottom};
}
/*
@ -70,9 +72,10 @@ using EdgeInsets = RectangleEdges<Float>;
* Adjusts a rectangle by the given edge insets.
*/
inline Rect insetBy(Rect const &rect, EdgeInsets const &insets) noexcept {
return Rect{{rect.origin.x + insets.left, rect.origin.y + insets.top},
{rect.size.width - insets.left - insets.right,
rect.size.height - insets.top - insets.bottom}};
return Rect{
{rect.origin.x + insets.left, rect.origin.y + insets.top},
{rect.size.width - insets.left - insets.right,
rect.size.height - insets.top - insets.bottom}};
}
} // namespace react
@ -82,8 +85,8 @@ namespace std {
template <typename T>
struct hash<facebook::react::RectangleEdges<T>> {
size_t operator()(facebook::react::RectangleEdges<T> const &edges) const
noexcept {
size_t operator()(
facebook::react::RectangleEdges<T> const &edges) const noexcept {
return folly::hash::hash_combine(
0, edges.left, edges.right, edges.top, edges.bottom);
}

Просмотреть файл

@ -22,10 +22,11 @@ SharedColor colorFromComponents(ColorComponents components) {
ColorComponents colorComponentsFromColor(SharedColor sharedColor) {
float ratio = 256;
Color color = *sharedColor;
return ColorComponents{(float)((color >> 16) & 0xff) / ratio,
(float)((color >> 8) & 0xff) / ratio,
(float)((color >> 0) & 0xff) / ratio,
(float)((color >> 24) & 0xff) / ratio};
return ColorComponents{
(float)((color >> 16) & 0xff) / ratio,
(float)((color >> 8) & 0xff) / ratio,
(float)((color >> 0) & 0xff) / ratio,
(float)((color >> 24) & 0xff) / ratio};
}
SharedColor clearColor() {

Просмотреть файл

@ -29,10 +29,11 @@ ColorComponents colorComponentsFromColor(SharedColor sharedColor) {
float ratio = 256;
Color color = *sharedColor;
return ColorComponents{(float)((color >> 16) & 0xff) / ratio,
(float)((color >> 8) & 0xff) / ratio,
(float)((color >> 0) & 0xff) / ratio,
(float)((color >> 24) & 0xff) / ratio};
return ColorComponents{
(float)((color >> 16) & 0xff) / ratio,
(float)((color >> 8) & 0xff) / ratio,
(float)((color >> 0) & 0xff) / ratio,
(float)((color >> 24) & 0xff) / ratio};
}
SharedColor clearColor() {

Просмотреть файл

@ -30,20 +30,23 @@ Float roundToPixel(Float value, Float scaleFactor) {
template <Float (*RoundingFunction)(Float)>
Point roundToPixel(Point value, Float scaleFactor) {
return Point{roundToPixel<RoundingFunction>(value.x, scaleFactor),
roundToPixel<RoundingFunction>(value.y, scaleFactor)};
return Point{
roundToPixel<RoundingFunction>(value.x, scaleFactor),
roundToPixel<RoundingFunction>(value.y, scaleFactor)};
}
template <Float (*RoundingFunction)(Float)>
Size roundToPixel(Size value, Float scaleFactor) {
return Size{roundToPixel<RoundingFunction>(value.width, scaleFactor),
roundToPixel<RoundingFunction>(value.height, scaleFactor)};
return Size{
roundToPixel<RoundingFunction>(value.width, scaleFactor),
roundToPixel<RoundingFunction>(value.height, scaleFactor)};
}
template <Float (*RoundingFunction)(Float)>
Rect roundToPixel(Rect value, Float scaleFactor) {
return Rect{roundToPixel<RoundingFunction>(value.origin),
roundToPixel<RoundingFunction>(value.size)};
return Rect{
roundToPixel<RoundingFunction>(value.origin),
roundToPixel<RoundingFunction>(value.size)};
}
/*

Просмотреть файл

@ -6,6 +6,7 @@
*/
#include <react/renderer/graphics/Transform.h>
#include <gtest/gtest.h>
#include <math.h>

Просмотреть файл

@ -774,14 +774,14 @@ static void calculateShadowViewMutationsV2(
auto updateMutations = ShadowViewMutation::List{};
auto downwardMutations = ShadowViewMutation::List{};
auto destructiveDownwardMutations = ShadowViewMutation::List{};
auto mutationInstructionContainer =
OrderedMutationInstructionContainer{createMutations,
deleteMutations,
insertMutations,
removeMutations,
updateMutations,
downwardMutations,
destructiveDownwardMutations};
auto mutationInstructionContainer = OrderedMutationInstructionContainer{
createMutations,
deleteMutations,
insertMutations,
removeMutations,
updateMutations,
downwardMutations,
destructiveDownwardMutations};
DEBUG_LOGS({
LOG(ERROR) << "Differ Entry: Child Pairs of node: [" << parentShadowView.tag

Просмотреть файл

@ -45,8 +45,8 @@ bool operator!=(StubView const &lhs, StubView const &rhs) {
std::string getDebugName(StubView const &stubView) {
return std::string{"Stub"} +
std::string{stubView.componentHandle ? stubView.componentName
: "[invalid]"};
std::string{
stubView.componentHandle ? stubView.componentName : "[invalid]"};
}
std::vector<DebugStringConvertibleObject> getDebugProps(

Просмотреть файл

@ -72,9 +72,9 @@ StubViewTree buildStubViewTreeWithoutUsingDifferentiator(
ShadowView(rootShadowNode),
sliceChildShadowNodeViewPairsLegacy(rootShadowNode));
auto emptyRootShadowNode = rootShadowNode.clone(
ShadowNodeFragment{ShadowNodeFragment::propsPlaceholder(),
ShadowNode::emptySharedShadowNodeSharedList()});
auto emptyRootShadowNode = rootShadowNode.clone(ShadowNodeFragment{
ShadowNodeFragment::propsPlaceholder(),
ShadowNode::emptySharedShadowNodeSharedList()});
auto stubViewTree = StubViewTree(ShadowView(*emptyRootShadowNode));
stubViewTree.mutate(mutations);
@ -83,9 +83,9 @@ StubViewTree buildStubViewTreeWithoutUsingDifferentiator(
StubViewTree buildStubViewTreeUsingDifferentiator(
ShadowNode const &rootShadowNode) {
auto emptyRootShadowNode = rootShadowNode.clone(
ShadowNodeFragment{ShadowNodeFragment::propsPlaceholder(),
ShadowNode::emptySharedShadowNodeSharedList()});
auto emptyRootShadowNode = rootShadowNode.clone(ShadowNodeFragment{
ShadowNodeFragment::propsPlaceholder(),
ShadowNode::emptySharedShadowNodeSharedList()});
auto mutations =
calculateShadowViewMutations(*emptyRootShadowNode, rootShadowNode);

Просмотреть файл

@ -44,8 +44,8 @@ static ShadowNode::Shared makeNode(
: nonFlattenedDefaultProps(componentDescriptor);
return componentDescriptor.createShadowNode(
ShadowNodeFragment{props,
std::make_shared<SharedShadowNodeList>(children)},
ShadowNodeFragment{
props, std::make_shared<SharedShadowNodeList>(children)},
componentDescriptor.createFamily({tag, SurfaceId(1), nullptr}, nullptr));
}
@ -80,8 +80,8 @@ TEST(MountingTest, testReorderingInstructionGeneration) {
// Applying size constraints.
emptyRootNode = emptyRootNode->clone(
LayoutConstraints{Size{512, 0},
Size{512, std::numeric_limits<Float>::infinity()}},
LayoutConstraints{
Size{512, 0}, Size{512, std::numeric_limits<Float>::infinity()}},
LayoutContext{});
auto childA = makeNode(viewComponentDescriptor, 100, {});
@ -101,22 +101,23 @@ TEST(MountingTest, testReorderingInstructionGeneration) {
// Construct "identical" shadow nodes: they differ only in children.
auto shadowNodeV1 = viewComponentDescriptor.createShadowNode(
ShadowNodeFragment{generateDefaultProps(viewComponentDescriptor),
std::make_shared<SharedShadowNodeList>(
SharedShadowNodeList{childB, childC, childD})},
ShadowNodeFragment{
generateDefaultProps(viewComponentDescriptor),
std::make_shared<SharedShadowNodeList>(
SharedShadowNodeList{childB, childC, childD})},
family);
auto shadowNodeV2 = shadowNodeV1->clone(ShadowNodeFragment{
generateDefaultProps(viewComponentDescriptor),
std::make_shared<SharedShadowNodeList>(
SharedShadowNodeList{childA, childB, childC, childD})});
auto shadowNodeV3 = shadowNodeV2->clone(
ShadowNodeFragment{generateDefaultProps(viewComponentDescriptor),
std::make_shared<SharedShadowNodeList>(
SharedShadowNodeList{childB, childC, childD})});
auto shadowNodeV4 = shadowNodeV3->clone(
ShadowNodeFragment{generateDefaultProps(viewComponentDescriptor),
std::make_shared<SharedShadowNodeList>(
SharedShadowNodeList{childB, childD, childE})});
auto shadowNodeV3 = shadowNodeV2->clone(ShadowNodeFragment{
generateDefaultProps(viewComponentDescriptor),
std::make_shared<SharedShadowNodeList>(
SharedShadowNodeList{childB, childC, childD})});
auto shadowNodeV4 = shadowNodeV3->clone(ShadowNodeFragment{
generateDefaultProps(viewComponentDescriptor),
std::make_shared<SharedShadowNodeList>(
SharedShadowNodeList{childB, childD, childE})});
auto shadowNodeV5 = shadowNodeV4->clone(ShadowNodeFragment{
generateDefaultProps(viewComponentDescriptor),
std::make_shared<SharedShadowNodeList>(
@ -127,52 +128,53 @@ TEST(MountingTest, testReorderingInstructionGeneration) {
childB, childA, childD, childF, childE, childC})});
auto shadowNodeV7 = shadowNodeV6->clone(ShadowNodeFragment{
generateDefaultProps(viewComponentDescriptor),
std::make_shared<SharedShadowNodeList>(SharedShadowNodeList{childF,
childE,
childC,
childD,
childG,
childH,
childI,
childJ,
childK})});
std::make_shared<SharedShadowNodeList>(SharedShadowNodeList{
childF,
childE,
childC,
childD,
childG,
childH,
childI,
childJ,
childK})});
// Injecting a tree into the root node.
auto rootNodeV1 = std::static_pointer_cast<RootShadowNode const>(
emptyRootNode->ShadowNode::clone(
ShadowNodeFragment{ShadowNodeFragment::propsPlaceholder(),
std::make_shared<SharedShadowNodeList>(
SharedShadowNodeList{shadowNodeV1})}));
emptyRootNode->ShadowNode::clone(ShadowNodeFragment{
ShadowNodeFragment::propsPlaceholder(),
std::make_shared<SharedShadowNodeList>(
SharedShadowNodeList{shadowNodeV1})}));
auto rootNodeV2 = std::static_pointer_cast<RootShadowNode const>(
rootNodeV1->ShadowNode::clone(
ShadowNodeFragment{ShadowNodeFragment::propsPlaceholder(),
std::make_shared<SharedShadowNodeList>(
SharedShadowNodeList{shadowNodeV2})}));
rootNodeV1->ShadowNode::clone(ShadowNodeFragment{
ShadowNodeFragment::propsPlaceholder(),
std::make_shared<SharedShadowNodeList>(
SharedShadowNodeList{shadowNodeV2})}));
auto rootNodeV3 = std::static_pointer_cast<RootShadowNode const>(
rootNodeV2->ShadowNode::clone(
ShadowNodeFragment{ShadowNodeFragment::propsPlaceholder(),
std::make_shared<SharedShadowNodeList>(
SharedShadowNodeList{shadowNodeV3})}));
rootNodeV2->ShadowNode::clone(ShadowNodeFragment{
ShadowNodeFragment::propsPlaceholder(),
std::make_shared<SharedShadowNodeList>(
SharedShadowNodeList{shadowNodeV3})}));
auto rootNodeV4 = std::static_pointer_cast<RootShadowNode const>(
rootNodeV3->ShadowNode::clone(
ShadowNodeFragment{ShadowNodeFragment::propsPlaceholder(),
std::make_shared<SharedShadowNodeList>(
SharedShadowNodeList{shadowNodeV4})}));
rootNodeV3->ShadowNode::clone(ShadowNodeFragment{
ShadowNodeFragment::propsPlaceholder(),
std::make_shared<SharedShadowNodeList>(
SharedShadowNodeList{shadowNodeV4})}));
auto rootNodeV5 = std::static_pointer_cast<RootShadowNode const>(
rootNodeV4->ShadowNode::clone(
ShadowNodeFragment{ShadowNodeFragment::propsPlaceholder(),
std::make_shared<SharedShadowNodeList>(
SharedShadowNodeList{shadowNodeV5})}));
rootNodeV4->ShadowNode::clone(ShadowNodeFragment{
ShadowNodeFragment::propsPlaceholder(),
std::make_shared<SharedShadowNodeList>(
SharedShadowNodeList{shadowNodeV5})}));
auto rootNodeV6 = std::static_pointer_cast<RootShadowNode const>(
rootNodeV5->ShadowNode::clone(
ShadowNodeFragment{ShadowNodeFragment::propsPlaceholder(),
std::make_shared<SharedShadowNodeList>(
SharedShadowNodeList{shadowNodeV6})}));
rootNodeV5->ShadowNode::clone(ShadowNodeFragment{
ShadowNodeFragment::propsPlaceholder(),
std::make_shared<SharedShadowNodeList>(
SharedShadowNodeList{shadowNodeV6})}));
auto rootNodeV7 = std::static_pointer_cast<RootShadowNode const>(
rootNodeV6->ShadowNode::clone(
ShadowNodeFragment{ShadowNodeFragment::propsPlaceholder(),
std::make_shared<SharedShadowNodeList>(
SharedShadowNodeList{shadowNodeV7})}));
rootNodeV6->ShadowNode::clone(ShadowNodeFragment{
ShadowNodeFragment::propsPlaceholder(),
std::make_shared<SharedShadowNodeList>(
SharedShadowNodeList{shadowNodeV7})}));
// Layout
std::vector<LayoutableShadowNode const *> affectedLayoutableNodesV1{};
@ -383,8 +385,8 @@ TEST(MountingTest, testViewReparentingInstructionGeneration) {
// Applying size constraints.
emptyRootNode = emptyRootNode->clone(
LayoutConstraints{Size{512, 0},
Size{512, std::numeric_limits<Float>::infinity()}},
LayoutConstraints{
Size{512, 0}, Size{512, std::numeric_limits<Float>::infinity()}},
LayoutContext{});
auto childA = makeNode(viewComponentDescriptor, 100, {});
@ -535,30 +537,30 @@ TEST(MountingTest, testViewReparentingInstructionGeneration) {
// Injecting a tree into the root node.
auto rootNodeV1 = std::static_pointer_cast<RootShadowNode const>(
emptyRootNode->ShadowNode::clone(
ShadowNodeFragment{ShadowNodeFragment::propsPlaceholder(),
std::make_shared<SharedShadowNodeList>(
SharedShadowNodeList{shadowNodeV1})}));
emptyRootNode->ShadowNode::clone(ShadowNodeFragment{
ShadowNodeFragment::propsPlaceholder(),
std::make_shared<SharedShadowNodeList>(
SharedShadowNodeList{shadowNodeV1})}));
auto rootNodeV2 = std::static_pointer_cast<RootShadowNode const>(
rootNodeV1->ShadowNode::clone(
ShadowNodeFragment{ShadowNodeFragment::propsPlaceholder(),
std::make_shared<SharedShadowNodeList>(
SharedShadowNodeList{shadowNodeV2})}));
rootNodeV1->ShadowNode::clone(ShadowNodeFragment{
ShadowNodeFragment::propsPlaceholder(),
std::make_shared<SharedShadowNodeList>(
SharedShadowNodeList{shadowNodeV2})}));
auto rootNodeV3 = std::static_pointer_cast<RootShadowNode const>(
rootNodeV2->ShadowNode::clone(
ShadowNodeFragment{ShadowNodeFragment::propsPlaceholder(),
std::make_shared<SharedShadowNodeList>(
SharedShadowNodeList{shadowNodeV3})}));
rootNodeV2->ShadowNode::clone(ShadowNodeFragment{
ShadowNodeFragment::propsPlaceholder(),
std::make_shared<SharedShadowNodeList>(
SharedShadowNodeList{shadowNodeV3})}));
auto rootNodeV4 = std::static_pointer_cast<RootShadowNode const>(
rootNodeV3->ShadowNode::clone(
ShadowNodeFragment{ShadowNodeFragment::propsPlaceholder(),
std::make_shared<SharedShadowNodeList>(
SharedShadowNodeList{shadowNodeV4})}));
rootNodeV3->ShadowNode::clone(ShadowNodeFragment{
ShadowNodeFragment::propsPlaceholder(),
std::make_shared<SharedShadowNodeList>(
SharedShadowNodeList{shadowNodeV4})}));
auto rootNodeV5 = std::static_pointer_cast<RootShadowNode const>(
rootNodeV4->ShadowNode::clone(
ShadowNodeFragment{ShadowNodeFragment::propsPlaceholder(),
std::make_shared<SharedShadowNodeList>(
SharedShadowNodeList{shadowNodeV5})}));
rootNodeV4->ShadowNode::clone(ShadowNodeFragment{
ShadowNodeFragment::propsPlaceholder(),
std::make_shared<SharedShadowNodeList>(
SharedShadowNodeList{shadowNodeV5})}));
// Layout
std::vector<LayoutableShadowNode const *> affectedLayoutableNodesV1{};

Просмотреть файл

@ -57,8 +57,8 @@ static void testShadowNodeTreeLifeCycle(
// Applying size constraints.
emptyRootNode = emptyRootNode->clone(
LayoutConstraints{Size{512, 0},
Size{512, std::numeric_limits<Float>::infinity()}},
LayoutConstraints{
Size{512, 0}, Size{512, std::numeric_limits<Float>::infinity()}},
LayoutContext{});
// Generation of a random tree.

Просмотреть файл

@ -98,12 +98,13 @@ TEST(StateReconciliationTest, testStateReconciliation) {
auto eventDispatcher = EventDispatcher::Shared{};
auto rootComponentDescriptor =
ComponentDescriptorParameters{eventDispatcher, nullptr, nullptr};
ShadowTree shadowTree{SurfaceId{11},
LayoutConstraints{},
LayoutContext{},
rootComponentDescriptor,
shadowTreeDelegate,
{}};
ShadowTree shadowTree{
SurfaceId{11},
LayoutConstraints{},
LayoutContext{},
rootComponentDescriptor,
shadowTreeDelegate,
{}};
shadowTree.commit(
[&](RootShadowNode const &oldRootShadowNode) {
@ -121,9 +122,10 @@ TEST(StateReconciliationTest, testStateReconciliation) {
auto rootShadowNodeState2 =
shadowNode->cloneTree(family, [&](ShadowNode const &oldShadowNode) {
return oldShadowNode.clone({ShadowNodeFragment::propsPlaceholder(),
ShadowNodeFragment::childrenPlaceholder(),
state2});
return oldShadowNode.clone(
{ShadowNodeFragment::propsPlaceholder(),
ShadowNodeFragment::childrenPlaceholder(),
state2});
});
EXPECT_EQ(
@ -143,9 +145,10 @@ TEST(StateReconciliationTest, testStateReconciliation) {
auto rootShadowNodeState3 = rootShadowNodeState2->cloneTree(
family, [&](ShadowNode const &oldShadowNode) {
return oldShadowNode.clone({ShadowNodeFragment::propsPlaceholder(),
ShadowNodeFragment::childrenPlaceholder(),
state3});
return oldShadowNode.clone(
{ShadowNodeFragment::propsPlaceholder(),
ShadowNodeFragment::childrenPlaceholder(),
state3});
});
EXPECT_EQ(

Просмотреть файл

@ -250,8 +250,9 @@ static inline ShadowNode::Shared generateShadowNodeTree(
auto family = componentDescriptor.createFamily(
{generateReactTag(), SurfaceId(1), nullptr}, nullptr);
return componentDescriptor.createShadowNode(
ShadowNodeFragment{generateDefaultProps(componentDescriptor),
std::make_shared<SharedShadowNodeList>(children)},
ShadowNodeFragment{
generateDefaultProps(componentDescriptor),
std::make_shared<SharedShadowNodeList>(children)},
family);
}

Просмотреть файл

@ -166,8 +166,8 @@ TextMeasurement TextLayoutManager::doMeasure(
float width = (float)fragment["width"].getDouble();
float height = (float)fragment["height"].getDouble();
auto rect = facebook::react::Rect{{left, top},
facebook::react::Size{width, height}};
auto rect = facebook::react::Rect{
{left, top}, facebook::react::Size{width, height}};
attachments.push_back(TextMeasurement::Attachment{rect, false});
attachmentIndex++;
}

Просмотреть файл

@ -41,15 +41,16 @@ inline static UIFontWeight RCTUIFontWeightFromInteger(NSInteger fontWeight)
assert(fontWeight > 50);
assert(fontWeight < 950);
static UIFontWeight weights[] = {/* ~100 */ UIFontWeightUltraLight,
/* ~200 */ UIFontWeightThin,
/* ~300 */ UIFontWeightLight,
/* ~400 */ UIFontWeightRegular,
/* ~500 */ UIFontWeightMedium,
/* ~600 */ UIFontWeightSemibold,
/* ~700 */ UIFontWeightBold,
/* ~800 */ UIFontWeightHeavy,
/* ~900 */ UIFontWeightBlack};
static UIFontWeight weights[] = {
/* ~100 */ UIFontWeightUltraLight,
/* ~200 */ UIFontWeightThin,
/* ~300 */ UIFontWeightLight,
/* ~400 */ UIFontWeightRegular,
/* ~500 */ UIFontWeightMedium,
/* ~600 */ UIFontWeightSemibold,
/* ~700 */ UIFontWeightBold,
/* ~800 */ UIFontWeightHeavy,
/* ~900 */ UIFontWeightBlack};
// The expression is designed to convert something like 760 or 830 to 7.
return weights[(fontWeight + 50) / 100 - 1];
}
@ -319,8 +320,9 @@ NSAttributedString *RCTNSAttributedStringFromAttributedString(const AttributedSt
if (fragment.isAttachment()) {
auto layoutMetrics = fragment.parentShadowView.layoutMetrics;
CGRect bounds = {.origin = {.x = layoutMetrics.frame.origin.x, .y = layoutMetrics.frame.origin.y},
.size = {.width = layoutMetrics.frame.size.width, .height = layoutMetrics.frame.size.height}};
CGRect bounds = {
.origin = {.x = layoutMetrics.frame.origin.x, .y = layoutMetrics.frame.origin.y},
.size = {.width = layoutMetrics.frame.size.width, .height = layoutMetrics.frame.size.height}};
NSTextAttachment *attachment = [NSTextAttachment new];
attachment.image = placeholderImage;

Просмотреть файл

@ -75,12 +75,14 @@ static NSLineBreakMode RCTNSLineBreakModeFromEllipsizeMode(EllipsizeMode ellipsi
UIFont *font = [textStorage attribute:NSFontAttributeName atIndex:range.location effectiveRange:nil];
CGRect frame = {{glyphRect.origin.x,
glyphRect.origin.y + glyphRect.size.height - attachmentSize.height + font.descender},
attachmentSize};
CGRect frame = {
{glyphRect.origin.x,
glyphRect.origin.y + glyphRect.size.height - attachmentSize.height + font.descender},
attachmentSize};
auto rect = facebook::react::Rect{facebook::react::Point{frame.origin.x, frame.origin.y},
facebook::react::Size{frame.size.width, frame.size.height}};
auto rect = facebook::react::Rect{
facebook::react::Point{frame.origin.x, frame.origin.y},
facebook::react::Size{frame.size.width, frame.size.height}};
attachments.push_back(TextMeasurement::Attachment{rect, false});
}];
@ -156,12 +158,13 @@ static NSLineBreakMode RCTNSLineBreakModeFromEllipsizeMode(EllipsizeMode ellipsi
auto rect = facebook::react::Rect{
facebook::react::Point{usedRect.origin.x, usedRect.origin.y},
facebook::react::Size{usedRect.size.width, usedRect.size.height}};
auto line = LineMeasurement{std::string([renderedString UTF8String]),
rect,
-font.descender,
font.capHeight,
font.ascender,
font.xHeight};
auto line = LineMeasurement{
std::string([renderedString UTF8String]),
rect,
-font.descender,
font.capHeight,
font.ascender,
font.xHeight};
blockParagraphLines->push_back(line);
}];
return paragraphLines;

Просмотреть файл

@ -217,10 +217,10 @@ jsi::Value UIManagerBinding::get(
name,
5,
[uiManager](
jsi::Runtime & runtime,
jsi::Runtime &runtime,
jsi::Value const &thisValue,
jsi::Value const *arguments,
size_t count) noexcept->jsi::Value {
size_t count) noexcept -> jsi::Value {
return valueFromShadowNode(
runtime,
uiManager->createNode(
@ -239,10 +239,10 @@ jsi::Value UIManagerBinding::get(
name,
1,
[uiManager](
jsi::Runtime & runtime,
jsi::Runtime &runtime,
jsi::Value const &thisValue,
jsi::Value const *arguments,
size_t count) noexcept->jsi::Value {
size_t count) noexcept -> jsi::Value {
return valueFromShadowNode(
runtime,
uiManager->cloneNode(shadowNodeFromValue(runtime, arguments[0])));
@ -255,10 +255,10 @@ jsi::Value UIManagerBinding::get(
name,
2,
[uiManager](
jsi::Runtime & runtime,
jsi::Runtime &runtime,
jsi::Value const &thisValue,
jsi::Value const *arguments,
size_t count) noexcept->jsi::Value {
size_t count) noexcept -> jsi::Value {
uiManager->setJSResponder(
shadowNodeFromValue(runtime, arguments[0]),
arguments[1].getBool());
@ -273,10 +273,10 @@ jsi::Value UIManagerBinding::get(
name,
2,
[uiManager](
jsi::Runtime & runtime,
jsi::Runtime &runtime,
jsi::Value const &thisValue,
jsi::Value const *arguments,
size_t count) noexcept->jsi::Value {
size_t count) noexcept -> jsi::Value {
auto node = shadowNodeFromValue(runtime, arguments[0]);
auto locationX = (Float)arguments[1].getNumber();
auto locationY = (Float)arguments[2].getNumber();
@ -303,10 +303,10 @@ jsi::Value UIManagerBinding::get(
name,
0,
[uiManager](
jsi::Runtime & runtime,
jsi::Runtime &runtime,
jsi::Value const &thisValue,
jsi::Value const *arguments,
size_t count) noexcept->jsi::Value {
size_t count) noexcept -> jsi::Value {
uiManager->clearJSResponder();
return jsi::Value::undefined();
@ -320,10 +320,10 @@ jsi::Value UIManagerBinding::get(
name,
1,
[uiManager](
jsi::Runtime & runtime,
jsi::Runtime &runtime,
jsi::Value const &thisValue,
jsi::Value const *arguments,
size_t count) noexcept->jsi::Value {
size_t count) noexcept -> jsi::Value {
return valueFromShadowNode(
runtime,
uiManager->cloneNode(
@ -339,10 +339,10 @@ jsi::Value UIManagerBinding::get(
name,
2,
[uiManager](
jsi::Runtime & runtime,
jsi::Runtime &runtime,
jsi::Value const &thisValue,
jsi::Value const *arguments,
size_t count) noexcept->jsi::Value {
size_t count) noexcept -> jsi::Value {
auto const &rawProps = RawProps(runtime, arguments[1]);
return valueFromShadowNode(
runtime,
@ -360,10 +360,10 @@ jsi::Value UIManagerBinding::get(
name,
2,
[uiManager](
jsi::Runtime & runtime,
jsi::Runtime &runtime,
jsi::Value const &thisValue,
jsi::Value const *arguments,
size_t count) noexcept->jsi::Value {
size_t count) noexcept -> jsi::Value {
auto const &rawProps = RawProps(runtime, arguments[1]);
return valueFromShadowNode(
runtime,
@ -380,10 +380,10 @@ jsi::Value UIManagerBinding::get(
name,
2,
[uiManager](
jsi::Runtime & runtime,
jsi::Runtime &runtime,
jsi::Value const &thisValue,
jsi::Value const *arguments,
size_t count) noexcept->jsi::Value {
size_t count) noexcept -> jsi::Value {
uiManager->appendChild(
shadowNodeFromValue(runtime, arguments[0]),
shadowNodeFromValue(runtime, arguments[1]));
@ -396,10 +396,10 @@ jsi::Value UIManagerBinding::get(
runtime,
name,
1,
[](jsi::Runtime & runtime,
[](jsi::Runtime &runtime,
jsi::Value const &thisValue,
jsi::Value const *arguments,
size_t count) noexcept->jsi::Value {
size_t count) noexcept -> jsi::Value {
auto shadowNodeList =
std::make_shared<SharedShadowNodeList>(SharedShadowNodeList({}));
return valueFromShadowNodeList(runtime, shadowNodeList);
@ -411,10 +411,10 @@ jsi::Value UIManagerBinding::get(
runtime,
name,
2,
[](jsi::Runtime & runtime,
[](jsi::Runtime &runtime,
jsi::Value const &thisValue,
jsi::Value const *arguments,
size_t count) noexcept->jsi::Value {
size_t count) noexcept -> jsi::Value {
auto shadowNodeList = shadowNodeListFromValue(runtime, arguments[0]);
auto shadowNode = shadowNodeFromValue(runtime, arguments[1]);
shadowNodeList->push_back(shadowNode);
@ -430,11 +430,11 @@ jsi::Value UIManagerBinding::get(
runtime,
name,
2,
[ uiManager, sharedUIManager = uiManager_ ](
jsi::Runtime & runtime,
[uiManager, sharedUIManager = uiManager_](
jsi::Runtime &runtime,
jsi::Value const &thisValue,
jsi::Value const *arguments,
size_t count) noexcept->jsi::Value {
size_t count) noexcept -> jsi::Value {
auto surfaceId = surfaceIdFromValue(runtime, arguments[0]);
auto shadowNodeList =
shadowNodeListFromValue(runtime, arguments[1]);
@ -472,10 +472,10 @@ jsi::Value UIManagerBinding::get(
name,
2,
[uiManager](
jsi::Runtime & runtime,
jsi::Runtime &runtime,
jsi::Value const &thisValue,
jsi::Value const *arguments,
size_t count) noexcept->jsi::Value {
size_t count) noexcept -> jsi::Value {
uiManager->completeSurface(
surfaceIdFromValue(runtime, arguments[0]),
shadowNodeListFromValue(runtime, arguments[1]),
@ -492,10 +492,10 @@ jsi::Value UIManagerBinding::get(
name,
1,
[this](
jsi::Runtime & runtime,
jsi::Runtime &runtime,
jsi::Value const &thisValue,
jsi::Value const *arguments,
size_t count) noexcept->jsi::Value {
size_t count) noexcept -> jsi::Value {
auto eventHandler =
arguments[0].getObject(runtime).getFunction(runtime);
eventHandler_ =
@ -510,10 +510,10 @@ jsi::Value UIManagerBinding::get(
name,
2,
[uiManager](
jsi::Runtime & runtime,
jsi::Runtime &runtime,
jsi::Value const &thisValue,
jsi::Value const *arguments,
size_t count) noexcept->jsi::Value {
size_t count) noexcept -> jsi::Value {
auto layoutMetrics = uiManager->getRelativeLayoutMetrics(
*shadowNodeFromValue(runtime, arguments[0]),
shadowNodeFromValue(runtime, arguments[1]).get(),
@ -534,10 +534,10 @@ jsi::Value UIManagerBinding::get(
name,
3,
[uiManager](
jsi::Runtime & runtime,
jsi::Runtime &runtime,
jsi::Value const &thisValue,
jsi::Value const *arguments,
size_t count) noexcept->jsi::Value {
size_t count) noexcept -> jsi::Value {
uiManager->dispatchCommand(
shadowNodeFromValue(runtime, arguments[0]),
stringFromValue(runtime, arguments[1]),
@ -554,10 +554,10 @@ jsi::Value UIManagerBinding::get(
name,
4,
[uiManager](
jsi::Runtime & runtime,
jsi::Runtime &runtime,
jsi::Value const &thisValue,
jsi::Value const *arguments,
size_t count) noexcept->jsi::Value {
size_t count) noexcept -> jsi::Value {
auto layoutMetrics = uiManager->getRelativeLayoutMetrics(
*shadowNodeFromValue(runtime, arguments[0]),
shadowNodeFromValue(runtime, arguments[1]).get(),
@ -590,10 +590,10 @@ jsi::Value UIManagerBinding::get(
name,
2,
[uiManager](
jsi::Runtime & runtime,
jsi::Runtime &runtime,
jsi::Value const &thisValue,
jsi::Value const *arguments,
size_t count) noexcept->jsi::Value {
size_t count) noexcept -> jsi::Value {
auto shadowNode = shadowNodeFromValue(runtime, arguments[0]);
auto layoutMetrics = uiManager->getRelativeLayoutMetrics(
*shadowNode, nullptr, {/* .includeTransform = */ true});
@ -632,10 +632,10 @@ jsi::Value UIManagerBinding::get(
name,
2,
[uiManager](
jsi::Runtime & runtime,
jsi::Runtime &runtime,
jsi::Value const &thisValue,
jsi::Value const *arguments,
size_t count) noexcept->jsi::Value {
size_t count) noexcept -> jsi::Value {
auto layoutMetrics = uiManager->getRelativeLayoutMetrics(
*shadowNodeFromValue(runtime, arguments[0]),
nullptr,
@ -667,10 +667,10 @@ jsi::Value UIManagerBinding::get(
name,
2,
[uiManager](
jsi::Runtime & runtime,
jsi::Runtime &runtime,
jsi::Value const &thisValue,
jsi::Value const *arguments,
size_t count) noexcept->jsi::Value {
size_t count) noexcept -> jsi::Value {
uiManager->sendAccessibilityEvent(
shadowNodeFromValue(runtime, arguments[0]),
stringFromValue(runtime, arguments[1]));
@ -685,10 +685,10 @@ jsi::Value UIManagerBinding::get(
name,
3,
[uiManager](
jsi::Runtime & runtime,
jsi::Runtime &runtime,
jsi::Value const &thisValue,
jsi::Value const *arguments,
size_t count) noexcept->jsi::Value {
size_t count) noexcept -> jsi::Value {
uiManager->configureNextLayoutAnimation(
runtime,
// TODO: pass in JSI value instead of folly::dynamic to RawValue

Просмотреть файл

@ -23,10 +23,10 @@ class UIManagerCommitHook {
/*
* Called right after the commit hook is registered or unregistered.
*/
virtual void commitHookWasRegistered(UIManager const &uiManager) const
noexcept = 0;
virtual void commitHookWasUnregistered(UIManager const &uiManager) const
noexcept = 0;
virtual void commitHookWasRegistered(
UIManager const &uiManager) const noexcept = 0;
virtual void commitHookWasUnregistered(
UIManager const &uiManager) const noexcept = 0;
/*
* Called right before a `ShadowTree` commits a new tree.