From b7d74010ff29f5f6af821b82dfda8e18f0fa6718 Mon Sep 17 00:00:00 2001 From: Andrew <30809111+acoates-ms@users.noreply.github.com> Date: Fri, 23 May 2025 09:16:04 -0700 Subject: [PATCH 1/7] Cleanup a bunch of unneeded ReactCommon patching, and extra hostplatform overrides --- .vscode/settings.json | 3 +- vnext/Desktop/React.Windows.Desktop.vcxproj | 2 - .../Composition/ParagraphComponentView.cpp | 4 +- .../Fabric/Composition/ReactNativeIsland.cpp | 5 +- .../WindowsTextInputComponentDescriptor.h | 3 +- .../WindowsTextInputComponentView.cpp | 3 +- .../TextInput/WindowsTextInputShadowNode.cpp | 8 - .../TextInput/WindowsTextInputShadowNode.h | 4 +- .../Fabric/Composition/TooltipService.cpp | 5 +- .../Fabric/FabricUIManagerModule.cpp | 6 + .../WindowsComponentDescriptorRegistry.h | 2 + .../components/view/HostPlatformTouch.h | 10 - .../platform/react/renderer/graphics/Float.h | 20 - .../renderer/graphics/HostPlatformColor.h | 1 - .../renderer/graphics/PlatformColorUtils.h | 2 +- .../textlayoutmanager/TextLayoutManager.h | 117 ----- ...nager.cpp => WindowsTextLayoutManager.cpp} | 61 +-- .../WindowsTextLayoutManager.h | 68 +++ .../Microsoft.ReactNative.vcxproj | 2 - vnext/PropertySheets/React.Cpp.props | 7 +- vnext/ReactCommon/ReactCommon.vcxproj | 6 +- .../react/bridging/Bridging.h | 6 +- .../components/textinput/TextInputState.h | 73 --- .../components/view/HostPlatformTouch.h | 14 - .../view/HostPlatformViewEventEmitter.h | 14 - .../components/view/HostPlatformViewProps.h | 14 - .../react/renderer/graphics/Float.h | 433 ------------------ .../renderer/graphics/HostPlatformColor.h | 62 --- .../imagemanager/ImageRequestParams.h | 30 -- .../runtimescheduler/SchedulerPriorityUtils.h | 60 --- vnext/ReactCommon/packages.lock.json | 6 + vnext/Shared/Shared.vcxitems | 8 +- vnext/Shared/Shared.vcxitems.filters | 2 + vnext/overrides.json | 21 - 34 files changed, 139 insertions(+), 943 deletions(-) delete mode 100644 vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/components/view/HostPlatformTouch.h delete mode 100644 vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/Float.h delete mode 100644 vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/TextLayoutManager.h rename vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/{TextLayoutManager.cpp => WindowsTextLayoutManager.cpp} (93%) create mode 100644 vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/WindowsTextLayoutManager.h delete mode 100644 vnext/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/textinput/TextInputState.h delete mode 100644 vnext/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/HostPlatformTouch.h delete mode 100644 vnext/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/HostPlatformViewEventEmitter.h delete mode 100644 vnext/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/HostPlatformViewProps.h delete mode 100644 vnext/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/graphics/Float.h delete mode 100644 vnext/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/graphics/HostPlatformColor.h delete mode 100644 vnext/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/imagemanager/ImageRequestParams.h delete mode 100644 vnext/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/runtimescheduler/SchedulerPriorityUtils.h diff --git a/.vscode/settings.json b/.vscode/settings.json index 2130d0cb1c5..b6474c5976c 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -102,7 +102,8 @@ "xtree": "cpp", "xutility": "cpp", "xstddef": "cpp", - "cfenv": "cpp" + "cfenv": "cpp", + "cfloat": "cpp" }, "search.exclude": { "**/dist/**/*.js": true, diff --git a/vnext/Desktop/React.Windows.Desktop.vcxproj b/vnext/Desktop/React.Windows.Desktop.vcxproj index 74b8151709c..bc4b90f9d24 100644 --- a/vnext/Desktop/React.Windows.Desktop.vcxproj +++ b/vnext/Desktop/React.Windows.Desktop.vcxproj @@ -127,12 +127,10 @@ "$(ReactNativeWindowsDir)Microsoft.ReactNative"; - "$(ReactNativeWindowsDir)Microsoft.ReactNative\Fabric\platform"; "$(ReactNativeWindowsDir)Microsoft.ReactNative\ReactHost"; "$(ReactNativeWindowsDir)Microsoft.ReactNative\Views"; "$(ReactNativeWindowsDir)codegen"; "$(ReactNativeWindowsDir)codegen\react\components\rnwcore"; - $(ReactNativeDir)\ReactCommon\react\renderer\graphics\platform\cxx; %(AdditionalIncludeDirectories); %(AdditionalOptions) /Zc:strictStrings /bigobj /await diff --git a/vnext/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.cpp b/vnext/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.cpp index 03d313ad02d..00130079577 100644 --- a/vnext/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.cpp +++ b/vnext/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.cpp @@ -5,6 +5,8 @@ #include "ParagraphComponentView.h" +#include + #include #include #include @@ -169,7 +171,7 @@ void ParagraphComponentView::updateVisualBrush() noexcept { constraints.maximumSize.height = m_layoutMetrics.frame.size.height - m_layoutMetrics.contentInsets.top - m_layoutMetrics.contentInsets.bottom; - facebook::react::TextLayoutManager::GetTextLayout( + facebook::react::WindowsTextLayoutManager::GetTextLayout( m_attributedStringBox, m_paragraphAttributes, constraints, m_textLayout); requireNewBrush = true; diff --git a/vnext/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp b/vnext/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp index 9b3a34964e7..d45b6107d0a 100644 --- a/vnext/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp +++ b/vnext/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp @@ -5,6 +5,7 @@ #include "FocusNavigationRequest.g.cpp" #include "ReactNativeIsland.g.cpp" #include +#include #include #include @@ -609,7 +610,7 @@ facebook::react::Size ReactNativeIsland::MeasureLoading( auto attributedStringBox = CreateLoadingAttributedString(); winrt::com_ptr<::IDWriteTextLayout> textLayout; - facebook::react::TextLayoutManager::GetTextLayout( + facebook::react::WindowsTextLayoutManager::GetTextLayout( attributedStringBox, CreateLoadingParagraphAttributes(), fbLayoutConstraints, textLayout); DWRITE_TEXT_METRICS tm; @@ -691,7 +692,7 @@ Composition::Experimental::IDrawingSurfaceBrush ReactNativeIsland::CreateLoading textAttributes.foregroundColor = facebook::react::whiteColor(); winrt::com_ptr<::IDWriteTextLayout> textLayout; - facebook::react::TextLayoutManager::GetTextLayout( + facebook::react::WindowsTextLayoutManager::GetTextLayout( attributedStringBox, CreateLoadingParagraphAttributes(), constraints, textLayout); DWRITE_TEXT_METRICS tm; diff --git a/vnext/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentDescriptor.h b/vnext/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentDescriptor.h index d5c2ace95d6..0c230a135f6 100644 --- a/vnext/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentDescriptor.h +++ b/vnext/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentDescriptor.h @@ -10,6 +10,7 @@ #include +#include #include namespace facebook::react { @@ -21,7 +22,7 @@ class WindowsTextInputComponentDescriptor final : public ConcreteComponentDescri public: WindowsTextInputComponentDescriptor(const ComponentDescriptorParameters ¶meters) : ConcreteComponentDescriptor(parameters), - textLayoutManager_(std::make_shared(contextContainer_)) {} + textLayoutManager_(getManagerByName(contextContainer_, TextLayoutManagerKey)) {} /* virtual State::Shared createInitialState( diff --git a/vnext/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp b/vnext/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp index c5ead841f4e..506c2eb88fd 100644 --- a/vnext/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +++ b/vnext/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -1482,7 +1483,7 @@ winrt::com_ptr<::IDWriteTextLayout> WindowsTextInputComponentView::CreatePlaceho constraints.maximumSize.width = static_cast(m_imgWidth); constraints.maximumSize.height = static_cast(m_imgHeight); - facebook::react::TextLayoutManager::GetTextLayout( + facebook::react::WindowsTextLayoutManager::GetTextLayout( facebook::react::AttributedStringBox(attributedString), {} /*TODO*/, constraints, textLayout); return textLayout; diff --git a/vnext/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputShadowNode.cpp b/vnext/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputShadowNode.cpp index f67892f034a..60d78c7f819 100644 --- a/vnext/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputShadowNode.cpp +++ b/vnext/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputShadowNode.cpp @@ -24,14 +24,6 @@ void WindowsTextInputShadowNode::setTextLayoutManager(std::shared_ptrmeasureCachedSpannableById(getStateData().cachedAttributedStringId, paragraphAttributes, layoutConstraints) - .size; - } - // Layout is called right after measure. // Measure is marked as `const`, and `layout` is not; so State can be updated // during layout, but not during `measure`. If State is out-of-date in layout, diff --git a/vnext/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputShadowNode.h b/vnext/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputShadowNode.h index e8b35e704d8..3c9077168df 100644 --- a/vnext/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputShadowNode.h +++ b/vnext/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputShadowNode.h @@ -3,6 +3,8 @@ #pragma once +#include + #include #include #include "WindowsTextInputEventEmitter.h" @@ -13,8 +15,6 @@ #include #include -#include - namespace facebook::react { extern const char WindowsTextInputComponentName[]; diff --git a/vnext/Microsoft.ReactNative/Fabric/Composition/TooltipService.cpp b/vnext/Microsoft.ReactNative/Fabric/Composition/TooltipService.cpp index b33947457ca..86285df5e5d 100644 --- a/vnext/Microsoft.ReactNative/Fabric/Composition/TooltipService.cpp +++ b/vnext/Microsoft.ReactNative/Fabric/Composition/TooltipService.cpp @@ -4,11 +4,12 @@ #include "TooltipService.h" +#include + #include #include #include #include -#include #include #include #include "TextDrawing.h" @@ -255,7 +256,7 @@ void TooltipTracker::ShowTooltip(const winrt::Microsoft::ReactNative::ComponentV layoutConstraints.minimumSize.height = 0; layoutConstraints.minimumSize.width = 0; - facebook::react::TextLayoutManager::GetTextLayout( + facebook::react::WindowsTextLayoutManager::GetTextLayout( tooltipData->attributedString, {} /*paragraphAttributes*/, layoutConstraints, tooltipData->textLayout); if (tooltipData->textLayout) { diff --git a/vnext/Microsoft.ReactNative/Fabric/FabricUIManagerModule.cpp b/vnext/Microsoft.ReactNative/Fabric/FabricUIManagerModule.cpp index 790fd270389..a8ea3e13c44 100644 --- a/vnext/Microsoft.ReactNative/Fabric/FabricUIManagerModule.cpp +++ b/vnext/Microsoft.ReactNative/Fabric/FabricUIManagerModule.cpp @@ -22,11 +22,13 @@ #include #include #include +#include #include #include #include #include #include +#include #include #include #include @@ -79,6 +81,10 @@ void FabricUIManager::installFabricUIManager() noexcept { runtimeExecutor = SchedulerSettings::GetRuntimeExecutor(m_context.Properties()); } + contextContainer->insert( + facebook::react::TextLayoutManagerKey, + std::make_shared(contextContainer)); + facebook::react::EventBeat::Factory asynchronousBeatFactory = [runtimeScheduler, context = m_context](std::shared_ptr const &ownerBox) { return std::make_unique(ownerBox, context, runtimeScheduler); diff --git a/vnext/Microsoft.ReactNative/Fabric/WindowsComponentDescriptorRegistry.h b/vnext/Microsoft.ReactNative/Fabric/WindowsComponentDescriptorRegistry.h index ca73af5e293..f29dc581841 100644 --- a/vnext/Microsoft.ReactNative/Fabric/WindowsComponentDescriptorRegistry.h +++ b/vnext/Microsoft.ReactNative/Fabric/WindowsComponentDescriptorRegistry.h @@ -4,6 +4,8 @@ #pragma once +#include + #include #include #include diff --git a/vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/components/view/HostPlatformTouch.h b/vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/components/view/HostPlatformTouch.h deleted file mode 100644 index 3f7af7db204..00000000000 --- a/vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/components/view/HostPlatformTouch.h +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -#pragma once - -#include - -namespace facebook::react { -using HostPlatformTouch = BaseTouch; -} // namespace facebook::react \ No newline at end of file diff --git a/vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/Float.h b/vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/Float.h deleted file mode 100644 index ee0ee3e6a37..00000000000 --- a/vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/Float.h +++ /dev/null @@ -1,20 +0,0 @@ -/* - * 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. - */ - -#pragma once - -#include - -namespace facebook::react { - -/* - * Exact type of float numbers which ideally should match a type behing - * platform- and chip-architecture-specific float type. - */ -using Float = float; - -} // namespace facebook::react diff --git a/vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/HostPlatformColor.h b/vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/HostPlatformColor.h index 157ec5367b3..9e45b5d6391 100644 --- a/vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/HostPlatformColor.h +++ b/vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/HostPlatformColor.h @@ -3,7 +3,6 @@ #pragma once -#include #include #include #include "PlatformColorUtils.h" diff --git a/vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/PlatformColorUtils.h b/vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/PlatformColorUtils.h index e408b25da68..86f92b96ce1 100644 --- a/vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/PlatformColorUtils.h +++ b/vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/PlatformColorUtils.h @@ -3,7 +3,7 @@ #pragma once -#include +#include namespace facebook::react { diff --git a/vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/TextLayoutManager.h b/vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/TextLayoutManager.h deleted file mode 100644 index e95e6cea8a1..00000000000 --- a/vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/TextLayoutManager.h +++ /dev/null @@ -1,117 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace facebook { -namespace react { - -class TextLayoutManager; - -using SharedTextLayoutManager = std::shared_ptr; - -/* - * Windows-specific TextLayoutManager. - */ -class TextLayoutManager { - public: - using Shared = std::shared_ptr; - -#pragma region required interface from core cxx cross platform impl - TextLayoutManager(const ContextContainer::Shared &contextContainer) : m_contextContainer(contextContainer){}; - ~TextLayoutManager() = default; - - /* - * Measures `attributedStringBox` using native text rendering infrastructure. - */ - TextMeasurement measure( - const AttributedStringBox &attributedStringBox, - const ParagraphAttributes ¶graphAttributes, - const TextLayoutContext &layoutContext, - LayoutConstraints layoutConstraints) const; - - /* - * Measures lines of `attributedString` using native text rendering - * infrastructure. - */ - LinesMeasurements measureLines( - const AttributedStringBox &attributedStringBox, - const ParagraphAttributes ¶graphAttributes, - Size size) const; - - std::shared_ptr getHostTextStorage( - const AttributedStringBox &attributedStringBox, - const ParagraphAttributes ¶graphAttributes, - LayoutConstraints layoutConstraints) const; - - /** - * Measures an AttributedString on the platform, as identified by some - * opaque cache ID. - */ - TextMeasurement measureCachedSpannableById( - int64_t cacheId, - const ParagraphAttributes ¶graphAttributes, - LayoutConstraints layoutConstraints) const; - - /* - * Calculates baseline of `attributedString` using native text rendering - * infrastructure. - */ - Float baseline(AttributedStringBox attributedStringBox, ParagraphAttributes paragraphAttributes, Size size) const; - - /* - * Returns an opaque pointer to platform-specific TextLayoutManager. - * Is used on a native views layer to delegate text rendering to the manager. - */ - void *getNativeTextLayoutManager() const; - - static void GetTextLayout( - const AttributedStringBox &attributedStringBox, - const ParagraphAttributes ¶graphAttributes, - Size size, - winrt::com_ptr &spTextLayout, - TextMeasurement::Attachments &attachments) noexcept; - - static void GetTextLayout( - const AttributedStringBox &attributedStringBox, - const ParagraphAttributes ¶graphAttributes, - LayoutConstraints layoutConstraints, - winrt::com_ptr &spTextLayout) noexcept; - - static void GetTextLayoutByAdjustingFontSizeToFit( - AttributedStringBox attributedStringBox, - const ParagraphAttributes ¶graphAttributes, - LayoutConstraints layoutConstraints, - winrt::com_ptr &spTextLayout, - TextMeasurement::Attachments &attachments, - float minimumFontScale) noexcept; - -#pragma endregion - - private: - static winrt::hstring GetTransformedText(const AttributedStringBox &attributedStringBox); - static void GetTextLayout( - const AttributedStringBox &attributedStringBox, - const ParagraphAttributes ¶graphAttributes, - Size size, - winrt::com_ptr &spTextLayout) noexcept; - - ContextContainer::Shared m_contextContainer; -#pragma warning(push) -#pragma warning(disable : 5028) - TextMeasureCache m_measureCache{}; -#pragma warning(pop) -}; - -} // namespace react -} // namespace facebook diff --git a/vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/TextLayoutManager.cpp b/vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/WindowsTextLayoutManager.cpp similarity index 93% rename from vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/TextLayoutManager.cpp rename to vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/WindowsTextLayoutManager.cpp index 8b9cdbf7f45..cef086a832e 100644 --- a/vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/TextLayoutManager.cpp +++ b/vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/WindowsTextLayoutManager.cpp @@ -10,7 +10,7 @@ #include #include #include -#include "TextLayoutManager.h" +#include "WindowsTextLayoutManager.h" #include @@ -66,7 +66,17 @@ class AttachmentInlineObject : public winrt::implements spTextLayout; TextMeasurement::Attachments attachments; - GetTextLayout( + WindowsTextLayoutManager::GetTextLayout( attributedStringBox, paragraphAttributes, layoutConstraints.maximumSize, spTextLayout, attachments); if (spTextLayout) { @@ -381,18 +391,6 @@ TextMeasurement TextLayoutManager::measure( return measurement; } -/** - * Measures an AttributedString on the platform, as identified by some - * opaque cache ID. - */ -TextMeasurement TextLayoutManager::measureCachedSpannableById( - int64_t cacheId, - const ParagraphAttributes ¶graphAttributes, - LayoutConstraints layoutConstraints) const { - assert(false); - return {}; -} - Microsoft::ReactNative::TextTransform ConvertTextTransform(std::optional const &transform) { if (transform) { switch (transform.value()) { @@ -415,12 +413,12 @@ Microsoft::ReactNative::TextTransform ConvertTextTransform(std::optional spTextLayout; TextMeasurement::Attachments attachments; - GetTextLayout(attributedStringBox, paragraphAttributes, size, spTextLayout, attachments); + WindowsTextLayoutManager::GetTextLayout(attributedStringBox, paragraphAttributes, size, spTextLayout, attachments); if (spTextLayout) { std::vector lineMetrics; @@ -485,24 +483,13 @@ LinesMeasurements TextLayoutManager::measureLines( return lineMeasurements; } -std::shared_ptr TextLayoutManager::getHostTextStorage( - const AttributedStringBox &attributedStringBox, - const ParagraphAttributes ¶graphAttributes, - LayoutConstraints layoutConstraints) const { - return nullptr; -} - -void *TextLayoutManager::getNativeTextLayoutManager() const { - return (void *)this; -} - Float TextLayoutManager::baseline( - AttributedStringBox attributedStringBox, - ParagraphAttributes paragraphAttributes, - Size size) const { + const AttributedStringBox& attributedStringBox, + const ParagraphAttributes& paragraphAttributes, + const Size& size) const { winrt::com_ptr spTextLayout; TextMeasurement::Attachments attachments; - GetTextLayout(attributedStringBox, paragraphAttributes, size, spTextLayout, attachments); + WindowsTextLayoutManager::GetTextLayout(attributedStringBox, paragraphAttributes, size, spTextLayout, attachments); if (!spTextLayout) { return 0; } @@ -513,7 +500,7 @@ Float TextLayoutManager::baseline( 0.8f; // https://learn.microsoft.com/en-us/windows/win32/api/dwrite/nf-dwrite-idwritetextformat-getlinespacing } -winrt::hstring TextLayoutManager::GetTransformedText(const AttributedStringBox &attributedStringBox) { +winrt::hstring WindowsTextLayoutManager::GetTransformedText(const AttributedStringBox &attributedStringBox) { winrt::hstring result{}; const auto &attributedString = attributedStringBox.getValue(); diff --git a/vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/WindowsTextLayoutManager.h b/vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/WindowsTextLayoutManager.h new file mode 100644 index 00000000000..15347f3b555 --- /dev/null +++ b/vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/WindowsTextLayoutManager.h @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +#pragma once + +#pragma warning(push) +#pragma warning(disable:5028) // 'Node': Alignment specified in prior declaration (1) not specified in definition +#include +#pragma warning(pop) + +#include +#include +#include +#include +#include +#include +#include + +namespace facebook::react { + +class WindowsTextLayoutManager: public TextLayoutManager { + public: + WindowsTextLayoutManager(const ContextContainer::Shared& contextContainer); + virtual ~WindowsTextLayoutManager() = default; + + /* + * Not copyable. + */ + WindowsTextLayoutManager(const WindowsTextLayoutManager&) = delete; + WindowsTextLayoutManager& operator=(const WindowsTextLayoutManager&) = delete; + + /* + * Not movable. + */ + WindowsTextLayoutManager(WindowsTextLayoutManager&&) = delete; + WindowsTextLayoutManager& operator=(WindowsTextLayoutManager&&) = delete; + + static void GetTextLayout( + const AttributedStringBox &attributedStringBox, + const ParagraphAttributes ¶graphAttributes, + Size size, + winrt::com_ptr &spTextLayout, + TextMeasurement::Attachments &attachments) noexcept; + + static void GetTextLayout( + const AttributedStringBox &attributedStringBox, + const ParagraphAttributes ¶graphAttributes, + LayoutConstraints layoutConstraints, + winrt::com_ptr &spTextLayout) noexcept; + + static void GetTextLayoutByAdjustingFontSizeToFit( + AttributedStringBox attributedStringBox, + const ParagraphAttributes ¶graphAttributes, + LayoutConstraints layoutConstraints, + winrt::com_ptr &spTextLayout, + TextMeasurement::Attachments &attachments, + float minimumFontScale) noexcept; + + private: + static winrt::hstring GetTransformedText(const AttributedStringBox &attributedStringBox); + static void GetTextLayout( + const AttributedStringBox &attributedStringBox, + const ParagraphAttributes ¶graphAttributes, + Size size, + winrt::com_ptr &spTextLayout) noexcept; +}; + +} // namespace facebook::react diff --git a/vnext/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj b/vnext/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj index ef968d81f40..b50fab3cadb 100644 --- a/vnext/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +++ b/vnext/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj @@ -17,7 +17,6 @@ true - false false @@ -101,7 +100,6 @@ $(FmtDir)\include; $(ReactNativeWindowsDir)Microsoft.ReactNative; - $(ReactNativeWindowsDir)Microsoft.ReactNative\Fabric\platform; $(ReactNativeWindowsDir)Microsoft.ReactNative\Pch; $(ReactNativeWindowsDir)Microsoft.ReactNative\ReactHost; $(ReactNativeWindowsDir)Microsoft.ReactNative\Views; diff --git a/vnext/PropertySheets/React.Cpp.props b/vnext/PropertySheets/React.Cpp.props index d5ca9ebe3df..327fe4f6b82 100644 --- a/vnext/PropertySheets/React.Cpp.props +++ b/vnext/PropertySheets/React.Cpp.props @@ -138,7 +138,7 @@ ProgramDatabase false true - /utf-8 %(AdditionalOptions) + /utf-8 %(AdditionalOptions) /await Guard Spectre @@ -155,7 +155,10 @@ $(ReactNativeDir)\ReactCommon\react\bridging; $(ReactNativeDir)\ReactCommon\reactperflogger; $(ReactNativeDir)\ReactCommon\runtimeexecutor; - $(ReactNativeDir)\ReactCxxPlatform; + $(ReactNativeWindowsDir)Microsoft.ReactNative\Fabric\platform; + $(ReactNativeDir)\ReactCommon\react\renderer\graphics\platform\cxx; + $(ReactNativeDir)\ReactCommon\react\renderer\components\view\platform\cxx; + $(ReactNativeDir)\ReactCommon\react\renderer\imagemanager\platform\cxx; %(AdditionalIncludeDirectories); diff --git a/vnext/ReactCommon/ReactCommon.vcxproj b/vnext/ReactCommon/ReactCommon.vcxproj index 3992e406717..1c5ab6266ae 100644 --- a/vnext/ReactCommon/ReactCommon.vcxproj +++ b/vnext/ReactCommon/ReactCommon.vcxproj @@ -70,11 +70,6 @@ true $(ReactNativeDir)\ReactCommon; - $(ReactNativeDir)\ReactCommon\react; - $(ReactNativeDir)\ReactCommon\react\nativemodule\core\ReactCommon; - $(ReactNativeDir)\ReactCommon\react\renderer; - $(ReactNativeDir)\ReactCommon\react\renderer\components\view; - $(ReactNativeDir)\ReactCommon\react\renderer\graphics; $(ReactNativeDir)\ReactCommon\jsi; $(ReactNativeDir)\ReactCommon\jsitooling; $(FmtDir)\include; @@ -224,6 +219,7 @@ + $(NodeApiJsiDir)..\.node-api-jsi-zip diff --git a/vnext/ReactCommon/TEMP_UntilReactCommonUpdate/react/bridging/Bridging.h b/vnext/ReactCommon/TEMP_UntilReactCommonUpdate/react/bridging/Bridging.h index 3428b47bf86..b55ff0f8730 100644 --- a/vnext/ReactCommon/TEMP_UntilReactCommonUpdate/react/bridging/Bridging.h +++ b/vnext/ReactCommon/TEMP_UntilReactCommonUpdate/react/bridging/Bridging.h @@ -11,11 +11,11 @@ #include #include #include -// #include // Line causes Error C1083 Cannot open include file: 'double-conversion/double-conversion.h' #11644 +// #include // [Windows] Line causes Error C1083 Cannot open include file: 'double-conversion/double-conversion.h' #11644 #include -#include // [Windows #13391] +#include #include #include #include #include -#include // [Windows #13391] +#include diff --git a/vnext/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/textinput/TextInputState.h b/vnext/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/textinput/TextInputState.h deleted file mode 100644 index 8d6e2c84423..00000000000 --- a/vnext/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/textinput/TextInputState.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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. - */ - -#pragma once - -#include -#include -#include - -#ifdef ANDROID -#include -#include -#endif - -namespace facebook::react { - -/* - * State for component. - */ -class TextInputState final { - public: - TextInputState() = default; - - TextInputState( - AttributedStringBox attributedStringBox, - AttributedString reactTreeAttributedString, - ParagraphAttributes paragraphAttributes, - int64_t mostRecentEventCount); - -#ifdef ANDROID - TextInputState( - const TextInputState& previousState, - const folly::dynamic& data); - folly::dynamic getDynamic() const; - MapBuffer getMapBuffer() const; -#endif - - /* - * All content of component. - */ - AttributedStringBox attributedStringBox; - - /* - * All content of component represented as an `AttributedString`. - * This stores the previous computed *from the React tree*. This usually - * doesn't change as the TextInput contents are being updated. If it does - * change, we need to wipe out current contents of the TextInput and replace - * with the new value from the tree. - */ - AttributedString reactTreeAttributedString{}; - - /* - * Represents all visual attributes of a paragraph of text represented as - * a ParagraphAttributes. - */ - ParagraphAttributes paragraphAttributes; - - int64_t mostRecentEventCount{0}; - - - /** - * Stores an opaque cache ID used on the Java side to refer to a specific - * AttributedString for measurement purposes only. - */ - int64_t cachedAttributedStringId{0}; - -}; - -} // namespace facebook::react diff --git a/vnext/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/HostPlatformTouch.h b/vnext/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/HostPlatformTouch.h deleted file mode 100644 index 226b1c37924..00000000000 --- a/vnext/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/HostPlatformTouch.h +++ /dev/null @@ -1,14 +0,0 @@ -/* - * 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. - */ - - #pragma once - - #include - - namespace facebook::react { - using HostPlatformTouch = BaseTouch; - } // namespace facebook::react \ No newline at end of file diff --git a/vnext/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/HostPlatformViewEventEmitter.h b/vnext/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/HostPlatformViewEventEmitter.h deleted file mode 100644 index 7468f404651..00000000000 --- a/vnext/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/HostPlatformViewEventEmitter.h +++ /dev/null @@ -1,14 +0,0 @@ -/* - * 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. - */ - - #pragma once - - #include - - namespace facebook::react { - using HostPlatformViewEventEmitter = BaseViewEventEmitter; - } // namespace facebook::react \ No newline at end of file diff --git a/vnext/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/HostPlatformViewProps.h b/vnext/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/HostPlatformViewProps.h deleted file mode 100644 index cf88c0b86b2..00000000000 --- a/vnext/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/HostPlatformViewProps.h +++ /dev/null @@ -1,14 +0,0 @@ -/* - * 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. - */ - - #pragma once - - #include - - namespace facebook::react { - using HostPlatformViewProps = BaseViewProps; - } // namespace facebook::react \ No newline at end of file diff --git a/vnext/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/graphics/Float.h b/vnext/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/graphics/Float.h deleted file mode 100644 index d679377a71d..00000000000 --- a/vnext/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/graphics/Float.h +++ /dev/null @@ -1,433 +0,0 @@ -/* - * 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. - */ - - #pragma once - - #include // Windows - #include - -// [[Windows -// -// float.h -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// Implementation-defined values commonly used by sophisticated numerical -// (floating point) programs. -// -#pragma once -#ifndef _INC_FLOAT // include guard for 3rd party interop -#define _INC_FLOAT - -#include - -#pragma warning(push) -#pragma warning(disable: _UCRT_DISABLED_WARNINGS) -_UCRT_DISABLE_CLANG_WARNINGS - -_CRT_BEGIN_C_HEADER - - - -#ifndef _CRT_MANAGED_FP_DEPRECATE - #ifdef _CRT_MANAGED_FP_NO_DEPRECATE - #define _CRT_MANAGED_FP_DEPRECATE - #else - #ifdef _M_CEE - #define _CRT_MANAGED_FP_DEPRECATE _CRT_DEPRECATE_TEXT("Direct floating point control is not supported or reliable from within managed code. ") - #else - #define _CRT_MANAGED_FP_DEPRECATE - #endif - #endif -#endif - - -// Define the floating point precision used. -// -// For x86, results are in double precision (unless /arch:sse2 is used, in which -// case results are in source precision. -// -// For x64 and ARM, results are in source precision. -// -// If the compiler is invoked with /fp:fast, the compiler is allowed to use the -// fastest precision and even mix within a single function, so precision is -// indeterminable. -// -// Note that manipulating the floating point behavior using the float_control/ -// fenv_access/fp_contract #pragmas may alter the actual floating point evaluation -// method, which may in turn invalidate the value of FLT_EVAL_METHOD. -#ifdef _M_FP_FAST - #define FLT_EVAL_METHOD -1 -#else - #ifdef _M_IX86 - #if _M_IX86_FP >= 2 - #define FLT_EVAL_METHOD 0 - #else - #define FLT_EVAL_METHOD 2 - #endif - #else - #define FLT_EVAL_METHOD 0 - #endif -#endif - - - -//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// -// Constants -// -//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -#define DBL_DECIMAL_DIG 17 // # of decimal digits of rounding precision -#define DBL_DIG 15 // # of decimal digits of precision -#define DBL_EPSILON 2.2204460492503131e-016 // smallest such that 1.0+DBL_EPSILON != 1.0 -#define DBL_HAS_SUBNORM 1 // type does support subnormal numbers -#define DBL_MANT_DIG 53 // # of bits in mantissa -#define DBL_MAX 1.7976931348623158e+308 // max value -#define DBL_MAX_10_EXP 308 // max decimal exponent -#define DBL_MAX_EXP 1024 // max binary exponent -#define DBL_MIN 2.2250738585072014e-308 // min positive value -#define DBL_MIN_10_EXP (-307) // min decimal exponent -#define DBL_MIN_EXP (-1021) // min binary exponent -#define _DBL_RADIX 2 // exponent radix -#define DBL_TRUE_MIN 4.9406564584124654e-324 // min positive value - -#define FLT_DECIMAL_DIG 9 // # of decimal digits of rounding precision -#define FLT_DIG 6 // # of decimal digits of precision -#define FLT_EPSILON 1.192092896e-07F // smallest such that 1.0+FLT_EPSILON != 1.0 -#define FLT_HAS_SUBNORM 1 // type does support subnormal numbers -#define FLT_GUARD 0 -#define FLT_MANT_DIG 24 // # of bits in mantissa -#define FLT_MAX 3.402823466e+38F // max value -#define FLT_MAX_10_EXP 38 // max decimal exponent -#define FLT_MAX_EXP 128 // max binary exponent -#define FLT_MIN 1.175494351e-38F // min normalized positive value -#define FLT_MIN_10_EXP (-37) // min decimal exponent -#define FLT_MIN_EXP (-125) // min binary exponent -#define FLT_NORMALIZE 0 -#define FLT_RADIX 2 // exponent radix -#define FLT_TRUE_MIN 1.401298464e-45F // min positive value - -#define LDBL_DIG DBL_DIG // # of decimal digits of precision -#define LDBL_EPSILON DBL_EPSILON // smallest such that 1.0+LDBL_EPSILON != 1.0 -#define LDBL_HAS_SUBNORM DBL_HAS_SUBNORM // type does support subnormal numbers -#define LDBL_MANT_DIG DBL_MANT_DIG // # of bits in mantissa -#define LDBL_MAX DBL_MAX // max value -#define LDBL_MAX_10_EXP DBL_MAX_10_EXP // max decimal exponent -#define LDBL_MAX_EXP DBL_MAX_EXP // max binary exponent -#define LDBL_MIN DBL_MIN // min normalized positive value -#define LDBL_MIN_10_EXP DBL_MIN_10_EXP // min decimal exponent -#define LDBL_MIN_EXP DBL_MIN_EXP // min binary exponent -#define _LDBL_RADIX _DBL_RADIX // exponent radix -#define LDBL_TRUE_MIN DBL_TRUE_MIN // min positive value - -#define DECIMAL_DIG DBL_DECIMAL_DIG - - - -//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// -// Flags -// -//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -#define _SW_INEXACT 0x00000001 // Inexact (precision) -#define _SW_UNDERFLOW 0x00000002 // Underflow -#define _SW_OVERFLOW 0x00000004 // Overflow -#define _SW_ZERODIVIDE 0x00000008 // Divide by zero -#define _SW_INVALID 0x00000010 // Invalid -#define _SW_DENORMAL 0x00080000 // Denormal status bit - -// New Control Bit that specifies the ambiguity in control word. -#define _EM_AMBIGUIOUS 0x80000000 // For backwards compatibility -#define _EM_AMBIGUOUS 0x80000000 - -// Abstract User Control Word Mask and bit definitions -#define _MCW_EM 0x0008001f // Interrupt Exception Masks -#define _EM_INEXACT 0x00000001 // inexact (precision) -#define _EM_UNDERFLOW 0x00000002 // underflow -#define _EM_OVERFLOW 0x00000004 // overflow -#define _EM_ZERODIVIDE 0x00000008 // zero divide -#define _EM_INVALID 0x00000010 // invalid -#define _EM_DENORMAL 0x00080000 // Denormal exception mask (_control87 only) - -#define _MCW_RC 0x00000300 // Rounding Control -#define _RC_NEAR 0x00000000 // near -#define _RC_DOWN 0x00000100 // down -#define _RC_UP 0x00000200 // up -#define _RC_CHOP 0x00000300 // chop - -// i386 specific definitions -#define _MCW_PC 0x00030000 // Precision Control -#define _PC_64 0x00000000 // 64 bits -#define _PC_53 0x00010000 // 53 bits -#define _PC_24 0x00020000 // 24 bits - -#define _MCW_IC 0x00040000 // Infinity Control -#define _IC_AFFINE 0x00040000 // affine -#define _IC_PROJECTIVE 0x00000000 // projective - -// RISC specific definitions -#define _MCW_DN 0x03000000 // Denormal Control -#define _DN_SAVE 0x00000000 // save denormal results and operands -#define _DN_FLUSH 0x01000000 // flush denormal results and operands to zero -#define _DN_FLUSH_OPERANDS_SAVE_RESULTS 0x02000000 // flush operands to zero and save results -#define _DN_SAVE_OPERANDS_FLUSH_RESULTS 0x03000000 // save operands and flush results to zero - - - -// Invalid subconditions (_SW_INVALID also set) -#define _SW_UNEMULATED 0x0040 // Unemulated instruction -#define _SW_SQRTNEG 0x0080 // Square root of a negative number -#define _SW_STACKOVERFLOW 0x0200 // FP stack overflow -#define _SW_STACKUNDERFLOW 0x0400 // FP stack underflow - - - -// Floating point error signals and return codes -#define _FPE_INVALID 0x81 -#define _FPE_DENORMAL 0x82 -#define _FPE_ZERODIVIDE 0x83 -#define _FPE_OVERFLOW 0x84 -#define _FPE_UNDERFLOW 0x85 -#define _FPE_INEXACT 0x86 - -#define _FPE_UNEMULATED 0x87 -#define _FPE_SQRTNEG 0x88 -#define _FPE_STACKOVERFLOW 0x8a -#define _FPE_STACKUNDERFLOW 0x8b - -#define _FPE_EXPLICITGEN 0x8c // raise(SIGFPE); - -// On x86 with arch:SSE2, the OS returns these exceptions -#define _FPE_MULTIPLE_TRAPS 0x8d -#define _FPE_MULTIPLE_FAULTS 0x8e - - - -#define _FPCLASS_SNAN 0x0001 // signaling NaN -#define _FPCLASS_QNAN 0x0002 // quiet NaN -#define _FPCLASS_NINF 0x0004 // negative infinity -#define _FPCLASS_NN 0x0008 // negative normal -#define _FPCLASS_ND 0x0010 // negative denormal -#define _FPCLASS_NZ 0x0020 // -0 -#define _FPCLASS_PZ 0x0040 // +0 -#define _FPCLASS_PD 0x0080 // positive denormal -#define _FPCLASS_PN 0x0100 // positive normal -#define _FPCLASS_PINF 0x0200 // positive infinity - - - -// Initial Control Word value -#if defined _M_IX86 - - #define _CW_DEFAULT (_RC_NEAR + _PC_53 + _EM_INVALID + _EM_ZERODIVIDE + _EM_OVERFLOW + _EM_UNDERFLOW + _EM_INEXACT + _EM_DENORMAL) - -#elif defined _M_X64 || defined _M_ARM || defined _M_ARM64 - - #define _CW_DEFAULT (_RC_NEAR + _EM_INVALID + _EM_ZERODIVIDE + _EM_OVERFLOW + _EM_UNDERFLOW + _EM_INEXACT + _EM_DENORMAL) - -#endif - - - -//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// -// State Manipulation -// -//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// Note that reading or writing the floating point control or status words is -// not supported in managed code. -_CRT_MANAGED_FP_DEPRECATE -_ACRTIMP unsigned int __cdecl _clearfp(void); - -#pragma warning(push) -#pragma warning(disable: 4141) // Double deprecation - -_CRT_MANAGED_FP_DEPRECATE _CRT_INSECURE_DEPRECATE(_controlfp_s) -_ACRTIMP unsigned int __cdecl _controlfp( - _In_ unsigned int _NewValue, - _In_ unsigned int _Mask - ); - -#pragma warning(pop) - -_CRT_MANAGED_FP_DEPRECATE -_ACRTIMP void __cdecl _set_controlfp( - _In_ unsigned int _NewValue, - _In_ unsigned int _Mask - ); - -_CRT_MANAGED_FP_DEPRECATE -_ACRTIMP errno_t __cdecl _controlfp_s( - _Out_opt_ unsigned int* _CurrentState, - _In_ unsigned int _NewValue, - _In_ unsigned int _Mask - ); - -_CRT_MANAGED_FP_DEPRECATE -_ACRTIMP unsigned int __cdecl _statusfp(void); - -_CRT_MANAGED_FP_DEPRECATE -_ACRTIMP void __cdecl _fpreset(void); - -#ifdef _M_IX86 - - _CRT_MANAGED_FP_DEPRECATE - _ACRTIMP void __cdecl _statusfp2( - _Out_opt_ unsigned int* _X86Status, - _Out_opt_ unsigned int* _SSE2Status - ); - -#endif - -#define _clear87 _clearfp -#define _status87 _statusfp - -_CRT_MANAGED_FP_DEPRECATE -_ACRTIMP unsigned int __cdecl _control87( - _In_ unsigned int _NewValue, - _In_ unsigned int _Mask - ); - -#ifdef _M_IX86 - _CRT_MANAGED_FP_DEPRECATE - _ACRTIMP int __cdecl __control87_2( - _In_ unsigned int _NewValue, - _In_ unsigned int _Mask, - _Out_opt_ unsigned int* _X86ControlWord, - _Out_opt_ unsigned int* _Sse2ControlWord - ); -#endif - -// Global variable holding floating point error code -_Check_return_ -_ACRTIMP int* __cdecl __fpecode(void); - -#define _fpecode (*__fpecode()) - -_Check_return_ -_ACRTIMP int __cdecl __fpe_flt_rounds(void); - -#define FLT_ROUNDS (__fpe_flt_rounds()) -#define _DBL_ROUNDS FLT_ROUNDS -#define _LDBL_ROUNDS _DBL_ROUNDS - - - -//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// -// IEEE Recommended Functions -// -//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -_Check_return_ _ACRTIMP double __cdecl _copysign(_In_ double _Number, _In_ double _Sign); -_Check_return_ _ACRTIMP double __cdecl _chgsign(_In_ double _X); -_Check_return_ _ACRTIMP double __cdecl _scalb(_In_ double _X, _In_ long _Y); -_Check_return_ _ACRTIMP double __cdecl _logb(_In_ double _X); -_Check_return_ _ACRTIMP double __cdecl _nextafter(_In_ double _X, _In_ double _Y); -_Check_return_ _ACRTIMP int __cdecl _finite(_In_ double _X); -_Check_return_ _ACRTIMP int __cdecl _isnan(_In_ double _X); -_Check_return_ _ACRTIMP int __cdecl _fpclass(_In_ double _X); - -#ifdef _M_X64 - _Check_return_ _ACRTIMP float __cdecl _scalbf(_In_ float _X, _In_ long _Y); -#endif - - - -//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// -// Nonstandard Names for Compatibility -// -//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -#if defined(_CRT_INTERNAL_NONSTDC_NAMES) && _CRT_INTERNAL_NONSTDC_NAMES - - #define clear87 _clear87 - #define status87 _status87 - #define control87 _control87 - - _CRT_MANAGED_FP_DEPRECATE - _ACRTIMP void __cdecl fpreset(void); - - #define DBL_RADIX _DBL_RADIX - #define DBL_ROUNDS _DBL_ROUNDS - - #define LDBL_RADIX _LDBL_RADIX - #define LDBL_ROUNDS _LDBL_ROUNDS - - // For backwards compatibility with the old spelling - #define EM_AMBIGUIOUS _EM_AMBIGUOUS - #define EM_AMBIGUOUS _EM_AMBIGUOUS - - #define MCW_EM _MCW_EM - #define EM_INVALID _EM_INVALID - #define EM_DENORMAL _EM_DENORMAL - #define EM_ZERODIVIDE _EM_ZERODIVIDE - #define EM_OVERFLOW _EM_OVERFLOW - #define EM_UNDERFLOW _EM_UNDERFLOW - #define EM_INEXACT _EM_INEXACT - - #define MCW_IC _MCW_IC - #define IC_AFFINE _IC_AFFINE - #define IC_PROJECTIVE _IC_PROJECTIVE - - #define MCW_RC _MCW_RC - #define RC_CHOP _RC_CHOP - #define RC_UP _RC_UP - #define RC_DOWN _RC_DOWN - #define RC_NEAR _RC_NEAR - - #define MCW_PC _MCW_PC - #define PC_24 _PC_24 - #define PC_53 _PC_53 - #define PC_64 _PC_64 - - #define CW_DEFAULT _CW_DEFAULT - - #define SW_INVALID _SW_INVALID - #define SW_DENORMAL _SW_DENORMAL - #define SW_ZERODIVIDE _SW_ZERODIVIDE - #define SW_OVERFLOW _SW_OVERFLOW - #define SW_UNDERFLOW _SW_UNDERFLOW - #define SW_INEXACT _SW_INEXACT - - #define SW_UNEMULATED _SW_UNEMULATED - #define SW_SQRTNEG _SW_SQRTNEG - #define SW_STACKOVERFLOW _SW_STACKOVERFLOW - #define SW_STACKUNDERFLOW _SW_STACKUNDERFLOW - - #define FPE_INVALID _FPE_INVALID - #define FPE_DENORMAL _FPE_DENORMAL - #define FPE_ZERODIVIDE _FPE_ZERODIVIDE - #define FPE_OVERFLOW _FPE_OVERFLOW - #define FPE_UNDERFLOW _FPE_UNDERFLOW - #define FPE_INEXACT _FPE_INEXACT - - #define FPE_UNEMULATED _FPE_UNEMULATED - #define FPE_SQRTNEG _FPE_SQRTNEG - #define FPE_STACKOVERFLOW _FPE_STACKOVERFLOW - #define FPE_STACKUNDERFLOW _FPE_STACKUNDERFLOW - - #define FPE_EXPLICITGEN _FPE_EXPLICITGEN - -#endif // _CRT_INTERNAL_NONSTDC_NAMES - - - -_CRT_END_C_HEADER -_UCRT_RESTORE_CLANG_WARNINGS -#pragma warning(pop) // _UCRT_DISABLED_WARNINGS -#endif // _INC_FLOAT -// Windows]] - - namespace facebook::react { - - /* - * Exact type of float numbers which ideally should match a type behing - * platform- and chip-architecture-specific float type. - */ - using Float = float; - - } // namespace facebook::react diff --git a/vnext/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/graphics/HostPlatformColor.h b/vnext/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/graphics/HostPlatformColor.h deleted file mode 100644 index 9e4f79fdd6f..00000000000 --- a/vnext/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/graphics/HostPlatformColor.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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. - */ - - #pragma once - - #include - #include - #include - - namespace facebook::react { - - using Color = int32_t; - - namespace HostPlatformColor { - static const facebook::react::Color UndefinedColor = - std::numeric_limits::max(); - } - - inline Color - hostPlatformColorFromRGBA(uint8_t r, uint8_t g, uint8_t b, uint8_t a) { - return (a & 0xff) << 24 | (r & 0xff) << 16 | (g & 0xff) << 8 | (b & 0xff); - } - - inline Color hostPlatformColorFromComponents(ColorComponents components) { - float ratio = 255; - return hostPlatformColorFromRGBA( - static_cast(std::round(components.red * ratio)), - static_cast(std::round(components.green * ratio)), - static_cast(std::round(components.blue * ratio)), - static_cast(std::round(components.alpha * ratio))); - } - - inline float alphaFromHostPlatformColor(Color color) { - return static_cast((color >> 24) & 0xff); - } - - inline float redFromHostPlatformColor(Color color) { - return static_cast((color >> 16) & 0xff); - } - - inline float greenFromHostPlatformColor(Color color) { - return static_cast((color >> 8) & 0xff); - } - - inline float blueFromHostPlatformColor(Color color) { - return static_cast((color >> 0) & 0xff); - } - - inline ColorComponents colorComponentsFromHostPlatformColor(Color color) { - float ratio = 255; - return ColorComponents{ - static_cast(redFromHostPlatformColor(color)) / ratio, - static_cast(greenFromHostPlatformColor(color)) / ratio, - static_cast(blueFromHostPlatformColor(color)) / ratio, - static_cast(alphaFromHostPlatformColor(color)) / ratio}; - } - - } // namespace facebook::react \ No newline at end of file diff --git a/vnext/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/imagemanager/ImageRequestParams.h b/vnext/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/imagemanager/ImageRequestParams.h deleted file mode 100644 index 8f1edd7ed96..00000000000 --- a/vnext/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/imagemanager/ImageRequestParams.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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. - */ - -#pragma once - -#include - -namespace facebook::react { - -class ImageRequestParams { - public: - ImageRequestParams() = default; - explicit ImageRequestParams(Float blurRadius) : blurRadius(blurRadius) {} - - Float blurRadius{}; - - bool operator==(const ImageRequestParams& rhs) const { - return this->blurRadius == rhs.blurRadius; - } - - bool operator!=(const ImageRequestParams& rhs) const { - return !(*this == rhs); - } -}; - -} // namespace facebook::react diff --git a/vnext/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/runtimescheduler/SchedulerPriorityUtils.h b/vnext/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/runtimescheduler/SchedulerPriorityUtils.h deleted file mode 100644 index 904217239b8..00000000000 --- a/vnext/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/runtimescheduler/SchedulerPriorityUtils.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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. - */ - -#pragma once - -#include -#include -#include - -namespace facebook::react { - -static constexpr std::underlying_type::type serialize( - SchedulerPriority schedulerPriority) { - return static_cast::type>( - schedulerPriority); -} - -static inline SchedulerPriority fromRawValue(double value) { - switch ((int)value) { - case 1: - return SchedulerPriority::ImmediatePriority; - case 2: - return SchedulerPriority::UserBlockingPriority; - case 3: - return SchedulerPriority::NormalPriority; - case 4: - return SchedulerPriority::LowPriority; - case 5: - return SchedulerPriority::IdlePriority; - } - react_native_assert(false && "Unsupported SchedulerPriority value"); - return SchedulerPriority::NormalPriority; -} - -static inline std::chrono::milliseconds timeoutForSchedulerPriority( - SchedulerPriority schedulerPriority) noexcept { - switch (schedulerPriority) { - case SchedulerPriority::ImmediatePriority: - return std::chrono::milliseconds(0); - case SchedulerPriority::UserBlockingPriority: - return std::chrono::milliseconds(250); - case SchedulerPriority::NormalPriority: - return std::chrono::seconds(5); - case SchedulerPriority::LowPriority: - return std::chrono::seconds(10); - case SchedulerPriority::IdlePriority: - return std::chrono::minutes(5); - default: - react_native_assert(false && "Unsupported SchedulerPriority value"); - return std::chrono::seconds(5); - } - react_native_assert(false && "Unsupported SchedulerPriority value"); - return std::chrono::seconds(5); -} - -} // namespace facebook::react diff --git a/vnext/ReactCommon/packages.lock.json b/vnext/ReactCommon/packages.lock.json index ad1114ebda3..afc0581efdf 100644 --- a/vnext/ReactCommon/packages.lock.json +++ b/vnext/ReactCommon/packages.lock.json @@ -8,6 +8,12 @@ "resolved": "1.83.0", "contentHash": "cy53VNMzysEMvhBixDe8ujPk67Fcj3v6FPHQnH91NYJNLHpc6jxa2xq9ruCaaJjE4M3YrGSHDi4uUSTGBWw6EQ==" }, + "Microsoft.Windows.CppWinRT": { + "type": "Direct", + "requested": "[2.0.230706.1, )", + "resolved": "2.0.230706.1", + "contentHash": "l0D7oCw/5X+xIKHqZTi62TtV+1qeSz7KVluNFdrJ9hXsst4ghvqQ/Yhura7JqRdZWBXAuDS0G0KwALptdoxweQ==" + }, "fmt": { "type": "Project" }, diff --git a/vnext/Shared/Shared.vcxitems b/vnext/Shared/Shared.vcxitems index 13b57d87f70..0bb372c02b3 100644 --- a/vnext/Shared/Shared.vcxitems +++ b/vnext/Shared/Shared.vcxitems @@ -219,7 +219,7 @@ true - + true @@ -593,12 +593,12 @@ - + - - + + diff --git a/vnext/Shared/Shared.vcxitems.filters b/vnext/Shared/Shared.vcxitems.filters index 1bc977f8e60..9c1e7812a0a 100644 --- a/vnext/Shared/Shared.vcxitems.filters +++ b/vnext/Shared/Shared.vcxitems.filters @@ -343,6 +343,8 @@ + + diff --git a/vnext/overrides.json b/vnext/overrides.json index 7531e7592e9..4acc2bf3e92 100644 --- a/vnext/overrides.json +++ b/vnext/overrides.json @@ -171,20 +171,6 @@ "baseHash": "c1726985d8916b671f7239356e3c08c4693d3be8", "issue": 14665 }, - { - "type": "patch", - "file": "ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/graphics/Float.h", - "baseFile": "packages/react-native/ReactCommon/react/renderer/graphics/platform/cxx/react/renderer/graphics/Float.h", - "baseHash": "4a707c9cab0c6534094cd303e000265b664f05b4", - "issue": 14674 - }, - { - "type": "copy", - "file": "ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/imagemanager/ImageRequestParams.h", - "baseFile": "packages/react-native/ReactCommon/react/renderer/imagemanager/platform/cxx/react/renderer/imagemanager/ImageRequestParams.h", - "baseHash": "2b7c528622a247f45f4fe01660583bd7cfa4db56", - "issue": 14216 - }, { "type": "patch", "file": "ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/mounting/internal/CullingContext.cpp", @@ -199,13 +185,6 @@ "baseHash": "e03ce8e5db0216f23389ff8b3e9ea450c8a031b7", "issue": 14673 }, - { - "type": "patch", - "file": "ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/runtimescheduler/SchedulerPriorityUtils.h", - "baseFile": "packages/react-native/ReactCommon/react/renderer/runtimescheduler/SchedulerPriorityUtils.h", - "baseHash": "0ccd2735e3cb04ce640fbd6af86b20ffcc5d9ab5", - "issue": 14131 - }, { "type": "patch", "file": "ReactCommon/TEMP_UntilReactCommonUpdate/react/runtime/ReactInstance.cpp", From 4269b4fcb073197f89710d302fbdb2900923fc39 Mon Sep 17 00:00:00 2001 From: Andrew <30809111+acoates-ms@users.noreply.github.com> Date: Fri, 23 May 2025 09:24:25 -0700 Subject: [PATCH 2/7] Change files --- ...ative-windows-eeda745f-25f4-452a-83c8-4b23671412de.json | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 change/react-native-windows-eeda745f-25f4-452a-83c8-4b23671412de.json diff --git a/change/react-native-windows-eeda745f-25f4-452a-83c8-4b23671412de.json b/change/react-native-windows-eeda745f-25f4-452a-83c8-4b23671412de.json new file mode 100644 index 00000000000..d51b394b130 --- /dev/null +++ b/change/react-native-windows-eeda745f-25f4-452a-83c8-4b23671412de.json @@ -0,0 +1,7 @@ +{ + "type": "prerelease", + "comment": "Cleanup a bunch of unneeded ReactCommon patching, and extra hostplatform overrides", + "packageName": "react-native-windows", + "email": "30809111+acoates-ms@users.noreply.github.com", + "dependentChangeType": "patch" +} From ad0d52407fa48faa7cebf091962ccd16f00f768e Mon Sep 17 00:00:00 2001 From: Andrew <30809111+acoates-ms@users.noreply.github.com> Date: Fri, 23 May 2025 09:27:23 -0700 Subject: [PATCH 3/7] minor cleanup --- vnext/Common/Common.vcxproj | 2 +- vnext/Desktop/React.Windows.Desktop.vcxproj | 2 +- vnext/ReactCommon/ReactCommon.vcxproj | 3 --- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/vnext/Common/Common.vcxproj b/vnext/Common/Common.vcxproj index 8c652366030..6432d559e36 100644 --- a/vnext/Common/Common.vcxproj +++ b/vnext/Common/Common.vcxproj @@ -72,7 +72,7 @@ string literals. It prevents code like wchar_t* str = L"hello"; from compiling. --> - %(AdditionalOptions) /Zc:strictStrings /await + %(AdditionalOptions) /Zc:strictStrings false diff --git a/vnext/Desktop/React.Windows.Desktop.vcxproj b/vnext/Desktop/React.Windows.Desktop.vcxproj index bc4b90f9d24..7a756fcd35d 100644 --- a/vnext/Desktop/React.Windows.Desktop.vcxproj +++ b/vnext/Desktop/React.Windows.Desktop.vcxproj @@ -133,7 +133,7 @@ "$(ReactNativeWindowsDir)codegen\react\components\rnwcore"; %(AdditionalIncludeDirectories); - %(AdditionalOptions) /Zc:strictStrings /bigobj /await + %(AdditionalOptions) /Zc:strictStrings /bigobj Use pch.h true diff --git a/vnext/ReactCommon/ReactCommon.vcxproj b/vnext/ReactCommon/ReactCommon.vcxproj index 1c5ab6266ae..4f24dec227a 100644 --- a/vnext/ReactCommon/ReactCommon.vcxproj +++ b/vnext/ReactCommon/ReactCommon.vcxproj @@ -69,10 +69,7 @@ false true - $(ReactNativeDir)\ReactCommon; - $(ReactNativeDir)\ReactCommon\jsi; $(ReactNativeDir)\ReactCommon\jsitooling; - $(FmtDir)\include; $(ReactNativeWindowsDir)stubs; $(ReactNativeWindowsDir)\Shared\tracing; %(AdditionalIncludeDirectories); From 319c3cc34d87a864257f85e7c7804fcd70dce1a0 Mon Sep 17 00:00:00 2001 From: Andrew <30809111+acoates-ms@users.noreply.github.com> Date: Fri, 23 May 2025 10:29:44 -0700 Subject: [PATCH 4/7] Fix desktop build --- .../Fabric/AbiShadowNode.cpp | 8 ++++---- .../Microsoft.ReactNative/Fabric/AbiShadowNode.h | 10 +++++----- .../Microsoft.ReactNative/Fabric/ComponentView.h | 11 ++++++----- .../Composition/CompositionViewComponentView.h | 1 + .../Composition/ContentIslandComponentView.h | 2 +- .../Fabric/Composition/RootComponentView.h | 2 +- .../Fabric/Composition/UiaHelpers.h | 10 +++++++--- .../WindowsTextLayoutManager.cpp | 16 +++++++--------- .../textlayoutmanager/WindowsTextLayoutManager.h | 14 +++++++------- vnext/Shared/Shared.vcxitems.filters | 4 +--- 10 files changed, 40 insertions(+), 38 deletions(-) diff --git a/vnext/Microsoft.ReactNative/Fabric/AbiShadowNode.cpp b/vnext/Microsoft.ReactNative/Fabric/AbiShadowNode.cpp index d35d25104f2..15e62a6cf08 100644 --- a/vnext/Microsoft.ReactNative/Fabric/AbiShadowNode.cpp +++ b/vnext/Microsoft.ReactNative/Fabric/AbiShadowNode.cpp @@ -35,15 +35,15 @@ void ShadowNode::EnsureUnsealed() noexcept { } } -winrt::IInspectable ShadowNode::Tag() const noexcept { +winrt::Windows::Foundation::IInspectable ShadowNode::Tag() const noexcept { return m_tag; } -void ShadowNode::Tag(winrt::IInspectable tag) noexcept { +void ShadowNode::Tag(winrt::Windows::Foundation::IInspectable tag) noexcept { m_tag = tag; } -winrt::IInspectable ShadowNode::StateData() const noexcept { +winrt::Windows::Foundation::IInspectable ShadowNode::StateData() const noexcept { if (auto shadowNode = m_shadowNode.lock()) { auto state = shadowNode->getState(); react_native_assert(state && "State must not be `nullptr`."); @@ -55,7 +55,7 @@ winrt::IInspectable ShadowNode::StateData() const noexcept { return nullptr; } -void ShadowNode::StateData(winrt::IInspectable tag) noexcept { +void ShadowNode::StateData(winrt::Windows::Foundation::IInspectable tag) noexcept { if (auto shadowNode = m_shadowNode.lock()) { shadowNode->ensureUnsealed(); diff --git a/vnext/Microsoft.ReactNative/Fabric/AbiShadowNode.h b/vnext/Microsoft.ReactNative/Fabric/AbiShadowNode.h index fe689b105fa..4a685ae6887 100644 --- a/vnext/Microsoft.ReactNative/Fabric/AbiShadowNode.h +++ b/vnext/Microsoft.ReactNative/Fabric/AbiShadowNode.h @@ -37,17 +37,17 @@ struct ShadowNode : ShadowNodeT { ShadowNode(facebook::react::ShadowNode::Shared shadowNode) noexcept; void EnsureUnsealed() noexcept; - winrt::IInspectable Tag() const noexcept; - void Tag(winrt::IInspectable tag) noexcept; + winrt::Windows::Foundation::IInspectable Tag() const noexcept; + void Tag(winrt::Windows::Foundation::IInspectable tag) noexcept; - winrt::IInspectable StateData() const noexcept; - void StateData(winrt::IInspectable tag) noexcept; + winrt::Windows::Foundation::IInspectable StateData() const noexcept; + void StateData(winrt::Windows::Foundation::IInspectable tag) noexcept; winrt::Microsoft::ReactNative::EventEmitter EventEmitter() const noexcept; protected: facebook::react::ShadowNode::Weak m_shadowNode; - winrt::IInspectable m_tag; + winrt::Windows::Foundation::IInspectable m_tag; }; } // namespace winrt::Microsoft::ReactNative::implementation diff --git a/vnext/Microsoft.ReactNative/Fabric/ComponentView.h b/vnext/Microsoft.ReactNative/Fabric/ComponentView.h index 45f22c34c1d..66a1de581fd 100644 --- a/vnext/Microsoft.ReactNative/Fabric/ComponentView.h +++ b/vnext/Microsoft.ReactNative/Fabric/ComponentView.h @@ -103,7 +103,8 @@ struct ComponentView const noexcept; virtual void parent(const winrt::Microsoft::ReactNative::ComponentView &parent) noexcept; virtual winrt::Microsoft::ReactNative::ComponentView Parent() const noexcept; - virtual winrt::IVectorView Children() const noexcept; + virtual winrt::Windows::Foundation::Collections::IVectorView Children() + const noexcept; virtual void theme(winrt::Microsoft::ReactNative::Composition::implementation::Theme *theme) noexcept; virtual winrt::Microsoft::ReactNative::Composition::implementation::Theme *theme() const noexcept; virtual void onThemeChanged() noexcept; @@ -206,7 +207,7 @@ struct ComponentView // If ignorePointerEvents = true, all Components are treated as valid targets virtual facebook::react::Tag hitTest(facebook::react::Point pt, facebook::react::Point &localPt, bool ignorePointerEvents = false) const noexcept; - virtual winrt::IInspectable EnsureUiaProvider() noexcept; + virtual winrt::Windows::Foundation::IInspectable EnsureUiaProvider() noexcept; virtual std::optional getAccessiblityValue() noexcept; virtual void setAcccessiblityValue(std::string &&value) noexcept; virtual bool getAcccessiblityIsReadOnly() noexcept; @@ -223,8 +224,8 @@ struct ComponentView virtual const winrt::Microsoft::ReactNative::IComponentProps userProps( facebook::react::Props::Shared const &props) noexcept; - void UserData(const winrt::IInspectable &userData) noexcept; - winrt::IInspectable UserData() const noexcept; + void UserData(const winrt::Windows::Foundation::IInspectable &userData) noexcept; + winrt::Windows::Foundation::IInspectable UserData() const noexcept; virtual void MountChildComponentView( const winrt::Microsoft::ReactNative::ComponentView &childComponentView, @@ -256,7 +257,7 @@ struct ComponentView winrt::com_ptr m_builder; bool m_mounted : 1 {false}; const facebook::react::Tag m_tag; - winrt::IInspectable m_userData; + winrt::Windows::Foundation::IInspectable m_userData; mutable winrt::Microsoft::ReactNative::Composition::implementation::RootComponentView *m_rootView{nullptr}; mutable winrt::Microsoft::ReactNative::Composition::implementation::Theme *m_theme{nullptr}; const winrt::Microsoft::ReactNative::ReactContext m_reactContext; diff --git a/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.h b/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.h index 9a59c4c4dfe..588af7ad463 100644 --- a/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.h +++ b/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.h @@ -4,6 +4,7 @@ #pragma once +#include #include #include #include diff --git a/vnext/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.h b/vnext/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.h index c55cff5e43d..f530baa3400 100644 --- a/vnext/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.h +++ b/vnext/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.h @@ -40,7 +40,7 @@ struct ContentIslandComponentView : ContentIslandComponentViewT &oldValue, const std::optional &newValue) noexcept; diff --git a/vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/WindowsTextLayoutManager.cpp b/vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/WindowsTextLayoutManager.cpp index cef086a832e..332001f604a 100644 --- a/vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/WindowsTextLayoutManager.cpp +++ b/vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/WindowsTextLayoutManager.cpp @@ -66,14 +66,12 @@ class AttachmentInlineObject : public winrt::implements spTextLayout; @@ -484,9 +482,9 @@ LinesMeasurements TextLayoutManager::measureLines( } Float TextLayoutManager::baseline( - const AttributedStringBox& attributedStringBox, - const ParagraphAttributes& paragraphAttributes, - const Size& size) const { + const AttributedStringBox &attributedStringBox, + const ParagraphAttributes ¶graphAttributes, + const Size &size) const { winrt::com_ptr spTextLayout; TextMeasurement::Attachments attachments; WindowsTextLayoutManager::GetTextLayout(attributedStringBox, paragraphAttributes, size, spTextLayout, attachments); diff --git a/vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/WindowsTextLayoutManager.h b/vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/WindowsTextLayoutManager.h index 15347f3b555..60a32b99562 100644 --- a/vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/WindowsTextLayoutManager.h +++ b/vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/WindowsTextLayoutManager.h @@ -4,7 +4,7 @@ #pragma once #pragma warning(push) -#pragma warning(disable:5028) // 'Node': Alignment specified in prior declaration (1) not specified in definition +#pragma warning(disable : 5028) // 'Node': Alignment specified in prior declaration (1) not specified in definition #include #pragma warning(pop) @@ -18,22 +18,22 @@ namespace facebook::react { -class WindowsTextLayoutManager: public TextLayoutManager { +class WindowsTextLayoutManager : public TextLayoutManager { public: - WindowsTextLayoutManager(const ContextContainer::Shared& contextContainer); + WindowsTextLayoutManager(const ContextContainer::Shared &contextContainer); virtual ~WindowsTextLayoutManager() = default; /* * Not copyable. */ - WindowsTextLayoutManager(const WindowsTextLayoutManager&) = delete; - WindowsTextLayoutManager& operator=(const WindowsTextLayoutManager&) = delete; + WindowsTextLayoutManager(const WindowsTextLayoutManager &) = delete; + WindowsTextLayoutManager &operator=(const WindowsTextLayoutManager &) = delete; /* * Not movable. */ - WindowsTextLayoutManager(WindowsTextLayoutManager&&) = delete; - WindowsTextLayoutManager& operator=(WindowsTextLayoutManager&&) = delete; + WindowsTextLayoutManager(WindowsTextLayoutManager &&) = delete; + WindowsTextLayoutManager &operator=(WindowsTextLayoutManager &&) = delete; static void GetTextLayout( const AttributedStringBox &attributedStringBox, diff --git a/vnext/Shared/Shared.vcxitems.filters b/vnext/Shared/Shared.vcxitems.filters index 9c1e7812a0a..26156838da0 100644 --- a/vnext/Shared/Shared.vcxitems.filters +++ b/vnext/Shared/Shared.vcxitems.filters @@ -236,9 +236,6 @@ Source Files\Fabric - - Source Files\Fabric\platform\react\renderer\textlayoutmanager - @@ -345,6 +342,7 @@ + From 0181395e071d98b41e5de2e1785e6d7a2029716a Mon Sep 17 00:00:00 2001 From: Andrew <30809111+acoates-ms@users.noreply.github.com> Date: Fri, 23 May 2025 10:41:11 -0700 Subject: [PATCH 5/7] Remove ReactInstance.h fork --- vnext/PropertySheets/React.Cpp.props | 1 + vnext/ReactCommon/ReactCommon.vcxproj | 1 - .../react/runtime/ReactInstance.h | 87 ------------------- vnext/overrides.json | 7 -- 4 files changed, 1 insertion(+), 95 deletions(-) delete mode 100644 vnext/ReactCommon/TEMP_UntilReactCommonUpdate/react/runtime/ReactInstance.h diff --git a/vnext/PropertySheets/React.Cpp.props b/vnext/PropertySheets/React.Cpp.props index 327fe4f6b82..1e17a731773 100644 --- a/vnext/PropertySheets/React.Cpp.props +++ b/vnext/PropertySheets/React.Cpp.props @@ -150,6 +150,7 @@ $(ReactNativeDir)\ReactCommon\callinvoker; $(ReactNativeDir)\ReactCommon\jsi; $(ReactNativeDir)\ReactCommon\jsiexecutor; + $(ReactNativeDir)\ReactCommon\jsitooling; $(ReactNativeDir)\ReactCommon\react\nativemodule\core; $(ReactNativeDir)\ReactCommon\react\nativemodule\samples; $(ReactNativeDir)\ReactCommon\react\bridging; diff --git a/vnext/ReactCommon/ReactCommon.vcxproj b/vnext/ReactCommon/ReactCommon.vcxproj index 4f24dec227a..8c9d204e66b 100644 --- a/vnext/ReactCommon/ReactCommon.vcxproj +++ b/vnext/ReactCommon/ReactCommon.vcxproj @@ -69,7 +69,6 @@ false true - $(ReactNativeDir)\ReactCommon\jsitooling; $(ReactNativeWindowsDir)stubs; $(ReactNativeWindowsDir)\Shared\tracing; %(AdditionalIncludeDirectories); diff --git a/vnext/ReactCommon/TEMP_UntilReactCommonUpdate/react/runtime/ReactInstance.h b/vnext/ReactCommon/TEMP_UntilReactCommonUpdate/react/runtime/ReactInstance.h deleted file mode 100644 index c066eec4030..00000000000 --- a/vnext/ReactCommon/TEMP_UntilReactCommonUpdate/react/runtime/ReactInstance.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * 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. - */ - - #pragma once - - #include - #include - #include - #include - #include - #include - #include - #include - #include // Windows - #include - #include - - namespace facebook::react { - - class ReactInstance final : private jsinspector_modern::InstanceTargetDelegate { - public: - using BindingsInstallFunc = std::function; - - ReactInstance( - std::unique_ptr runtime, - std::shared_ptr jsMessageQueueThread, - std::shared_ptr timerManager, - JsErrorHandler::OnJsError onJsError, - jsinspector_modern::HostTarget* parentInspectorTarget = nullptr); - - RuntimeExecutor getUnbufferedRuntimeExecutor() noexcept; - - RuntimeExecutor getBufferedRuntimeExecutor() noexcept; - - std::shared_ptr getRuntimeScheduler() noexcept; - - struct JSRuntimeFlags { - bool isProfiling = false; - const std::string runtimeDiagnosticFlags = ""; - }; - - void initializeRuntime( - JSRuntimeFlags options, - BindingsInstallFunc bindingsInstallFunc) noexcept; - - void loadScript( - std::unique_ptr script, - const std::string& sourceURL, - std::function&& completion = nullptr); - - void registerSegment(uint32_t segmentId, const std::string& segmentPath); - - void callFunctionOnModule( - const std::string& moduleName, - const std::string& methodName, - folly::dynamic&& args); - - void handleMemoryPressureJs(int pressureLevel); - - /** - * Unregisters the instance from the inspector. This method must be called - * on the main (non-JS) thread. - */ - void unregisterFromInspector(); - - void* getJavaScriptContext(); - - private: - std::shared_ptr runtime_; - std::shared_ptr jsMessageQueueThread_; - std::shared_ptr bufferedRuntimeExecutor_; - std::shared_ptr timerManager_; - std::unordered_map> - callableModules_; - std::shared_ptr runtimeScheduler_; - std::shared_ptr jsErrorHandler_; - - jsinspector_modern::InstanceTarget* inspectorTarget_{nullptr}; - jsinspector_modern::RuntimeTarget* runtimeInspectorTarget_{nullptr}; - jsinspector_modern::HostTarget* parentInspectorTarget_{nullptr}; - }; - - } // namespace facebook::react \ No newline at end of file diff --git a/vnext/overrides.json b/vnext/overrides.json index 4acc2bf3e92..4642864f373 100644 --- a/vnext/overrides.json +++ b/vnext/overrides.json @@ -192,13 +192,6 @@ "baseHash": "651098ef1888fbabab0a70d8e542f46c35d09d7a", "issue": 13172 }, - { - "type": "patch", - "file": "ReactCommon/TEMP_UntilReactCommonUpdate/react/runtime/ReactInstance.h", - "baseFile": "packages/react-native/ReactCommon/react/runtime/ReactInstance.h", - "baseHash": "a14f5bd109ebae2141ec8347fef23bf467420621", - "issue": 14664 - }, { "type": "copy", "directory": "ReactCopies/IntegrationTests", From d6dac02b5c53e5bec3baff4280a5a080d5e567ec Mon Sep 17 00:00:00 2001 From: Andrew <30809111+acoates-ms@users.noreply.github.com> Date: Fri, 23 May 2025 10:52:10 -0700 Subject: [PATCH 6/7] fix --- vnext/overrides.json | 7 ------- 1 file changed, 7 deletions(-) diff --git a/vnext/overrides.json b/vnext/overrides.json index 4642864f373..b8077ac8291 100644 --- a/vnext/overrides.json +++ b/vnext/overrides.json @@ -40,13 +40,6 @@ "baseFile": "packages/react-native/ReactCommon/react/renderer/imagemanager/ImageRequest.cpp", "baseHash": "8ff58257e2af054b3c8367cad566abcaf36d7cba" }, - { - "type": "copy", - "file": "Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/Float.h", - "baseFile": "packages/react-native/ReactCommon/react/renderer/graphics/platform/cxx/react/renderer/graphics/Float.h", - "baseHash": "4a707c9cab0c6534094cd303e000265b664f05b4", - "issue": 7821 - }, { "type": "patch", "file": "ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/JSExecutor.cpp", From 1c90327ad2cae7befc41f89869c222a03a4c7b34 Mon Sep 17 00:00:00 2001 From: Andrew <30809111+acoates-ms@users.noreply.github.com> Date: Tue, 27 May 2025 09:44:52 -0700 Subject: [PATCH 7/7] fix leak --- .../Microsoft.ReactNative/Fabric/FabricUIManagerModule.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/vnext/Microsoft.ReactNative/Fabric/FabricUIManagerModule.cpp b/vnext/Microsoft.ReactNative/Fabric/FabricUIManagerModule.cpp index a80ca60a084..f530668a7e1 100644 --- a/vnext/Microsoft.ReactNative/Fabric/FabricUIManagerModule.cpp +++ b/vnext/Microsoft.ReactNative/Fabric/FabricUIManagerModule.cpp @@ -76,7 +76,7 @@ void FabricUIManager::installFabricUIManager() noexcept { auto runtimeScheduler = SchedulerSettings::RuntimeSchedulerFromProperties(m_context.Properties()); if (runtimeScheduler) { - contextContainer->insert("RuntimeScheduler", runtimeScheduler); + contextContainer->insert(facebook::react::RuntimeSchedulerKey, runtimeScheduler); runtimeExecutor = [runtimeScheduler](std::function &&callback) { runtimeScheduler->scheduleWork(std::move(callback)); }; @@ -84,9 +84,12 @@ void FabricUIManager::installFabricUIManager() noexcept { runtimeExecutor = SchedulerSettings::GetRuntimeExecutor(m_context.Properties()); } + // Use an empty ContextContainer here, since using contextContainer would cause a ref cycle. We are not currently + // using the ContextContainer within WindowsTextLayoutManager/TextLayoutManager anyway contextContainer->insert( facebook::react::TextLayoutManagerKey, - std::make_shared(contextContainer)); + std::make_shared( + std::make_shared())); facebook::react::EventBeat::Factory asynchronousBeatFactory = [runtimeScheduler, context = m_context](std::shared_ptr const &ownerBox) {