From 6cb55147369097ced17474b211436607a072b19d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dawid=20Ma=C5=82ecki?= Date: Thu, 1 Oct 2026 08:46:58 -0700 Subject: [PATCH] Use public umbrellas in attributedstring headers (#58710) Summary: Pull Request resolved: https://github.com/react/react-native/pull/58710 Migrate React-Fabric attributedstring headers to consume stable Debug, FeatureFlags, CSS, Graphics, MapBuffer, RendererCore, Utils, and View umbrellas instead of guarded leaf headers. Add the direct Buck and CocoaPods dependencies required by those public imports. Avoid RendererDebug.h because its current utility-template export changes downstream overload lookup; RendererCore already provides the debug declaration types used by attributedstring. Changelog: [Internal] Reviewed By: cortinico Differential Revision: D121793359 --- packages/react-native/React/Base/RCTUtils.mm | 9 +++++---- .../ReactCommon/React-Fabric.podspec | 4 +++- .../attributedstring/AttributedString.h | 5 ++--- .../attributedstring/AttributedStringBox.h | 1 + .../attributedstring/ParagraphAttributes.h | 6 +++--- .../renderer/attributedstring/TextAttributes.h | 12 ++++-------- .../renderer/attributedstring/conversions.h | 18 +++++------------- .../renderer/graphics/HostPlatformColor.mm | 8 +++++--- .../textlayoutmanager/RCTTextLayoutManager.mm | 5 +++-- 9 files changed, 31 insertions(+), 37 deletions(-) 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 4f2250e700b9..e322460bbe48 100644 --- a/packages/react-native/ReactCommon/React-Fabric.podspec +++ b/packages/react-native/ReactCommon/React-Fabric.podspec @@ -81,7 +81,9 @@ Pod::Spec.new do |s| end s.subspec "attributedstring" do |ss| - ss.dependency "React-renderercss" + 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/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];