From 8bd9952eaf28fe8feca7490293656caeefe7897e Mon Sep 17 00:00:00 2001 From: Jingbo Yang Date: Tue, 25 Jun 2024 18:48:15 -0700 Subject: [PATCH] Replace YogaConstants.UNDEFINED with Float.NaN (#45141) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/45141 Reviewed By: javache, NickGerleman Differential Revision: D58915391 fbshipit-source-id: 73ebee6abaced092366abdfc0ff41a66e7ff6c03 --- .../com/facebook/react/uimanager/LayoutShadowNode.java | 4 ++-- .../com/facebook/react/views/image/ReactImageManager.java | 5 ++--- .../views/scroll/ReactHorizontalScrollViewManager.java | 8 ++++---- .../react/views/scroll/ReactScrollViewManager.java | 8 ++++---- .../react/views/text/ReactTextAnchorViewManager.java | 8 ++++---- .../react/views/textinput/ReactTextInputManager.java | 8 ++++---- .../com/facebook/react/views/view/ReactViewManager.java | 8 ++++---- 7 files changed, 24 insertions(+), 25 deletions(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/LayoutShadowNode.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/LayoutShadowNode.java index eca5c86f87b3d9..d1fbd2479aa5c2 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/LayoutShadowNode.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/LayoutShadowNode.java @@ -330,7 +330,7 @@ public void setFlexBasis(Dynamic flexBasis) { flexBasis.recycle(); } - @ReactProp(name = ViewProps.ASPECT_RATIO, defaultFloat = YogaConstants.UNDEFINED) + @ReactProp(name = ViewProps.ASPECT_RATIO, defaultFloat = Float.NaN) public void setAspectRatio(float aspectRatio) { setStyleAspectRatio(aspectRatio); } @@ -863,7 +863,7 @@ public void setPaddings(int index, Dynamic padding) { ViewProps.BORDER_LEFT_WIDTH, ViewProps.BORDER_RIGHT_WIDTH, }, - defaultFloat = YogaConstants.UNDEFINED) + defaultFloat = Float.NaN) public void setBorderWidths(int index, float borderWidth) { if (isVirtual()) { return; diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/image/ReactImageManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/image/ReactImageManager.java index ec5f5cecc7c743..f9e66481c16158 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/image/ReactImageManager.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/image/ReactImageManager.java @@ -24,7 +24,6 @@ import com.facebook.react.uimanager.ViewProps; import com.facebook.react.uimanager.annotations.ReactProp; import com.facebook.react.uimanager.annotations.ReactPropGroup; -import com.facebook.yoga.YogaConstants; import java.util.HashMap; import java.util.Map; @@ -190,9 +189,9 @@ public void setBorderWidth(ReactImageView view, float borderWidth) { ViewProps.BORDER_BOTTOM_RIGHT_RADIUS, ViewProps.BORDER_BOTTOM_LEFT_RADIUS }, - defaultFloat = YogaConstants.UNDEFINED) + defaultFloat = Float.NaN) public void setBorderRadius(ReactImageView view, int index, float borderRadius) { - if (!YogaConstants.isUndefined(borderRadius)) { + if (!Float.isNaN(borderRadius)) { borderRadius = PixelUtil.toPixelFromDIP(borderRadius); } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollViewManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollViewManager.java index 579d5ab467bb3f..86abb6baacba60 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollViewManager.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollViewManager.java @@ -255,9 +255,9 @@ public void setBottomFillColor(ReactHorizontalScrollView view, int color) { ViewProps.BORDER_BOTTOM_RIGHT_RADIUS, ViewProps.BORDER_BOTTOM_LEFT_RADIUS }, - defaultFloat = YogaConstants.UNDEFINED) + defaultFloat = Float.NaN) public void setBorderRadius(ReactHorizontalScrollView view, int index, float borderRadius) { - if (!YogaConstants.isUndefined(borderRadius)) { + if (!Float.isNaN(borderRadius)) { borderRadius = PixelUtil.toPixelFromDIP(borderRadius); } @@ -281,9 +281,9 @@ public void setBorderStyle(ReactHorizontalScrollView view, @Nullable String bord ViewProps.BORDER_TOP_WIDTH, ViewProps.BORDER_BOTTOM_WIDTH, }, - defaultFloat = YogaConstants.UNDEFINED) + defaultFloat = Float.NaN) public void setBorderWidth(ReactHorizontalScrollView view, int index, float width) { - if (!YogaConstants.isUndefined(width)) { + if (!Float.isNaN(width)) { width = PixelUtil.toPixelFromDIP(width); } view.setBorderWidth(SPACING_TYPES[index], width); diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewManager.java index 3413383cd5a3da..1db0a0e5f360e3 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewManager.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewManager.java @@ -236,9 +236,9 @@ public void scrollTo( ViewProps.BORDER_BOTTOM_RIGHT_RADIUS, ViewProps.BORDER_BOTTOM_LEFT_RADIUS }, - defaultFloat = YogaConstants.UNDEFINED) + defaultFloat = Float.NaN) public void setBorderRadius(ReactScrollView view, int index, float borderRadius) { - if (!YogaConstants.isUndefined(borderRadius)) { + if (!Float.isNaN(borderRadius)) { borderRadius = PixelUtil.toPixelFromDIP(borderRadius); } @@ -262,9 +262,9 @@ public void setBorderStyle(ReactScrollView view, @Nullable String borderStyle) { ViewProps.BORDER_TOP_WIDTH, ViewProps.BORDER_BOTTOM_WIDTH, }, - defaultFloat = YogaConstants.UNDEFINED) + defaultFloat = Float.NaN) public void setBorderWidth(ReactScrollView view, int index, float width) { - if (!YogaConstants.isUndefined(width)) { + if (!Float.isNaN(width)) { width = PixelUtil.toPixelFromDIP(width); } view.setBorderWidth(SPACING_TYPES[index], width); diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextAnchorViewManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextAnchorViewManager.java index deb5097c15f23b..29a67a81ae83e1 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextAnchorViewManager.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextAnchorViewManager.java @@ -137,9 +137,9 @@ public void setAndroidHyphenationFrequency(ReactTextView view, @Nullable String ViewProps.BORDER_BOTTOM_RIGHT_RADIUS, ViewProps.BORDER_BOTTOM_LEFT_RADIUS }, - defaultFloat = YogaConstants.UNDEFINED) + defaultFloat = Float.NaN) public void setBorderRadius(ReactTextView view, int index, float borderRadius) { - if (!YogaConstants.isUndefined(borderRadius)) { + if (!Float.isNaN(borderRadius)) { borderRadius = PixelUtil.toPixelFromDIP(borderRadius); } @@ -163,9 +163,9 @@ public void setBorderStyle(ReactTextView view, @Nullable String borderStyle) { ViewProps.BORDER_TOP_WIDTH, ViewProps.BORDER_BOTTOM_WIDTH, }, - defaultFloat = YogaConstants.UNDEFINED) + defaultFloat = Float.NaN) public void setBorderWidth(ReactTextView view, int index, float width) { - if (!YogaConstants.isUndefined(width)) { + if (!Float.isNaN(width)) { width = PixelUtil.toPixelFromDIP(width); } view.setBorderWidth(SPACING_TYPES[index], width); diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java index a0e92290e417c6..983a0ae0afd0b3 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java @@ -957,9 +957,9 @@ public void setReturnKeyLabel(ReactEditText view, String returnKeyLabel) { ViewProps.BORDER_BOTTOM_RIGHT_RADIUS, ViewProps.BORDER_BOTTOM_LEFT_RADIUS }, - defaultFloat = YogaConstants.UNDEFINED) + defaultFloat = Float.NaN) public void setBorderRadius(ReactEditText view, int index, float borderRadius) { - if (!YogaConstants.isUndefined(borderRadius)) { + if (!Float.isNaN(borderRadius)) { borderRadius = PixelUtil.toPixelFromDIP(borderRadius); } @@ -1007,9 +1007,9 @@ public void setTextDecorationLine(ReactEditText view, @Nullable String textDecor ViewProps.BORDER_TOP_WIDTH, ViewProps.BORDER_BOTTOM_WIDTH, }, - defaultFloat = YogaConstants.UNDEFINED) + defaultFloat = Float.NaN) public void setBorderWidth(ReactEditText view, int index, float width) { - if (!YogaConstants.isUndefined(width)) { + if (!Float.isNaN(width)) { width = PixelUtil.toPixelFromDIP(width); } view.setBorderWidth(SPACING_TYPES[index], width); diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewManager.java index df4b9c85ce4f9c..14a31a4366981a 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewManager.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewManager.java @@ -219,13 +219,13 @@ public void setNeedsOffscreenAlphaCompositing( ViewProps.BORDER_START_WIDTH, ViewProps.BORDER_END_WIDTH, }, - defaultFloat = YogaConstants.UNDEFINED) + defaultFloat = Float.NaN) public void setBorderWidth(ReactViewGroup view, int index, float width) { - if (!YogaConstants.isUndefined(width) && width < 0) { - width = YogaConstants.UNDEFINED; + if (!Float.isNaN(width) && width < 0) { + width = Float.NaN; } - if (!YogaConstants.isUndefined(width)) { + if (!Float.isNaN(width)) { width = PixelUtil.toPixelFromDIP(width); }