Skip to content

Commit fe04344

Browse files
generatedunixname89002005287564facebook-github-bot
authored andcommitted
Fix CQS signal modernize-use-designated-initializers in xplat/js/react-native-github/packages [A] (#53971)
Summary: Pull Request resolved: #53971 Reviewed By: rshest Differential Revision: D83395511 fbshipit-source-id: 832901c112d6ebf0b58280bf12a50f7845251c5c
1 parent c472059 commit fe04344

File tree

12 files changed

+140
-102
lines changed

12 files changed

+140
-102
lines changed

packages/react-native/ReactCommon/react/renderer/css/CSSRatio.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,12 @@ struct CSSDataTypeParser<CSSRatio> {
5555
if (std::holds_alternative<CSSNumber>(denominator) &&
5656
std::get<CSSNumber>(denominator).value >= 0) {
5757
parseNextCSSValue<CSSNumber>(parser, CSSDelimiter::Solidus);
58-
return CSSRatio{numeratorValue, std::get<CSSNumber>(denominator).value};
58+
return CSSRatio{
59+
.numerator = numeratorValue,
60+
.denominator = std::get<CSSNumber>(denominator).value};
5961
}
6062

61-
return CSSRatio{numeratorValue, 1.0f};
63+
return CSSRatio{.numerator = numeratorValue, .denominator = 1.0f};
6264
}
6365

6466
return {};

packages/react-native/ReactCommon/react/renderer/css/CSSTransform.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ struct CSSDataTypeParser<CSSScale> {
310310
? std::get<CSSNumber>(y).value
311311
: std::get<CSSPercentage>(y).value / 100.0f;
312312

313-
return CSSScale{normX, normY};
313+
return CSSScale{.x = normX, .y = normY};
314314
}
315315
};
316316

packages/react-native/ReactCommon/react/renderer/css/tests/CSSFilterTest.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ TEST(CSSFilter, drop_shadow_no_blur_pre_color) {
177177
std::get<CSSDropShadowFilter>(value).standardDeviation.unit,
178178
CSSLengthUnit::Px);
179179

180-
CSSColor red{255, 0, 0, 255};
180+
CSSColor red{.r = 255, .g = 0, .b = 0, .a = 255};
181181
EXPECT_EQ(std::get<CSSDropShadowFilter>(value).color, red);
182182
}
183183

@@ -195,7 +195,7 @@ TEST(CSSFilter, drop_shadow_no_blur_post_color) {
195195
EXPECT_EQ(
196196
std::get<CSSDropShadowFilter>(value).standardDeviation.unit,
197197
CSSLengthUnit::Px);
198-
CSSColor red{255, 0, 0, 255};
198+
CSSColor red{.r = 255, .g = 0, .b = 0, .a = 255};
199199

200200
EXPECT_EQ(std::get<CSSDropShadowFilter>(value).color, red);
201201
}
@@ -231,7 +231,7 @@ TEST(CSSFilter, drop_shadow_with_blur_pre_color) {
231231
std::get<CSSDropShadowFilter>(value).standardDeviation.unit,
232232
CSSLengthUnit::Px);
233233

234-
CSSColor red{255, 0, 0, 255};
234+
CSSColor red{.r = 255, .g = 0, .b = 0, .a = 255};
235235
EXPECT_EQ(std::get<CSSDropShadowFilter>(value).color, red);
236236
}
237237

@@ -250,7 +250,7 @@ TEST(CSSFilter, drop_shadow_with_blur_post_color) {
250250
std::get<CSSDropShadowFilter>(value).standardDeviation.unit,
251251
CSSLengthUnit::Px);
252252

253-
CSSColor red{255, 0, 0, 255};
253+
CSSColor red{.r = 255, .g = 0, .b = 0, .a = 255};
254254
EXPECT_EQ(std::get<CSSDropShadowFilter>(value).color, red);
255255
}
256256

@@ -550,7 +550,7 @@ TEST(CSSFilter, filter_list) {
550550
EXPECT_EQ(
551551
std::get<CSSDropShadowFilter>(list[2]).standardDeviation.unit,
552552
CSSLengthUnit::Px);
553-
CSSColor red{255, 0, 0, 255};
553+
CSSColor red{.r = 255, .g = 0, .b = 0, .a = 255};
554554
EXPECT_EQ(std::get<CSSDropShadowFilter>(list[2]).color, red);
555555

556556
EXPECT_TRUE(std::holds_alternative<CSSDropShadowFilter>(list[3]));

packages/react-native/ReactCommon/react/renderer/css/tests/CSSShadowTest.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ TEST(CSSShadow, trailing_color) {
9494
EXPECT_EQ(shadow.spreadDistance.value, 0.0f);
9595
EXPECT_EQ(shadow.spreadDistance.unit, CSSLengthUnit::Px);
9696

97-
CSSColor red{255u, 0u, 0u, 255u};
97+
CSSColor red{.r = 255u, .g = 0u, .b = 0u, .a = 255u};
9898
EXPECT_EQ(shadow.color, red);
9999
EXPECT_FALSE(shadow.inset);
100100
}
@@ -113,7 +113,7 @@ TEST(CSSShadow, leading_color) {
113113
EXPECT_EQ(shadow.spreadDistance.value, 0.0f);
114114
EXPECT_EQ(shadow.spreadDistance.unit, CSSLengthUnit::Px);
115115

116-
CSSColor red{255u, 0u, 0u, 255u};
116+
CSSColor red{.r = 255u, .g = 0u, .b = 0u, .a = 255u};
117117
EXPECT_EQ(shadow.color, red);
118118
EXPECT_FALSE(shadow.inset);
119119
}
@@ -132,7 +132,7 @@ TEST(CSSShadow, color_function) {
132132
EXPECT_EQ(shadow.spreadDistance.value, 0.0f);
133133
EXPECT_EQ(shadow.spreadDistance.unit, CSSLengthUnit::Px);
134134

135-
CSSColor red{255u, 0u, 0u, 128u};
135+
CSSColor red{.r = 255u, .g = 0u, .b = 0u, .a = 128u};
136136
EXPECT_EQ(shadow.color, red);
137137
EXPECT_FALSE(shadow.inset);
138138
}
@@ -202,7 +202,7 @@ TEST(CSShadow, color_length_inset) {
202202
EXPECT_EQ(shadow.spreadDistance.value, 0.0f);
203203
EXPECT_EQ(shadow.spreadDistance.unit, CSSLengthUnit::Px);
204204

205-
CSSColor red{255u, 0u, 0u, 255u};
205+
CSSColor red{.r = 255u, .g = 0u, .b = 0u, .a = 255u};
206206
EXPECT_EQ(shadow.color, red);
207207
EXPECT_TRUE(shadow.inset);
208208
}
@@ -224,7 +224,7 @@ TEST(CSSShadow, multiple_shadows) {
224224
EXPECT_EQ(shadows[0].spreadDistance.value, 0.0f);
225225
EXPECT_EQ(shadows[0].spreadDistance.unit, CSSLengthUnit::Px);
226226

227-
CSSColor red{255u, 0u, 0u, 255u};
227+
CSSColor red{.r = 255u, .g = 0u, .b = 0u, .a = 255u};
228228
EXPECT_EQ(shadows[0].color, red);
229229
EXPECT_FALSE(shadows[0].inset);
230230

@@ -268,7 +268,7 @@ TEST(CSSShadow, multiple_shadows_with_new_line) {
268268
EXPECT_EQ(shadows[0].spreadDistance.value, 0.0f);
269269
EXPECT_EQ(shadows[0].spreadDistance.unit, CSSLengthUnit::Px);
270270

271-
CSSColor red{255u, 0u, 0u, 255u};
271+
CSSColor red{.r = 255u, .g = 0u, .b = 0u, .a = 255u};
272272
EXPECT_EQ(shadows[0].color, red);
273273
EXPECT_FALSE(shadows[0].inset);
274274

packages/react-native/ReactCommon/react/renderer/dom/DOM.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,9 @@ Rect getScrollableContentBounds(
151151
: std::max(
152152
paddingFrame.getMaxX(), contentBounds.getMaxX() + paddingRight);
153153

154-
return Rect{Point{minX, minY}, Size{maxX - minX, maxY - minY}};
154+
return Rect{
155+
.origin = Point{.x = minX, .y = minY},
156+
.size = Size{.width = maxX - minX, .height = maxY - minY}};
155157
}
156158

157159
} // namespace

packages/react-native/ReactCommon/react/renderer/element/ComponentBuilder.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,19 @@ std::shared_ptr<ShadowNode> ComponentBuilder::build(
2727
}
2828

2929
auto family = componentDescriptor.createFamily(ShadowNodeFamilyFragment{
30-
elementFragment.tag, elementFragment.surfaceId, nullptr});
30+
.tag = elementFragment.tag,
31+
.surfaceId = elementFragment.surfaceId,
32+
.instanceHandle = nullptr});
3133

3234
auto initialState =
3335
componentDescriptor.createInitialState(elementFragment.props, family);
3436

3537
auto constShadowNode = componentDescriptor.createShadowNode(
3638
ShadowNodeFragment{
37-
elementFragment.props,
38-
std::make_shared<
39+
.props = elementFragment.props,
40+
.children = std::make_shared<
3941
const std::vector<std::shared_ptr<const ShadowNode>>>(children),
40-
initialState},
42+
.state = initialState},
4143
family);
4244

4345
if (elementFragment.stateCallback) {
@@ -46,9 +48,9 @@ std::shared_ptr<ShadowNode> ComponentBuilder::build(
4648
constShadowNode = componentDescriptor.cloneShadowNode(
4749
*constShadowNode,
4850
ShadowNodeFragment{
49-
ShadowNodeFragment::propsPlaceholder(),
50-
ShadowNodeFragment::childrenPlaceholder(),
51-
newState});
51+
.props = ShadowNodeFragment::propsPlaceholder(),
52+
.children = ShadowNodeFragment::childrenPlaceholder(),
53+
.state = newState});
5254
}
5355

5456
auto shadowNode = std::const_pointer_cast<ShadowNode>(constShadowNode);

packages/react-native/ReactCommon/react/renderer/element/testUtils.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ inline ComponentBuilder simpleComponentBuilder(
2626
auto componentDescriptorRegistry =
2727
componentDescriptorProviderRegistry.createComponentDescriptorRegistry(
2828
ComponentDescriptorParameters{
29-
eventDispatcher, std::move(contextContainer), nullptr});
29+
.eventDispatcher = eventDispatcher,
30+
.contextContainer = std::move(contextContainer),
31+
.flavor = nullptr});
3032

3133
componentDescriptorProviderRegistry.add(
3234
concreteComponentDescriptorProvider<RootComponentDescriptor>());

packages/react-native/ReactCommon/react/renderer/graphics/Color.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,20 @@ SharedColor colorFromRGBA(uint8_t r, uint8_t g, uint8_t b, uint8_t a) {
5353
}
5454

5555
SharedColor clearColor() {
56-
static SharedColor color = colorFromComponents(ColorComponents{0, 0, 0, 0});
56+
static SharedColor color = colorFromComponents(
57+
ColorComponents{.red = 0, .green = 0, .blue = 0, .alpha = 0});
5758
return color;
5859
}
5960

6061
SharedColor blackColor() {
61-
static SharedColor color = colorFromComponents(ColorComponents{0, 0, 0, 1});
62+
static SharedColor color = colorFromComponents(
63+
ColorComponents{.red = 0, .green = 0, .blue = 0, .alpha = 1});
6264
return color;
6365
}
6466

6567
SharedColor whiteColor() {
66-
static SharedColor color = colorFromComponents(ColorComponents{1, 1, 1, 1});
68+
static SharedColor color = colorFromComponents(
69+
ColorComponents{.red = 1, .green = 1, .blue = 1, .alpha = 1});
6770
return color;
6871
}
6972

packages/react-native/ReactCommon/react/renderer/graphics/Rect.h

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ namespace facebook::react {
2121
* Contains the location and dimensions of a rectangle.
2222
*/
2323
struct Rect {
24-
Point origin{0, 0};
25-
Size size{0, 0};
24+
Point origin{.x = 0, .y = 0};
25+
Size size{.width = 0, .height = 0};
2626

2727
bool operator==(const Rect& rhs) const noexcept {
2828
return std::tie(this->origin, this->size) == std::tie(rhs.origin, rhs.size);
@@ -51,16 +51,16 @@ struct Rect {
5151
return origin.y + size.height / 2;
5252
}
5353
Point getCenter() const noexcept {
54-
return {getMidX(), getMidY()};
54+
return {.x = getMidX(), .y = getMidY()};
5555
}
5656

5757
void unionInPlace(const Rect& rect) noexcept {
5858
auto x1 = std::min(getMinX(), rect.getMinX());
5959
auto y1 = std::min(getMinY(), rect.getMinY());
6060
auto x2 = std::max(getMaxX(), rect.getMaxX());
6161
auto y2 = std::max(getMaxY(), rect.getMaxY());
62-
origin = {x1, y1};
63-
size = {x2 - x1, y2 - y1};
62+
origin = {.x = x1, .y = y1};
63+
size = {.width = x2 - x1, .height = y2 - y1};
6464
}
6565

6666
bool containsPoint(Point point) noexcept {
@@ -84,7 +84,9 @@ struct Rect {
8484
return {};
8585
}
8686

87-
return {{x1, y1}, {intersectionWidth, intersectionHeight}};
87+
return {
88+
.origin = {.x = x1, .y = y1},
89+
.size = {.width = intersectionWidth, .height = intersectionHeight}};
8890
}
8991

9092
static Rect boundingRect(
@@ -112,9 +114,10 @@ struct Rect {
112114
rightBottomPoint.y = std::max(rightBottomPoint.y, d.y);
113115

114116
return {
115-
leftTopPoint,
116-
{rightBottomPoint.x - leftTopPoint.x,
117-
rightBottomPoint.y - leftTopPoint.y}};
117+
.origin = leftTopPoint,
118+
.size = {
119+
.width = rightBottomPoint.x - leftTopPoint.x,
120+
.height = rightBottomPoint.y - leftTopPoint.y}};
118121
}
119122
};
120123

packages/react-native/ReactCommon/react/renderer/graphics/RectangleEdges.h

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,19 +77,23 @@ using EdgeInsets = RectangleEdges<Float>;
7777
*/
7878
inline Rect insetBy(const Rect& rect, const EdgeInsets& insets) noexcept {
7979
return Rect{
80-
{rect.origin.x + insets.left, rect.origin.y + insets.top},
81-
{rect.size.width - insets.left - insets.right,
82-
rect.size.height - insets.top - insets.bottom}};
80+
.origin =
81+
{.x = rect.origin.x + insets.left, .y = rect.origin.y + insets.top},
82+
.size = {
83+
.width = rect.size.width - insets.left - insets.right,
84+
.height = rect.size.height - insets.top - insets.bottom}};
8385
}
8486

8587
/*
8688
* Adjusts a rectangle by the given edge outsets.
8789
*/
8890
inline Rect outsetBy(const Rect& rect, const EdgeInsets& outsets) noexcept {
8991
return Rect{
90-
{rect.origin.x - outsets.left, rect.origin.y - outsets.top},
91-
{rect.size.width + outsets.left + outsets.right,
92-
rect.size.height + outsets.top + outsets.bottom}};
92+
.origin =
93+
{.x = rect.origin.x - outsets.left, .y = rect.origin.y - outsets.top},
94+
.size = {
95+
.width = rect.size.width + outsets.left + outsets.right,
96+
.height = rect.size.height + outsets.top + outsets.bottom}};
9397
}
9498

9599
} // namespace facebook::react

0 commit comments

Comments
 (0)