Skip to content

Commit 10d41d4

Browse files
sahrensfacebook-github-bot
authored andcommitted
more lint auto fixing
Summary: ran `find js/react-native-github/ReactCommon | xargs arc lint -a` Reviewed By: fkgozali Differential Revision: D12902865 fbshipit-source-id: 9c68c0f7e28893e76df966ad4110299e89895454
1 parent 81e5d64 commit 10d41d4

File tree

8 files changed

+324
-228
lines changed

8 files changed

+324
-228
lines changed

ReactCommon/fabric/attributedstring/conversions.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@
77

88
#pragma once
99

10-
#include <fabric/attributedstring/conversions.h>
11-
#include <fabric/attributedstring/primitives.h>
1210
#include <fabric/attributedstring/AttributedString.h>
1311
#include <fabric/attributedstring/ParagraphAttributes.h>
1412
#include <fabric/attributedstring/TextAttributes.h>
15-
#include <fabric/core/conversions.h>
13+
#include <fabric/attributedstring/conversions.h>
14+
#include <fabric/attributedstring/primitives.h>
1615
#include <fabric/core/LayoutableShadowNode.h>
1716
#include <fabric/core/ShadowNode.h>
18-
#include <fabric/graphics/conversions.h>
17+
#include <fabric/core/conversions.h>
1918
#include <fabric/graphics/Geometry.h>
19+
#include <fabric/graphics/conversions.h>
2020
#include <folly/dynamic.h>
2121

2222
namespace facebook {
@@ -388,7 +388,8 @@ inline folly::dynamic toDynamic(
388388
inline folly::dynamic toDynamic(const TextAttributes &textAttributes) {
389389
auto _textAttributes = folly::dynamic::object();
390390
if (textAttributes.foregroundColor) {
391-
_textAttributes("foregroundColor", toDynamic(textAttributes.foregroundColor));
391+
_textAttributes(
392+
"foregroundColor", toDynamic(textAttributes.foregroundColor));
392393
}
393394
if (textAttributes.backgroundColor) {
394395
_textAttributes(

ReactCommon/fabric/components/view/ViewShadowNode.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ const char ViewComponentName[] = "View";
1515
bool ViewShadowNode::isLayoutOnly() const {
1616
const auto &viewProps = *std::static_pointer_cast<const ViewProps>(props_);
1717

18-
return
19-
viewProps.collapsable &&
18+
return viewProps.collapsable &&
2019
// Event listeners
2120
!viewProps.onLayout &&
2221
// Generic Props

ReactCommon/fabric/textlayoutmanager/platform/ios/NSTextStorage+FontScaling.m

Lines changed: 41 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,17 @@
88
#import "NSTextStorage+FontScaling.h"
99

1010
typedef NS_OPTIONS(NSInteger, RCTTextSizeComparisonOptions) {
11-
RCTTextSizeComparisonSmaller = 1 << 0,
12-
RCTTextSizeComparisonLarger = 1 << 1,
11+
RCTTextSizeComparisonSmaller = 1 << 0,
12+
RCTTextSizeComparisonLarger = 1 << 1,
1313
RCTTextSizeComparisonWithinRange = 1 << 2,
1414
};
1515

1616
@implementation NSTextStorage (FontScaling)
1717

1818
- (void)scaleFontSizeToFitSize:(CGSize)size
1919
minimumFontSize:(CGFloat)minimumFontSize
20-
maximumFontSize:(CGFloat)maximumFontSize
21-
{
22-
CGFloat bottomRatio = 1.0/128.0;
20+
maximumFontSize:(CGFloat)maximumFontSize {
21+
CGFloat bottomRatio = 1.0 / 128.0;
2322
CGFloat topRatio = 128.0;
2423
CGFloat ratio = 1.0;
2524

@@ -32,13 +31,11 @@ - (void)scaleFontSizeToFitSize:(CGSize)size
3231
minimumFontSize:minimumFontSize
3332
maximumFontSize:maximumFontSize];
3433

35-
RCTTextSizeComparisonOptions comparsion =
36-
[self compareToSize:size thresholdRatio:0.01];
34+
RCTTextSizeComparisonOptions comparsion = [self compareToSize:size
35+
thresholdRatio:0.01];
3736

38-
if (
39-
(comparsion & RCTTextSizeComparisonWithinRange) &&
40-
(comparsion & RCTTextSizeComparisonSmaller)
41-
) {
37+
if ((comparsion & RCTTextSizeComparisonWithinRange) &&
38+
(comparsion & RCTTextSizeComparisonSmaller)) {
4239
return;
4340
} else if (comparsion & RCTTextSizeComparisonSmaller) {
4441
bottomRatio = ratio;
@@ -50,11 +47,9 @@ - (void)scaleFontSizeToFitSize:(CGSize)size
5047
ratio = (topRatio + bottomRatio) / 2.0;
5148

5249
CGFloat kRatioThreshold = 0.005;
53-
if (
54-
ABS(topRatio - bottomRatio) < kRatioThreshold ||
50+
if (ABS(topRatio - bottomRatio) < kRatioThreshold ||
5551
ABS(topRatio - ratio) < kRatioThreshold ||
56-
ABS(bottomRatio - ratio) < kRatioThreshold
57-
) {
52+
ABS(bottomRatio - ratio) < kRatioThreshold) {
5853
[self replaceCharactersInRange:(NSRange){0, self.length}
5954
withAttributedString:originalAttributedString];
6055

@@ -69,37 +64,38 @@ - (void)scaleFontSizeToFitSize:(CGSize)size
6964
}
7065
}
7166

72-
73-
- (RCTTextSizeComparisonOptions)compareToSize:(CGSize)size thresholdRatio:(CGFloat)thresholdRatio
74-
{
67+
- (RCTTextSizeComparisonOptions)compareToSize:(CGSize)size
68+
thresholdRatio:(CGFloat)thresholdRatio {
7569
NSLayoutManager *layoutManager = self.layoutManagers.firstObject;
7670
NSTextContainer *textContainer = layoutManager.textContainers.firstObject;
7771

7872
[layoutManager ensureLayoutForTextContainer:textContainer];
7973

8074
// Does it fit the text container?
8175
NSRange glyphRange = [layoutManager glyphRangeForTextContainer:textContainer];
82-
NSRange truncatedGlyphRange = [layoutManager truncatedGlyphRangeInLineFragmentForGlyphAtIndex:glyphRange.length - 1];
76+
NSRange truncatedGlyphRange = [layoutManager
77+
truncatedGlyphRangeInLineFragmentForGlyphAtIndex:glyphRange.length - 1];
8378

8479
if (truncatedGlyphRange.location != NSNotFound) {
8580
return RCTTextSizeComparisonLarger;
8681
}
8782

88-
CGSize measuredSize = [layoutManager usedRectForTextContainer:textContainer].size;
83+
CGSize measuredSize =
84+
[layoutManager usedRectForTextContainer:textContainer].size;
8985

9086
// Does it fit the size?
9187
BOOL fitsSize =
92-
size.width >= measuredSize.width &&
93-
size.height >= measuredSize.height;
88+
size.width >= measuredSize.width && size.height >= measuredSize.height;
9489

9590
CGSize thresholdSize = (CGSize){
96-
size.width * thresholdRatio,
97-
size.height * thresholdRatio,
91+
size.width * thresholdRatio,
92+
size.height * thresholdRatio,
9893
};
9994

10095
RCTTextSizeComparisonOptions result = 0;
10196

102-
result |= (fitsSize) ? RCTTextSizeComparisonSmaller : RCTTextSizeComparisonLarger;
97+
result |=
98+
(fitsSize) ? RCTTextSizeComparisonSmaller : RCTTextSizeComparisonLarger;
10399

104100
if (ABS(measuredSize.width - size.width) < thresholdSize.width) {
105101
result = result | RCTTextSizeComparisonWithinRange;
@@ -110,26 +106,28 @@ - (RCTTextSizeComparisonOptions)compareToSize:(CGSize)size thresholdRatio:(CGFlo
110106

111107
- (void)scaleFontSizeWithRatio:(CGFloat)ratio
112108
minimumFontSize:(CGFloat)minimumFontSize
113-
maximumFontSize:(CGFloat)maximumFontSize
114-
{
109+
maximumFontSize:(CGFloat)maximumFontSize {
115110
[self beginEditing];
116111

117-
[self enumerateAttribute:NSFontAttributeName
118-
inRange:(NSRange){0, self.length}
119-
options:NSAttributedStringEnumerationLongestEffectiveRangeNotRequired
120-
usingBlock:
121-
^(UIFont *_Nullable font, NSRange range, BOOL *_Nonnull stop) {
122-
if (!font) {
123-
return;
124-
}
125-
126-
CGFloat fontSize = MAX(MIN(font.pointSize * ratio, maximumFontSize), minimumFontSize);
127-
128-
[self addAttribute:NSFontAttributeName
129-
value:[font fontWithSize:fontSize]
130-
range:range];
131-
}
132-
];
112+
[self
113+
enumerateAttribute:NSFontAttributeName
114+
inRange:(NSRange){0, self.length}
115+
options:
116+
NSAttributedStringEnumerationLongestEffectiveRangeNotRequired
117+
usingBlock:^(
118+
UIFont *_Nullable font, NSRange range, BOOL *_Nonnull stop) {
119+
if (!font) {
120+
return;
121+
}
122+
123+
CGFloat fontSize =
124+
MAX(MIN(font.pointSize * ratio, maximumFontSize),
125+
minimumFontSize);
126+
127+
[self addAttribute:NSFontAttributeName
128+
value:[font fontWithSize:fontSize]
129+
range:range];
130+
}];
133131

134132
[self endEditing];
135133
}

ReactCommon/fabric/textlayoutmanager/platform/ios/RCTFontUtils.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ static UIFontWeight RCTUIFontWeightFromFloat(CGFloat fontWeight) {
120120

121121
fontDescriptor =
122122
[fontDescriptor fontDescriptorWithSymbolicTraits:symbolicTraits];
123-
font =
124-
[UIFont fontWithDescriptor:fontDescriptor size:fontProperties.size];
123+
font = [UIFont fontWithDescriptor:fontDescriptor
124+
size:fontProperties.size];
125125
}
126126

127127
{

ReactCommon/fabric/uimanager/ComponentDescriptorRegistry.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ static const std::string componentNameByReactViewName(std::string viewName) {
8181
}
8282

8383
static const RawProps rawPropsFromDynamic(const folly::dynamic object) {
84-
// TODO: Convert this to something smarter, probably returning `std::iterator`.
84+
// TODO: Convert this to something smarter, probably returning
85+
// `std::iterator`.
8586
RawProps result;
8687

8788
if (object.isNull()) {
@@ -103,13 +104,12 @@ SharedShadowNode ComponentDescriptorRegistry::createNode(Tag tag, const std::str
103104
const SharedComponentDescriptor &componentDescriptor = (*this)[componentName];
104105
RawProps rawProps = rawPropsFromDynamic(props);
105106

106-
SharedShadowNode shadowNode =
107-
componentDescriptor->createShadowNode({
108-
.tag = tag,
109-
.rootTag = rootTag,
110-
.eventEmitter = componentDescriptor->createEventEmitter(std::move(eventTarget), tag),
111-
.props = componentDescriptor->cloneProps(nullptr, rawProps)
112-
});
107+
SharedShadowNode shadowNode = componentDescriptor->createShadowNode(
108+
{.tag = tag,
109+
.rootTag = rootTag,
110+
.eventEmitter =
111+
componentDescriptor->createEventEmitter(std::move(eventTarget), tag),
112+
.props = componentDescriptor->cloneProps(nullptr, rawProps)});
113113
return shadowNode;
114114
}
115115

ReactCommon/fabric/uimanager/FabricUIManager.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,14 @@ void FabricUIManager::stopSurface(SurfaceId surfaceId) const {
123123
(*executor_)([this, surfaceId] { stopSurfaceFunction_(surfaceId); });
124124
}
125125

126-
SharedShadowNode FabricUIManager::createNode(int tag, std::string viewName, int rootTag, folly::dynamic props, SharedEventTarget eventTarget) const {
127-
SharedShadowNode shadowNode = componentDescriptorRegistry_->createNode(tag, viewName, rootTag, props, eventTarget);
126+
SharedShadowNode FabricUIManager::createNode(
127+
int tag,
128+
std::string viewName,
129+
int rootTag,
130+
folly::dynamic props,
131+
SharedEventTarget eventTarget) const {
132+
SharedShadowNode shadowNode = componentDescriptorRegistry_->createNode(
133+
tag, viewName, rootTag, props, eventTarget);
128134
if (delegate_) {
129135
delegate_->uiManagerDidCreateShadowNode(shadowNode);
130136
}

0 commit comments

Comments
 (0)