diff --git a/packages/react-native/ReactCommon/react/renderer/components/view/FilterPropsConversions.h b/packages/react-native/ReactCommon/react/renderer/components/view/FilterPropsConversions.h index 55653634ba3..8cea91e4fd0 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/view/FilterPropsConversions.h +++ b/packages/react-native/ReactCommon/react/renderer/components/view/FilterPropsConversions.h @@ -301,7 +301,8 @@ inline std::optional parseDropShadow( } } - return FilterFunction{FilterType::DropShadow, dropShadowParams}; + return FilterFunction{ + .type = FilterType::DropShadow, .parameters = dropShadowParams}; } inline std::optional parseFilterRawValue( @@ -326,12 +327,13 @@ inline std::optional parseFilterRawValue( if (*length < 0.0f) { return {}; } - return FilterFunction{FilterType::Blur, *length}; + return FilterFunction{.type = FilterType::Blur, .parameters = *length}; } return {}; } else if (filterKey == "hue-rotate") { if (auto angle = coerceAngle(rawFilter.begin()->second)) { - return FilterFunction{FilterType::HueRotate, *angle}; + return FilterFunction{ + .type = FilterType::HueRotate, .parameters = *angle}; } return {}; } else { @@ -339,7 +341,8 @@ inline std::optional parseFilterRawValue( if (*amount < 0.0f) { return {}; } - return FilterFunction{filterTypeFromString(filterKey), *amount}; + return FilterFunction{ + .type = filterTypeFromString(filterKey), .parameters = *amount}; } return {}; } diff --git a/packages/react-native/ReactCommon/react/renderer/components/view/PointerEvent.cpp b/packages/react-native/ReactCommon/react/renderer/components/view/PointerEvent.cpp index 23ab7a9cfc9..46a3ba86996 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/view/PointerEvent.cpp +++ b/packages/react-native/ReactCommon/react/renderer/components/view/PointerEvent.cpp @@ -58,27 +58,46 @@ std::vector getDebugProps( const PointerEvent& pointerEvent, DebugStringConvertibleOptions options) { return { - {"pointerId", getDebugDescription(pointerEvent.pointerId, options)}, - {"pressure", getDebugDescription(pointerEvent.pressure, options)}, - {"pointerType", getDebugDescription(pointerEvent.pointerType, options)}, - {"clientPoint", getDebugDescription(pointerEvent.clientPoint, options)}, - {"screenPoint", getDebugDescription(pointerEvent.screenPoint, options)}, - {"offsetPoint", getDebugDescription(pointerEvent.offsetPoint, options)}, - {"width", getDebugDescription(pointerEvent.width, options)}, - {"height", getDebugDescription(pointerEvent.height, options)}, - {"tiltX", getDebugDescription(pointerEvent.tiltX, options)}, - {"tiltY", getDebugDescription(pointerEvent.tiltY, options)}, - {"detail", getDebugDescription(pointerEvent.detail, options)}, - {"buttons", getDebugDescription(pointerEvent.buttons, options)}, - {"tangentialPressure", - getDebugDescription(pointerEvent.tangentialPressure, options)}, - {"twist", getDebugDescription(pointerEvent.twist, options)}, - {"ctrlKey", getDebugDescription(pointerEvent.ctrlKey, options)}, - {"shiftKey", getDebugDescription(pointerEvent.shiftKey, options)}, - {"altKey", getDebugDescription(pointerEvent.altKey, options)}, - {"metaKey", getDebugDescription(pointerEvent.metaKey, options)}, - {"isPrimary", getDebugDescription(pointerEvent.isPrimary, options)}, - {"button", getDebugDescription(pointerEvent.button, options)}, + {.name = "pointerId", + .value = getDebugDescription(pointerEvent.pointerId, options)}, + {.name = "pressure", + .value = getDebugDescription(pointerEvent.pressure, options)}, + {.name = "pointerType", + .value = getDebugDescription(pointerEvent.pointerType, options)}, + {.name = "clientPoint", + .value = getDebugDescription(pointerEvent.clientPoint, options)}, + {.name = "screenPoint", + .value = getDebugDescription(pointerEvent.screenPoint, options)}, + {.name = "offsetPoint", + .value = getDebugDescription(pointerEvent.offsetPoint, options)}, + {.name = "width", + .value = getDebugDescription(pointerEvent.width, options)}, + {.name = "height", + .value = getDebugDescription(pointerEvent.height, options)}, + {.name = "tiltX", + .value = getDebugDescription(pointerEvent.tiltX, options)}, + {.name = "tiltY", + .value = getDebugDescription(pointerEvent.tiltY, options)}, + {.name = "detail", + .value = getDebugDescription(pointerEvent.detail, options)}, + {.name = "buttons", + .value = getDebugDescription(pointerEvent.buttons, options)}, + {.name = "tangentialPressure", + .value = getDebugDescription(pointerEvent.tangentialPressure, options)}, + {.name = "twist", + .value = getDebugDescription(pointerEvent.twist, options)}, + {.name = "ctrlKey", + .value = getDebugDescription(pointerEvent.ctrlKey, options)}, + {.name = "shiftKey", + .value = getDebugDescription(pointerEvent.shiftKey, options)}, + {.name = "altKey", + .value = getDebugDescription(pointerEvent.altKey, options)}, + {.name = "metaKey", + .value = getDebugDescription(pointerEvent.metaKey, options)}, + {.name = "isPrimary", + .value = getDebugDescription(pointerEvent.isPrimary, options)}, + {.name = "button", + .value = getDebugDescription(pointerEvent.button, options)}, }; } diff --git a/packages/react-native/ReactCommon/react/renderer/components/view/TouchEvent.cpp b/packages/react-native/ReactCommon/react/renderer/components/view/TouchEvent.cpp index b7ccb24d644..d2641e567ce 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/view/TouchEvent.cpp +++ b/packages/react-native/ReactCommon/react/renderer/components/view/TouchEvent.cpp @@ -19,10 +19,12 @@ std::vector getDebugProps( const TouchEvent& touchEvent, DebugStringConvertibleOptions options) { return { - {"touches", getDebugDescription(touchEvent.touches, options)}, - {"changedTouches", - getDebugDescription(touchEvent.changedTouches, options)}, - {"targetTouches", getDebugDescription(touchEvent.targetTouches, options)}, + {.name = "touches", + .value = getDebugDescription(touchEvent.touches, options)}, + {.name = "changedTouches", + .value = getDebugDescription(touchEvent.changedTouches, options)}, + {.name = "targetTouches", + .value = getDebugDescription(touchEvent.targetTouches, options)}, }; } diff --git a/packages/react-native/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp b/packages/react-native/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp index 961a8bb25b9..bfe2c82b9a3 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp +++ b/packages/react-native/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp @@ -531,9 +531,9 @@ YogaLayoutableShadowNode& YogaLayoutableShadowNode::cloneChildInPlace( // TODO: Why does this not use `ShadowNodeFragment::statePlaceholder()` like // `adoptYogaChild()`? auto clonedChildNode = childNode.clone( - {ShadowNodeFragment::propsPlaceholder(), - ShadowNodeFragment::childrenPlaceholder(), - childNode.getState()}); + {.props = ShadowNodeFragment::propsPlaceholder(), + .children = ShadowNodeFragment::childrenPlaceholder(), + .state = childNode.getState()}); replaceChild(childNode, clonedChildNode, layoutableChildIndex); return static_cast(*clonedChildNode); @@ -814,10 +814,10 @@ YGSize YogaLayoutableShadowNode::yogaNodeMeasureCallbackConnector( auto& shadowNode = shadowNodeFromContext(yogaNode); - auto minimumSize = Size{0, 0}; + auto minimumSize = Size{.width = 0, .height = 0}; auto maximumSize = Size{ - std::numeric_limits::infinity(), - std::numeric_limits::infinity()}; + .width = std::numeric_limits::infinity(), + .height = std::numeric_limits::infinity()}; switch (widthMode) { case YGMeasureModeUndefined: @@ -844,7 +844,8 @@ YGSize YogaLayoutableShadowNode::yogaNodeMeasureCallbackConnector( } auto size = shadowNode.measureContent( - threadLocalLayoutContext, {minimumSize, maximumSize}); + threadLocalLayoutContext, + {.minimumSize = minimumSize, .maximumSize = maximumSize}); #ifdef REACT_NATIVE_DEBUG bool widthInBounds = size.width + kDefaultEpsilon >= minimumSize.width && diff --git a/packages/react-native/ReactCommon/react/renderer/components/view/conversions.h b/packages/react-native/ReactCommon/react/renderer/components/view/conversions.h index 115d9e0163a..c8fe90ddbe2 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/view/conversions.h +++ b/packages/react-native/ReactCommon/react/renderer/components/view/conversions.h @@ -131,12 +131,13 @@ inline LayoutMetrics layoutMetricsFromYogaNode(yoga::Node& yogaNode) { auto layoutMetrics = LayoutMetrics{}; layoutMetrics.frame = Rect{ - Point{ - floatFromYogaFloat(YGNodeLayoutGetLeft(&yogaNode)), - floatFromYogaFloat(YGNodeLayoutGetTop(&yogaNode))}, - Size{ - floatFromYogaFloat(YGNodeLayoutGetWidth(&yogaNode)), - floatFromYogaFloat(YGNodeLayoutGetHeight(&yogaNode))}}; + .origin = + Point{ + .x = floatFromYogaFloat(YGNodeLayoutGetLeft(&yogaNode)), + .y = floatFromYogaFloat(YGNodeLayoutGetTop(&yogaNode))}, + .size = Size{ + .width = floatFromYogaFloat(YGNodeLayoutGetWidth(&yogaNode)), + .height = floatFromYogaFloat(YGNodeLayoutGetHeight(&yogaNode))}}; layoutMetrics.borderWidth = EdgeInsets{ floatFromYogaFloat(YGNodeLayoutGetBorder(&yogaNode, YGEdgeLeft)), @@ -645,7 +646,10 @@ inline void fromRawValue( transformMatrix.matrix[15] = numbers[8]; } transformMatrix.operations.push_back(TransformOperation{ - TransformOperationType::Arbitrary, Zero, Zero, Zero}); + .type = TransformOperationType::Arbitrary, + .x = Zero, + .y = Zero, + .z = Zero}); } else if (operation == "perspective") { if (!parameters.hasType()) { result = {}; @@ -653,10 +657,10 @@ inline void fromRawValue( } transformMatrix.operations.push_back(TransformOperation{ - TransformOperationType::Perspective, - ValueUnit((Float)parameters, UnitType::Point), - Zero, - Zero}); + .type = TransformOperationType::Perspective, + .x = ValueUnit((Float)parameters, UnitType::Point), + .y = Zero, + .z = Zero}); } else if (operation == "rotateX") { auto radians = toRadians(parameters); if (!radians.has_value()) { @@ -665,10 +669,10 @@ inline void fromRawValue( } transformMatrix.operations.push_back(TransformOperation{ - TransformOperationType::Rotate, - ValueUnit(*radians, UnitType::Point), - Zero, - Zero}); + .type = TransformOperationType::Rotate, + .x = ValueUnit(*radians, UnitType::Point), + .y = Zero, + .z = Zero}); } else if (operation == "rotateY") { auto radians = toRadians(parameters); if (!radians.has_value()) { @@ -677,10 +681,10 @@ inline void fromRawValue( } transformMatrix.operations.push_back(TransformOperation{ - TransformOperationType::Rotate, - Zero, - ValueUnit(*radians, UnitType::Point), - Zero}); + .type = TransformOperationType::Rotate, + .x = Zero, + .y = ValueUnit(*radians, UnitType::Point), + .z = Zero}); } else if (operation == "rotateZ" || operation == "rotate") { auto radians = toRadians(parameters); if (!radians.has_value()) { @@ -689,10 +693,10 @@ inline void fromRawValue( } transformMatrix.operations.push_back(TransformOperation{ - TransformOperationType::Rotate, - Zero, - Zero, - ValueUnit(*radians, UnitType::Point)}); + .type = TransformOperationType::Rotate, + .x = Zero, + .y = Zero, + .z = ValueUnit(*radians, UnitType::Point)}); } else if (operation == "scale") { if (!parameters.hasType()) { result = {}; @@ -701,7 +705,10 @@ inline void fromRawValue( auto number = ValueUnit((Float)parameters, UnitType::Point); transformMatrix.operations.push_back(TransformOperation{ - TransformOperationType::Scale, number, number, number}); + .type = TransformOperationType::Scale, + .x = number, + .y = number, + .z = number}); } else if (operation == "scaleX") { if (!parameters.hasType()) { result = {}; @@ -709,10 +716,10 @@ inline void fromRawValue( } transformMatrix.operations.push_back(TransformOperation{ - TransformOperationType::Scale, - ValueUnit((Float)parameters, UnitType::Point), - One, - One}); + .type = TransformOperationType::Scale, + .x = ValueUnit((Float)parameters, UnitType::Point), + .y = One, + .z = One}); } else if (operation == "scaleY") { if (!parameters.hasType()) { result = {}; @@ -720,10 +727,10 @@ inline void fromRawValue( } transformMatrix.operations.push_back(TransformOperation{ - TransformOperationType::Scale, - One, - ValueUnit((Float)parameters, UnitType::Point), - One}); + .type = TransformOperationType::Scale, + .x = One, + .y = ValueUnit((Float)parameters, UnitType::Point), + .z = One}); } else if (operation == "scaleZ") { if (!parameters.hasType()) { result = {}; @@ -731,10 +738,10 @@ inline void fromRawValue( } transformMatrix.operations.push_back(TransformOperation{ - TransformOperationType::Scale, - One, - One, - ValueUnit((Float)parameters, UnitType::Point)}); + .type = TransformOperationType::Scale, + .x = One, + .y = One, + .z = ValueUnit((Float)parameters, UnitType::Point)}); } else if (operation == "translate") { if (!parameters.hasType>()) { result = {}; @@ -760,7 +767,10 @@ inline void fromRawValue( } transformMatrix.operations.push_back(TransformOperation{ - TransformOperationType::Translate, valueX, valueY, Zero}); + .type = TransformOperationType::Translate, + .x = valueX, + .y = valueY, + .z = Zero}); } else if (operation == "translateX") { auto valueX = toValueUnit(parameters); if (!valueX) { @@ -769,7 +779,10 @@ inline void fromRawValue( } transformMatrix.operations.push_back(TransformOperation{ - TransformOperationType::Translate, valueX, Zero, Zero}); + .type = TransformOperationType::Translate, + .x = valueX, + .y = Zero, + .z = Zero}); } else if (operation == "translateY") { auto valueY = toValueUnit(parameters); if (!valueY) { @@ -778,7 +791,10 @@ inline void fromRawValue( } transformMatrix.operations.push_back(TransformOperation{ - TransformOperationType::Translate, Zero, valueY, Zero}); + .type = TransformOperationType::Translate, + .x = Zero, + .y = valueY, + .z = Zero}); } else if (operation == "skewX") { auto radians = toRadians(parameters); if (!radians.has_value()) { @@ -787,10 +803,10 @@ inline void fromRawValue( } transformMatrix.operations.push_back(TransformOperation{ - TransformOperationType::Skew, - ValueUnit(*radians, UnitType::Point), - Zero, - Zero}); + .type = TransformOperationType::Skew, + .x = ValueUnit(*radians, UnitType::Point), + .y = Zero, + .z = Zero}); } else if (operation == "skewY") { auto radians = toRadians(parameters); if (!radians.has_value()) { @@ -799,10 +815,10 @@ inline void fromRawValue( } transformMatrix.operations.push_back(TransformOperation{ - TransformOperationType::Skew, - Zero, - ValueUnit(*radians, UnitType::Point), - Zero}); + .type = TransformOperationType::Skew, + .x = Zero, + .y = ValueUnit(*radians, UnitType::Point), + .z = Zero}); } } @@ -1332,7 +1348,7 @@ inline void fromRawValue( if (xIt != sizeMap.end() && yIt != sizeMap.end()) { RadialGradientSize sizeObj; sizeObj.value = RadialGradientSize::Dimensions{ - toValueUnit(xIt->second), toValueUnit(yIt->second)}; + .x = toValueUnit(xIt->second), .y = toValueUnit(yIt->second)}; radialGradient.size = sizeObj; } } diff --git a/packages/react-native/ReactCommon/react/renderer/components/view/tests/LayoutTest.cpp b/packages/react-native/ReactCommon/react/renderer/components/view/tests/LayoutTest.cpp index d722f674135..22cf5d7c602 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/view/tests/LayoutTest.cpp +++ b/packages/react-native/ReactCommon/react/renderer/components/view/tests/LayoutTest.cpp @@ -75,7 +75,7 @@ class LayoutTest : public ::testing::Test { .props([] { auto sharedProps = std::make_shared(); auto &props = *sharedProps; - props.layoutConstraints = LayoutConstraints{{0,0}, {500, 500}}; + props.layoutConstraints = LayoutConstraints{.minimumSize={.width=0,.height=0}, .maximumSize={.width=500, .height=500}}; auto &yogaStyle = props.yogaStyle; yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleSizeLength::points(200)); yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleSizeLength::points(200)); diff --git a/packages/react-native/ReactCommon/react/renderer/components/view/tests/ViewTest.cpp b/packages/react-native/ReactCommon/react/renderer/components/view/tests/ViewTest.cpp index 3339437b50f..c6d426ac558 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/view/tests/ViewTest.cpp +++ b/packages/react-native/ReactCommon/react/renderer/components/view/tests/ViewTest.cpp @@ -97,7 +97,7 @@ TEST_F(YogaDirtyFlagTest, cloningPropsWithoutChangingThem) { auto& componentDescriptor = oldShadowNode.getComponentDescriptor(); auto props = componentDescriptor.cloneProps( parserContext, oldShadowNode.getProps(), RawProps()); - return oldShadowNode.clone(ShadowNodeFragment{props}); + return oldShadowNode.clone(ShadowNodeFragment{.props = props}); }); EXPECT_FALSE( @@ -120,7 +120,7 @@ TEST_F(YogaDirtyFlagTest, changingNonLayoutSubPropsMustNotDirtyYogaNode) { props.shouldRasterize = !props.shouldRasterize; props.collapsable = !props.collapsable; - return oldShadowNode.clone(ShadowNodeFragment{viewProps}); + return oldShadowNode.clone(ShadowNodeFragment{.props = viewProps}); }); EXPECT_FALSE( @@ -139,7 +139,7 @@ TEST_F(YogaDirtyFlagTest, changingLayoutSubPropsMustDirtyYogaNode) { props.yogaStyle.setAlignContent(yoga::Align::Baseline); props.yogaStyle.setDisplay(yoga::Display::None); - return oldShadowNode.clone(ShadowNodeFragment{viewProps}); + return oldShadowNode.clone(ShadowNodeFragment{.props = viewProps}); }); EXPECT_TRUE( @@ -153,8 +153,8 @@ TEST_F(YogaDirtyFlagTest, removingAllChildrenMustDirtyYogaNode) { auto newRootShadowNode = rootShadowNode_->cloneTree( innerShadowNode_->getFamily(), [](const ShadowNode& oldShadowNode) { return oldShadowNode.clone( - {ShadowNodeFragment::propsPlaceholder(), - ShadowNode::emptySharedShadowNodeSharedList()}); + {.props = ShadowNodeFragment::propsPlaceholder(), + .children = ShadowNode::emptySharedShadowNodeSharedList()}); }); EXPECT_TRUE( @@ -173,8 +173,8 @@ TEST_F(YogaDirtyFlagTest, removingLastChildMustDirtyYogaNode) { std::reverse(children.begin(), children.end()); return oldShadowNode.clone( - {ShadowNodeFragment::propsPlaceholder(), - std::make_shared< + {.props = ShadowNodeFragment::propsPlaceholder(), + .children = std::make_shared< const std::vector>>( children)}); }); @@ -194,8 +194,8 @@ TEST_F(YogaDirtyFlagTest, reversingListOfChildrenMustDirtyYogaNode) { std::reverse(children.begin(), children.end()); return oldShadowNode.clone( - {ShadowNodeFragment::propsPlaceholder(), - std::make_shared< + {.props = ShadowNodeFragment::propsPlaceholder(), + .children = std::make_shared< const std::vector>>( children)}); }); @@ -212,7 +212,7 @@ TEST_F(YogaDirtyFlagTest, updatingStateForScrollViewMistNotDirtyYogaNode) { auto newRootShadowNode = rootShadowNode_->cloneTree( scrollViewShadowNode_->getFamily(), [](const ShadowNode& oldShadowNode) { auto state = ScrollViewState{}; - state.contentOffset = Point{42, 9000}; + state.contentOffset = Point{.x = 42, .y = 9000}; auto& componentDescriptor = oldShadowNode.getComponentDescriptor(); auto newState = componentDescriptor.createState( @@ -220,9 +220,9 @@ TEST_F(YogaDirtyFlagTest, updatingStateForScrollViewMistNotDirtyYogaNode) { std::make_shared(state)); return oldShadowNode.clone( - {ShadowNodeFragment::propsPlaceholder(), - ShadowNodeFragment::childrenPlaceholder(), - newState}); + {.props = ShadowNodeFragment::propsPlaceholder(), + .children = ShadowNodeFragment::childrenPlaceholder(), + .state = newState}); }); EXPECT_FALSE( diff --git a/packages/react-native/ReactCommon/react/renderer/core/LayoutConstraints.cpp b/packages/react-native/ReactCommon/react/renderer/core/LayoutConstraints.cpp index 9f616638a02..206719f1c16 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/LayoutConstraints.cpp +++ b/packages/react-native/ReactCommon/react/renderer/core/LayoutConstraints.cpp @@ -13,8 +13,10 @@ namespace facebook::react { Size LayoutConstraints::clamp(const Size& size) const { return { - std::max(minimumSize.width, std::min(maximumSize.width, size.width)), - std::max(minimumSize.height, std::min(maximumSize.height, size.height))}; + .width = + std::max(minimumSize.width, std::min(maximumSize.width, size.width)), + .height = std::max( + minimumSize.height, std::min(maximumSize.height, size.height))}; } } // namespace facebook::react diff --git a/packages/react-native/ReactCommon/react/renderer/core/LayoutConstraints.h b/packages/react-native/ReactCommon/react/renderer/core/LayoutConstraints.h index ea3506065c1..20bfebca74b 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/LayoutConstraints.h +++ b/packages/react-native/ReactCommon/react/renderer/core/LayoutConstraints.h @@ -19,10 +19,10 @@ namespace facebook::react { * Unified layout constraints for measuring. */ struct LayoutConstraints { - Size minimumSize{0, 0}; + Size minimumSize{.width = 0, .height = 0}; Size maximumSize{ - std::numeric_limits::infinity(), - std::numeric_limits::infinity()}; + .width = std::numeric_limits::infinity(), + .height = std::numeric_limits::infinity()}; LayoutDirection layoutDirection{LayoutDirection::Undefined}; /* diff --git a/packages/react-native/ReactCommon/react/renderer/core/LayoutMetrics.cpp b/packages/react-native/ReactCommon/react/renderer/core/LayoutMetrics.cpp index f2fa1e9077d..a7add9fd041 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/LayoutMetrics.cpp +++ b/packages/react-native/ReactCommon/react/renderer/core/LayoutMetrics.cpp @@ -22,39 +22,39 @@ std::vector getDebugProps( const LayoutMetrics& object, DebugStringConvertibleOptions options) { return { - {"frame", - "{x:" + getDebugDescription(object.frame.origin.x, {}) + + {.name = "frame", + .value = "{x:" + getDebugDescription(object.frame.origin.x, {}) + ",y:" + getDebugDescription(object.frame.origin.y, {}) + ",width:" + getDebugDescription(object.frame.size.width, {}) + ",height:" + getDebugDescription(object.frame.size.height, {}) + "}"}, - {"contentInsets", - "{top:" + getDebugDescription(object.contentInsets.top, {}) + + {.name = "contentInsets", + .value = "{top:" + getDebugDescription(object.contentInsets.top, {}) + ",right:" + getDebugDescription(object.contentInsets.right, {}) + ",bottom:" + getDebugDescription(object.contentInsets.bottom, {}) + ",left:" + getDebugDescription(object.contentInsets.left, {}) + "}"}, - {"borderWidth", - "{top:" + getDebugDescription(object.borderWidth.top, {}) + + {.name = "borderWidth", + .value = "{top:" + getDebugDescription(object.borderWidth.top, {}) + ",right:" + getDebugDescription(object.borderWidth.right, {}) + ",bottom:" + getDebugDescription(object.borderWidth.bottom, {}) + ",left:" + getDebugDescription(object.borderWidth.left, {}) + "}"}, - {"overflowInset", - "{top:" + getDebugDescription(object.overflowInset.top, {}) + + {.name = "overflowInset", + .value = "{top:" + getDebugDescription(object.overflowInset.top, {}) + ",right:" + getDebugDescription(object.overflowInset.right, {}) + ",bottom:" + getDebugDescription(object.overflowInset.bottom, {}) + ",left:" + getDebugDescription(object.overflowInset.left, {}) + "}"}, - {"displayType", - object.displayType == DisplayType::None + {.name = "displayType", + .value = object.displayType == DisplayType::None ? "None" : (object.displayType == DisplayType::Flex ? "Flex" : "Inline")}, - {"layoutDirection", - object.layoutDirection == LayoutDirection::Undefined + {.name = "layoutDirection", + .value = object.layoutDirection == LayoutDirection::Undefined ? "Undefined" : (object.layoutDirection == LayoutDirection::LeftToRight ? "LeftToRight" : "RightToLeft")}, - {"pointScaleFactor", - getDebugDescription(object.pointScaleFactor, options)}, + {.name = "pointScaleFactor", + .value = getDebugDescription(object.pointScaleFactor, options)}, }; } diff --git a/packages/react-native/ReactCommon/react/renderer/core/LayoutMetrics.h b/packages/react-native/ReactCommon/react/renderer/core/LayoutMetrics.h index aab9d6275a4..74515cbaf3c 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/LayoutMetrics.h +++ b/packages/react-native/ReactCommon/react/renderer/core/LayoutMetrics.h @@ -50,10 +50,12 @@ struct LayoutMetrics { // Size: includes content only. 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}}; + .origin = Point{.x = contentInsets.left, .y = contentInsets.top}, + .size = Size{ + .width = + frame.size.width - contentInsets.left - contentInsets.right, + .height = + frame.size.height - contentInsets.top - contentInsets.bottom}}; } // Calculates the frame of the node including overflow insets. @@ -61,13 +63,15 @@ struct LayoutMetrics { // node (and their children, recursively). Rect getOverflowInsetFrame() const { return Rect{ - Point{ - frame.origin.x + std::min(Float{0}, overflowInset.left), - frame.origin.y + std::min(Float{0}, overflowInset.top)}, - Size{ - frame.size.width - std::min(Float{0}, overflowInset.left) + + .origin = + Point{ + .x = frame.origin.x + std::min(Float{0}, overflowInset.left), + .y = frame.origin.y + std::min(Float{0}, overflowInset.top)}, + .size = Size{ + .width = frame.size.width - std::min(Float{0}, overflowInset.left) + -std::min(Float{0}, overflowInset.right), - frame.size.height - std::min(Float{0}, overflowInset.top) + + .height = frame.size.height - + std::min(Float{0}, overflowInset.top) + -std::min(Float{0}, overflowInset.bottom)}}; } @@ -75,10 +79,11 @@ struct LayoutMetrics { // Size: includes content and padding (but no borders). Rect getPaddingFrame() const { return Rect{ - Point{borderWidth.left, borderWidth.top}, - Size{ - frame.size.width - borderWidth.left - borderWidth.right, - frame.size.height - borderWidth.top - borderWidth.bottom}}; + .origin = Point{.x = borderWidth.left, .y = borderWidth.top}, + .size = Size{ + .width = frame.size.width - borderWidth.left - borderWidth.right, + .height = + frame.size.height - borderWidth.top - borderWidth.bottom}}; } bool operator==(const LayoutMetrics& rhs) const = default; @@ -92,7 +97,9 @@ struct LayoutMetrics { * The value is comparable by equality with any other `LayoutMetrics` value. */ static const LayoutMetrics EmptyLayoutMetrics = { - /* .frame = */ {{0, 0}, {-1.0, -1.0}}}; + /* .frame = */ .frame = { + .origin = {.x = 0, .y = 0}, + .size = {.width = -1.0, .height = -1.0}}}; #if RN_DEBUG_STRING_CONVERTIBLE diff --git a/packages/react-native/ReactCommon/react/renderer/core/LayoutableShadowNode.cpp b/packages/react-native/ReactCommon/react/renderer/core/LayoutableShadowNode.cpp index 314c0fc6a78..c604120be4f 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/LayoutableShadowNode.cpp +++ b/packages/react-native/ReactCommon/react/renderer/core/LayoutableShadowNode.cpp @@ -70,7 +70,7 @@ LayoutMetrics LayoutableShadowNode::computeRelativeLayoutMetrics( if (policy.includeTransform) { layoutMetrics.frame = layoutMetrics.frame * ancestorNode.getTransform(); } - layoutMetrics.frame.origin = {0, 0}; + layoutMetrics.frame.origin = {.x = 0, .y = 0}; return layoutMetrics; } @@ -130,7 +130,7 @@ LayoutMetrics LayoutableShadowNode::computeRelativeLayoutMetrics( auto layoutMetrics = descendantLayoutableNode->getLayoutMetrics(); auto& resultFrame = layoutMetrics.frame; - resultFrame.origin = {0, 0}; + resultFrame.origin = {.x = 0, .y = 0}; // Step 3. // Iterating on a list of nodes computing compound offset and size. @@ -152,7 +152,7 @@ LayoutMetrics LayoutableShadowNode::computeRelativeLayoutMetrics( auto currentFrame = currentShadowNode->getLayoutMetrics().frame; if (i == size - 1) { // If it's the last element, its origin is irrelevant. - currentFrame.origin = {0, 0}; + currentFrame.origin = {.x = 0, .y = 0}; } auto isRootNode = currentShadowNode->getTraits().check( @@ -216,7 +216,7 @@ Transform LayoutableShadowNode::getTransform() const { Point LayoutableShadowNode::getContentOriginOffset( bool /*includeTransform*/) const { - return {0, 0}; + return {.x = 0, .y = 0}; } bool LayoutableShadowNode::canBeTouchTarget() const { diff --git a/packages/react-native/ReactCommon/react/renderer/core/RawProps.cpp b/packages/react-native/ReactCommon/react/renderer/core/RawProps.cpp index f79f588f1f8..66b021d43e3 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/RawProps.cpp +++ b/packages/react-native/ReactCommon/react/renderer/core/RawProps.cpp @@ -117,7 +117,8 @@ const RawValue* RawProps::at( react_native_assert( parser_ && "The object is not parsed. `parse` must be called before `at`."); - return parser_->at(*this, RawPropsKey{prefix, name, suffix}); + return parser_->at( + *this, RawPropsKey{.prefix = prefix, .name = name, .suffix = suffix}); } } // namespace facebook::react diff --git a/packages/react-native/ReactCommon/react/renderer/core/graphicsConversions.h b/packages/react-native/ReactCommon/react/renderer/core/graphicsConversions.h index bb593516606..126c289798d 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/graphicsConversions.h +++ b/packages/react-native/ReactCommon/react/renderer/core/graphicsConversions.h @@ -112,9 +112,9 @@ inline void fromRawValue( auto array = (std::vector)value; react_native_expect(array.size() == 2); if (array.size() >= 2) { - result = {array.at(0), array.at(1)}; + result = {.x = array.at(0), .y = array.at(1)}; } else { - result = {0, 0}; + result = {.x = 0, .y = 0}; LOG(ERROR) << "Unsupported Point vector size: " << array.size(); } } else { @@ -146,9 +146,9 @@ inline void fromRawValue( auto array = (std::vector)value; react_native_expect(array.size() == 2); if (array.size() >= 2) { - result = {array.at(0), array.at(1)}; + result = {.width = array.at(0), .height = array.at(1)}; } else { - result = {0, 0}; + result = {.width = 0, .height = 0}; LOG(ERROR) << "Unsupported Size vector size: " << array.size(); } } else { @@ -162,7 +162,7 @@ inline void fromRawValue( EdgeInsets& result) { if (value.hasType()) { auto number = (Float)value; - result = {number, number, number, number}; + result = {.left = number, .top = number, .right = number, .bottom = number}; return; } @@ -190,9 +190,13 @@ inline void fromRawValue( auto array = (std::vector)value; react_native_expect(array.size() == 4); if (array.size() >= 4) { - result = {array.at(0), array.at(1), array.at(2), array.at(3)}; + result = { + .left = array.at(0), + .top = array.at(1), + .right = array.at(2), + .bottom = array.at(3)}; } else { - result = {0, 0, 0, 0}; + result = {.left = 0, .top = 0, .right = 0, .bottom = 0}; LOG(ERROR) << "Unsupported EdgeInsets vector size: " << array.size(); } } else { @@ -217,7 +221,11 @@ inline void fromRawValue( CornerInsets& result) { if (value.hasType()) { auto number = (Float)value; - result = {number, number, number, number}; + result = { + .topLeft = number, + .topRight = number, + .bottomLeft = number, + .bottomRight = number}; return; } @@ -245,7 +253,11 @@ inline void fromRawValue( auto array = (std::vector)value; react_native_expect(array.size() == 4); if (array.size() >= 4) { - result = {array.at(0), array.at(1), array.at(2), array.at(3)}; + result = { + .topLeft = array.at(0), + .topRight = array.at(1), + .bottomLeft = array.at(2), + .bottomRight = array.at(3)}; } else { LOG(ERROR) << "Unsupported CornerInsets vector size: " << array.size(); } @@ -253,7 +265,7 @@ inline void fromRawValue( // Error case - we should only here if all other supported cases fail // In dev we would crash on assert before this point - result = {0, 0, 0, 0}; + result = {.topLeft = 0, .topRight = 0, .bottomLeft = 0, .bottomRight = 0}; LOG(ERROR) << "Unsupported CornerInsets type"; } diff --git a/packages/react-native/ReactCommon/react/renderer/core/propsConversions.h b/packages/react-native/ReactCommon/react/renderer/core/propsConversions.h index be402974adc..57f2c537b2f 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/propsConversions.h +++ b/packages/react-native/ReactCommon/react/renderer/core/propsConversions.h @@ -168,7 +168,7 @@ T convertRawProp( return result; } catch (const std::exception& e) { // In case of errors, log the error and fall back to the default - RawPropsKey key{namePrefix, name, nameSuffix}; + RawPropsKey key{.prefix = namePrefix, .name = name, .suffix = nameSuffix}; // TODO: report this using ErrorUtils so it's more visible to the user LOG(ERROR) << "Error while converting prop '" << static_cast(key) << "': " << e.what(); diff --git a/packages/react-native/ReactCommon/react/renderer/core/tests/ComponentDescriptorTest.cpp b/packages/react-native/ReactCommon/react/renderer/core/tests/ComponentDescriptorTest.cpp index fc5d7c5d77c..988ab9b54a6 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/tests/ComponentDescriptorTest.cpp +++ b/packages/react-native/ReactCommon/react/renderer/core/tests/ComponentDescriptorTest.cpp @@ -16,8 +16,10 @@ using namespace facebook::react; TEST(ComponentDescriptorTest, createShadowNode) { auto eventDispatcher = std::shared_ptr(); SharedComponentDescriptor descriptor = - std::make_shared( - ComponentDescriptorParameters{eventDispatcher, nullptr, nullptr}); + std::make_shared(ComponentDescriptorParameters{ + .eventDispatcher = eventDispatcher, + .contextContainer = nullptr, + .flavor = nullptr}); EXPECT_EQ(descriptor->getComponentHandle(), TestShadowNode::Handle()); EXPECT_STREQ(descriptor->getComponentName(), TestShadowNode::Name()); @@ -31,14 +33,14 @@ TEST(ComponentDescriptorTest, createShadowNode) { descriptor->cloneProps(parserContext, nullptr, std::move(rawProps)); auto family = descriptor->createFamily(ShadowNodeFamilyFragment{ - /* .tag = */ 9, - /* .surfaceId = */ 1, - /* .instanceHandle = */ nullptr, + /* .tag = */ .tag = 9, + /* .surfaceId = */ .surfaceId = 1, + /* .instanceHandle = */ .instanceHandle = nullptr, }); std::shared_ptr node = descriptor->createShadowNode( ShadowNodeFragment{ - /* .props = */ props, + /* .props = */ .props = props, }, family); @@ -53,8 +55,10 @@ TEST(ComponentDescriptorTest, createShadowNode) { TEST(ComponentDescriptorTest, cloneShadowNode) { auto eventDispatcher = std::shared_ptr(); SharedComponentDescriptor descriptor = - std::make_shared( - ComponentDescriptorParameters{eventDispatcher, nullptr, nullptr}); + std::make_shared(ComponentDescriptorParameters{ + .eventDispatcher = eventDispatcher, + .contextContainer = nullptr, + .flavor = nullptr}); ContextContainer contextContainer{}; PropsParserContext parserContext{-1, contextContainer}; @@ -63,13 +67,13 @@ TEST(ComponentDescriptorTest, cloneShadowNode) { Props::Shared props = descriptor->cloneProps(parserContext, nullptr, std::move(rawProps)); auto family = descriptor->createFamily(ShadowNodeFamilyFragment{ - /* .tag = */ 9, - /* .surfaceId = */ 1, - /* .instanceHandle = */ nullptr, + /* .tag = */ .tag = 9, + /* .surfaceId = */ .surfaceId = 1, + /* .instanceHandle = */ .instanceHandle = nullptr, }); std::shared_ptr node = descriptor->createShadowNode( ShadowNodeFragment{ - /* .props = */ props, + /* .props = */ .props = props, }, family); std::shared_ptr cloned = @@ -88,8 +92,10 @@ TEST(ComponentDescriptorTest, cloneShadowNode) { TEST(ComponentDescriptorTest, appendChild) { auto eventDispatcher = std::shared_ptr(); SharedComponentDescriptor descriptor = - std::make_shared( - ComponentDescriptorParameters{eventDispatcher, nullptr, nullptr}); + std::make_shared(ComponentDescriptorParameters{ + .eventDispatcher = eventDispatcher, + .contextContainer = nullptr, + .flavor = nullptr}); ContextContainer contextContainer{}; PropsParserContext parserContext{-1, contextContainer}; @@ -98,33 +104,33 @@ TEST(ComponentDescriptorTest, appendChild) { Props::Shared props = descriptor->cloneProps(parserContext, nullptr, std::move(rawProps)); auto family1 = descriptor->createFamily(ShadowNodeFamilyFragment{ - /* .tag = */ 1, - /* .surfaceId = */ 1, - /* .instanceHandle = */ nullptr, + /* .tag = */ .tag = 1, + /* .surfaceId = */ .surfaceId = 1, + /* .instanceHandle = */ .instanceHandle = nullptr, }); std::shared_ptr node1 = descriptor->createShadowNode( ShadowNodeFragment{ - /* .props = */ props, + /* .props = */ .props = props, }, family1); auto family2 = descriptor->createFamily(ShadowNodeFamilyFragment{ - /* .tag = */ 2, - /* .surfaceId = */ 1, - /* .instanceHandle = */ nullptr, + /* .tag = */ .tag = 2, + /* .surfaceId = */ .surfaceId = 1, + /* .instanceHandle = */ .instanceHandle = nullptr, }); std::shared_ptr node2 = descriptor->createShadowNode( ShadowNodeFragment{ - /* .props = */ props, + /* .props = */ .props = props, }, family2); auto family3 = descriptor->createFamily(ShadowNodeFamilyFragment{ - /* .tag = */ 3, - /* .surfaceId = */ 1, - /* .instanceHandle = */ nullptr, + /* .tag = */ .tag = 3, + /* .surfaceId = */ .surfaceId = 1, + /* .instanceHandle = */ .instanceHandle = nullptr, }); std::shared_ptr node3 = descriptor->createShadowNode( ShadowNodeFragment{ - /* .props = */ props, + /* .props = */ .props = props, }, family3); diff --git a/packages/react-native/ReactCommon/react/renderer/core/tests/ConcreteShadowNodeTest.cpp b/packages/react-native/ReactCommon/react/renderer/core/tests/ConcreteShadowNodeTest.cpp index f5e49e72793..33f5e432912 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/tests/ConcreteShadowNodeTest.cpp +++ b/packages/react-native/ReactCommon/react/renderer/core/tests/ConcreteShadowNodeTest.cpp @@ -26,7 +26,10 @@ TEST(ConcreteShadowNodeTest, testSetStateData) { auto shadowNode = builder.build(element); - shadowNode->setStateData({{10, 11}, {{21, 22}, {301, 302}}, 0}); + shadowNode->setStateData( + {{.x = 10, .y = 11}, + {.origin = {.x = 21, .y = 22}, .size = {.width = 301, .height = 302}}, + 0}); EXPECT_NE( shadowNode->getState(), shadowNode->getFamily().getMostRecentState()); diff --git a/packages/react-native/ReactCommon/react/renderer/core/tests/FindNodeAtPointTest.cpp b/packages/react-native/ReactCommon/react/renderer/core/tests/FindNodeAtPointTest.cpp index 0776acf8983..ea14d216265 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/tests/FindNodeAtPointTest.cpp +++ b/packages/react-native/ReactCommon/react/renderer/core/tests/FindNodeAtPointTest.cpp @@ -23,7 +23,7 @@ TEST(FindNodeAtPointTest, withoutTransform) { .tag(1) .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.size = {1000, 1000}; + layoutMetrics.frame.size = {.width=1000, .height=1000}; shadowNode.setLayoutMetrics(layoutMetrics); }) .children({ @@ -31,8 +31,8 @@ TEST(FindNodeAtPointTest, withoutTransform) { .tag(2) .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.origin = {100, 100}; - layoutMetrics.frame.size = {100, 100}; + layoutMetrics.frame.origin = {.x=100, .y=100}; + layoutMetrics.frame.size = {.width=100, .height=100}; shadowNode.setLayoutMetrics(layoutMetrics); }) .children({ @@ -40,8 +40,8 @@ TEST(FindNodeAtPointTest, withoutTransform) { .tag(3) .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.origin = {10, 10}; - layoutMetrics.frame.size = {10, 10}; + layoutMetrics.frame.origin = {.x=10, .y=10}; + layoutMetrics.frame.size = {.width=10, .height=10}; shadowNode.setLayoutMetrics(layoutMetrics); }) }) @@ -66,19 +66,19 @@ TEST(FindNodeAtPointTest, viewIsTranslated) { .tag(1) .finalize([](ScrollViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.size = {1000, 1000}; + layoutMetrics.frame.size = {.width=1000, .height=1000}; shadowNode.setLayoutMetrics(layoutMetrics); }) .stateData([](ScrollViewState &data) { - data.contentOffset = {100, 100}; + data.contentOffset = {.x=100, .y=100}; }) .children({ Element() .tag(2) .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.origin = {100, 100}; - layoutMetrics.frame.size = {100, 100}; + layoutMetrics.frame.origin = {.x=100, .y=100}; + layoutMetrics.frame.size = {.width=100, .height=100}; shadowNode.setLayoutMetrics(layoutMetrics); }) .children({ @@ -86,8 +86,8 @@ TEST(FindNodeAtPointTest, viewIsTranslated) { .tag(3) .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.origin = {10, 10}; - layoutMetrics.frame.size = {10, 10}; + layoutMetrics.frame.origin = {.x=10, .y=10}; + layoutMetrics.frame.size = {.width=10, .height=10}; shadowNode.setLayoutMetrics(layoutMetrics); }) }) @@ -110,7 +110,7 @@ TEST(FindNodeAtPointTest, viewIsScaled) { .tag(1) .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.size = {1000, 1000}; + layoutMetrics.frame.size = {.width=1000, .height=1000}; shadowNode.setLayoutMetrics(layoutMetrics); }) .children({ @@ -118,8 +118,8 @@ TEST(FindNodeAtPointTest, viewIsScaled) { .tag(2) .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.origin = {100, 100}; - layoutMetrics.frame.size = {100, 100}; + layoutMetrics.frame.origin = {.x=100, .y=100}; + layoutMetrics.frame.size = {.width=100, .height=100}; shadowNode.setLayoutMetrics(layoutMetrics); }) .children({ @@ -132,8 +132,8 @@ TEST(FindNodeAtPointTest, viewIsScaled) { }) .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.origin = {10, 10}; - layoutMetrics.frame.size = {10, 10}; + layoutMetrics.frame.origin = {.x=10, .y=10}; + layoutMetrics.frame.size = {.width=10, .height=10}; shadowNode.setLayoutMetrics(layoutMetrics); }) }) @@ -155,7 +155,7 @@ TEST(FindNodeAtPointTest, overlappingViews) { .tag(1) .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.size = {100, 100}; + layoutMetrics.frame.size = {.width=100, .height=100}; shadowNode.setLayoutMetrics(layoutMetrics); }) .children({ @@ -163,16 +163,16 @@ TEST(FindNodeAtPointTest, overlappingViews) { .tag(2) .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.origin = {25, 25}; - layoutMetrics.frame.size = {50, 50}; + layoutMetrics.frame.origin = {.x=25, .y=25}; + layoutMetrics.frame.size = {.width=50, .height=50}; shadowNode.setLayoutMetrics(layoutMetrics); }), Element() .tag(3) .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.origin = {50, 50}; - layoutMetrics.frame.size = {50, 50}; + layoutMetrics.frame.origin = {.x=50, .y=50}; + layoutMetrics.frame.size = {.width=50, .height=50}; shadowNode.setLayoutMetrics(layoutMetrics); }) }); @@ -192,7 +192,7 @@ TEST(FindNodeAtPointTest, overlappingViewsWithZIndex) { .tag(1) .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.size = {100, 100}; + layoutMetrics.frame.size = {.width=100, .height=100}; shadowNode.setLayoutMetrics(layoutMetrics); }) .children({ @@ -207,16 +207,16 @@ TEST(FindNodeAtPointTest, overlappingViewsWithZIndex) { }) .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.origin = {25, 25}; - layoutMetrics.frame.size = {50, 50}; + layoutMetrics.frame.origin = {.x=25, .y=25}; + layoutMetrics.frame.size = {.width=50, .height=50}; shadowNode.setLayoutMetrics(layoutMetrics); }), Element() .tag(3) .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.origin = {50, 50}; - layoutMetrics.frame.size = {50, 50}; + layoutMetrics.frame.origin = {.x=50, .y=50}; + layoutMetrics.frame.size = {.width=50, .height=50}; shadowNode.setLayoutMetrics(layoutMetrics); }) }); @@ -241,7 +241,7 @@ TEST(FindNodeAtPointTest, overlappingViewsWithParentPointerEventsBoxOnly) { }) .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.size = {100, 100}; + layoutMetrics.frame.size = {.width=100, .height=100}; shadowNode.setLayoutMetrics(layoutMetrics); }) .children({ @@ -249,16 +249,16 @@ TEST(FindNodeAtPointTest, overlappingViewsWithParentPointerEventsBoxOnly) { .tag(2) .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.origin = {50, 50}; - layoutMetrics.frame.size = {50, 50}; + layoutMetrics.frame.origin = {.x=50, .y=50}; + layoutMetrics.frame.size = {.width=50, .height=50}; shadowNode.setLayoutMetrics(layoutMetrics); }), Element() .tag(3) .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.origin = {50, 50}; - layoutMetrics.frame.size = {50, 50}; + layoutMetrics.frame.origin = {.x=50, .y=50}; + layoutMetrics.frame.size = {.width=50, .height=50}; shadowNode.setLayoutMetrics(layoutMetrics); }) }); @@ -283,7 +283,7 @@ TEST(FindNodeAtPointTest, overlappingViewsWithParentPointerEventsBoxNone) { }) .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.size = {100, 100}; + layoutMetrics.frame.size = {.width=100, .height=100}; shadowNode.setLayoutMetrics(layoutMetrics); }) .children({ @@ -298,16 +298,16 @@ TEST(FindNodeAtPointTest, overlappingViewsWithParentPointerEventsBoxNone) { }) .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.origin = {25, 25}; - layoutMetrics.frame.size = {50, 50}; + layoutMetrics.frame.origin = {.x=25, .y=25}; + layoutMetrics.frame.size = {.width=50, .height=50}; shadowNode.setLayoutMetrics(layoutMetrics); }), Element() .tag(3) .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.origin = {50, 50}; - layoutMetrics.frame.size = {50, 50}; + layoutMetrics.frame.origin = {.x=50, .y=50}; + layoutMetrics.frame.size = {.width=50, .height=50}; shadowNode.setLayoutMetrics(layoutMetrics); }) }); @@ -332,7 +332,7 @@ TEST(FindNodeAtPointTest, overlappingViewsWithParentPointerEventsNone) { }) .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.size = {100, 100}; + layoutMetrics.frame.size = {.width=100, .height=100}; shadowNode.setLayoutMetrics(layoutMetrics); }) .children({ @@ -347,16 +347,16 @@ TEST(FindNodeAtPointTest, overlappingViewsWithParentPointerEventsNone) { }) .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.origin = {25, 25}; - layoutMetrics.frame.size = {50, 50}; + layoutMetrics.frame.origin = {.x=25, .y=25}; + layoutMetrics.frame.size = {.width=50, .height=50}; shadowNode.setLayoutMetrics(layoutMetrics); }), Element() .tag(3) .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.origin = {50, 50}; - layoutMetrics.frame.size = {50, 50}; + layoutMetrics.frame.origin = {.x=50, .y=50}; + layoutMetrics.frame.size = {.width=50, .height=50}; shadowNode.setLayoutMetrics(layoutMetrics); }) }); @@ -381,7 +381,7 @@ TEST(FindNodeAtPointTest, invertedList) { .tag(1) .finalize([](ScrollViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.size = {100, 200}; + layoutMetrics.frame.size = {.width=100, .height=200}; shadowNode.setLayoutMetrics(layoutMetrics); }) .children({ @@ -389,16 +389,16 @@ TEST(FindNodeAtPointTest, invertedList) { .tag(2) .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.origin = {0, 0}; - layoutMetrics.frame.size = {100, 100}; + layoutMetrics.frame.origin = {.x=0, .y=0}; + layoutMetrics.frame.size = {.width=100, .height=100}; shadowNode.setLayoutMetrics(layoutMetrics); }), Element() .tag(3) .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.origin = {0, 100}; - layoutMetrics.frame.size = {100, 100}; + layoutMetrics.frame.origin = {.x=0, .y=100}; + layoutMetrics.frame.size = {.width=100, .height=100}; shadowNode.setLayoutMetrics(layoutMetrics); }) }); @@ -424,22 +424,25 @@ TEST(FindNodeAtPointTest, considersOverflowAreaOfTheParent) { .tag(1) .finalize([](ViewShadowNode& shadowNode) { auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.size = {100, 100}; + layoutMetrics.frame.size = {.width = 100, .height = 100}; shadowNode.setLayoutMetrics(layoutMetrics); }) .children({Element() .tag(2) .finalize([](ViewShadowNode& shadowNode) { auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.size = {100, 0}; - layoutMetrics.overflowInset = {0, 0, 0, -100}; + layoutMetrics.frame.size = { + .width = 100, .height = 0}; + layoutMetrics.overflowInset = { + .left = 0, .top = 0, .right = 0, .bottom = -100}; shadowNode.setLayoutMetrics(layoutMetrics); }) .children({Element().tag(3).finalize( [](ViewShadowNode& shadowNode) { auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.size = {100, 100}; + layoutMetrics.frame.size = { + .width = 100, .height = 100}; shadowNode.setLayoutMetrics(layoutMetrics); })})}); diff --git a/packages/react-native/ReactCommon/react/renderer/core/tests/LayoutableShadowNodeTest.cpp b/packages/react-native/ReactCommon/react/renderer/core/tests/LayoutableShadowNodeTest.cpp index 60cb39374a7..575221be7a3 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/tests/LayoutableShadowNodeTest.cpp +++ b/packages/react-native/ReactCommon/react/renderer/core/tests/LayoutableShadowNodeTest.cpp @@ -30,16 +30,16 @@ TEST(LayoutableShadowNodeTest, relativeLayoutMetrics) { Element() .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.origin = {10, 20}; - layoutMetrics.frame.size = {100, 200}; + layoutMetrics.frame.origin = {.x=10, .y=20}; + layoutMetrics.frame.size = {.width=100, .height=200}; shadowNode.setLayoutMetrics(layoutMetrics); }) .children({ Element() .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.origin = {10, 20}; - layoutMetrics.frame.size = {100, 200}; + layoutMetrics.frame.origin = {.x=10, .y=20}; + layoutMetrics.frame.size = {.width=100, .height=200}; shadowNode.setLayoutMetrics(layoutMetrics); }) .reference(childShadowNode) @@ -75,8 +75,8 @@ TEST(LayoutableShadowNodeTest, relativeLayoutMetricsOnNodeWithDisplayNone) { Element() .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.size = {100, 200}; - layoutMetrics.frame.origin = {10, 20}; + layoutMetrics.frame.size = {.width=100, .height=200}; + layoutMetrics.frame.origin = {.x=10, .y=20}; layoutMetrics.displayType = DisplayType::None; shadowNode.setLayoutMetrics(layoutMetrics); }); @@ -113,8 +113,8 @@ TEST( Element() .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.origin = {10, 20}; - layoutMetrics.frame.size = {100, 200}; + layoutMetrics.frame.origin = {.x=10, .y=20}; + layoutMetrics.frame.size = {.width=100, .height=200}; layoutMetrics.displayType = DisplayType::None; shadowNode.setLayoutMetrics(layoutMetrics); }) @@ -122,8 +122,8 @@ TEST( Element() .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.origin = {10, 20}; - layoutMetrics.frame.size = {100, 200}; + layoutMetrics.frame.origin = {.x=10, .y=20}; + layoutMetrics.frame.size = {.width=100, .height=200}; shadowNode.setLayoutMetrics(layoutMetrics); }) .reference(childShadowNode) @@ -165,8 +165,8 @@ TEST( Element() .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.origin = {0, 0}; - layoutMetrics.frame.size = {1000, 1000}; + layoutMetrics.frame.origin = {.x=0, .y=0}; + layoutMetrics.frame.size = {.width=1000, .height=1000}; layoutMetrics.displayType = DisplayType::None; shadowNode.setLayoutMetrics(layoutMetrics); }) @@ -174,16 +174,16 @@ TEST( Element() .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.origin = {50, 50}; - layoutMetrics.frame.size = {200, 200}; + layoutMetrics.frame.origin = {.x=50, .y=50}; + layoutMetrics.frame.size = {.width=200, .height=200}; shadowNode.setLayoutMetrics(layoutMetrics); }) .children({ Element() .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.origin = {10, 20}; - layoutMetrics.frame.size = {100, 200}; + layoutMetrics.frame.origin = {.x=10, .y=20}; + layoutMetrics.frame.size = {.width=100, .height=200}; shadowNode.setLayoutMetrics(layoutMetrics); }).reference(childShadowNode) }) @@ -223,19 +223,19 @@ TEST(LayoutableShadowNodeTest, contentOriginOffset) { Element() .finalize([](ScrollViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.origin = {10, 20}; - layoutMetrics.frame.size = {100, 200}; + layoutMetrics.frame.origin = {.x=10, .y=20}; + layoutMetrics.frame.size = {.width=100, .height=200}; shadowNode.setLayoutMetrics(layoutMetrics); }) .stateData([](ScrollViewState &data) { - data.contentOffset = {10, 10}; + data.contentOffset = {.x=10, .y=10}; }) .children({ Element() .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.origin = {10, 20}; - layoutMetrics.frame.size = {100, 200}; + layoutMetrics.frame.origin = {.x=10, .y=20}; + layoutMetrics.frame.size = {.width=100, .height=200}; shadowNode.setLayoutMetrics(layoutMetrics); }) .reference(childShadowNode) @@ -248,7 +248,7 @@ TEST(LayoutableShadowNodeTest, contentOriginOffset) { LayoutableShadowNode::computeRelativeLayoutMetrics( childShadowNode->getFamily(), *parentShadowNode, - {/* includeTransform = */ true}); + {.includeTransform = true}); EXPECT_EQ(relativeLayoutMetrics.frame.origin.x, 0); EXPECT_EQ(relativeLayoutMetrics.frame.origin.y, 10); @@ -256,7 +256,7 @@ TEST(LayoutableShadowNodeTest, contentOriginOffset) { relativeLayoutMetrics = LayoutableShadowNode::computeRelativeLayoutMetrics( childShadowNode->getFamily(), *parentShadowNode, - {/* includeTransform = */ false}); + {.includeTransform = false}); EXPECT_EQ(relativeLayoutMetrics.frame.origin.x, 10); EXPECT_EQ(relativeLayoutMetrics.frame.origin.y, 20); @@ -279,15 +279,15 @@ TEST(LayoutableShadowNodeTest, relativeLayoutMetricsOnTransformedNode) { Element() .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.size = {1000, 1000}; + layoutMetrics.frame.size = {.width=1000, .height=1000}; shadowNode.setLayoutMetrics(layoutMetrics); }) .children({ Element() .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.origin = {10, 20}; - layoutMetrics.frame.size = {100, 200}; + layoutMetrics.frame.origin = {.x=10, .y=20}; + layoutMetrics.frame.size = {.width=100, .height=200}; shadowNode.setLayoutMetrics(layoutMetrics); }) .props([] { @@ -332,7 +332,7 @@ TEST(LayoutableShadowNodeTest, noOverflow) { .props([] { auto sharedProps = std::make_shared(); auto &props = *sharedProps; - props.layoutConstraints = LayoutConstraints{{0,0}, {500, 500}}; + props.layoutConstraints = LayoutConstraints{.minimumSize={.width=0,.height=0}, .maximumSize={.width=500, .height=500}}; auto &yogaStyle = props.yogaStyle; yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleSizeLength::points(500)); yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleSizeLength::points(500)); @@ -397,7 +397,7 @@ TEST(LayoutableShadowNodeTest, overflowInsetFrameToRightAndDown) { .props([] { auto sharedProps = std::make_shared(); auto &props = *sharedProps; - props.layoutConstraints = LayoutConstraints{{0,0}, {500, 500}}; + props.layoutConstraints = LayoutConstraints{.minimumSize={.width=0,.height=0}, .maximumSize={.width=500, .height=500}}; auto &yogaStyle = props.yogaStyle; yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleSizeLength::points(500)); yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleSizeLength::points(500)); @@ -463,7 +463,7 @@ TEST(LayoutableShadowNodeTest, overflowInsetFrameToLeftAndTop) { .props([] { auto sharedProps = std::make_shared(); auto &props = *sharedProps; - props.layoutConstraints = LayoutConstraints{{0,0}, {500, 500}}; + props.layoutConstraints = LayoutConstraints{.minimumSize={.width=0,.height=0}, .maximumSize={.width=500, .height=500}}; auto &yogaStyle = props.yogaStyle; yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleSizeLength::points(500)); yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleSizeLength::points(500)); @@ -533,7 +533,7 @@ TEST(LayoutableShadowNodeTest, overflowInsetFrameToAllSides) { .props([] { auto sharedProps = std::make_shared(); auto &props = *sharedProps; - props.layoutConstraints = LayoutConstraints{{0,0}, {500, 500}}; + props.layoutConstraints = LayoutConstraints{.minimumSize={.width=0,.height=0}, .maximumSize={.width=500, .height=500}}; auto &yogaStyle = props.yogaStyle; yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleSizeLength::points(500)); yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleSizeLength::points(500)); @@ -614,7 +614,7 @@ TEST(LayoutableShadowNodeTest, relativeLayoutMetricsOnTransformedParent) { Element() .finalize([](RootShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.size = {900, 900}; + layoutMetrics.frame.size = {.width=900, .height=900}; shadowNode.setLayoutMetrics(layoutMetrics); }) .children({ @@ -626,8 +626,8 @@ TEST(LayoutableShadowNodeTest, relativeLayoutMetricsOnTransformedParent) { }) .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.origin = {10, 10}; - layoutMetrics.frame.size = {100, 100}; + layoutMetrics.frame.origin = {.x=10, .y=10}; + layoutMetrics.frame.size = {.width=100, .height=100}; shadowNode.setLayoutMetrics(layoutMetrics); }) .children({ @@ -635,8 +635,8 @@ TEST(LayoutableShadowNodeTest, relativeLayoutMetricsOnTransformedParent) { .reference(childShadowNode) .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.origin = {10, 10}; - layoutMetrics.frame.size = {50, 50}; + layoutMetrics.frame.origin = {.x=10, .y=10}; + layoutMetrics.frame.size = {.width=50, .height=50}; shadowNode.setLayoutMetrics(layoutMetrics); }) }) @@ -680,15 +680,15 @@ TEST(LayoutableShadowNodeTest, relativeLayoutMetricsOnParentWithClipping) { Element() .finalize([](RootShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.size = {900, 900}; + layoutMetrics.frame.size = {.width=900, .height=900}; shadowNode.setLayoutMetrics(layoutMetrics); }) .children({ Element() .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.origin = {10, 10}; - layoutMetrics.frame.size = {100, 100}; + layoutMetrics.frame.origin = {.x=10, .y=10}; + layoutMetrics.frame.size = {.width=100, .height=100}; shadowNode.setLayoutMetrics(layoutMetrics); }) .children({ @@ -696,8 +696,8 @@ TEST(LayoutableShadowNodeTest, relativeLayoutMetricsOnParentWithClipping) { .reference(childShadowNode) .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.origin = {10, 10}; - layoutMetrics.frame.size = {150, 150}; + layoutMetrics.frame.origin = {.x=10, .y=10}; + layoutMetrics.frame.size = {.width=150, .height=150}; shadowNode.setLayoutMetrics(layoutMetrics); }) }) @@ -711,9 +711,9 @@ TEST(LayoutableShadowNodeTest, relativeLayoutMetricsOnParentWithClipping) { childShadowNode->getFamily(), *parentShadowNode, { - /* includeTransform = */ true, - /* includeViewportOffset = */ false, - /* enableOverflowClipping = */ true, + .includeTransform = true, + .includeViewportOffset = false, + .enableOverflowClipping = true, }); EXPECT_EQ(relativeLayoutMetrics.frame.origin.x, 20); @@ -749,7 +749,7 @@ TEST( Element() .finalize([](RootShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.size = {900, 900}; + layoutMetrics.frame.size = {.width=900, .height=900}; shadowNode.setLayoutMetrics(layoutMetrics); }) .children({ @@ -761,8 +761,8 @@ TEST( }) .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.origin = {10, 10}; - layoutMetrics.frame.size = {100, 100}; + layoutMetrics.frame.origin = {.x=10, .y=10}; + layoutMetrics.frame.size = {.width=100, .height=100}; shadowNode.setLayoutMetrics(layoutMetrics); }) .children({ @@ -770,8 +770,8 @@ TEST( .reference(childShadowNode) .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.origin = {10, 10}; - layoutMetrics.frame.size = {150, 150}; + layoutMetrics.frame.origin = {.x=10, .y=10}; + layoutMetrics.frame.size = {.width=150, .height=150}; shadowNode.setLayoutMetrics(layoutMetrics); }) }) @@ -785,9 +785,9 @@ TEST( childShadowNode->getFamily(), *parentShadowNode, { - /* includeTransform = */ true, - /* includeViewportOffset = */ false, - /* enableOverflowClipping = */ true, + .includeTransform = true, + .includeViewportOffset = false, + .enableOverflowClipping = true, }); EXPECT_EQ(relativeLayoutMetrics.frame.origin.x, 40); @@ -810,8 +810,8 @@ TEST(LayoutableShadowNodeTest, relativeLayoutMetricsOnSameNode) { Element() .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.size = {100, 200}; - layoutMetrics.frame.origin = {10, 20}; + layoutMetrics.frame.size = {.width=100, .height=200}; + layoutMetrics.frame.origin = {.x=10, .y=20}; shadowNode.setLayoutMetrics(layoutMetrics); }); // clang-format on @@ -846,8 +846,8 @@ TEST(LayoutableShadowNodeTest, relativeLayoutMetricsOnSameTransformedNode) { }) .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.size = {100, 200}; - layoutMetrics.frame.origin = {10, 20}; + layoutMetrics.frame.size = {.width=100, .height=200}; + layoutMetrics.frame.origin = {.x=10, .y=20}; shadowNode.setLayoutMetrics(layoutMetrics); }); // clang-format on @@ -891,7 +891,7 @@ TEST(LayoutableShadowNodeTest, relativeLayoutMetricsOnClonedNode) { auto clonedChildShadowNode = std::static_pointer_cast(childShadowNode->clone({})); auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.size = {50, 60}; + layoutMetrics.frame.size = {.width = 50, .height = 60}; clonedChildShadowNode->setLayoutMetrics(layoutMetrics); parentShadowNode->replaceChild(*childShadowNode, clonedChildShadowNode); @@ -932,7 +932,7 @@ TEST( Element() .finalize([](ModalHostViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.origin = {10, 10}; + layoutMetrics.frame.origin = {.x=10, .y=10}; shadowNode.setLayoutMetrics(layoutMetrics); }) .children({ @@ -940,7 +940,7 @@ TEST( .reference(childShadowNode) .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.origin = {10, 10}; + layoutMetrics.frame.origin = {.x=10, .y=10}; shadowNode.setLayoutMetrics(layoutMetrics); }) }) @@ -966,7 +966,7 @@ TEST(LayoutableShadowNodeTest, includeViewportOffset) { Element() .props([] { auto sharedProps = std::make_shared(); - sharedProps->layoutContext.viewportOffset = {10, 20}; + sharedProps->layoutContext.viewportOffset = {.x=10, .y=20}; return sharedProps; }) .children({ @@ -982,14 +982,14 @@ TEST(LayoutableShadowNodeTest, includeViewportOffset) { auto layoutMetrics = LayoutableShadowNode::computeRelativeLayoutMetrics( viewShadowNode->getFamily(), *rootShadowNode, - {/* includeTransform = */ false, /* includeViewportOffset = */ true}); + {.includeTransform = false, .includeViewportOffset = true}); EXPECT_EQ(layoutMetrics.frame.origin.x, 10); EXPECT_EQ(layoutMetrics.frame.origin.y, 20); layoutMetrics = LayoutableShadowNode::computeRelativeLayoutMetrics( viewShadowNode->getFamily(), *rootShadowNode, - {/* includeTransform = */ true, /* includeViewportOffset = */ true}); + {.includeTransform = true, .includeViewportOffset = true}); EXPECT_EQ(layoutMetrics.frame.origin.x, 10); EXPECT_EQ(layoutMetrics.frame.origin.y, 20); } @@ -1023,23 +1023,23 @@ TEST(LayoutableShadowNodeTest, invertedVerticalView) { }) .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.size = {200, 200}; + layoutMetrics.frame.size = {.width=200, .height=200}; shadowNode.setLayoutMetrics(layoutMetrics); }).children({ Element() .reference(childShadowNode1) .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.origin = {0, 0}; - layoutMetrics.frame.size = {100, 100}; + layoutMetrics.frame.origin = {.x=0, .y=0}; + layoutMetrics.frame.size = {.width=100, .height=100}; shadowNode.setLayoutMetrics(layoutMetrics); }), Element() .reference(childShadowNode2) .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.origin = {0, 100}; - layoutMetrics.frame.size = {100, 100}; + layoutMetrics.frame.origin = {.x=0, .y=100}; + layoutMetrics.frame.size = {.width=100, .height=100}; shadowNode.setLayoutMetrics(layoutMetrics); }) }); @@ -1099,31 +1099,31 @@ TEST(LayoutableShadowNodeTest, nestedInvertedVerticalView) { }) .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.size = {400, 400}; + layoutMetrics.frame.size = {.width=400, .height=400}; shadowNode.setLayoutMetrics(layoutMetrics); }) .children({ Element() .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.origin = {100, 50}; - layoutMetrics.frame.size = {200, 200}; + layoutMetrics.frame.origin = {.x=100, .y=50}; + layoutMetrics.frame.size = {.width=200, .height=200}; shadowNode.setLayoutMetrics(layoutMetrics); }).children({ Element() .reference(childShadowNode1) .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.origin = {0, 0}; - layoutMetrics.frame.size = {100, 100}; + layoutMetrics.frame.origin = {.x=0, .y=0}; + layoutMetrics.frame.size = {.width=100, .height=100}; shadowNode.setLayoutMetrics(layoutMetrics); }), Element() .reference(childShadowNode2) .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.origin = {0, 100}; - layoutMetrics.frame.size = {100, 100}; + layoutMetrics.frame.origin = {.x=0, .y=100}; + layoutMetrics.frame.size = {.width=100, .height=100}; shadowNode.setLayoutMetrics(layoutMetrics); }) }) @@ -1185,14 +1185,14 @@ TEST(LayoutableShadowNodeTest, nestedDoubleInvertedVerticalView) { }) .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.size = {100, 300}; + layoutMetrics.frame.size = {.width=100, .height=300}; shadowNode.setLayoutMetrics(layoutMetrics); }) .children({ Element() .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.size = {100, 200}; + layoutMetrics.frame.size = {.width=100, .height=200}; shadowNode.setLayoutMetrics(layoutMetrics); }).props([] { auto sharedProps = std::make_shared(); @@ -1203,16 +1203,16 @@ TEST(LayoutableShadowNodeTest, nestedDoubleInvertedVerticalView) { .reference(childShadowNode1) .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.origin = {0, 0}; - layoutMetrics.frame.size = {100, 100}; + layoutMetrics.frame.origin = {.x=0, .y=0}; + layoutMetrics.frame.size = {.width=100, .height=100}; shadowNode.setLayoutMetrics(layoutMetrics); }), Element() .reference(childShadowNode2) .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.origin = {0, 100}; - layoutMetrics.frame.size = {100, 100}; + layoutMetrics.frame.origin = {.x=0, .y=100}; + layoutMetrics.frame.size = {.width=100, .height=100}; shadowNode.setLayoutMetrics(layoutMetrics); }) }) @@ -1265,23 +1265,23 @@ TEST(LayoutableShadowNodeTest, invertedHorizontalView) { }) .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.size = {200, 200}; + layoutMetrics.frame.size = {.width=200, .height=200}; shadowNode.setLayoutMetrics(layoutMetrics); }).children({ Element() .reference(childShadowNode1) .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.origin = {0, 0}; - layoutMetrics.frame.size = {100, 100}; + layoutMetrics.frame.origin = {.x=0, .y=0}; + layoutMetrics.frame.size = {.width=100, .height=100}; shadowNode.setLayoutMetrics(layoutMetrics); }), Element() .reference(childShadowNode2) .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.origin = {100, 0}; - layoutMetrics.frame.size = {100, 100}; + layoutMetrics.frame.origin = {.x=100, .y=0}; + layoutMetrics.frame.size = {.width=100, .height=100}; shadowNode.setLayoutMetrics(layoutMetrics); }) }); @@ -1337,31 +1337,31 @@ TEST(LayoutableShadowNodeTest, nestedInvertedHorizontalView) { }) .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.size = {400, 400}; + layoutMetrics.frame.size = {.width=400, .height=400}; shadowNode.setLayoutMetrics(layoutMetrics); }) .children({ Element() .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.origin = {50, 100}; - layoutMetrics.frame.size = {200, 200}; + layoutMetrics.frame.origin = {.x=50, .y=100}; + layoutMetrics.frame.size = {.width=200, .height=200}; shadowNode.setLayoutMetrics(layoutMetrics); }).children({ Element() .reference(childShadowNode1) .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.origin = {0, 0}; - layoutMetrics.frame.size = {100, 100}; + layoutMetrics.frame.origin = {.x=0, .y=0}; + layoutMetrics.frame.size = {.width=100, .height=100}; shadowNode.setLayoutMetrics(layoutMetrics); }), Element() .reference(childShadowNode2) .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.origin = {100, 0}; - layoutMetrics.frame.size = {100, 100}; + layoutMetrics.frame.origin = {.x=100, .y=0}; + layoutMetrics.frame.size = {.width=100, .height=100}; shadowNode.setLayoutMetrics(layoutMetrics); }) }) @@ -1403,18 +1403,18 @@ TEST(LayoutableShadowNodeTest, inversedContentOriginOffset) { }) .finalize([](ScrollViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.size = {300, 350}; + layoutMetrics.frame.size = {.width=300, .height=350}; shadowNode.setLayoutMetrics(layoutMetrics); }) .stateData([](ScrollViewState &data) { - data.contentOffset = {10, 20}; + data.contentOffset = {.x=10, .y=20}; }) .children({ Element() .finalize([](ViewShadowNode &shadowNode){ auto layoutMetrics = EmptyLayoutMetrics; - layoutMetrics.frame.origin = {30, 40}; - layoutMetrics.frame.size = {100, 200}; + layoutMetrics.frame.origin = {.x=30, .y=40}; + layoutMetrics.frame.size = {.width=100, .height=200}; shadowNode.setLayoutMetrics(layoutMetrics); }) .reference(childShadowNode) diff --git a/packages/react-native/ReactCommon/react/renderer/core/tests/ShadowNodeFamilyTest.cpp b/packages/react-native/ReactCommon/react/renderer/core/tests/ShadowNodeFamilyTest.cpp index 238b4e579a7..819beb7b3d8 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/tests/ShadowNodeFamilyTest.cpp +++ b/packages/react-native/ReactCommon/react/renderer/core/tests/ShadowNodeFamilyTest.cpp @@ -29,7 +29,10 @@ TEST(ShadowNodeFamilyTest, sealObjectCorrectly) { auto eventDispatcher = EventDispatcher::Shared{}; auto componentDescriptorRegistry = componentDescriptorProviderRegistry.createComponentDescriptorRegistry( - ComponentDescriptorParameters{eventDispatcher, nullptr, nullptr}); + ComponentDescriptorParameters{ + .eventDispatcher = eventDispatcher, + .contextContainer = nullptr, + .flavor = nullptr}); componentDescriptorProviderRegistry.add( concreteComponentDescriptorProvider()); diff --git a/packages/react-native/ReactCommon/react/renderer/core/tests/ShadowNodeTest.cpp b/packages/react-native/ReactCommon/react/renderer/core/tests/ShadowNodeTest.cpp index e26f36aff17..4392b67b752 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/tests/ShadowNodeTest.cpp +++ b/packages/react-native/ReactCommon/react/renderer/core/tests/ShadowNodeTest.cpp @@ -21,7 +21,8 @@ class ShadowNodeTest : public testing::Test { protected: ShadowNodeTest() : eventDispatcher_(std::shared_ptr()), - componentDescriptor_(TestComponentDescriptor({eventDispatcher_})) { + componentDescriptor_( + TestComponentDescriptor({.eventDispatcher = eventDispatcher_})) { /* * The structure: * @@ -40,40 +41,43 @@ class ShadowNodeTest : public testing::Test { auto traits = TestShadowNode::BaseTraits(); auto familyAA = componentDescriptor_.createFamily(ShadowNodeFamilyFragment{ - /* .tag = */ 11, - /* .surfaceId = */ surfaceId_, - /* .instanceHandle = */ nullptr, + /* .tag = */ .tag = 11, + /* .surfaceId = */ .surfaceId = surfaceId_, + /* .instanceHandle = */ .instanceHandle = nullptr, }); nodeAA_ = std::make_shared( ShadowNodeFragment{ - /* .props = */ props, - /* .children = */ ShadowNode::emptySharedShadowNodeSharedList(), + /* .props = */ .props = props, + /* .children = */ .children = + ShadowNode::emptySharedShadowNodeSharedList(), }, familyAA, traits); auto familyABA = componentDescriptor_.createFamily(ShadowNodeFamilyFragment{ - /* .tag = */ 12, - /* .surfaceId = */ surfaceId_, - /* .instanceHandle = */ nullptr, + /* .tag = */ .tag = 12, + /* .surfaceId = */ .surfaceId = surfaceId_, + /* .instanceHandle = */ .instanceHandle = nullptr, }); nodeABA_ = std::make_shared( ShadowNodeFragment{ - /* .props = */ props, - /* .children = */ ShadowNode::emptySharedShadowNodeSharedList(), + /* .props = */ .props = props, + /* .children = */ .children = + ShadowNode::emptySharedShadowNodeSharedList(), }, familyABA, traits); auto familyABB = componentDescriptor_.createFamily(ShadowNodeFamilyFragment{ - /* .tag = */ 13, - /* .surfaceId = */ surfaceId_, - /* .instanceHandle = */ nullptr, + /* .tag = */ .tag = 13, + /* .surfaceId = */ .surfaceId = surfaceId_, + /* .instanceHandle = */ .instanceHandle = nullptr, }); nodeABB_ = std::make_shared( ShadowNodeFragment{ - /* .props = */ props, - /* .children = */ ShadowNode::emptySharedShadowNodeSharedList(), + /* .props = */ .props = props, + /* .children = */ .children = + ShadowNode::emptySharedShadowNodeSharedList(), }, familyABB, traits); @@ -83,27 +87,28 @@ class ShadowNodeTest : public testing::Test { std::vector>{nodeABA_, nodeABB_}); auto familyAB = componentDescriptor_.createFamily(ShadowNodeFamilyFragment{ - /* .tag = */ 15, - /* .surfaceId = */ surfaceId_, - /* .instanceHandle = */ nullptr, + /* .tag = */ .tag = 15, + /* .surfaceId = */ .surfaceId = surfaceId_, + /* .instanceHandle = */ .instanceHandle = nullptr, }); nodeAB_ = std::make_shared( ShadowNodeFragment{ - /* .props = */ props, - /* .children = */ nodeABChildren, + /* .props = */ .props = props, + /* .children = */ .children = nodeABChildren, }, familyAB, traits); auto familyAC = componentDescriptor_.createFamily(ShadowNodeFamilyFragment{ - /* .tag = */ 16, - /* .surfaceId = */ surfaceId_, - /* .instanceHandle = */ nullptr, + /* .tag = */ .tag = 16, + /* .surfaceId = */ .surfaceId = surfaceId_, + /* .instanceHandle = */ .instanceHandle = nullptr, }); nodeAC_ = std::make_shared( ShadowNodeFragment{ - /* .props = */ props, - /* .children = */ ShadowNode::emptySharedShadowNodeSharedList(), + /* .props = */ .props = props, + /* .children = */ .children = + ShadowNode::emptySharedShadowNodeSharedList(), }, familyAC, traits); @@ -114,27 +119,28 @@ class ShadowNodeTest : public testing::Test { nodeAA_, nodeAB_, nodeAC_}); auto familyA = componentDescriptor_.createFamily(ShadowNodeFamilyFragment{ - /* .tag = */ 17, - /* .surfaceId = */ surfaceId_, - /* .instanceHandle = */ nullptr, + /* .tag = */ .tag = 17, + /* .surfaceId = */ .surfaceId = surfaceId_, + /* .instanceHandle = */ .instanceHandle = nullptr, }); nodeA_ = std::make_shared( ShadowNodeFragment{ - /* .props = */ props, - /* .children = */ nodeAChildren, + /* .props = */ .props = props, + /* .children = */ .children = nodeAChildren, }, familyA, traits); auto familyZ = componentDescriptor_.createFamily(ShadowNodeFamilyFragment{ - /* .tag = */ 18, - /* .surfaceId = */ surfaceId_, - /* .instanceHandle = */ nullptr, + /* .tag = */ .tag = 18, + /* .surfaceId = */ .surfaceId = surfaceId_, + /* .instanceHandle = */ .instanceHandle = nullptr, }); nodeZ_ = std::make_shared( ShadowNodeFragment{ - /* .props = */ props, - /* .children = */ ShadowNode::emptySharedShadowNodeSharedList(), + /* .props = */ .props = props, + /* .children = */ .children = + ShadowNode::emptySharedShadowNodeSharedList(), }, familyZ, traits); @@ -229,9 +235,9 @@ TEST_F(ShadowNodeTest, handleCloneFunction) { TEST_F(ShadowNodeTest, handleState) { auto family = componentDescriptor_.createFamily(ShadowNodeFamilyFragment{ - /* .tag = */ 9, - /* .surfaceId = */ surfaceId_, - /* .instanceHandle = */ nullptr, + /* .tag = */ .tag = 9, + /* .surfaceId = */ .surfaceId = surfaceId_, + /* .instanceHandle = */ .instanceHandle = nullptr, }); auto traits = TestShadowNode::BaseTraits(); @@ -243,23 +249,26 @@ TEST_F(ShadowNodeTest, handleState) { auto firstNode = std::make_shared( ShadowNodeFragment{ - /* .props = */ props, - /* .children = */ ShadowNode::emptySharedShadowNodeSharedList(), - /* .state = */ initialState}, + /* .props = */ .props = props, + /* .children = */ .children = + ShadowNode::emptySharedShadowNodeSharedList(), + /* .state = */ .state = initialState}, family, traits); auto secondNode = std::make_shared( ShadowNodeFragment{ - /* .props = */ props, - /* .children = */ ShadowNode::emptySharedShadowNodeSharedList(), - /* .state = */ initialState}, + /* .props = */ .props = props, + /* .children = */ .children = + ShadowNode::emptySharedShadowNodeSharedList(), + /* .state = */ .state = initialState}, family, traits); auto thirdNode = std::make_shared( ShadowNodeFragment{ - /* .props = */ props, - /* .children = */ ShadowNode::emptySharedShadowNodeSharedList(), - /* .state = */ initialState}, + /* .props = */ .props = props, + /* .children = */ .children = + ShadowNode::emptySharedShadowNodeSharedList(), + /* .state = */ .state = initialState}, family, traits); diff --git a/packages/react-native/ReactCommon/react/renderer/core/tests/benchmarks/RawPropsBenchmark.cpp b/packages/react-native/ReactCommon/react/renderer/core/tests/benchmarks/RawPropsBenchmark.cpp index fe7bdc5e4ff..88857af9d03 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/tests/benchmarks/RawPropsBenchmark.cpp +++ b/packages/react-native/ReactCommon/react/renderer/core/tests/benchmarks/RawPropsBenchmark.cpp @@ -19,8 +19,10 @@ namespace facebook::react { auto contextContainer = std::make_shared(); auto eventDispatcher = std::shared_ptr{nullptr}; -auto viewComponentDescriptor = ViewComponentDescriptor{ - ComponentDescriptorParameters{eventDispatcher, contextContainer}}; +auto viewComponentDescriptor = + ViewComponentDescriptor{ComponentDescriptorParameters{ + .eventDispatcher = eventDispatcher, + .contextContainer = contextContainer}}; auto emptyPropsDynamic = folly::parseJson("{}"); auto propsString = std::string{ diff --git a/packages/react-native/ReactCommon/react/renderer/css/CSSColor.h b/packages/react-native/ReactCommon/react/renderer/css/CSSColor.h index 0a2c22234c6..06f76bf84ac 100644 --- a/packages/react-native/ReactCommon/react/renderer/css/CSSColor.h +++ b/packages/react-native/ReactCommon/react/renderer/css/CSSColor.h @@ -29,7 +29,7 @@ struct CSSColor { constexpr bool operator==(const CSSColor& rhs) const = default; static constexpr CSSColor black() { - return {0, 0, 0, 255}; + return {.r = 0, .g = 0, .b = 0, .a = 255}; } }; diff --git a/packages/react-native/ReactCommon/react/renderer/css/CSSLength.h b/packages/react-native/ReactCommon/react/renderer/css/CSSLength.h index 39849450f15..130d84f1ab5 100644 --- a/packages/react-native/ReactCommon/react/renderer/css/CSSLength.h +++ b/packages/react-native/ReactCommon/react/renderer/css/CSSLength.h @@ -32,7 +32,7 @@ struct CSSDataTypeParser { switch (token.type()) { case CSSTokenType::Dimension: if (auto unit = parseCSSLengthUnit(token.unit())) { - return CSSLength{token.numericValue(), *unit}; + return CSSLength{.value = token.numericValue(), .unit = *unit}; } break; case CSSTokenType::Number: @@ -42,7 +42,8 @@ struct CSSDataTypeParser { // property (such as line-height), it must parse as a . // https://www.w3.org/TR/css-values-4/#lengths if (token.numericValue() == 0) { - return CSSLength{token.numericValue(), CSSLengthUnit::Px}; + return CSSLength{ + .value = token.numericValue(), .unit = CSSLengthUnit::Px}; } break; default: