diff --git a/packages/react-native/React/Tests/Text/RCTParagraphComponentViewTests.mm b/packages/react-native/React/Tests/Text/RCTParagraphComponentViewTests.mm index 760d1601616caa..d94ca995977e5c 100644 --- a/packages/react-native/React/Tests/Text/RCTParagraphComponentViewTests.mm +++ b/packages/react-native/React/Tests/Text/RCTParagraphComponentViewTests.mm @@ -121,8 +121,8 @@ - (void)setUp auto &props = *sharedProps; props.layoutConstraints = LayoutConstraints{{0, 0}, {500, 500}}; auto &yogaStyle = props.yogaStyle; - yogaStyle.setDimension(yoga::Dimension::Width, yoga::value::points(200)); - yogaStyle.setDimension(yoga::Dimension::Height, yoga::value::points(200)); + yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleLength::points(200)); + yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleLength::points(200)); return sharedProps; }) .children({ @@ -134,10 +134,10 @@ - (void)setUp props.accessible = true; auto &yogaStyle = props.yogaStyle; yogaStyle.setPositionType(yoga::PositionType::Absolute); - yogaStyle.setPosition(yoga::Edge::Left, yoga::value::points(0)); - yogaStyle.setPosition(yoga::Edge::Top, yoga::value::points(0)); - yogaStyle.setDimension(yoga::Dimension::Width, yoga::value::points(200)); - yogaStyle.setDimension(yoga::Dimension::Height, yoga::value::points(200)); + yogaStyle.setPosition(yoga::Edge::Left, yoga::StyleLength::points(0)); + yogaStyle.setPosition(yoga::Edge::Top, yoga::StyleLength::points(0)); + yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleLength::points(200)); + yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleLength::points(200)); return sharedProps; }) .children({ @@ -214,10 +214,10 @@ - (void)setUp props.accessible = true; auto &yogaStyle = props.yogaStyle; yogaStyle.setPositionType(yoga::PositionType::Absolute); - yogaStyle.setPosition(yoga::Edge::Left, yoga::value::points(0)); - yogaStyle.setPosition(yoga::Edge::Top, yoga::value::points(30)); - yogaStyle.setDimension(yoga::Dimension::Width, yoga::value::points(200)); - yogaStyle.setDimension(yoga::Dimension::Height, yoga::value::points(50)); + yogaStyle.setPosition(yoga::Edge::Left, yoga::StyleLength::points(0)); + yogaStyle.setPosition(yoga::Edge::Top, yoga::StyleLength::points(30)); + yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleLength::points(200)); + yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleLength::points(50)); return sharedProps; }) .children({ @@ -258,10 +258,10 @@ - (void)setUp props.accessible = true; auto &yogaStyle = props.yogaStyle; yogaStyle.setPositionType(yoga::PositionType::Absolute); - yogaStyle.setPosition(yoga::Edge::Left, yoga::value::points(0)); - yogaStyle.setPosition(yoga::Edge::Top, yoga::value::points(90)); - yogaStyle.setDimension(yoga::Dimension::Width, yoga::value::points(200)); - yogaStyle.setDimension(yoga::Dimension::Height, yoga::value::points(50)); + yogaStyle.setPosition(yoga::Edge::Left, yoga::StyleLength::points(0)); + yogaStyle.setPosition(yoga::Edge::Top, yoga::StyleLength::points(90)); + yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleLength::points(200)); + yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleLength::points(50)); return sharedProps; }) .children({ @@ -418,8 +418,8 @@ - (void)testEntireParagraphLink auto &props = *sharedProps; props.layoutConstraints = LayoutConstraints{{0, 0}, {500, 500}}; auto &yogaStyle = props.yogaStyle; - yogaStyle.setDimension(yoga::Dimension::Width, yoga::value::points(200)); - yogaStyle.setDimension(yoga::Dimension::Height, yoga::value::points(200)); + yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleLength::points(200)); + yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleLength::points(200)); return sharedProps; }) .children({ @@ -432,10 +432,10 @@ - (void)testEntireParagraphLink props.accessibilityTraits = AccessibilityTraits::Link; auto &yogaStyle = props.yogaStyle; yogaStyle.setPositionType(yoga::PositionType::Absolute); - yogaStyle.setPosition(yoga::Edge::Left, yoga::value::points(0)); - yogaStyle.setPosition(yoga::Edge::Top, yoga::value::points(90)); - yogaStyle.setDimension(yoga::Dimension::Width, yoga::value::points(200)); - yogaStyle.setDimension(yoga::Dimension::Height, yoga::value::points(20)); + yogaStyle.setPosition(yoga::Edge::Left, yoga::StyleLength::points(0)); + yogaStyle.setPosition(yoga::Edge::Top, yoga::StyleLength::points(90)); + yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleLength::points(200)); + yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleLength::points(20)); return sharedProps; }) .children({ diff --git a/packages/react-native/ReactCommon/react/renderer/components/textinput/platform/android/react/renderer/components/androidtextinput/AndroidTextInputComponentDescriptor.h b/packages/react-native/ReactCommon/react/renderer/components/textinput/platform/android/react/renderer/components/androidtextinput/AndroidTextInputComponentDescriptor.h index 6ee6c1e73c192c..dd31d0ba53dca5 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/textinput/platform/android/react/renderer/components/androidtextinput/AndroidTextInputComponentDescriptor.h +++ b/packages/react-native/ReactCommon/react/renderer/components/textinput/platform/android/react/renderer/components/androidtextinput/AndroidTextInputComponentDescriptor.h @@ -105,23 +105,25 @@ class AndroidTextInputComponentDescriptor final !textInputProps.hasPaddingLeft && !textInputProps.hasPaddingHorizontal) { changedPadding = true; - style.setPadding(yoga::Edge::Start, yoga::value::points(theme.start)); + style.setPadding( + yoga::Edge::Start, yoga::StyleLength::points(theme.start)); } if (!textInputProps.hasPadding && !textInputProps.hasPaddingEnd && !textInputProps.hasPaddingRight && !textInputProps.hasPaddingHorizontal) { changedPadding = true; - style.setPadding(yoga::Edge::End, yoga::value::points(theme.end)); + style.setPadding(yoga::Edge::End, yoga::StyleLength::points(theme.end)); } if (!textInputProps.hasPadding && !textInputProps.hasPaddingTop && !textInputProps.hasPaddingVertical) { changedPadding = true; - style.setPadding(yoga::Edge::Top, yoga::value::points(theme.top)); + style.setPadding(yoga::Edge::Top, yoga::StyleLength::points(theme.top)); } if (!textInputProps.hasPadding && !textInputProps.hasPaddingBottom && !textInputProps.hasPaddingVertical) { changedPadding = true; - style.setPadding(yoga::Edge::Bottom, yoga::value::points(theme.bottom)); + style.setPadding( + yoga::Edge::Bottom, yoga::StyleLength::points(theme.bottom)); } // If the TextInput initially does not have paddingLeft or paddingStart, a @@ -132,12 +134,12 @@ class AndroidTextInputComponentDescriptor final if ((textInputProps.hasPadding || textInputProps.hasPaddingLeft || textInputProps.hasPaddingHorizontal) && !textInputProps.hasPaddingStart) { - style.setPadding(yoga::Edge::Start, yoga::value::undefined()); + style.setPadding(yoga::Edge::Start, yoga::StyleLength::undefined()); } if ((textInputProps.hasPadding || textInputProps.hasPaddingRight || textInputProps.hasPaddingHorizontal) && !textInputProps.hasPaddingEnd) { - style.setPadding(yoga::Edge::End, yoga::value::undefined()); + style.setPadding(yoga::Edge::End, yoga::StyleLength::undefined()); } // Note that this is expensive: on every adopt, we need to set the Yoga 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 ecd79739d0faf8..c57292dfbc54a5 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp +++ b/packages/react-native/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp @@ -532,8 +532,10 @@ void YogaLayoutableShadowNode::setSize(Size size) const { ensureUnsealed(); auto style = yogaNode_.style(); - style.setDimension(yoga::Dimension::Width, yoga::value::points(size.width)); - style.setDimension(yoga::Dimension::Height, yoga::value::points(size.height)); + style.setDimension( + yoga::Dimension::Width, yoga::StyleLength::points(size.width)); + style.setDimension( + yoga::Dimension::Height, yoga::StyleLength::points(size.height)); yogaNode_.setStyle(style); yogaNode_.setDirty(true); } @@ -543,19 +545,21 @@ void YogaLayoutableShadowNode::setPadding(RectangleEdges padding) const { auto style = yogaNode_.style(); - auto leftPadding = yoga::value::points(padding.left); - auto topPadding = yoga::value::points(padding.top); - auto rightPadding = yoga::value::points(padding.right); - auto bottomPadding = yoga::value::points(padding.bottom); + auto leftPadding = yoga::StyleLength::points(padding.left); + auto topPadding = yoga::StyleLength::points(padding.top); + auto rightPadding = yoga::StyleLength::points(padding.right); + auto bottomPadding = yoga::StyleLength::points(padding.bottom); if (leftPadding != style.padding(yoga::Edge::Left) || topPadding != style.padding(yoga::Edge::Top) || rightPadding != style.padding(yoga::Edge::Right) || bottomPadding != style.padding(yoga::Edge::Bottom)) { - style.setPadding(yoga::Edge::Top, yoga::value::points(padding.top)); - style.setPadding(yoga::Edge::Left, yoga::value::points(padding.left)); - style.setPadding(yoga::Edge::Right, yoga::value::points(padding.right)); - style.setPadding(yoga::Edge::Bottom, yoga::value::points(padding.bottom)); + style.setPadding(yoga::Edge::Top, yoga::StyleLength::points(padding.top)); + style.setPadding(yoga::Edge::Left, yoga::StyleLength::points(padding.left)); + style.setPadding( + yoga::Edge::Right, yoga::StyleLength::points(padding.right)); + style.setPadding( + yoga::Edge::Bottom, yoga::StyleLength::points(padding.bottom)); yogaNode_.setStyle(style); yogaNode_.setDirty(true); } @@ -622,16 +626,16 @@ void YogaLayoutableShadowNode::layoutTree( auto ownerHeight = yogaFloatFromFloat(maximumSize.height); yogaStyle.setMaxDimension( - yoga::Dimension::Width, yoga::value::points(maximumSize.width)); + yoga::Dimension::Width, yoga::StyleLength::points(maximumSize.width)); yogaStyle.setMaxDimension( - yoga::Dimension::Height, yoga::value::points(maximumSize.height)); + yoga::Dimension::Height, yoga::StyleLength::points(maximumSize.height)); yogaStyle.setMinDimension( - yoga::Dimension::Width, yoga::value::points(minimumSize.width)); + yoga::Dimension::Width, yoga::StyleLength::points(minimumSize.width)); yogaStyle.setMinDimension( - yoga::Dimension::Height, yoga::value::points(minimumSize.height)); + yoga::Dimension::Height, yoga::StyleLength::points(minimumSize.height)); auto direction = yogaDirectionFromLayoutDirection(layoutConstraints.layoutDirection); @@ -894,44 +898,44 @@ void YogaLayoutableShadowNode::swapLeftAndRightInYogaStyleProps() { if (yogaStyle.position(yoga::Edge::Left).isDefined()) { yogaStyle.setPosition( yoga::Edge::Start, yogaStyle.position(yoga::Edge::Left)); - yogaStyle.setPosition(yoga::Edge::Left, yoga::value::undefined()); + yogaStyle.setPosition(yoga::Edge::Left, yoga::StyleLength::undefined()); } if (yogaStyle.position(yoga::Edge::Right).isDefined()) { yogaStyle.setPosition( yoga::Edge::End, yogaStyle.position(yoga::Edge::Right)); - yogaStyle.setPosition(yoga::Edge::Right, yoga::value::undefined()); + yogaStyle.setPosition(yoga::Edge::Right, yoga::StyleLength::undefined()); } if (yogaStyle.padding(yoga::Edge::Left).isDefined()) { yogaStyle.setPadding( yoga::Edge::Start, yogaStyle.padding(yoga::Edge::Left)); - yogaStyle.setPadding(yoga::Edge::Left, yoga::value::undefined()); + yogaStyle.setPadding(yoga::Edge::Left, yoga::StyleLength::undefined()); } if (yogaStyle.padding(yoga::Edge::Right).isDefined()) { yogaStyle.setPadding(yoga::Edge::End, yogaStyle.padding(yoga::Edge::Right)); - yogaStyle.setPadding(yoga::Edge::Right, yoga::value::undefined()); + yogaStyle.setPadding(yoga::Edge::Right, yoga::StyleLength::undefined()); } if (yogaStyle.margin(yoga::Edge::Left).isDefined()) { yogaStyle.setMargin(yoga::Edge::Start, yogaStyle.margin(yoga::Edge::Left)); - yogaStyle.setMargin(yoga::Edge::Left, yoga::value::undefined()); + yogaStyle.setMargin(yoga::Edge::Left, yoga::StyleLength::undefined()); } if (yogaStyle.margin(yoga::Edge::Right).isDefined()) { yogaStyle.setMargin(yoga::Edge::End, yogaStyle.margin(yoga::Edge::Right)); - yogaStyle.setMargin(yoga::Edge::Right, yoga::value::undefined()); + yogaStyle.setMargin(yoga::Edge::Right, yoga::StyleLength::undefined()); } if (yogaStyle.border(yoga::Edge::Left).isDefined()) { yogaStyle.setBorder(yoga::Edge::Start, yogaStyle.border(yoga::Edge::Left)); - yogaStyle.setBorder(yoga::Edge::Left, yoga::value::undefined()); + yogaStyle.setBorder(yoga::Edge::Left, yoga::StyleLength::undefined()); } if (yogaStyle.border(yoga::Edge::Right).isDefined()) { yogaStyle.setBorder(yoga::Edge::End, yogaStyle.border(yoga::Edge::Right)); - yogaStyle.setBorder(yoga::Edge::Right, yoga::value::undefined()); + yogaStyle.setBorder(yoga::Edge::Right, yoga::StyleLength::undefined()); } yogaNode_.setStyle(yogaStyle); diff --git a/packages/react-native/ReactCommon/react/renderer/components/view/YogaStylableProps.cpp b/packages/react-native/ReactCommon/react/renderer/components/view/YogaStylableProps.cpp index 3a3f7ee8cba3a6..4f36bf6bb813e1 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/view/YogaStylableProps.cpp +++ b/packages/react-native/ReactCommon/react/renderer/components/view/YogaStylableProps.cpp @@ -790,98 +790,98 @@ void YogaStylableProps::convertRawPropAliases( rawProps, "insetBlockEnd", sourceProps.insetBlockEnd, - yoga::value::undefined()); + yoga::StyleLength::undefined()); insetBlockStart = convertRawProp( context, rawProps, "insetBlockStart", sourceProps.insetBlockStart, - yoga::value::undefined()); + yoga::StyleLength::undefined()); insetInlineEnd = convertRawProp( context, rawProps, "insetInlineEnd", sourceProps.insetInlineEnd, - yoga::value::undefined()); + yoga::StyleLength::undefined()); insetInlineStart = convertRawProp( context, rawProps, "insetInlineStart", sourceProps.insetInlineStart, - yoga::value::undefined()); + yoga::StyleLength::undefined()); marginInline = convertRawProp( context, rawProps, "marginInline", sourceProps.marginInline, - yoga::value::undefined()); + yoga::StyleLength::undefined()); marginInlineStart = convertRawProp( context, rawProps, "marginInlineStart", sourceProps.marginInlineStart, - yoga::value::undefined()); + yoga::StyleLength::undefined()); marginInlineEnd = convertRawProp( context, rawProps, "marginInlineEnd", sourceProps.marginInlineEnd, - yoga::value::undefined()); + yoga::StyleLength::undefined()); marginBlock = convertRawProp( context, rawProps, "marginBlock", sourceProps.marginBlock, - yoga::value::undefined()); + yoga::StyleLength::undefined()); marginBlockStart = convertRawProp( context, rawProps, "marginBlockStart", sourceProps.marginBlockStart, - yoga::value::undefined()); + yoga::StyleLength::undefined()); marginBlockEnd = convertRawProp( context, rawProps, "marginBlockEnd", sourceProps.marginBlockEnd, - yoga::value::undefined()); + yoga::StyleLength::undefined()); paddingInline = convertRawProp( context, rawProps, "paddingInline", sourceProps.paddingInline, - yoga::value::undefined()); + yoga::StyleLength::undefined()); paddingInlineStart = convertRawProp( context, rawProps, "paddingInlineStart", sourceProps.paddingInlineStart, - yoga::value::undefined()); + yoga::StyleLength::undefined()); paddingInlineEnd = convertRawProp( context, rawProps, "paddingInlineEnd", sourceProps.paddingInlineEnd, - yoga::value::undefined()); + yoga::StyleLength::undefined()); paddingBlock = convertRawProp( context, rawProps, "paddingBlock", sourceProps.paddingBlock, - yoga::value::undefined()); + yoga::StyleLength::undefined()); paddingBlockStart = convertRawProp( context, rawProps, "paddingBlockStart", sourceProps.paddingBlockStart, - yoga::value::undefined()); + yoga::StyleLength::undefined()); paddingBlockEnd = convertRawProp( context, rawProps, "paddingBlockEnd", sourceProps.paddingBlockEnd, - yoga::value::undefined()); + yoga::StyleLength::undefined()); } } // namespace facebook::react 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 b1b71c0ebbf777..35f6047c318c22 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/view/conversions.h +++ b/packages/react-native/ReactCommon/react/renderer/components/view/conversions.h @@ -437,31 +437,31 @@ inline void fromRawValue( const RawValue& value, yoga::Style::Length& result) { if (value.hasType()) { - result = yoga::value::points((float)value); + result = yoga::StyleLength::points((float)value); return; } else if (value.hasType()) { const auto stringValue = (std::string)value; if (stringValue == "auto") { - result = yoga::value::ofAuto(); + result = yoga::StyleLength::ofAuto(); return; } else { if (stringValue.back() == '%') { auto tryValue = folly::tryTo( std::string_view(stringValue).substr(0, stringValue.length() - 1)); if (tryValue.hasValue()) { - result = yoga::value::percent(tryValue.value()); + result = yoga::StyleLength::percent(tryValue.value()); return; } } else { auto tryValue = folly::tryTo(stringValue); if (tryValue.hasValue()) { - result = yoga::value::points(tryValue.value()); + result = yoga::StyleLength::points(tryValue.value()); return; } } } } - result = yoga::value::undefined(); + result = yoga::StyleLength::undefined(); } inline void fromRawValue( 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 9933cce9f47ed7..5277a2b153401d 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 @@ -77,8 +77,8 @@ class LayoutTest : public ::testing::Test { auto &props = *sharedProps; props.layoutConstraints = LayoutConstraints{{0,0}, {500, 500}}; auto &yogaStyle = props.yogaStyle; - yogaStyle.setDimension(yoga::Dimension::Width, yoga::value::points(200)); - yogaStyle.setDimension(yoga::Dimension::Height, yoga::value::points(200)); + yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleLength::points(200)); + yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleLength::points(200)); return sharedProps; }) .children({ @@ -90,8 +90,8 @@ class LayoutTest : public ::testing::Test { auto &props = *sharedProps; auto &yogaStyle = props.yogaStyle; yogaStyle.setPositionType(yoga::PositionType::Absolute); - yogaStyle.setDimension(yoga::Dimension::Width, yoga::value::points(50)); - yogaStyle.setDimension(yoga::Dimension::Height, yoga::value::points(50)); + yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleLength::points(50)); + yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleLength::points(50)); return sharedProps; }) .children({ @@ -103,10 +103,10 @@ class LayoutTest : public ::testing::Test { auto &props = *sharedProps; auto &yogaStyle = props.yogaStyle; yogaStyle.setPositionType(yoga::PositionType::Absolute); - yogaStyle.setPosition(yoga::Edge::Left, yoga::value::points(10)); - yogaStyle.setPosition(yoga::Edge::Top, yoga::value::points(10)); - yogaStyle.setDimension(yoga::Dimension::Width, yoga::value::points(30)); - yogaStyle.setDimension(yoga::Dimension::Height, yoga::value::points(90)); + yogaStyle.setPosition(yoga::Edge::Left, yoga::StyleLength::points(10)); + yogaStyle.setPosition(yoga::Edge::Top, yoga::StyleLength::points(10)); + yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleLength::points(30)); + yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleLength::points(90)); if (testCase == TRANSFORM_SCALE) { props.transform = props.transform * Transform::Scale(2, 2, 1); @@ -136,10 +136,10 @@ class LayoutTest : public ::testing::Test { } yogaStyle.setPositionType(yoga::PositionType::Absolute); - yogaStyle.setPosition(yoga::Edge::Left, yoga::value::points(10)); - yogaStyle.setPosition(yoga::Edge::Top, yoga::value::points(10)); - yogaStyle.setDimension(yoga::Dimension::Width, yoga::value::points(110)); - yogaStyle.setDimension(yoga::Dimension::Height, yoga::value::points(20)); + yogaStyle.setPosition(yoga::Edge::Left, yoga::StyleLength::points(10)); + yogaStyle.setPosition(yoga::Edge::Top, yoga::StyleLength::points(10)); + yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleLength::points(110)); + yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleLength::points(20)); return sharedProps; }) .children({ @@ -151,10 +151,10 @@ class LayoutTest : public ::testing::Test { auto &props = *sharedProps; auto &yogaStyle = props.yogaStyle; yogaStyle.setPositionType(yoga::PositionType::Absolute); - yogaStyle.setPosition(yoga::Edge::Left, yoga::value::points(70)); - yogaStyle.setPosition(yoga::Edge::Top, yoga::value::points(-50)); - yogaStyle.setDimension(yoga::Dimension::Width, yoga::value::points(30)); - yogaStyle.setDimension(yoga::Dimension::Height, yoga::value::points(60)); + yogaStyle.setPosition(yoga::Edge::Left, yoga::StyleLength::points(70)); + yogaStyle.setPosition(yoga::Edge::Top, yoga::StyleLength::points(-50)); + yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleLength::points(30)); + yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleLength::points(60)); return sharedProps; }) }), @@ -166,10 +166,10 @@ class LayoutTest : public ::testing::Test { auto &props = *sharedProps; auto &yogaStyle = props.yogaStyle; yogaStyle.setPositionType(yoga::PositionType::Absolute); - yogaStyle.setPosition(yoga::Edge::Left, yoga::value::points(-60)); - yogaStyle.setPosition(yoga::Edge::Top, yoga::value::points(50)); - yogaStyle.setDimension(yoga::Dimension::Width, yoga::value::points(70)); - yogaStyle.setDimension(yoga::Dimension::Height, yoga::value::points(20)); + yogaStyle.setPosition(yoga::Edge::Left, yoga::StyleLength::points(-60)); + yogaStyle.setPosition(yoga::Edge::Top, yoga::StyleLength::points(50)); + yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleLength::points(70)); + yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleLength::points(20)); return sharedProps; }) }) diff --git a/packages/react-native/ReactCommon/react/renderer/mounting/tests/StackingContextTest.cpp b/packages/react-native/ReactCommon/react/renderer/mounting/tests/StackingContextTest.cpp index 82fc8321652a13..dd7d74a5245816 100644 --- a/packages/react-native/ReactCommon/react/renderer/mounting/tests/StackingContextTest.cpp +++ b/packages/react-native/ReactCommon/react/renderer/mounting/tests/StackingContextTest.cpp @@ -252,8 +252,8 @@ TEST_F(StackingContextTest, mostPropsDoNotForceViewsToMaterialize) { mutateViewShadowNodeProps_(nodeAA_, [](ViewProps& props) { auto& yogaStyle = props.yogaStyle; - yogaStyle.setPadding(yoga::Edge::All, yoga::value::points(42)); - yogaStyle.setMargin(yoga::Edge::All, yoga::value::points(42)); + yogaStyle.setPadding(yoga::Edge::All, yoga::StyleLength::points(42)); + yogaStyle.setMargin(yoga::Edge::All, yoga::StyleLength::points(42)); yogaStyle.setPositionType(yoga::PositionType::Absolute); props.shadowRadius = 42; props.shadowOffset = Size{42, 42}; @@ -264,7 +264,7 @@ TEST_F(StackingContextTest, mostPropsDoNotForceViewsToMaterialize) { auto& yogaStyle = props.yogaStyle; props.zIndex = 42; yogaStyle.setPositionType(yoga::PositionType::Static); - yogaStyle.setMargin(yoga::Edge::All, yoga::value::points(42)); + yogaStyle.setMargin(yoga::Edge::All, yoga::StyleLength::points(42)); props.shadowColor = clearColor(); props.shadowOpacity = 0.42; }); diff --git a/packages/react-native/ReactCommon/react/renderer/uimanager/tests/PointerEventsProcessorTest.cpp b/packages/react-native/ReactCommon/react/renderer/uimanager/tests/PointerEventsProcessorTest.cpp index 889507450da684..d51547f310f073 100644 --- a/packages/react-native/ReactCommon/react/renderer/uimanager/tests/PointerEventsProcessorTest.cpp +++ b/packages/react-native/ReactCommon/react/renderer/uimanager/tests/PointerEventsProcessorTest.cpp @@ -87,8 +87,8 @@ class PointerEventsProcessorTest : public ::testing::Test { listenToAllPointerEvents(props); props.layoutConstraints = LayoutConstraints{{0,0}, {500, 500}}; auto &yogaStyle = props.yogaStyle; - yogaStyle.setDimension(yoga::Dimension::Width, yoga::value::points(400)); - yogaStyle.setDimension(yoga::Dimension::Height, yoga::value::points(400)); + yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleLength::points(400)); + yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleLength::points(400)); yogaStyle.setDisplay(yoga::Display::Flex); yogaStyle.setFlexDirection(yoga::FlexDirection::Row); yogaStyle.setAlignItems(yoga::Align::Center); @@ -109,8 +109,8 @@ class PointerEventsProcessorTest : public ::testing::Test { yogaStyle.setFlexDirection(yoga::FlexDirection::Column); yogaStyle.setAlignItems(yoga::Align::FlexEnd); yogaStyle.setJustifyContent(yoga::Justify::Center); - yogaStyle.setDimension(yoga::Dimension::Width, yoga::value::points(150)); - yogaStyle.setDimension(yoga::Dimension::Height, yoga::value::points(300)); + yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleLength::points(150)); + yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleLength::points(300)); return sharedProps; }) .children({ @@ -123,8 +123,8 @@ class PointerEventsProcessorTest : public ::testing::Test { auto &props = *sharedProps; listenToAllPointerEvents(props); auto &yogaStyle = props.yogaStyle; - yogaStyle.setDimension(yoga::Dimension::Width, yoga::value::points(100)); - yogaStyle.setDimension(yoga::Dimension::Height, yoga::value::points(200)); + yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleLength::points(100)); + yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleLength::points(200)); return sharedProps; }) }), @@ -141,8 +141,8 @@ class PointerEventsProcessorTest : public ::testing::Test { yogaStyle.setFlexDirection(yoga::FlexDirection::Column); yogaStyle.setAlignItems(yoga::Align::FlexStart); yogaStyle.setJustifyContent(yoga::Justify::Center); - yogaStyle.setDimension(yoga::Dimension::Width, yoga::value::points(150)); - yogaStyle.setDimension(yoga::Dimension::Height, yoga::value::points(300)); + yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleLength::points(150)); + yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleLength::points(300)); return sharedProps; }) .children({ @@ -155,8 +155,8 @@ class PointerEventsProcessorTest : public ::testing::Test { auto &props = *sharedProps; listenToAllPointerEvents(props); auto &yogaStyle = props.yogaStyle; - yogaStyle.setDimension(yoga::Dimension::Width, yoga::value::points(100)); - yogaStyle.setDimension(yoga::Dimension::Height, yoga::value::points(200)); + yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleLength::points(100)); + yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleLength::points(200)); return sharedProps; }) }) diff --git a/packages/react-native/ReactCommon/yoga/yoga/YGNodeStyle.cpp b/packages/react-native/ReactCommon/yoga/yoga/YGNodeStyle.cpp index d2a10b0591a1d1..8664b53ec81518 100644 --- a/packages/react-native/ReactCommon/yoga/yoga/YGNodeStyle.cpp +++ b/packages/react-native/ReactCommon/yoga/yoga/YGNodeStyle.cpp @@ -177,18 +177,19 @@ float YGNodeStyleGetFlexShrink(const YGNodeConstRef nodeRef) { void YGNodeStyleSetFlexBasis(const YGNodeRef node, const float flexBasis) { updateStyle<&Style::flexBasis, &Style::setFlexBasis>( - node, value::points(flexBasis)); + node, StyleLength::points(flexBasis)); } void YGNodeStyleSetFlexBasisPercent( const YGNodeRef node, const float flexBasisPercent) { updateStyle<&Style::flexBasis, &Style::setFlexBasis>( - node, value::percent(flexBasisPercent)); + node, StyleLength::percent(flexBasisPercent)); } void YGNodeStyleSetFlexBasisAuto(const YGNodeRef node) { - updateStyle<&Style::flexBasis, &Style::setFlexBasis>(node, value::ofAuto()); + updateStyle<&Style::flexBasis, &Style::setFlexBasis>( + node, StyleLength::ofAuto()); } YGValue YGNodeStyleGetFlexBasis(const YGNodeConstRef node) { @@ -197,17 +198,17 @@ YGValue YGNodeStyleGetFlexBasis(const YGNodeConstRef node) { void YGNodeStyleSetPosition(YGNodeRef node, YGEdge edge, float points) { updateStyle<&Style::position, &Style::setPosition>( - node, scopedEnum(edge), value::points(points)); + node, scopedEnum(edge), StyleLength::points(points)); } void YGNodeStyleSetPositionPercent(YGNodeRef node, YGEdge edge, float percent) { updateStyle<&Style::position, &Style::setPosition>( - node, scopedEnum(edge), value::percent(percent)); + node, scopedEnum(edge), StyleLength::percent(percent)); } void YGNodeStyleSetPositionAuto(YGNodeRef node, YGEdge edge) { updateStyle<&Style::position, &Style::setPosition>( - node, scopedEnum(edge), value::ofAuto()); + node, scopedEnum(edge), StyleLength::ofAuto()); } YGValue YGNodeStyleGetPosition(YGNodeConstRef node, YGEdge edge) { @@ -216,17 +217,17 @@ YGValue YGNodeStyleGetPosition(YGNodeConstRef node, YGEdge edge) { void YGNodeStyleSetMargin(YGNodeRef node, YGEdge edge, float points) { updateStyle<&Style::margin, &Style::setMargin>( - node, scopedEnum(edge), value::points(points)); + node, scopedEnum(edge), StyleLength::points(points)); } void YGNodeStyleSetMarginPercent(YGNodeRef node, YGEdge edge, float percent) { updateStyle<&Style::margin, &Style::setMargin>( - node, scopedEnum(edge), value::percent(percent)); + node, scopedEnum(edge), StyleLength::percent(percent)); } void YGNodeStyleSetMarginAuto(YGNodeRef node, YGEdge edge) { updateStyle<&Style::margin, &Style::setMargin>( - node, scopedEnum(edge), value::ofAuto()); + node, scopedEnum(edge), StyleLength::ofAuto()); } YGValue YGNodeStyleGetMargin(YGNodeConstRef node, YGEdge edge) { @@ -235,12 +236,12 @@ YGValue YGNodeStyleGetMargin(YGNodeConstRef node, YGEdge edge) { void YGNodeStyleSetPadding(YGNodeRef node, YGEdge edge, float points) { updateStyle<&Style::padding, &Style::setPadding>( - node, scopedEnum(edge), value::points(points)); + node, scopedEnum(edge), StyleLength::points(points)); } void YGNodeStyleSetPaddingPercent(YGNodeRef node, YGEdge edge, float percent) { updateStyle<&Style::padding, &Style::setPadding>( - node, scopedEnum(edge), value::percent(percent)); + node, scopedEnum(edge), StyleLength::percent(percent)); } YGValue YGNodeStyleGetPadding(YGNodeConstRef node, YGEdge edge) { @@ -252,7 +253,7 @@ void YGNodeStyleSetBorder( const YGEdge edge, const float border) { updateStyle<&Style::border, &Style::setBorder>( - node, scopedEnum(edge), value::points(border)); + node, scopedEnum(edge), StyleLength::points(border)); } float YGNodeStyleGetBorder(const YGNodeConstRef node, const YGEdge edge) { @@ -269,12 +270,12 @@ void YGNodeStyleSetGap( const YGGutter gutter, const float gapLength) { updateStyle<&Style::gap, &Style::setGap>( - node, scopedEnum(gutter), value::points(gapLength)); + node, scopedEnum(gutter), StyleLength::points(gapLength)); } void YGNodeStyleSetGapPercent(YGNodeRef node, YGGutter gutter, float percent) { updateStyle<&Style::gap, &Style::setGap>( - node, scopedEnum(gutter), value::percent(percent)); + node, scopedEnum(gutter), StyleLength::percent(percent)); } float YGNodeStyleGetGap(const YGNodeConstRef node, const YGGutter gutter) { @@ -307,17 +308,17 @@ YGBoxSizing YGNodeStyleGetBoxSizing(const YGNodeConstRef node) { void YGNodeStyleSetWidth(YGNodeRef node, float points) { updateStyle<&Style::dimension, &Style::setDimension>( - node, Dimension::Width, value::points(points)); + node, Dimension::Width, StyleLength::points(points)); } void YGNodeStyleSetWidthPercent(YGNodeRef node, float percent) { updateStyle<&Style::dimension, &Style::setDimension>( - node, Dimension::Width, value::percent(percent)); + node, Dimension::Width, StyleLength::percent(percent)); } void YGNodeStyleSetWidthAuto(YGNodeRef node) { updateStyle<&Style::dimension, &Style::setDimension>( - node, Dimension::Width, value::ofAuto()); + node, Dimension::Width, StyleLength::ofAuto()); } YGValue YGNodeStyleGetWidth(YGNodeConstRef node) { @@ -326,17 +327,17 @@ YGValue YGNodeStyleGetWidth(YGNodeConstRef node) { void YGNodeStyleSetHeight(YGNodeRef node, float points) { updateStyle<&Style::dimension, &Style::setDimension>( - node, Dimension::Height, value::points(points)); + node, Dimension::Height, StyleLength::points(points)); } void YGNodeStyleSetHeightPercent(YGNodeRef node, float percent) { updateStyle<&Style::dimension, &Style::setDimension>( - node, Dimension::Height, value::percent(percent)); + node, Dimension::Height, StyleLength::percent(percent)); } void YGNodeStyleSetHeightAuto(YGNodeRef node) { updateStyle<&Style::dimension, &Style::setDimension>( - node, Dimension::Height, value::ofAuto()); + node, Dimension::Height, StyleLength::ofAuto()); } YGValue YGNodeStyleGetHeight(YGNodeConstRef node) { @@ -345,12 +346,12 @@ YGValue YGNodeStyleGetHeight(YGNodeConstRef node) { void YGNodeStyleSetMinWidth(const YGNodeRef node, const float minWidth) { updateStyle<&Style::minDimension, &Style::setMinDimension>( - node, Dimension::Width, value::points(minWidth)); + node, Dimension::Width, StyleLength::points(minWidth)); } void YGNodeStyleSetMinWidthPercent(const YGNodeRef node, const float minWidth) { updateStyle<&Style::minDimension, &Style::setMinDimension>( - node, Dimension::Width, value::percent(minWidth)); + node, Dimension::Width, StyleLength::percent(minWidth)); } YGValue YGNodeStyleGetMinWidth(const YGNodeConstRef node) { @@ -359,14 +360,14 @@ YGValue YGNodeStyleGetMinWidth(const YGNodeConstRef node) { void YGNodeStyleSetMinHeight(const YGNodeRef node, const float minHeight) { updateStyle<&Style::minDimension, &Style::setMinDimension>( - node, Dimension::Height, value::points(minHeight)); + node, Dimension::Height, StyleLength::points(minHeight)); } void YGNodeStyleSetMinHeightPercent( const YGNodeRef node, const float minHeight) { updateStyle<&Style::minDimension, &Style::setMinDimension>( - node, Dimension::Height, value::percent(minHeight)); + node, Dimension::Height, StyleLength::percent(minHeight)); } YGValue YGNodeStyleGetMinHeight(const YGNodeConstRef node) { @@ -375,12 +376,12 @@ YGValue YGNodeStyleGetMinHeight(const YGNodeConstRef node) { void YGNodeStyleSetMaxWidth(const YGNodeRef node, const float maxWidth) { updateStyle<&Style::maxDimension, &Style::setMaxDimension>( - node, Dimension::Width, value::points(maxWidth)); + node, Dimension::Width, StyleLength::points(maxWidth)); } void YGNodeStyleSetMaxWidthPercent(const YGNodeRef node, const float maxWidth) { updateStyle<&Style::maxDimension, &Style::setMaxDimension>( - node, Dimension::Width, value::percent(maxWidth)); + node, Dimension::Width, StyleLength::percent(maxWidth)); } YGValue YGNodeStyleGetMaxWidth(const YGNodeConstRef node) { @@ -389,14 +390,14 @@ YGValue YGNodeStyleGetMaxWidth(const YGNodeConstRef node) { void YGNodeStyleSetMaxHeight(const YGNodeRef node, const float maxHeight) { updateStyle<&Style::maxDimension, &Style::setMaxDimension>( - node, Dimension::Height, value::points(maxHeight)); + node, Dimension::Height, StyleLength::points(maxHeight)); } void YGNodeStyleSetMaxHeightPercent( const YGNodeRef node, const float maxHeight) { updateStyle<&Style::maxDimension, &Style::setMaxDimension>( - node, Dimension::Height, value::percent(maxHeight)); + node, Dimension::Height, StyleLength::percent(maxHeight)); } YGValue YGNodeStyleGetMaxHeight(const YGNodeConstRef node) { diff --git a/packages/react-native/ReactCommon/yoga/yoga/node/Node.cpp b/packages/react-native/ReactCommon/yoga/yoga/node/Node.cpp index 3189f3bbeff598..7c6bea55e3cfe7 100644 --- a/packages/react-native/ReactCommon/yoga/yoga/node/Node.cpp +++ b/packages/react-native/ReactCommon/yoga/yoga/node/Node.cpp @@ -288,9 +288,10 @@ Style::Length Node::processFlexBasis() const { return flexBasis; } if (style_.flex().isDefined() && style_.flex().unwrap() > 0.0f) { - return config_->useWebDefaults() ? value::ofAuto() : value::points(0); + return config_->useWebDefaults() ? StyleLength::ofAuto() + : StyleLength::points(0); } - return value::ofAuto(); + return StyleLength::ofAuto(); } FloatOptional Node::resolveFlexBasis( diff --git a/packages/react-native/ReactCommon/yoga/yoga/node/Node.h b/packages/react-native/ReactCommon/yoga/yoga/node/Node.h index 5f38ac1350f6e1..34ef6d955ed8da 100644 --- a/packages/react-native/ReactCommon/yoga/yoga/node/Node.h +++ b/packages/react-native/ReactCommon/yoga/yoga/node/Node.h @@ -302,7 +302,7 @@ class YG_EXPORT Node : public ::YGNode { std::vector children_; const Config* config_; std::array processedDimensions_{ - {value::undefined(), value::undefined()}}; + {StyleLength::undefined(), StyleLength::undefined()}}; }; inline Node* resolveRef(const YGNodeRef ref) { diff --git a/packages/react-native/ReactCommon/yoga/yoga/style/StyleLength.h b/packages/react-native/ReactCommon/yoga/yoga/style/StyleLength.h index 242698abf4e49b..7cc42d9eb5c8d0 100644 --- a/packages/react-native/ReactCommon/yoga/yoga/style/StyleLength.h +++ b/packages/react-native/ReactCommon/yoga/yoga/style/StyleLength.h @@ -104,36 +104,4 @@ inline bool inexactEquals(const StyleLength& a, const StyleLength& b) { return a.unit() == b.unit() && inexactEquals(a.value(), b.value()); } -namespace value { - -/** - * Canonical unit (one YGUnitPoint) - */ -constexpr StyleLength points(float value) { - return StyleLength::points(value); -} - -/** - * Percent of reference - */ -constexpr StyleLength percent(float value) { - return StyleLength::percent(value); -} - -/** - * "auto" keyword - */ -constexpr StyleLength ofAuto() { - return StyleLength::ofAuto(); -} - -/** - * Undefined - */ -constexpr StyleLength undefined() { - return StyleLength::undefined(); -} - -} // namespace value - } // namespace facebook::yoga diff --git a/packages/react-native/ReactCommon/yoga/yoga/style/StyleValuePool.h b/packages/react-native/ReactCommon/yoga/yoga/style/StyleValuePool.h index 3b177254447da4..597eae4c4374a9 100644 --- a/packages/react-native/ReactCommon/yoga/yoga/style/StyleValuePool.h +++ b/packages/react-native/ReactCommon/yoga/yoga/style/StyleValuePool.h @@ -49,9 +49,9 @@ class StyleValuePool { StyleLength getLength(StyleValueHandle handle) const { if (handle.isUndefined()) { - return value::undefined(); + return StyleLength::undefined(); } else if (handle.isAuto()) { - return value::ofAuto(); + return StyleLength::ofAuto(); } else { assert( handle.type() == StyleValueHandle::Type::Point || @@ -61,8 +61,8 @@ class StyleValuePool { : unpackInlineInteger(handle.value()); return handle.type() == StyleValueHandle::Type::Point - ? value::points(value) - : value::percent(value); + ? StyleLength::points(value) + : StyleLength::percent(value); } }