diff --git a/packages/react-native/React/Base/RCTUtils.mm b/packages/react-native/React/Base/RCTUtils.mm index 04f4e4ed3911..21ddfb6ff1f2 100644 --- a/packages/react-native/React/Base/RCTUtils.mm +++ b/packages/react-native/React/Base/RCTUtils.mm @@ -13,6 +13,7 @@ #import #import #import +#import #import #import @@ -437,20 +438,20 @@ CGSize RCTSwitchSize(void) CGFloat RCTRoundPixelValue(CGFloat value) { CGFloat scale = RCTScreenScale(); - return round(value * scale) / scale; + return std::round(value * scale) / scale; } CGFloat RCTCeilPixelValue(CGFloat value) { CGFloat scale = RCTScreenScale(); - return ceil(value * scale) / scale; + return std::ceil(value * scale) / scale; } CGSize RCTSizeInPixels(CGSize pointSize, CGFloat scale) { return (CGSize){ - ceil(pointSize.width * scale), - ceil(pointSize.height * scale), + std::ceil(pointSize.width * scale), + std::ceil(pointSize.height * scale), }; } diff --git a/packages/react-native/ReactCommon/React-Fabric.podspec b/packages/react-native/ReactCommon/React-Fabric.podspec index dbc0fb6faaf1..b8be410c3564 100644 --- a/packages/react-native/ReactCommon/React-Fabric.podspec +++ b/packages/react-native/ReactCommon/React-Fabric.podspec @@ -81,6 +81,9 @@ Pod::Spec.new do |s| end s.subspec "attributedstring" do |ss| + ss.dependency "React-Fabric/coreUmbrella" + ss.dependency "React-Fabric/components/viewUmbrella" + ss.dependency "React-renderercss" ss.source_files = podspec_sources("react/renderer/attributedstring/**/*.{m,mm,cpp,h}", "react/renderer/attributedstring/**/*.{h}") ss.exclude_files = "react/renderer/attributedstring/tests" ss.header_dir = "react/renderer/attributedstring" diff --git a/packages/react-native/ReactCommon/react/renderer/attributedstring/AttributedString.h b/packages/react-native/ReactCommon/react/renderer/attributedstring/AttributedString.h index f1cdbe4181cb..4913f3583704 100644 --- a/packages/react-native/ReactCommon/react/renderer/attributedstring/AttributedString.h +++ b/packages/react-native/ReactCommon/react/renderer/attributedstring/AttributedString.h @@ -9,11 +9,10 @@ #include +#include +#include #include -#include -#include #include -#include namespace facebook::react { diff --git a/packages/react-native/ReactCommon/react/renderer/attributedstring/AttributedStringBox.h b/packages/react-native/ReactCommon/react/renderer/attributedstring/AttributedStringBox.h index 4c9471bde5cf..077bf846c34d 100644 --- a/packages/react-native/ReactCommon/react/renderer/attributedstring/AttributedStringBox.h +++ b/packages/react-native/ReactCommon/react/renderer/attributedstring/AttributedStringBox.h @@ -11,6 +11,7 @@ #include +#include #include namespace facebook::react { diff --git a/packages/react-native/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.h b/packages/react-native/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.h index 7cd8252d7c8f..f9385bebe811 100644 --- a/packages/react-native/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.h +++ b/packages/react-native/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.h @@ -11,10 +11,10 @@ #include +#include +#include +#include #include -#include -#include -#include namespace facebook::react { diff --git a/packages/react-native/ReactCommon/react/renderer/attributedstring/TextAttributes.h b/packages/react-native/ReactCommon/react/renderer/attributedstring/TextAttributes.h index bcf902f9093a..9f9fdb02b824 100644 --- a/packages/react-native/ReactCommon/react/renderer/attributedstring/TextAttributes.h +++ b/packages/react-native/ReactCommon/react/renderer/attributedstring/TextAttributes.h @@ -14,16 +14,12 @@ #include #include +#include +#include +#include +#include #include #include -#include -#include -#include -#include -#include -#include -#include -#include namespace facebook::react { diff --git a/packages/react-native/ReactCommon/react/renderer/attributedstring/conversions.h b/packages/react-native/ReactCommon/react/renderer/attributedstring/conversions.h index c6d6f7ad9b3b..2db56776d143 100644 --- a/packages/react-native/ReactCommon/react/renderer/attributedstring/conversions.h +++ b/packages/react-native/ReactCommon/react/renderer/attributedstring/conversions.h @@ -9,28 +9,20 @@ #include -#include +#include +#include +#include +#include #include #include #include #include -#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include #ifdef RN_SERIALIZABLE_STATE +#include #include -#include -#include #endif #include diff --git a/packages/react-native/ReactCommon/react/renderer/graphics/platform/ios/react/renderer/graphics/HostPlatformColor.mm b/packages/react-native/ReactCommon/react/renderer/graphics/platform/ios/react/renderer/graphics/HostPlatformColor.mm index e47deaa95cf6..1fc1a37068bf 100644 --- a/packages/react-native/ReactCommon/react/renderer/graphics/platform/ios/react/renderer/graphics/HostPlatformColor.mm +++ b/packages/react-native/ReactCommon/react/renderer/graphics/platform/ios/react/renderer/graphics/HostPlatformColor.mm @@ -12,6 +12,7 @@ #import #import #import +#import #import using namespace facebook::react; @@ -86,9 +87,10 @@ bool UIColorIsP3ColorSpace(const std::shared_ptr &uiColor) int32_t ColorFromColorComponents(const facebook::react::ColorComponents &components) { float ratio = 255; - auto color = ((int32_t)round((float)components.alpha * ratio) & 0xff) << 24 | - ((int)round((float)components.red * ratio) & 0xff) << 16 | - ((int)round((float)components.green * ratio) & 0xff) << 8 | ((int)round((float)components.blue * ratio) & 0xff); + auto color = ((int32_t)std::round((float)components.alpha * ratio) & 0xff) << 24 | + ((int)std::round((float)components.red * ratio) & 0xff) << 16 | + ((int)std::round((float)components.green * ratio) & 0xff) << 8 | + ((int)std::round((float)components.blue * ratio) & 0xff); return color; } diff --git a/packages/react-native/ReactCommon/react/renderer/imagemanager/primitives.cpp b/packages/react-native/ReactCommon/react/renderer/imagemanager/primitives.cpp new file mode 100644 index 000000000000..bef05830294a --- /dev/null +++ b/packages/react-native/ReactCommon/react/renderer/imagemanager/primitives.cpp @@ -0,0 +1,49 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#include + +#if RN_DEBUG_STRING_CONVERTIBLE +#include +#endif + +namespace facebook::react { + +#if RN_DEBUG_STRING_CONVERTIBLE +SharedDebugStringConvertibleList ImageSource::getDebugProps( + const std::string& prefix) const { + ImageSource imageSource{}; + + SharedDebugStringConvertibleList headersList; + for (const auto& header : headers) { + headersList.push_back(debugStringConvertibleItem( + prefix + "-header-" + header.first, header.second)); + } + + return headersList + + SharedDebugStringConvertibleList{ + debugStringConvertibleItem( + prefix + "-type", toString(type), toString(imageSource.type)), + debugStringConvertibleItem(prefix + "-uri", uri, imageSource.uri), + debugStringConvertibleItem( + prefix + "-bundle", bundle, imageSource.bundle), + debugStringConvertibleItem( + prefix + "-scale", scale, imageSource.scale), + debugStringConvertibleItem( + prefix + "-size", + react::toString(size), + react::toString(imageSource.size)), + debugStringConvertibleItem(prefix + "-body", body, imageSource.body), + debugStringConvertibleItem( + prefix + "-method", method, imageSource.method), + debugStringConvertibleItem( + prefix + "-cache", toString(cache), toString(imageSource.cache)), + }; +} +#endif + +} // namespace facebook::react diff --git a/packages/react-native/ReactCommon/react/renderer/imagemanager/primitives.h b/packages/react-native/ReactCommon/react/renderer/imagemanager/primitives.h index 2743da4430ee..86756373d6da 100644 --- a/packages/react-native/ReactCommon/react/renderer/imagemanager/primitives.h +++ b/packages/react-native/ReactCommon/react/renderer/imagemanager/primitives.h @@ -16,7 +16,8 @@ #include #include #include -#include +#include +#include namespace facebook::react { @@ -96,27 +97,7 @@ class ImageSource { #endif #if RN_DEBUG_STRING_CONVERTIBLE - SharedDebugStringConvertibleList getDebugProps(const std::string &prefix) const - { - ImageSource imageSource{}; - - SharedDebugStringConvertibleList headersList; - for (const auto &header : headers) { - headersList.push_back(debugStringConvertibleItem(prefix + "-header-" + header.first, header.second)); - } - - return headersList + - SharedDebugStringConvertibleList{ - debugStringConvertibleItem(prefix + "-type", toString(type), toString(imageSource.type)), - debugStringConvertibleItem(prefix + "-uri", uri, imageSource.uri), - debugStringConvertibleItem(prefix + "-bundle", bundle, imageSource.bundle), - debugStringConvertibleItem(prefix + "-scale", scale, imageSource.scale), - debugStringConvertibleItem(prefix + "-size", react::toString(size), react::toString(imageSource.size)), - debugStringConvertibleItem(prefix + "-body", body, imageSource.body), - debugStringConvertibleItem(prefix + "-method", method, imageSource.method), - debugStringConvertibleItem(prefix + "-cache", toString(cache), toString(imageSource.cache)), - }; - } + SharedDebugStringConvertibleList getDebugProps(const std::string &prefix) const; std::string toString(const Type &typeValue) const { diff --git a/packages/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTTextLayoutManager.mm b/packages/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTTextLayoutManager.mm index af5b225e8e7e..3e5bfd528320 100644 --- a/packages/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTTextLayoutManager.mm +++ b/packages/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTTextLayoutManager.mm @@ -8,6 +8,7 @@ #import "RCTTextLayoutManager.h" #import +#import #import "RCTAttributedTextUtils.h" @@ -186,8 +187,8 @@ - (void)drawAttributedString:(AttributedString)attributedString // remains visible at small sizes and proportionate at // large ones. ~`fontSize / 12` plus a 1.5pt floor. CGFloat thickness = MAX(fontSize / 12.0f, 1.5f); - CGFloat wavyWavelength = 1.0f + 2.0f * round(2.0f * thickness + 0.5f); - CGFloat wavyCpDistance = 0.5f + round(3.0f * thickness + 0.5f); + CGFloat wavyWavelength = 1.0f + 2.0f * std::round(2.0f * thickness + 0.5f); + CGFloat wavyCpDistance = 0.5f + std::round(3.0f * thickness + 0.5f); NSRange targetGlyphRange = [layoutManager glyphRangeForCharacterRange:attrRange actualCharacterRange:nullptr];