Skip to content

Commit 9ea7df2

Browse files
coadometa-codesync[bot]
authored andcommitted
Use public umbrellas in attributedstring headers (#58710)
Summary: Pull Request resolved: #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 fbshipit-source-id: 586595e5a3aece28a14d2253c985440a23e2ace7
1 parent c69c54a commit 9ea7df2

9 files changed

Lines changed: 31 additions & 37 deletions

File tree

‎packages/react-native/React/Base/RCTUtils.mm‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#import <objc/runtime.h>
1414
#import <zlib.h>
1515
#import <atomic>
16+
#import <cmath>
1617
#import <vector>
1718

1819
#import <UIKit/UIKit.h>
@@ -437,20 +438,20 @@ CGSize RCTSwitchSize(void)
437438
CGFloat RCTRoundPixelValue(CGFloat value)
438439
{
439440
CGFloat scale = RCTScreenScale();
440-
return round(value * scale) / scale;
441+
return std::round(value * scale) / scale;
441442
}
442443

443444
CGFloat RCTCeilPixelValue(CGFloat value)
444445
{
445446
CGFloat scale = RCTScreenScale();
446-
return ceil(value * scale) / scale;
447+
return std::ceil(value * scale) / scale;
447448
}
448449

449450
CGSize RCTSizeInPixels(CGSize pointSize, CGFloat scale)
450451
{
451452
return (CGSize){
452-
ceil(pointSize.width * scale),
453-
ceil(pointSize.height * scale),
453+
std::ceil(pointSize.width * scale),
454+
std::ceil(pointSize.height * scale),
454455
};
455456
}
456457

‎packages/react-native/ReactCommon/React-Fabric.podspec‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ Pod::Spec.new do |s|
8181
end
8282

8383
s.subspec "attributedstring" do |ss|
84-
ss.dependency "React-renderercss"
84+
ss.dependency "React-Fabric/coreUmbrella"
85+
ss.dependency "React-Fabric/components/viewUmbrella"
86+
ss.dependency "React-renderercss"
8587
ss.source_files = podspec_sources("react/renderer/attributedstring/**/*.{m,mm,cpp,h}", "react/renderer/attributedstring/**/*.{h}")
8688
ss.exclude_files = "react/renderer/attributedstring/tests"
8789
ss.header_dir = "react/renderer/attributedstring"

‎packages/react-native/ReactCommon/react/renderer/attributedstring/AttributedString.h‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@
99

1010
#include <react/cxxstableapi/FrameworksGuard.h>
1111

12+
#include <React/RendererCore.h>
13+
#include <React/Utils.h>
1214
#include <react/renderer/attributedstring/TextAttributes.h>
13-
#include <react/renderer/core/Sealable.h>
14-
#include <react/renderer/debug/DebugStringConvertible.h>
1515
#include <react/renderer/mounting/ShadowView.h>
16-
#include <react/utils/hash_combine.h>
1716

1817
namespace facebook::react {
1918

‎packages/react-native/ReactCommon/react/renderer/attributedstring/AttributedStringBox.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#include <memory>
1313

14+
#include <React/Debug.h>
1415
#include <react/renderer/attributedstring/AttributedString.h>
1516

1617
namespace facebook::react {

‎packages/react-native/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.h‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111

1212
#include <limits>
1313

14+
#include <React/Graphics.h>
15+
#include <React/RendererCore.h>
16+
#include <React/Utils.h>
1417
#include <react/renderer/attributedstring/primitives.h>
15-
#include <react/renderer/debug/DebugStringConvertible.h>
16-
#include <react/renderer/graphics/Float.h>
17-
#include <react/utils/hash_combine.h>
1818

1919
namespace facebook::react {
2020

‎packages/react-native/ReactCommon/react/renderer/attributedstring/TextAttributes.h‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,12 @@
1414
#include <optional>
1515
#include <vector>
1616

17+
#include <React/Graphics.h>
18+
#include <React/RendererCore.h>
19+
#include <React/Utils.h>
20+
#include <React/View.h>
1721
#include <folly/dynamic.h>
1822
#include <react/renderer/attributedstring/primitives.h>
19-
#include <react/renderer/components/view/AccessibilityPrimitives.h>
20-
#include <react/renderer/core/LayoutPrimitives.h>
21-
#include <react/renderer/core/ReactPrimitives.h>
22-
#include <react/renderer/debug/DebugStringConvertible.h>
23-
#include <react/renderer/graphics/Color.h>
24-
#include <react/renderer/graphics/Float.h>
25-
#include <react/renderer/graphics/Size.h>
26-
#include <react/utils/hash_combine.h>
2723

2824
namespace facebook::react {
2925

‎packages/react-native/ReactCommon/react/renderer/attributedstring/conversions.h‎

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,20 @@
99

1010
#include <react/cxxstableapi/FrameworksGuard.h>
1111

12-
#include <react/debug/react_native_expect.h>
12+
#include <React/CSS.h>
13+
#include <React/Debug.h>
14+
#include <React/RendererCore.h>
15+
#include <React/View.h>
1316
#include <react/featureflags/ReactNativePublicFeatureFlags.h>
1417
#include <react/renderer/attributedstring/AttributedString.h>
1518
#include <react/renderer/attributedstring/ParagraphAttributes.h>
1619
#include <react/renderer/attributedstring/TextAttributes.h>
17-
#include <react/renderer/attributedstring/conversions.h>
1820
#include <react/renderer/attributedstring/primitives.h>
19-
#include <react/renderer/components/view/accessibilityPropsConversions.h>
20-
#include <react/renderer/core/LayoutableShadowNode.h>
21-
#include <react/renderer/core/PropsParserContext.h>
22-
#include <react/renderer/core/ShadowNode.h>
23-
#include <react/renderer/core/conversions.h>
24-
#include <react/renderer/core/graphicsConversions.h>
25-
#include <react/renderer/core/propsConversions.h>
26-
#include <react/renderer/css/CSSFontVariant.h>
27-
#include <react/renderer/css/CSSValueParser.h>
2821
#include <unordered_map>
2922

3023
#ifdef RN_SERIALIZABLE_STATE
24+
#include <React/MapBuffer.h>
3125
#include <folly/json.h>
32-
#include <react/renderer/mapbuffer/MapBuffer.h>
33-
#include <react/renderer/mapbuffer/MapBufferBuilder.h>
3426
#endif
3527

3628
#include <glog/logging.h>

‎packages/react-native/ReactCommon/react/renderer/graphics/platform/ios/react/renderer/graphics/HostPlatformColor.mm‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#import <objc/runtime.h>
1313
#import <react/renderer/graphics/RCTPlatformColorUtils.h>
1414
#import <react/utils/ManagedObjectWrapper.h>
15+
#import <cmath>
1516
#import <string>
1617

1718
using namespace facebook::react;
@@ -86,9 +87,10 @@ bool UIColorIsP3ColorSpace(const std::shared_ptr<void> &uiColor)
8687
int32_t ColorFromColorComponents(const facebook::react::ColorComponents &components)
8788
{
8889
float ratio = 255;
89-
auto color = ((int32_t)round((float)components.alpha * ratio) & 0xff) << 24 |
90-
((int)round((float)components.red * ratio) & 0xff) << 16 |
91-
((int)round((float)components.green * ratio) & 0xff) << 8 | ((int)round((float)components.blue * ratio) & 0xff);
90+
auto color = ((int32_t)std::round((float)components.alpha * ratio) & 0xff) << 24 |
91+
((int)std::round((float)components.red * ratio) & 0xff) << 16 |
92+
((int)std::round((float)components.green * ratio) & 0xff) << 8 |
93+
((int)std::round((float)components.blue * ratio) & 0xff);
9294
return color;
9395
}
9496

‎packages/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTTextLayoutManager.mm‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#import "RCTTextLayoutManager.h"
99

1010
#import <array>
11+
#import <cmath>
1112

1213
#import "RCTAttributedTextUtils.h"
1314

@@ -186,8 +187,8 @@ - (void)drawAttributedString:(AttributedString)attributedString
186187
// remains visible at small sizes and proportionate at
187188
// large ones. ~`fontSize / 12` plus a 1.5pt floor.
188189
CGFloat thickness = MAX(fontSize / 12.0f, 1.5f);
189-
CGFloat wavyWavelength = 1.0f + 2.0f * round(2.0f * thickness + 0.5f);
190-
CGFloat wavyCpDistance = 0.5f + round(3.0f * thickness + 0.5f);
190+
CGFloat wavyWavelength = 1.0f + 2.0f * std::round(2.0f * thickness + 0.5f);
191+
CGFloat wavyCpDistance = 0.5f + std::round(3.0f * thickness + 0.5f);
191192

192193
NSRange targetGlyphRange = [layoutManager glyphRangeForCharacterRange:attrRange
193194
actualCharacterRange:nullptr];

0 commit comments

Comments
 (0)