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 удалений

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

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

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

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

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

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

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

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

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

@ -160,7 +160,8 @@ using namespace facebook::react;
reusingView:(UILabel *)label reusingView:(UILabel *)label
{ {
if (!label) { if (!label) {
label = [[UILabel alloc] initWithFrame:(CGRect){CGPointZero, label = [[UILabel alloc] initWithFrame:(CGRect){
CGPointZero,
{ {
[pickerView rowSizeForComponent:component].width, [pickerView rowSizeForComponent:component].width,
[pickerView rowSizeForComponent:component].height, [pickerView rowSizeForComponent:component].height,

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

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

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

@ -74,7 +74,8 @@ using namespace facebook::react;
+ (std::vector<facebook::react::ComponentDescriptorProvider>)supplementalComponentDescriptorProviders + (std::vector<facebook::react::ComponentDescriptorProvider>)supplementalComponentDescriptorProviders
{ {
return {concreteComponentDescriptorProvider<RawTextComponentDescriptor>(), return {
concreteComponentDescriptorProvider<RawTextComponentDescriptor>(),
concreteComponentDescriptorProvider<TextComponentDescriptor>()}; concreteComponentDescriptorProvider<TextComponentDescriptor>()};
} }

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

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

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

@ -146,7 +146,8 @@ inline UIAccessibilityTraits RCTUIAccessibilityTraitsFromAccessibilityTraits(
inline CATransform3D RCTCATransform3DFromTransformMatrix(const facebook::react::Transform &transformMatrix) inline CATransform3D RCTCATransform3DFromTransformMatrix(const facebook::react::Transform &transformMatrix)
{ {
return {(CGFloat)transformMatrix.matrix[0], return {
(CGFloat)transformMatrix.matrix[0],
(CGFloat)transformMatrix.matrix[1], (CGFloat)transformMatrix.matrix[1],
(CGFloat)transformMatrix.matrix[2], (CGFloat)transformMatrix.matrix[2],
(CGFloat)transformMatrix.matrix[3], (CGFloat)transformMatrix.matrix[3],

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

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

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

@ -51,7 +51,8 @@ static inline LayoutConstraints RCTGetLayoutConstraintsForSize(CGSize minimumSiz
static inline LayoutContext RCTGetLayoutContext(CGPoint viewportOffset) static inline LayoutContext RCTGetLayoutContext(CGPoint viewportOffset)
{ {
return {.pointScaleFactor = RCTScreenScale(), return {
.pointScaleFactor = RCTScreenScale(),
.swapLeftAndRightInRTL = .swapLeftAndRightInRTL =
[[RCTI18nUtil sharedInstance] isRTL] && [[RCTI18nUtil sharedInstance] doLeftAndRightSwapInRTL], [[RCTI18nUtil sharedInstance] isRTL] && [[RCTI18nUtil sharedInstance] doLeftAndRightSwapInRTL],
.fontSizeMultiplier = RCTFontSizeMultiplier(), .fontSizeMultiplier = RCTFontSizeMultiplier(),

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

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

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

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

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

@ -33,7 +33,8 @@ BOOL RCTBorderColorsAreEqual(RCTBorderColors borderColors)
RCTCornerInsets RCTGetCornerInsets(RCTCornerRadii cornerRadii, UIEdgeInsets edgeInsets) RCTCornerInsets RCTGetCornerInsets(RCTCornerRadii cornerRadii, UIEdgeInsets edgeInsets)
{ {
return (RCTCornerInsets){{ return (RCTCornerInsets){
{
MAX(0, cornerRadii.topLeft - edgeInsets.left), MAX(0, cornerRadii.topLeft - edgeInsets.left),
MAX(0, cornerRadii.topLeft - edgeInsets.top), MAX(0, cornerRadii.topLeft - edgeInsets.top),
}, },
@ -206,8 +207,8 @@ static UIImage *RCTGetSolidBorderImage(
(borderInsets.top + cornerInsets.topRight.height + borderInsets.bottom + cornerInsets.bottomLeft.height <= (borderInsets.top + cornerInsets.topRight.height + borderInsets.bottom + cornerInsets.bottomLeft.height <=
viewSize.height); viewSize.height);
UIEdgeInsets edgeInsets = UIEdgeInsets edgeInsets = (UIEdgeInsets){
(UIEdgeInsets){borderInsets.top + MAX(cornerInsets.topLeft.height, cornerInsets.topRight.height), borderInsets.top + MAX(cornerInsets.topLeft.height, cornerInsets.topRight.height),
borderInsets.left + MAX(cornerInsets.topLeft.width, cornerInsets.bottomLeft.width), borderInsets.left + MAX(cornerInsets.topLeft.width, cornerInsets.bottomLeft.width),
borderInsets.bottom + MAX(cornerInsets.bottomLeft.height, cornerInsets.bottomRight.height), borderInsets.bottom + MAX(cornerInsets.bottomLeft.height, cornerInsets.bottomRight.height),
borderInsets.right + MAX(cornerInsets.bottomRight.width, cornerInsets.topRight.width)}; borderInsets.right + MAX(cornerInsets.bottomRight.width, cornerInsets.topRight.width)};
@ -271,7 +272,8 @@ static UIImage *RCTGetSolidBorderImage(
if (cornerInsets.bottomLeft.width > 0 && cornerInsets.bottomLeft.height > 0) { if (cornerInsets.bottomLeft.width > 0 && cornerInsets.bottomLeft.height > 0) {
CGPoint points[2]; CGPoint points[2];
RCTEllipseGetIntersectionsWithLine( RCTEllipseGetIntersectionsWithLine(
(CGRect){{bottomLeft.x, bottomLeft.y - 2 * cornerInsets.bottomLeft.height}, (CGRect){
{bottomLeft.x, bottomLeft.y - 2 * cornerInsets.bottomLeft.height},
{2 * cornerInsets.bottomLeft.width, 2 * cornerInsets.bottomLeft.height}}, {2 * cornerInsets.bottomLeft.width, 2 * cornerInsets.bottomLeft.height}},
(CGPoint){0, size.height}, (CGPoint){0, size.height},
bottomLeft, bottomLeft,
@ -285,7 +287,8 @@ static UIImage *RCTGetSolidBorderImage(
if (cornerInsets.topRight.width > 0 && cornerInsets.topRight.height > 0) { if (cornerInsets.topRight.width > 0 && cornerInsets.topRight.height > 0) {
CGPoint points[2]; CGPoint points[2];
RCTEllipseGetIntersectionsWithLine( RCTEllipseGetIntersectionsWithLine(
(CGRect){{topRight.x - 2 * cornerInsets.topRight.width, topRight.y}, (CGRect){
{topRight.x - 2 * cornerInsets.topRight.width, topRight.y},
{2 * cornerInsets.topRight.width, 2 * cornerInsets.topRight.height}}, {2 * cornerInsets.topRight.width, 2 * cornerInsets.topRight.height}},
(CGPoint){size.width, 0}, (CGPoint){size.width, 0},
topRight, topRight,

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

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

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

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

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

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

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

@ -18,7 +18,8 @@
- (UIEdgeInsets)paddingAsInsets - (UIEdgeInsets)paddingAsInsets
{ {
YGNodeRef yogaNode = self.yogaNode; YGNodeRef yogaNode = self.yogaNode;
return (UIEdgeInsets){RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetPadding(yogaNode, YGEdgeTop)), return (UIEdgeInsets){
RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetPadding(yogaNode, YGEdgeTop)),
RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetPadding(yogaNode, YGEdgeLeft)), RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetPadding(yogaNode, YGEdgeLeft)),
RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetPadding(yogaNode, YGEdgeBottom)), RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetPadding(yogaNode, YGEdgeBottom)),
RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetPadding(yogaNode, YGEdgeRight))}; RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetPadding(yogaNode, YGEdgeRight))};
@ -27,7 +28,8 @@
- (UIEdgeInsets)borderAsInsets - (UIEdgeInsets)borderAsInsets
{ {
YGNodeRef yogaNode = self.yogaNode; YGNodeRef yogaNode = self.yogaNode;
return (UIEdgeInsets){RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetBorder(yogaNode, YGEdgeTop)), return (UIEdgeInsets){
RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetBorder(yogaNode, YGEdgeTop)),
RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetBorder(yogaNode, YGEdgeLeft)), RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetBorder(yogaNode, YGEdgeLeft)),
RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetBorder(yogaNode, YGEdgeBottom)), RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetBorder(yogaNode, YGEdgeBottom)),
RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetBorder(yogaNode, YGEdgeRight))}; RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetBorder(yogaNode, YGEdgeRight))};
@ -38,7 +40,8 @@
UIEdgeInsets borderAsInsets = self.borderAsInsets; UIEdgeInsets borderAsInsets = self.borderAsInsets;
UIEdgeInsets paddingAsInsets = self.paddingAsInsets; UIEdgeInsets paddingAsInsets = self.paddingAsInsets;
return (UIEdgeInsets){borderAsInsets.top + paddingAsInsets.top, return (UIEdgeInsets){
borderAsInsets.top + paddingAsInsets.top,
borderAsInsets.left + paddingAsInsets.left, borderAsInsets.left + paddingAsInsets.left,
borderAsInsets.bottom + paddingAsInsets.bottom, borderAsInsets.bottom + paddingAsInsets.bottom,
borderAsInsets.right + paddingAsInsets.right}; borderAsInsets.right + paddingAsInsets.right};

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

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

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

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

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

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

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

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

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

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

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

@ -119,8 +119,8 @@ void LayoutAnimationDriver::animationMutationsForFrame(
// Copy so that if something else mutates the inflight animations, it // Copy so that if something else mutates the inflight animations, it
// won't change this mutation after this point. // won't change this mutation after this point.
auto mutation = auto mutation = ShadowViewMutation{
ShadowViewMutation{finalMutationForKeyFrame.type, finalMutationForKeyFrame.type,
finalMutationForKeyFrame.parentShadowView, finalMutationForKeyFrame.parentShadowView,
keyframe.viewPrev, keyframe.viewPrev,
finalMutationForKeyFrame.newChildShadowView, finalMutationForKeyFrame.newChildShadowView,
@ -136,7 +136,8 @@ void LayoutAnimationDriver::animationMutationsForFrame(
// mounting layer is the same as the one on the ShadowTree. This is // mounting layer is the same as the one on the ShadowTree. This is
// mostly to make the MountingCoordinator StubViewTree assertions // mostly to make the MountingCoordinator StubViewTree assertions
// pass. // pass.
auto mutation = ShadowViewMutation{ShadowViewMutation::Type::Update, auto mutation = ShadowViewMutation{
ShadowViewMutation::Type::Update,
keyframe.parentView, keyframe.parentView,
keyframe.viewPrev, keyframe.viewPrev,
keyframe.viewEnd, keyframe.viewEnd,

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

@ -119,7 +119,8 @@ static better::optional<AnimationConfig> parseAnimationConfig(
double defaultDuration, double defaultDuration,
bool parsePropertyType) { bool parsePropertyType) {
if (config.empty() || !config.isObject()) { if (config.empty() || !config.isObject()) {
return AnimationConfig{AnimationType::Linear, return AnimationConfig{
AnimationType::Linear,
AnimationProperty::NotApplicable, AnimationProperty::NotApplicable,
defaultDuration, defaultDuration,
0, 0,
@ -219,7 +220,8 @@ static better::optional<AnimationConfig> parseAnimationConfig(
} }
} }
return better::optional<AnimationConfig>(AnimationConfig{*animationType, return better::optional<AnimationConfig>(AnimationConfig{
*animationType,
animationProperty, animationProperty,
duration, duration,
delay, delay,
@ -291,8 +293,8 @@ void LayoutAnimationKeyFrameManager::uiManagerDidConfigureNextLayoutAnimation(
if (layoutAnimationConfig) { if (layoutAnimationConfig) {
std::lock_guard<std::mutex> lock(currentAnimationMutex_); std::lock_guard<std::mutex> lock(currentAnimationMutex_);
currentAnimation_ = better::optional<LayoutAnimation>{ currentAnimation_ = better::optional<LayoutAnimation>{LayoutAnimation{
LayoutAnimation{-1, -1,
0, 0,
false, false,
*layoutAnimationConfig, *layoutAnimationConfig,
@ -372,7 +374,8 @@ LayoutAnimationKeyFrameManager::calculateAnimationProgress(
} else if (mutationConfig.animationType == AnimationType::EaseInEaseOut) { } else if (mutationConfig.animationType == AnimationType::EaseInEaseOut) {
// This is a combination of accelerate+decelerate. // This is a combination of accelerate+decelerate.
// The animation starts and ends slowly, and speeds up in the middle. // The animation starts and ends slowly, and speeds up in the middle.
return {linearTimeProgression, return {
linearTimeProgression,
cos((linearTimeProgression + 1.0) * PI) / 2 + 0.5}; cos((linearTimeProgression + 1.0) * PI) / 2 + 0.5};
} else if (mutationConfig.animationType == AnimationType::Spring) { } else if (mutationConfig.animationType == AnimationType::Spring) {
// Using mSpringDamping in this equation is not really the exact // Using mSpringDamping in this equation is not really the exact
@ -926,8 +929,8 @@ LayoutAnimationKeyFrameManager::pullTransaction(
mutationConfig.animationType != AnimationType::None; mutationConfig.animationType != AnimationType::None;
if (wasInsertedTagRemoved && haveConfiguration) { if (wasInsertedTagRemoved && haveConfiguration) {
movesToAnimate.push_back( movesToAnimate.push_back(AnimationKeyFrame{
AnimationKeyFrame{{}, {},
AnimationConfigurationType::Update, AnimationConfigurationType::Update,
mutation.newChildShadowView.tag, mutation.newChildShadowView.tag,
mutation.parentShadowView, mutation.parentShadowView,
@ -1019,7 +1022,8 @@ LayoutAnimationKeyFrameManager::pullTransaction(
viewStart.props = props; viewStart.props = props;
} }
keyFrame = AnimationKeyFrame{{}, keyFrame = AnimationKeyFrame{
{},
AnimationConfigurationType::Create, AnimationConfigurationType::Create,
tag, tag,
parent, parent,
@ -1221,8 +1225,8 @@ LayoutAnimationKeyFrameManager::pullTransaction(
if (keyFrame.finalMutationForKeyFrame.hasValue()) { if (keyFrame.finalMutationForKeyFrame.hasValue()) {
auto &finalMutation = *keyFrame.finalMutationForKeyFrame; auto &finalMutation = *keyFrame.finalMutationForKeyFrame;
auto mutationInstruction = auto mutationInstruction = ShadowViewMutation{
ShadowViewMutation{finalMutation.type, finalMutation.type,
finalMutation.parentShadowView, finalMutation.parentShadowView,
keyFrame.viewPrev, keyFrame.viewPrev,
finalMutation.newChildShadowView, finalMutation.newChildShadowView,
@ -1409,7 +1413,8 @@ LayoutAnimationKeyFrameManager::pullTransaction(
for (auto const &keyFrame : conflictingAnimations) { for (auto const &keyFrame : conflictingAnimations) {
if (keyFrame.finalMutationForKeyFrame.hasValue()) { if (keyFrame.finalMutationForKeyFrame.hasValue()) {
auto &finalMutation = (*keyFrame.finalMutationForKeyFrame); auto &finalMutation = (*keyFrame.finalMutationForKeyFrame);
auto mutation = ShadowViewMutation{finalMutation.type, auto mutation = ShadowViewMutation{
finalMutation.type,
finalMutation.parentShadowView, finalMutation.parentShadowView,
keyFrame.viewPrev, keyFrame.viewPrev,
finalMutation.newChildShadowView, finalMutation.newChildShadowView,

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

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

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

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

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

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

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

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

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

@ -43,7 +43,8 @@ class SliderShadowNode final : public ConcreteViewShadowNode<
ShadowNodeFamilyFragment const &familyFragment, ShadowNodeFamilyFragment const &familyFragment,
ComponentDescriptor const &componentDescriptor) { ComponentDescriptor const &componentDescriptor) {
auto imageSource = ImageSource{ImageSource::Type::Invalid}; auto imageSource = ImageSource{ImageSource::Type::Invalid};
return {imageSource, return {
imageSource,
{imageSource, nullptr}, {imageSource, nullptr},
imageSource, imageSource,
{imageSource, nullptr}, {imageSource, nullptr},

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

@ -112,7 +112,8 @@ void ParagraphShadowNode::updateStateIfNeeded(Content const &content) {
return; return;
} }
setStateData(ParagraphState{content.attributedString, setStateData(ParagraphState{
content.attributedString,
content.paragraphAttributes, content.paragraphAttributes,
textLayoutManager_}); textLayoutManager_});
} }

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

@ -155,7 +155,8 @@ void AndroidTextInputShadowNode::updateStateIfNeeded() {
// current attributedString unchanged, and pass in zero for the "event count" // 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 // 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. // flowing to Java, so we just ensure it's a noop in those cases.
setStateData(AndroidTextInputState{newEventCount, setStateData(AndroidTextInputState{
newEventCount,
newAttributedString, newAttributedString,
reactTreeAttributedString, reactTreeAttributedString,
getConcreteProps().paragraphAttributes, getConcreteProps().paragraphAttributes,

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -45,7 +45,8 @@ ShadowNode::Unshared ComponentBuilder::build(
*family, elementFragment.stateCallback()); *family, elementFragment.stateCallback());
constShadowNode = componentDescriptor.cloneShadowNode( constShadowNode = componentDescriptor.cloneShadowNode(
*constShadowNode, *constShadowNode,
ShadowNodeFragment{ShadowNodeFragment::propsPlaceholder(), ShadowNodeFragment{
ShadowNodeFragment::propsPlaceholder(),
ShadowNodeFragment::childrenPlaceholder(), ShadowNodeFragment::childrenPlaceholder(),
newState}); newState});
} }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -774,8 +774,8 @@ static void calculateShadowViewMutationsV2(
auto updateMutations = ShadowViewMutation::List{}; auto updateMutations = ShadowViewMutation::List{};
auto downwardMutations = ShadowViewMutation::List{}; auto downwardMutations = ShadowViewMutation::List{};
auto destructiveDownwardMutations = ShadowViewMutation::List{}; auto destructiveDownwardMutations = ShadowViewMutation::List{};
auto mutationInstructionContainer = auto mutationInstructionContainer = OrderedMutationInstructionContainer{
OrderedMutationInstructionContainer{createMutations, createMutations,
deleteMutations, deleteMutations,
insertMutations, insertMutations,
removeMutations, removeMutations,

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -41,7 +41,8 @@ inline static UIFontWeight RCTUIFontWeightFromInteger(NSInteger fontWeight)
assert(fontWeight > 50); assert(fontWeight > 50);
assert(fontWeight < 950); assert(fontWeight < 950);
static UIFontWeight weights[] = {/* ~100 */ UIFontWeightUltraLight, static UIFontWeight weights[] = {
/* ~100 */ UIFontWeightUltraLight,
/* ~200 */ UIFontWeightThin, /* ~200 */ UIFontWeightThin,
/* ~300 */ UIFontWeightLight, /* ~300 */ UIFontWeightLight,
/* ~400 */ UIFontWeightRegular, /* ~400 */ UIFontWeightRegular,
@ -319,7 +320,8 @@ NSAttributedString *RCTNSAttributedStringFromAttributedString(const AttributedSt
if (fragment.isAttachment()) { if (fragment.isAttachment()) {
auto layoutMetrics = fragment.parentShadowView.layoutMetrics; auto layoutMetrics = fragment.parentShadowView.layoutMetrics;
CGRect bounds = {.origin = {.x = layoutMetrics.frame.origin.x, .y = layoutMetrics.frame.origin.y}, CGRect bounds = {
.origin = {.x = layoutMetrics.frame.origin.x, .y = layoutMetrics.frame.origin.y},
.size = {.width = layoutMetrics.frame.size.width, .height = layoutMetrics.frame.size.height}}; .size = {.width = layoutMetrics.frame.size.width, .height = layoutMetrics.frame.size.height}};
NSTextAttachment *attachment = [NSTextAttachment new]; NSTextAttachment *attachment = [NSTextAttachment new];

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

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

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

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