From ddf27c81097e7bb5023268c1f91704a8d0fe6ae2 Mon Sep 17 00:00:00 2001 From: Andrew Coates <30809111+acoates-ms@users.noreply.github.com> Date: Wed, 19 Nov 2025 12:29:37 -0800 Subject: [PATCH 1/8] Remove code related to USE_WINUI3 which is now always true --- .../playground-composition/YogaXamlPanel.idl | 8 +- vnext/Desktop/module.g.cpp | 4 - .../CppWinRTIncludes.h | 17 - .../DesktopWindowBridge.h | 2 +- .../NamespaceRedirect.h | 5 - .../UI.Composition.Effects.h | 4 - .../UI.Composition.h | 4 - vnext/Microsoft.ReactNative.Cxx/UI.Input.h | 4 - vnext/Microsoft.ReactNative.Cxx/UI.Popups.h | 4 - vnext/Microsoft.ReactNative.Cxx/UI.Text.h | 4 - .../UI.Xaml.Automation.Peers.h | 10 - .../UI.Xaml.Automation.h | 10 - .../UI.Xaml.Controls.Primitives.h | 10 - .../UI.Xaml.Controls.h | 13 - .../UI.Xaml.Documents.h | 10 - .../UI.Xaml.Hosting.DesktopWindowXamlSource.h | 11 - .../UI.Xaml.Hosting.h | 10 - .../Microsoft.ReactNative.Cxx/UI.Xaml.Input.h | 10 - .../UI.Xaml.Markup.h | 10 - .../UI.Xaml.Media.Imaging.h | 10 - .../UI.Xaml.Media.Media3D.h | 10 - .../Microsoft.ReactNative.Cxx/UI.Xaml.Media.h | 10 - .../UI.Xaml.Navigation.h | 10 - .../UI.Xaml.Shapes.h | 10 - vnext/Microsoft.ReactNative.Cxx/XamlUtils.h | 33 - .../ReactInstanceSettingsTests.cpp | 8 - .../ReactModuleBuilderMock.cs | 4 - .../UnitTestApp.xaml.cs | 11 - .../JSValueReader.cs | 4 - .../ReactContext.cs | 5 - .../ReactContextGenerator.cs | 4 - .../CompositionContext.idl | 2 - .../Fabric/AbiViewProps.cpp | 4 +- .../Fabric/AbiViewProps.h | 2 - .../Fabric/Composition/Composition.Input.cpp | 69 --- .../Fabric/Composition/Composition.Input.h | 14 - .../Composition/CompositionContextHelper.cpp | 31 - .../Composition/CompositionContextHelper.h | 10 - .../CompositionContextHelper_emptyimpl.cpp | 4 - .../Composition/CompositionEventHandler.cpp | 6 - .../Composition/CompositionEventHandler.h | 2 - .../Fabric/Composition/CompositionHelpers.h | 2 - .../Composition/CompositionHwndHost.cpp | 8 - .../CompositionRootAutomationProvider.cpp | 10 - .../CompositionRootAutomationProvider.h | 4 - .../CompositionViewComponentView.cpp | 1 - .../ContentIslandComponentView.cpp | 1 - .../Fabric/Composition/ImageComponentView.cpp | 1 - .../Fabric/Composition/ReactNativeIsland.cpp | 6 - .../Fabric/Composition/ReactNativeIsland.h | 2 - .../Composition/ScrollViewComponentView.cpp | 1 - .../Fabric/Composition/Theme.cpp | 30 - .../Fabric/Composition/Theme.h | 2 - .../Fabric/FabricUIManagerModule.cpp | 1 - .../renderer/graphics/PlatformColorUtils.cpp | 10 - .../Microsoft.ReactNative.vcxproj | 5 - .../Microsoft.ReactNative.vcxproj.filters | 15 - .../Animated/NativeAnimatedNodeManager.cpp | 5 + .../Animated/NativeAnimatedNodeManager.h | 1 - .../Modules/AppStateModule.cpp | 53 -- .../Modules/AppStateModule.h | 5 - .../Modules/AppThemeModuleUwp.cpp | 19 +- .../Modules/AppThemeModuleUwp.h | 2 - .../Modules/AppearanceModule.cpp | 10 +- .../Modules/DeviceInfoModule.cpp | 96 +-- .../Modules/I18nManagerModule.cpp | 11 +- .../Modules/ImageViewManagerModule.cpp | 3 - .../Microsoft.ReactNative/Modules/Timing.cpp | 11 +- .../ReactNativeIsland.idl | 4 - vnext/Microsoft.ReactNative/RedBox.cpp | 358 +---------- vnext/Microsoft.ReactNative/Theme.idl | 2 - .../Utils/BatchingEventEmitter.cpp | 171 ------ .../Utils/BatchingEventEmitter.h | 72 --- vnext/Microsoft.ReactNative/Utils/Helpers.cpp | 41 -- vnext/Microsoft.ReactNative/Utils/Helpers.h | 5 - .../Utils/KeyboardUtils.cpp | 9 - .../Utils/PropertyHandlerUtils.h | 87 --- .../Utils/PropertyUtils.h | 568 ------------------ .../Utils/ResourceBrushUtils.cpp | 182 ------ .../Utils/ResourceBrushUtils.h | 58 -- .../Utils/ValueUtils.cpp | 245 -------- .../Microsoft.ReactNative/Utils/ValueUtils.h | 23 - .../Utils/XamlIslandUtils.cpp | 93 --- .../Utils/XamlIslandUtils.h | 48 -- vnext/Microsoft.ReactNative/ViewProps.idl | 2 - .../dispatchQueue/dispatchQueueTest.cpp | 5 - .../src/dispatchQueue/uiScheduler_winrt.cpp | 8 - vnext/fmt/packages.lock.json | 13 + 88 files changed, 60 insertions(+), 2662 deletions(-) delete mode 100644 vnext/Microsoft.ReactNative.Cxx/UI.Xaml.Automation.Peers.h delete mode 100644 vnext/Microsoft.ReactNative.Cxx/UI.Xaml.Automation.h delete mode 100644 vnext/Microsoft.ReactNative.Cxx/UI.Xaml.Controls.Primitives.h delete mode 100644 vnext/Microsoft.ReactNative.Cxx/UI.Xaml.Controls.h delete mode 100644 vnext/Microsoft.ReactNative.Cxx/UI.Xaml.Documents.h delete mode 100644 vnext/Microsoft.ReactNative.Cxx/UI.Xaml.Hosting.DesktopWindowXamlSource.h delete mode 100644 vnext/Microsoft.ReactNative.Cxx/UI.Xaml.Hosting.h delete mode 100644 vnext/Microsoft.ReactNative.Cxx/UI.Xaml.Input.h delete mode 100644 vnext/Microsoft.ReactNative.Cxx/UI.Xaml.Markup.h delete mode 100644 vnext/Microsoft.ReactNative.Cxx/UI.Xaml.Media.Imaging.h delete mode 100644 vnext/Microsoft.ReactNative.Cxx/UI.Xaml.Media.Media3D.h delete mode 100644 vnext/Microsoft.ReactNative.Cxx/UI.Xaml.Media.h delete mode 100644 vnext/Microsoft.ReactNative.Cxx/UI.Xaml.Navigation.h delete mode 100644 vnext/Microsoft.ReactNative.Cxx/UI.Xaml.Shapes.h delete mode 100644 vnext/Microsoft.ReactNative/Utils/BatchingEventEmitter.cpp delete mode 100644 vnext/Microsoft.ReactNative/Utils/BatchingEventEmitter.h delete mode 100644 vnext/Microsoft.ReactNative/Utils/PropertyHandlerUtils.h delete mode 100644 vnext/Microsoft.ReactNative/Utils/PropertyUtils.h delete mode 100644 vnext/Microsoft.ReactNative/Utils/ResourceBrushUtils.cpp delete mode 100644 vnext/Microsoft.ReactNative/Utils/ResourceBrushUtils.h delete mode 100644 vnext/Microsoft.ReactNative/Utils/XamlIslandUtils.cpp delete mode 100644 vnext/Microsoft.ReactNative/Utils/XamlIslandUtils.h create mode 100644 vnext/fmt/packages.lock.json diff --git a/packages/playground/windows/playground-composition/YogaXamlPanel.idl b/packages/playground/windows/playground-composition/YogaXamlPanel.idl index 7be6fe9f04c..44132978f5c 100644 --- a/packages/playground/windows/playground-composition/YogaXamlPanel.idl +++ b/packages/playground/windows/playground-composition/YogaXamlPanel.idl @@ -1,18 +1,12 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -#ifndef USE_WINUI3 -#define XAML_NAMESPACE Windows.UI.Xaml -#else -#define XAML_NAMESPACE Microsoft.UI.Xaml -#endif - namespace PlaygroundApp { // Used to notify of layout changes to forward to yoga [default_interface] [webhosthidden] - runtimeclass YogaXamlPanel : XAML_NAMESPACE.Controls.Panel + runtimeclass YogaXamlPanel : Microsoft.UI.Xaml.Controls.Panel { } } diff --git a/vnext/Desktop/module.g.cpp b/vnext/Desktop/module.g.cpp index 255ac905ba5..e86a37d7065 100644 --- a/vnext/Desktop/module.g.cpp +++ b/vnext/Desktop/module.g.cpp @@ -8,12 +8,10 @@ void* winrt_make_Microsoft_Internal_TestController(); void* winrt_make_Microsoft_ReactNative_Color(); void* winrt_make_Microsoft_ReactNative_ReactNativeIsland(); -#ifdef USE_WINUI3 void *winrt_make_Microsoft_ReactNative_Composition_ImageFailedResponse(); void *winrt_make_Microsoft_ReactNative_Composition_StreamImageResponse(); void *winrt_make_Microsoft_ReactNative_Composition_Experimental_UriBrushFactoryImageResponse(); void *winrt_make_Microsoft_ReactNative_Composition_Experimental_MicrosoftCompositionContextHelper(); -#endif void *winrt_make_Microsoft_ReactNative_Composition_Experimental_SystemCompositionContextHelper(); void *winrt_make_Microsoft_ReactNative_Composition_CompositionUIService(); void *winrt_make_Microsoft_ReactNative_Composition_FocusManager(); @@ -57,7 +55,6 @@ void* __stdcall winrt_get_activation_factory([[maybe_unused]] std::wstring_view if (requal(name, L"Microsoft.ReactNative.ReactNativeIsland")) { return winrt_make_Microsoft_ReactNative_ReactNativeIsland(); } -#ifdef USE_WINUI3 if (requal(name, L"Microsoft.ReactNative.Composition.ImageFailedResponse")) { return winrt_make_Microsoft_ReactNative_Composition_ImageFailedResponse(); } @@ -70,7 +67,6 @@ void* __stdcall winrt_get_activation_factory([[maybe_unused]] std::wstring_view if (requal(name, L"Microsoft.ReactNative.Composition.Experimental.MicrosoftCompositionContextHelper")) { return winrt_make_Microsoft_ReactNative_Composition_Experimental_MicrosoftCompositionContextHelper(); } -#endif if (requal(name, L"Microsoft.ReactNative.Composition.Experimental.SystemCompositionContextHelper")) { return winrt_make_Microsoft_ReactNative_Composition_Experimental_SystemCompositionContextHelper(); } diff --git a/vnext/Microsoft.ReactNative.Cxx/CppWinRTIncludes.h b/vnext/Microsoft.ReactNative.Cxx/CppWinRTIncludes.h index 43e9351d57c..1c4efb9ad90 100644 --- a/vnext/Microsoft.ReactNative.Cxx/CppWinRTIncludes.h +++ b/vnext/Microsoft.ReactNative.Cxx/CppWinRTIncludes.h @@ -7,21 +7,6 @@ #include #include -#ifndef USE_WINUI3 - -#include -#include - -#define XAML_CPPWINRT_NAMESPACE winrt::Windows::UI::Xaml -namespace xaml = winrt::Windows::UI::Xaml; -namespace comp = winrt::Windows::UI::Composition; -namespace ui = winrt::Windows::UI; -namespace winrt { -namespace dispatching = winrt::Windows::System; -using Colors = winrt::Windows::UI::Colors; -} // namespace winrt -#else - #include #include @@ -40,8 +25,6 @@ using IUIElement9 = UIElement; using IUIElement10 = UIElement; } // namespace winrt::Microsoft::UI::Xaml -#endif - namespace winrt { using namespace Windows::UI::Core; using namespace Windows::Foundation; diff --git a/vnext/Microsoft.ReactNative.Cxx/DesktopWindowBridge.h b/vnext/Microsoft.ReactNative.Cxx/DesktopWindowBridge.h index 719c4425bdc..fe37c1bba0d 100644 --- a/vnext/Microsoft.ReactNative.Cxx/DesktopWindowBridge.h +++ b/vnext/Microsoft.ReactNative.Cxx/DesktopWindowBridge.h @@ -8,7 +8,7 @@ #include #include -#if defined(USE_WINUI3) && !defined(CORE_ABI) && !defined(__APPLE__) && \ +#if !defined(CORE_ABI) && !defined(__APPLE__) && \ WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM | WINAPI_PARTITION_GAMES) #include diff --git a/vnext/Microsoft.ReactNative.Cxx/NamespaceRedirect.h b/vnext/Microsoft.ReactNative.Cxx/NamespaceRedirect.h index d79709dff25..73e16b5fb7d 100644 --- a/vnext/Microsoft.ReactNative.Cxx/NamespaceRedirect.h +++ b/vnext/Microsoft.ReactNative.Cxx/NamespaceRedirect.h @@ -1,9 +1,4 @@ #pragma once -#ifndef USE_WINUI3 -#define XAML_NAMESPACE Windows.UI.Xaml -#define COMP_NAMESPACE Windows.UI.Composition -#else #define XAML_NAMESPACE Microsoft.UI.Xaml #define COMP_NAMESPACE Microsoft.UI.Composition -#endif diff --git a/vnext/Microsoft.ReactNative.Cxx/UI.Composition.Effects.h b/vnext/Microsoft.ReactNative.Cxx/UI.Composition.Effects.h index e76fd9e969d..5ac34fa3637 100644 --- a/vnext/Microsoft.ReactNative.Cxx/UI.Composition.Effects.h +++ b/vnext/Microsoft.ReactNative.Cxx/UI.Composition.Effects.h @@ -3,8 +3,4 @@ #pragma once -#ifdef USE_WINUI3 #include -#else -#include -#endif // USE_WINUI3 diff --git a/vnext/Microsoft.ReactNative.Cxx/UI.Composition.h b/vnext/Microsoft.ReactNative.Cxx/UI.Composition.h index c93633819d9..79f14882a2f 100644 --- a/vnext/Microsoft.ReactNative.Cxx/UI.Composition.h +++ b/vnext/Microsoft.ReactNative.Cxx/UI.Composition.h @@ -3,8 +3,4 @@ #pragma once -#ifdef USE_WINUI3 #include -#else -#include -#endif // USE_WINUI3 diff --git a/vnext/Microsoft.ReactNative.Cxx/UI.Input.h b/vnext/Microsoft.ReactNative.Cxx/UI.Input.h index 4dc9413bb12..5655523b03e 100644 --- a/vnext/Microsoft.ReactNative.Cxx/UI.Input.h +++ b/vnext/Microsoft.ReactNative.Cxx/UI.Input.h @@ -3,8 +3,4 @@ #pragma once -#ifdef USE_WINUI3 #include -#else -#include -#endif // USE_WINUI3 diff --git a/vnext/Microsoft.ReactNative.Cxx/UI.Popups.h b/vnext/Microsoft.ReactNative.Cxx/UI.Popups.h index c87ed5a4a75..f044205c1ee 100644 --- a/vnext/Microsoft.ReactNative.Cxx/UI.Popups.h +++ b/vnext/Microsoft.ReactNative.Cxx/UI.Popups.h @@ -3,8 +3,4 @@ #pragma once -#ifdef USE_WINUI3 #include -#else -#include -#endif // USE_WINUI3 diff --git a/vnext/Microsoft.ReactNative.Cxx/UI.Text.h b/vnext/Microsoft.ReactNative.Cxx/UI.Text.h index 4b375e44ffd..7f583fcb966 100644 --- a/vnext/Microsoft.ReactNative.Cxx/UI.Text.h +++ b/vnext/Microsoft.ReactNative.Cxx/UI.Text.h @@ -5,12 +5,8 @@ #include -#ifdef USE_WINUI3 #include namespace text = winrt::Microsoft::UI::Text; namespace winrt::Microsoft::UI::Text { using FontStyle = winrt::Windows::UI::Text::FontStyle; } -#else -namespace text = winrt::Windows::UI::Text; -#endif // USE_WINUI3 diff --git a/vnext/Microsoft.ReactNative.Cxx/UI.Xaml.Automation.Peers.h b/vnext/Microsoft.ReactNative.Cxx/UI.Xaml.Automation.Peers.h deleted file mode 100644 index 88a608eec28..00000000000 --- a/vnext/Microsoft.ReactNative.Cxx/UI.Xaml.Automation.Peers.h +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -#pragma once - -#ifdef USE_WINUI3 -#include -#else -#include -#endif // USE_WINUI3 diff --git a/vnext/Microsoft.ReactNative.Cxx/UI.Xaml.Automation.h b/vnext/Microsoft.ReactNative.Cxx/UI.Xaml.Automation.h deleted file mode 100644 index 9cb4c6f6697..00000000000 --- a/vnext/Microsoft.ReactNative.Cxx/UI.Xaml.Automation.h +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -#pragma once - -#ifdef USE_WINUI3 -#include -#else -#include -#endif // USE_WINUI3 diff --git a/vnext/Microsoft.ReactNative.Cxx/UI.Xaml.Controls.Primitives.h b/vnext/Microsoft.ReactNative.Cxx/UI.Xaml.Controls.Primitives.h deleted file mode 100644 index 53008c00f67..00000000000 --- a/vnext/Microsoft.ReactNative.Cxx/UI.Xaml.Controls.Primitives.h +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -#pragma once - -#ifdef USE_WINUI3 -#include -#else -#include -#endif // USE_WINUI3 diff --git a/vnext/Microsoft.ReactNative.Cxx/UI.Xaml.Controls.h b/vnext/Microsoft.ReactNative.Cxx/UI.Xaml.Controls.h deleted file mode 100644 index 1040f9786a3..00000000000 --- a/vnext/Microsoft.ReactNative.Cxx/UI.Xaml.Controls.h +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -#pragma once - -#ifdef USE_WINUI3 -#include -namespace winrt::Microsoft::UI::Xaml::Controls { -using IControl7 = Control; -} // namespace winrt::Microsoft::UI::Xaml::Controls -#else -#include -#endif // USE_WINUI3 diff --git a/vnext/Microsoft.ReactNative.Cxx/UI.Xaml.Documents.h b/vnext/Microsoft.ReactNative.Cxx/UI.Xaml.Documents.h deleted file mode 100644 index 15ff9e2b676..00000000000 --- a/vnext/Microsoft.ReactNative.Cxx/UI.Xaml.Documents.h +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -#pragma once - -#ifdef USE_WINUI3 -#include -#else -#include -#endif // USE_WINUI3 diff --git a/vnext/Microsoft.ReactNative.Cxx/UI.Xaml.Hosting.DesktopWindowXamlSource.h b/vnext/Microsoft.ReactNative.Cxx/UI.Xaml.Hosting.DesktopWindowXamlSource.h deleted file mode 100644 index 5f7c46064ee..00000000000 --- a/vnext/Microsoft.ReactNative.Cxx/UI.Xaml.Hosting.DesktopWindowXamlSource.h +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -#pragma once - -#ifdef USE_WINUI3 -#include -using IDesktopWindowXamlSourceNative2 = IDesktopWindowXamlSourceNative; -#else -#include -#endif // USE_WINUI3 diff --git a/vnext/Microsoft.ReactNative.Cxx/UI.Xaml.Hosting.h b/vnext/Microsoft.ReactNative.Cxx/UI.Xaml.Hosting.h deleted file mode 100644 index feebbc2d9aa..00000000000 --- a/vnext/Microsoft.ReactNative.Cxx/UI.Xaml.Hosting.h +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -#pragma once - -#ifdef USE_WINUI3 -#include -#else -#include -#endif // USE_WINUI3 diff --git a/vnext/Microsoft.ReactNative.Cxx/UI.Xaml.Input.h b/vnext/Microsoft.ReactNative.Cxx/UI.Xaml.Input.h deleted file mode 100644 index 0578d60987b..00000000000 --- a/vnext/Microsoft.ReactNative.Cxx/UI.Xaml.Input.h +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -#pragma once - -#ifdef USE_WINUI3 -#include -#else -#include -#endif // USE_WINUI3 diff --git a/vnext/Microsoft.ReactNative.Cxx/UI.Xaml.Markup.h b/vnext/Microsoft.ReactNative.Cxx/UI.Xaml.Markup.h deleted file mode 100644 index 0e86b75a562..00000000000 --- a/vnext/Microsoft.ReactNative.Cxx/UI.Xaml.Markup.h +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -#pragma once - -#ifdef USE_WINUI3 -#include -#else -#include -#endif // USE_WINUI3 diff --git a/vnext/Microsoft.ReactNative.Cxx/UI.Xaml.Media.Imaging.h b/vnext/Microsoft.ReactNative.Cxx/UI.Xaml.Media.Imaging.h deleted file mode 100644 index 3a627044f7a..00000000000 --- a/vnext/Microsoft.ReactNative.Cxx/UI.Xaml.Media.Imaging.h +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -#pragma once - -#ifdef USE_WINUI3 -#include -#else -#include -#endif // USE_WINUI3 diff --git a/vnext/Microsoft.ReactNative.Cxx/UI.Xaml.Media.Media3D.h b/vnext/Microsoft.ReactNative.Cxx/UI.Xaml.Media.Media3D.h deleted file mode 100644 index 11f78ef4ae6..00000000000 --- a/vnext/Microsoft.ReactNative.Cxx/UI.Xaml.Media.Media3D.h +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -#pragma once - -#ifdef USE_WINUI3 -#include -#else -#include -#endif // USE_WINUI3 diff --git a/vnext/Microsoft.ReactNative.Cxx/UI.Xaml.Media.h b/vnext/Microsoft.ReactNative.Cxx/UI.Xaml.Media.h deleted file mode 100644 index d2304656d5c..00000000000 --- a/vnext/Microsoft.ReactNative.Cxx/UI.Xaml.Media.h +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -#pragma once - -#ifdef USE_WINUI3 -#include -#else -#include -#endif // USE_WINUI3 diff --git a/vnext/Microsoft.ReactNative.Cxx/UI.Xaml.Navigation.h b/vnext/Microsoft.ReactNative.Cxx/UI.Xaml.Navigation.h deleted file mode 100644 index efc9f46188a..00000000000 --- a/vnext/Microsoft.ReactNative.Cxx/UI.Xaml.Navigation.h +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -#pragma once - -#ifdef USE_WINUI3 -#include -#else -#include -#endif // USE_WINUI3 diff --git a/vnext/Microsoft.ReactNative.Cxx/UI.Xaml.Shapes.h b/vnext/Microsoft.ReactNative.Cxx/UI.Xaml.Shapes.h deleted file mode 100644 index 8eaaa2ae53a..00000000000 --- a/vnext/Microsoft.ReactNative.Cxx/UI.Xaml.Shapes.h +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -#pragma once - -#ifdef USE_WINUI3 -#include -#else -#include -#endif // USE_WINUI3 diff --git a/vnext/Microsoft.ReactNative.Cxx/XamlUtils.h b/vnext/Microsoft.ReactNative.Cxx/XamlUtils.h index 71cbd24cbe2..abcadca54d7 100644 --- a/vnext/Microsoft.ReactNative.Cxx/XamlUtils.h +++ b/vnext/Microsoft.ReactNative.Cxx/XamlUtils.h @@ -33,39 +33,6 @@ WINRT_IMPL_LINK(GetModuleHandleW, 4); namespace XAML_CPPWINRT_NAMESPACE { -// Return Application::Current() when it is present or nullptr otherwise. -// It does not throw exception as Application::Current() does. -inline Application TryGetCurrentApplication() noexcept { -#ifndef USE_WINUI3 - constexpr auto xamlDll = L"Windows.UI.Xaml.dll"; -#else - constexpr auto xamlDll = L"Microsoft.UI.Xaml.dll"; -#endif - - if (auto xamlIsLoaded = WINRT_IMPL_GetModuleHandleW(xamlDll)) { - auto applicationStatics = get_activation_factory(name_of()); - auto abiApplicationStatics = static_cast *>(get_abi(applicationStatics)); - void *value{}; - abiApplicationStatics->get_Current(&value); - return Application{value, take_ownership_from_abi}; - } else { - // If we don't have XAML loaded, we are not a XAML app - return nullptr; - } -} - -// In the legacy architecture, RNW uses a Uwp Xaml app as the groundwork for the UI. -// In the new architecture, WinUI3 Xaml may be involved, but only as XamlIslands -- leaf nodes in the RNW content. -// This function returns the Uwp/System Xaml Application if we're running in the legacy architecture and Xaml is -// running, and null if otherwise. -inline Application TryGetCurrentUwpXamlApplication() noexcept { -#ifdef USE_WINUI3 - return nullptr; -#else - return TryGetCurrentApplication(); -#endif -} - // Using Windows::UI::ColorHelper causes the process to load Windows.UI.Xaml.dll which is not needed just to fill a // Color struct inline winrt::Windows::UI::Color FromArgb(uint8_t a, uint8_t r, uint8_t g, uint8_t b) { diff --git a/vnext/Microsoft.ReactNative.IntegrationTests/ReactInstanceSettingsTests.cpp b/vnext/Microsoft.ReactNative.IntegrationTests/ReactInstanceSettingsTests.cpp index 1ad2055ab55..67f6c84bf50 100644 --- a/vnext/Microsoft.ReactNative.IntegrationTests/ReactInstanceSettingsTests.cpp +++ b/vnext/Microsoft.ReactNative.IntegrationTests/ReactInstanceSettingsTests.cpp @@ -5,20 +5,12 @@ #include -#ifdef USE_WINUI3 #include -#else -#include -#endif using namespace winrt; using namespace Microsoft::ReactNative; -#ifdef USE_WINUI3 using namespace Microsoft::UI::Dispatching; -#else -using namespace Windows::System; -#endif namespace ReactNativeIntegrationTests { diff --git a/vnext/Microsoft.ReactNative.Managed.UnitTests/ReactModuleBuilderMock.cs b/vnext/Microsoft.ReactNative.Managed.UnitTests/ReactModuleBuilderMock.cs index 68c37e64beb..f0d7f5911f0 100644 --- a/vnext/Microsoft.ReactNative.Managed.UnitTests/ReactModuleBuilderMock.cs +++ b/vnext/Microsoft.ReactNative.Managed.UnitTests/ReactModuleBuilderMock.cs @@ -7,11 +7,7 @@ using System.Linq; using System.Threading.Tasks; -#if !USE_WINUI3 -using Windows.UI.Xaml; -#else using Microsoft.UI.Xaml; -#endif namespace Microsoft.ReactNative.Managed.UnitTests { diff --git a/vnext/Microsoft.ReactNative.Managed.UnitTests/UnitTestApp.xaml.cs b/vnext/Microsoft.ReactNative.Managed.UnitTests/UnitTestApp.xaml.cs index 9df0e1bdf90..396d06ee22b 100644 --- a/vnext/Microsoft.ReactNative.Managed.UnitTests/UnitTestApp.xaml.cs +++ b/vnext/Microsoft.ReactNative.Managed.UnitTests/UnitTestApp.xaml.cs @@ -3,16 +3,9 @@ using System; using Windows.ApplicationModel; -#if !USE_WINUI3 -using Windows.ApplicationModel.Activation; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Navigation; -#else using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Navigation; -#endif namespace Microsoft.ReactNative.Managed.UnitTests { @@ -39,11 +32,7 @@ public App() protected override void OnLaunched(LaunchActivatedEventArgs e_) { Windows.ApplicationModel.Activation.LaunchActivatedEventArgs e = -#if USE_WINUI3 e_.UWPLaunchActivatedEventArgs; -#else - e_; -#endif #if DEBUG if (global::System.Diagnostics.Debugger.IsAttached) diff --git a/vnext/Microsoft.ReactNative.Managed/JSValueReader.cs b/vnext/Microsoft.ReactNative.Managed/JSValueReader.cs index 0793f69f243..dd795e680b9 100644 --- a/vnext/Microsoft.ReactNative.Managed/JSValueReader.cs +++ b/vnext/Microsoft.ReactNative.Managed/JSValueReader.cs @@ -5,11 +5,7 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Threading; -#if !USE_WINUI3 -using Windows.UI.Xaml.Media; -#else using Microsoft.UI.Xaml.Media; -#endif namespace Microsoft.ReactNative.Managed { diff --git a/vnext/Microsoft.ReactNative.Managed/ReactContext.cs b/vnext/Microsoft.ReactNative.Managed/ReactContext.cs index 4fbf17810b8..97aace98a06 100644 --- a/vnext/Microsoft.ReactNative.Managed/ReactContext.cs +++ b/vnext/Microsoft.ReactNative.Managed/ReactContext.cs @@ -1,12 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -#if !USE_WINUI3 -using System.Reflection.Metadata; -using Windows.UI.Xaml; -#else using Microsoft.UI.Xaml; -#endif namespace Microsoft.ReactNative.Managed { diff --git a/vnext/Microsoft.ReactNative.Managed/ReactContextGenerator.cs b/vnext/Microsoft.ReactNative.Managed/ReactContextGenerator.cs index 45c0afc8e25..8b0823a5da0 100644 --- a/vnext/Microsoft.ReactNative.Managed/ReactContextGenerator.cs +++ b/vnext/Microsoft.ReactNative.Managed/ReactContextGenerator.cs @@ -4,11 +4,7 @@ using System; using System.Linq; using System.Reflection; -#if !USE_WINUI3 -using Windows.UI.Xaml; -#else using Microsoft.UI.Xaml; -#endif namespace Microsoft.ReactNative.Managed { diff --git a/vnext/Microsoft.ReactNative/CompositionContext.idl b/vnext/Microsoft.ReactNative/CompositionContext.idl index 08950fcd1b5..c612f30529a 100644 --- a/vnext/Microsoft.ReactNative/CompositionContext.idl +++ b/vnext/Microsoft.ReactNative/CompositionContext.idl @@ -28,7 +28,6 @@ namespace Microsoft.ReactNative.Composition.Experimental static Windows.UI.Composition.ICompositionSurface InnerSurface(IDrawingSurfaceBrush surface); } -#ifdef USE_WINUI3 [webhosthidden] [default_interface] [experimental] @@ -49,6 +48,5 @@ namespace Microsoft.ReactNative.Composition.Experimental static Microsoft.UI.Composition.CompositionBrush InnerBrush(IBrush brush); static Microsoft.UI.Composition.ICompositionSurface InnerSurface(IDrawingSurfaceBrush surface); } -#endif } // namespace Microsoft.ReactNative.Composition diff --git a/vnext/Microsoft.ReactNative/Fabric/AbiViewProps.cpp b/vnext/Microsoft.ReactNative/Fabric/AbiViewProps.cpp index 3751d99862b..ceeb6b2693b 100644 --- a/vnext/Microsoft.ReactNative/Fabric/AbiViewProps.cpp +++ b/vnext/Microsoft.ReactNative/Fabric/AbiViewProps.cpp @@ -53,13 +53,13 @@ winrt::Windows::UI::Color Color::AsWindowsColor( const winrt::Microsoft::ReactNative::Composition::Theme &theme) noexcept { return winrt::get_self(theme)->Color(*m_color); } -#ifdef USE_WINUI3 + winrt::Microsoft::UI::Composition::CompositionBrush Color::AsBrush( const winrt::Microsoft::ReactNative::Composition::Theme theme) noexcept { return winrt::Microsoft::ReactNative::Composition::Experimental::MicrosoftCompositionContextHelper::InnerBrush( winrt::get_self(theme)->Brush(*m_color)); } -#endif + winrt::Microsoft::ReactNative::Composition::Experimental::IBrush Color::AsInternalBrush( const winrt::Microsoft::ReactNative::Composition::Theme theme) noexcept { return winrt::get_self(theme)->Brush(*m_color); diff --git a/vnext/Microsoft.ReactNative/Fabric/AbiViewProps.h b/vnext/Microsoft.ReactNative/Fabric/AbiViewProps.h index c5391b6d92c..3e2335484a9 100644 --- a/vnext/Microsoft.ReactNative/Fabric/AbiViewProps.h +++ b/vnext/Microsoft.ReactNative/Fabric/AbiViewProps.h @@ -43,10 +43,8 @@ struct Color : ColorT { Color(facebook::react::SharedColor color); winrt::Windows::UI::Color AsWindowsColor(const winrt::Microsoft::ReactNative::Composition::Theme &theme) noexcept; -#ifdef USE_WINUI3 winrt::Microsoft::UI::Composition::CompositionBrush AsBrush( const winrt::Microsoft::ReactNative::Composition::Theme theme) noexcept; -#endif winrt::Microsoft::ReactNative::Composition::Experimental::IBrush AsInternalBrush( const winrt::Microsoft::ReactNative::Composition::Theme theme) noexcept; diff --git a/vnext/Microsoft.ReactNative/Fabric/Composition/Composition.Input.cpp b/vnext/Microsoft.ReactNative/Fabric/Composition/Composition.Input.cpp index 6dd4fcbd679..47ecc141b25 100644 --- a/vnext/Microsoft.ReactNative/Fabric/Composition/Composition.Input.cpp +++ b/vnext/Microsoft.ReactNative/Fabric/Composition/Composition.Input.cpp @@ -39,7 +39,6 @@ KeyRoutedEventArgs::KeyRoutedEventArgs( m_key = static_cast(wParam); } -#ifdef USE_WINUI3 KeyRoutedEventArgs::KeyRoutedEventArgs( facebook::react::Tag tag, winrt::Microsoft::UI::Input::KeyEventArgs const &args, @@ -54,7 +53,6 @@ KeyRoutedEventArgs::KeyRoutedEventArgs( m_keyStatus.IsKeyReleased = keyStatus.IsKeyReleased; m_key = args.VirtualKey(); } -#endif int32_t KeyRoutedEventArgs::OriginalSource() noexcept { return m_tag; @@ -103,7 +101,6 @@ CharacterReceivedRoutedEventArgs::CharacterReceivedRoutedEventArgs( m_keyStatus.IsKeyReleased = (lParam & 0x80000000) >> 31; // bit 31 } -#ifdef USE_WINUI3 CharacterReceivedRoutedEventArgs::CharacterReceivedRoutedEventArgs( facebook::react::Tag tag, winrt::Microsoft::UI::Input::CharacterReceivedEventArgs const &args, @@ -118,7 +115,6 @@ CharacterReceivedRoutedEventArgs::CharacterReceivedRoutedEventArgs( m_keyStatus.IsKeyReleased = keyStatus.IsKeyReleased; m_keycode = args.KeyCode(); } -#endif int32_t CharacterReceivedRoutedEventArgs::OriginalSource() noexcept { return m_tag; @@ -151,10 +147,8 @@ uint32_t Pointer::PointerId() const noexcept { return m_id; } -#ifdef USE_WINUI3 PointerPointProperties::PointerPointProperties(const winrt::Microsoft::UI::Input::PointerPointProperties &ppp) : m_sysPointerPointProps(ppp) {} -#endif PointerPointProperties::PointerPointProperties( bool isBarrelButtonPressed, @@ -199,196 +193,150 @@ PointerPointProperties::PointerPointProperties( m_yTilt(yTilt) {} winrt::Windows::Foundation::Rect PointerPointProperties::ContactRect() noexcept { -#ifdef USE_WINUI3 return m_sysPointerPointProps.ContactRect(); -#else - assert(false); - return {}; -#endif } bool PointerPointProperties::IsBarrelButtonPressed() noexcept { -#ifdef USE_WINUI3 if (m_sysPointerPointProps) { return m_sysPointerPointProps.IsBarrelButtonPressed(); } -#endif return m_isBarrelButtonPressed; } bool PointerPointProperties::IsCanceled() noexcept { -#ifdef USE_WINUI3 if (m_sysPointerPointProps) { return m_sysPointerPointProps.IsCanceled(); } -#endif return m_isCanceled; } bool PointerPointProperties::IsEraser() noexcept { -#ifdef USE_WINUI3 if (m_sysPointerPointProps) { return m_sysPointerPointProps.IsEraser(); } -#endif return m_isEraser; } bool PointerPointProperties::IsHorizontalMouseWheel() noexcept { -#ifdef USE_WINUI3 if (m_sysPointerPointProps) { return m_sysPointerPointProps.IsHorizontalMouseWheel(); } -#endif return m_isHorizontalMouseWheel; } bool PointerPointProperties::IsInRange() noexcept { -#ifdef USE_WINUI3 if (m_sysPointerPointProps) { return m_sysPointerPointProps.IsInRange(); } -#endif return m_isInRange; } bool PointerPointProperties::IsInverted() noexcept { -#ifdef USE_WINUI3 if (m_sysPointerPointProps) { return m_sysPointerPointProps.IsInverted(); } -#endif return m_isInverted; } bool PointerPointProperties::IsLeftButtonPressed() noexcept { -#ifdef USE_WINUI3 if (m_sysPointerPointProps) { return m_sysPointerPointProps.IsLeftButtonPressed(); } -#endif return m_isLeftButtonPressed; } bool PointerPointProperties::IsMiddleButtonPressed() noexcept { -#ifdef USE_WINUI3 if (m_sysPointerPointProps) { return m_sysPointerPointProps.IsMiddleButtonPressed(); } -#endif return m_isMiddleButtonPressed; } bool PointerPointProperties::IsPrimary() noexcept { -#ifdef USE_WINUI3 if (m_sysPointerPointProps) { return m_sysPointerPointProps.IsPrimary(); } -#endif return m_isPrimary; } bool PointerPointProperties::IsRightButtonPressed() noexcept { -#ifdef USE_WINUI3 if (m_sysPointerPointProps) { return m_sysPointerPointProps.IsRightButtonPressed(); } -#endif return m_isRightButtonPressed; } bool PointerPointProperties::IsXButton1Pressed() noexcept { -#ifdef USE_WINUI3 if (m_sysPointerPointProps) { return m_sysPointerPointProps.IsXButton1Pressed(); } -#endif return m_isXButton1Pressed; } bool PointerPointProperties::IsXButton2Pressed() noexcept { -#ifdef USE_WINUI3 if (m_sysPointerPointProps) { return m_sysPointerPointProps.IsXButton2Pressed(); } -#endif return m_isXButton2Pressed; } int32_t PointerPointProperties::MouseWheelDelta() noexcept { -#ifdef USE_WINUI3 if (m_sysPointerPointProps) { return m_sysPointerPointProps.MouseWheelDelta(); } -#endif return m_mouseWheelDelta; } float PointerPointProperties::Orientation() noexcept { -#ifdef USE_WINUI3 if (m_sysPointerPointProps) { return m_sysPointerPointProps.Orientation(); } -#endif return m_orientation; } PointerUpdateKind PointerPointProperties::PointerUpdateKind() noexcept { -#ifdef USE_WINUI3 if (m_sysPointerPointProps) { return static_cast( m_sysPointerPointProps.PointerUpdateKind()); } -#endif return m_pointerUpdateKind; } float PointerPointProperties::Pressure() noexcept { -#ifdef USE_WINUI3 if (m_sysPointerPointProps) { return m_sysPointerPointProps.Pressure(); } -#endif return m_pressure; } bool PointerPointProperties::TouchConfidence() noexcept { -#ifdef USE_WINUI3 if (m_sysPointerPointProps) { return m_sysPointerPointProps.TouchConfidence(); } -#endif return m_touchConfidence; } float PointerPointProperties::Twist() noexcept { -#ifdef USE_WINUI3 if (m_sysPointerPointProps) { return m_sysPointerPointProps.Twist(); } -#endif return m_twist; } float PointerPointProperties::XTilt() noexcept { -#ifdef USE_WINUI3 if (m_sysPointerPointProps) { return m_sysPointerPointProps.XTilt(); } -#endif return m_xTilt; } float PointerPointProperties::YTilt() noexcept { -#ifdef USE_WINUI3 if (m_sysPointerPointProps) { return m_sysPointerPointProps.YTilt(); } -#endif return m_yTilt; } -#ifdef USE_WINUI3 PointerPoint::PointerPoint(const winrt::Microsoft::UI::Input::PointerPoint &pp, float scaleFactor) : m_sysPointerPoint(pp), m_scaleFactor(scaleFactor), m_offset({0, 0}) {} @@ -397,7 +345,6 @@ PointerPoint::PointerPoint( float scaleFactor, const winrt::Windows::Foundation::Point &offset) : m_sysPointerPoint(pp), m_scaleFactor(scaleFactor), m_offset(offset) {} -#endif PointerPoint::PointerPoint( HWND hwnd, @@ -418,30 +365,24 @@ PointerPoint::PointerPoint(HWND hwnd, uint32_t msg, uint64_t wParam, int64_t lPa : PointerPoint(hwnd, msg, wParam, lParam, scaleFactor, {0, 0}) {} uint32_t PointerPoint::FrameId() const noexcept { -#ifdef USE_WINUI3 if (m_sysPointerPoint) { return m_sysPointerPoint.FrameId(); } -#endif return m_pi.frameId; } bool PointerPoint::IsInContact() const noexcept { -#ifdef USE_WINUI3 if (m_sysPointerPoint) { return m_sysPointerPoint.IsInContact(); } -#endif return ((m_pi.pointerFlags & POINTER_FLAG_INCONTACT) == POINTER_FLAG_INCONTACT); } winrt::Microsoft::ReactNative::Composition::Input::PointerDeviceType PointerPoint::PointerDeviceType() const noexcept { -#ifdef USE_WINUI3 if (m_sysPointerPoint) { return static_cast( m_sysPointerPoint.PointerDeviceType()); } -#endif if (m_pi.pointerId) { switch (m_pi.pointerType) { @@ -462,21 +403,17 @@ winrt::Microsoft::ReactNative::Composition::Input::PointerDeviceType PointerPoin } uint32_t PointerPoint::PointerId() const noexcept { -#ifdef USE_WINUI3 if (m_sysPointerPoint) { return m_sysPointerPoint.PointerId(); } -#endif return (m_pi.pointerId ? m_pi.pointerId : 1 /* MOUSE */); } winrt::Windows::Foundation::Point PointerPoint::Position() const noexcept { -#ifdef USE_WINUI3 if (m_sysPointerPoint) { auto pos = m_sysPointerPoint.Position(); return {pos.X - (m_offset.X / m_scaleFactor), pos.Y - (m_offset.Y / m_scaleFactor)}; } -#endif assert(m_hwnd); POINT clientPoint{ @@ -491,11 +428,9 @@ winrt::Windows::Foundation::Point PointerPoint::Position() const noexcept { } winrt::Microsoft::ReactNative::Composition::Input::PointerPointProperties PointerPoint::Properties() const noexcept { -#ifdef USE_WINUI3 if (m_sysPointerPoint) { return winrt::make(m_sysPointerPoint.Properties()); } -#endif if (m_pi.pointerId) { auto pointerUpdateKind = winrt::Microsoft::ReactNative::Composition::Input::PointerUpdateKind::Other; @@ -613,21 +548,17 @@ winrt::Microsoft::ReactNative::Composition::Input::PointerPointProperties Pointe } uint64_t PointerPoint::Timestamp() const noexcept { -#ifdef USE_WINUI3 if (m_sysPointerPoint) { return m_sysPointerPoint.Timestamp(); } -#endif return m_pi.dwTime; } winrt::Microsoft::ReactNative::Composition::Input::PointerPoint PointerPoint::GetOffsetPoint( const winrt::Windows::Foundation::Point &offset) const noexcept { -#ifdef USE_WINUI3 if (m_sysPointerPoint) { return winrt::make(m_sysPointerPoint, m_scaleFactor, offset); } -#endif return winrt::make(m_hwnd, m_msg, m_wParam, m_lParam, m_scaleFactor, offset); } diff --git a/vnext/Microsoft.ReactNative/Fabric/Composition/Composition.Input.h b/vnext/Microsoft.ReactNative/Fabric/Composition/Composition.Input.h index f29c4c6db89..8cce9170ecd 100644 --- a/vnext/Microsoft.ReactNative/Fabric/Composition/Composition.Input.h +++ b/vnext/Microsoft.ReactNative/Fabric/Composition/Composition.Input.h @@ -11,9 +11,7 @@ #include #include #include -#ifdef USE_WINUI3 #include -#endif namespace winrt::Microsoft::ReactNative::Composition::Input::implementation { @@ -27,12 +25,10 @@ struct KeyRoutedEventArgs : winrt::implements< uint64_t wParam, int64_t lParam, const winrt::Microsoft::ReactNative::Composition::Input::KeyboardSource &source); -#ifdef USE_WINUI3 KeyRoutedEventArgs( facebook::react::Tag tag, winrt::Microsoft::UI::Input::KeyEventArgs const &args, const winrt::Microsoft::ReactNative::Composition::Input::KeyboardSource &source); -#endif int32_t OriginalSource() noexcept; winrt::hstring DeviceId() noexcept; @@ -62,12 +58,10 @@ struct CharacterReceivedRoutedEventArgs uint64_t wParam, int64_t lParam, const winrt::Microsoft::ReactNative::Composition::Input::KeyboardSource &source); -#ifdef USE_WINUI3 CharacterReceivedRoutedEventArgs( facebook::react::Tag tag, winrt::Microsoft::UI::Input::CharacterReceivedEventArgs const &args, const winrt::Microsoft::ReactNative::Composition::Input::KeyboardSource &source); -#endif int32_t OriginalSource() noexcept; bool Handled() noexcept; @@ -96,9 +90,7 @@ struct Pointer : PointerT { }; struct PointerPointProperties : PointerPointPropertiesT { -#ifdef USE_WINUI3 PointerPointProperties(const winrt::Microsoft::UI::Input::PointerPointProperties &ppp); -#endif PointerPointProperties( bool isBarrelButtonPressed, @@ -145,9 +137,7 @@ struct PointerPointProperties : PointerPointPropertiesT float YTilt() noexcept; private: -#ifdef USE_WINUI3 winrt::Microsoft::UI::Input::PointerPointProperties m_sysPointerPointProps{nullptr}; -#endif // When not using m_sysPointerPointProps bool m_isBarrelButtonPressed : 1; @@ -173,13 +163,11 @@ struct PointerPointProperties : PointerPointPropertiesT }; struct PointerPoint : PointerPointT { -#ifdef USE_WINUI3 PointerPoint(const winrt::Microsoft::UI::Input::PointerPoint &pp, float scaleFactor); PointerPoint( const winrt::Microsoft::UI::Input::PointerPoint &pp, float scaleFactor, const winrt::Windows::Foundation::Point &offset); -#endif PointerPoint(HWND hwnd, uint32_t msg, uint64_t wParam, int64_t lParam, float scaleFactor); PointerPoint( HWND hwnd, @@ -204,9 +192,7 @@ struct PointerPoint : PointerPointT { bool IsPointerMessage(uint32_t message) const noexcept; // Windows::Input -#ifdef USE_WINUI3 winrt::Microsoft::UI::Input::PointerPoint m_sysPointerPoint{nullptr}; -#endif // Non Windows::Input HWND m_hwnd; // WM_POINTER* diff --git a/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionContextHelper.cpp b/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionContextHelper.cpp index 592375815d2..1fcd41d3a29 100644 --- a/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionContextHelper.cpp +++ b/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionContextHelper.cpp @@ -5,11 +5,9 @@ #if __has_include("Composition.Experimental.SystemCompositionContextHelper.g.cpp") #include "Composition.Experimental.SystemCompositionContextHelper.g.cpp" #endif -#ifdef USE_WINUI3 #if __has_include("Composition.Experimental.MicrosoftCompositionContextHelper.g.cpp") #include "Composition.Experimental.MicrosoftCompositionContextHelper.g.cpp" #endif -#endif #include #include @@ -19,11 +17,9 @@ #include #include "CompositionHelpers.h" -#ifdef USE_WINUI3 #include #include #include -#endif namespace Microsoft::ReactNative::Composition::Experimental { @@ -102,7 +98,6 @@ struct CompositionTypeTraits { }; using WindowsTypeRedirects = CompositionTypeTraits; -#ifdef USE_WINUI3 struct MicrosoftTypeTag; template <> struct CompositionTypeTraits { @@ -174,7 +169,6 @@ struct CompositionTypeTraits { winrt::Microsoft::ReactNative::Composition::Experimental::MicrosoftCompositionContextHelper; }; using MicrosoftTypeRedirects = CompositionTypeTraits; -#endif struct GeometrySource : public winrt::implements< GeometrySource, @@ -228,9 +222,7 @@ struct CompDropShadow : public winrt::implements< typename TTypeRedirects::DropShadow m_shadow; }; using WindowsCompDropShadow = CompDropShadow; -#ifdef USE_WINUI3 using MicrosoftCompDropShadow = CompDropShadow; -#endif template struct CompBrush : public winrt::implements< @@ -247,9 +239,7 @@ struct CompBrush : public winrt::implements< typename TTypeRedirects::CompositionBrush m_brush; }; using WindowsCompBrush = CompBrush; -#ifdef USE_WINUI3 using MicrosoftCompBrush = CompBrush; -#endif template struct CompDrawingSurfaceBrush : public winrt::implements< @@ -328,9 +318,7 @@ struct CompDrawingSurfaceBrush : public winrt::implements< winrt::com_ptr m_drawingSurfaceInterop; }; using WindowsCompDrawingSurfaceBrush = CompDrawingSurfaceBrush; -#ifdef USE_WINUI3 using MicrosoftCompDrawingSurfaceBrush = CompDrawingSurfaceBrush; -#endif template void SetAnimationClass( @@ -554,9 +542,7 @@ struct CompVisual : public winrt::implements< } }; using WindowsCompVisual = CompVisual; -#ifdef USE_WINUI3 using MicrosoftCompVisual = CompVisual; -#endif template struct CompSpriteVisual : winrt::implements< @@ -588,9 +574,7 @@ struct CompSpriteVisual : winrt::implements< } }; using WindowsCompSpriteVisual = CompSpriteVisual; -#ifdef USE_WINUI3 using MicrosoftCompSpriteVisual = CompSpriteVisual; -#endif template struct CompRoundedRectangleVisual @@ -671,9 +655,7 @@ struct CompRoundedRectangleVisual typename TTypeRedirects::CompositionRoundedRectangleGeometry m_geometry{nullptr}; }; using WindowsCompRoundedRectangleVisual = CompRoundedRectangleVisual; -#ifdef USE_WINUI3 using MicrosoftCompRoundedRectangleVisual = CompRoundedRectangleVisual; -#endif struct CompScrollPositionChangedArgs : winrt::implements< @@ -1315,9 +1297,7 @@ struct CompScrollerVisual : winrt::implements< typename TTypeRedirects::VisualInteractionSource m_visualInteractionSource{nullptr}; }; using WindowsCompScrollerVisual = CompScrollerVisual; -#ifdef USE_WINUI3 using MicrosoftCompScrollerVisual = CompScrollerVisual; -#endif template struct CompActivityVisual : winrt::implements< @@ -1805,9 +1785,7 @@ struct CompActivityVisual : winrt::implements< typename TTypeRedirects::SpriteVisual m_contentVisual{nullptr}; }; using WindowsCompActivityVisual = CompActivityVisual; -#ifdef USE_WINUI3 using MicrosoftCompActivityVisual = CompActivityVisual; -#endif template struct CompCaretVisual : winrt::implements< @@ -1890,13 +1868,11 @@ winrt::Microsoft::ReactNative::Composition::Experimental::IVisual CompCaretVisua } using WindowsCompCaretVisual = CompCaretVisual; -#ifdef USE_WINUI3 winrt::Microsoft::ReactNative::Composition::Experimental::IVisual CompCaretVisual::CreateVisual() const noexcept { return winrt::make(m_compVisual); } using MicrosoftCompCaretVisual = CompCaretVisual; -#endif template struct CompFocusVisual : winrt::implements< @@ -1961,13 +1937,11 @@ CompFocusVisual::CreateVisual() noexcept { } using WindowsCompFocusVisual = CompFocusVisual; -#ifdef USE_WINUI3 winrt::Microsoft::ReactNative::Composition::Experimental::IVisual CompFocusVisual::CreateVisual() noexcept { return winrt::make(m_compVisual); } using MicrosoftCompFocusVisual = CompFocusVisual; -#endif template struct CompContext : winrt::implements< @@ -2154,7 +2128,6 @@ CompContext::CompositionGraphicsDevice() noexcept { using WindowsCompContext = CompContext; -#ifdef USE_WINUI3 winrt::Microsoft::ReactNative::Composition::Experimental::ISpriteVisual CompContext::CreateSpriteVisual() noexcept { return winrt::make(m_compositor.CreateSpriteVisual()); @@ -2219,7 +2192,6 @@ CompContext::CompositionGraphicsDevice() noexcept { } using MicrosoftCompContext = CompContext; -#endif } // namespace Microsoft::ReactNative::Composition::Experimental @@ -2269,7 +2241,6 @@ winrt::Windows::UI::Composition::ICompositionSurface SystemCompositionContextHel return s ? s->Inner() : nullptr; } -#ifdef USE_WINUI3 ICompositionContext MicrosoftCompositionContextHelper::CreateContext( winrt::Microsoft::UI::Composition::Compositor const &compositor) noexcept { return winrt::make<::Microsoft::ReactNative::Composition::Experimental::MicrosoftCompContext>(compositor); @@ -2321,6 +2292,4 @@ winrt::Microsoft::ReactNative::Composition::Experimental::IBrush MicrosoftCompos return winrt::make<::Microsoft::ReactNative::Composition::Experimental::MicrosoftCompBrush>(brush); } -#endif - } // namespace winrt::Microsoft::ReactNative::Composition::Experimental::implementation diff --git a/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionContextHelper.h b/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionContextHelper.h index a8224fdfebd..9cdb1e0901a 100644 --- a/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionContextHelper.h +++ b/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionContextHelper.h @@ -2,9 +2,7 @@ // Licensed under the MIT License. #pragma once -#ifdef USE_WINUI3 #include "Composition.Experimental.MicrosoftCompositionContextHelper.g.h" -#endif #include "Composition.Experimental.SystemCompositionContextHelper.g.h" #include @@ -13,11 +11,7 @@ #include "CompositionHelpers.h" namespace winrt::Microsoft::ReactNative::Composition::Experimental { -#ifdef USE_WINUI3 using CompositionContextHelper = MicrosoftCompositionContextHelper; -#else -using CompositionContextHelper = SystemCompositionContextHelper; -#endif } // namespace winrt::Microsoft::ReactNative::Composition::Experimental namespace winrt::Microsoft::ReactNative::Composition::Experimental::implementation { @@ -34,7 +28,6 @@ struct SystemCompositionContextHelper : SystemCompositionContextHelperT { MicrosoftCompositionContextHelper() = default; @@ -48,7 +41,6 @@ struct MicrosoftCompositionContextHelper : MicrosoftCompositionContextHelperT { }; -#ifdef USE_WINUI3 struct MicrosoftCompositionContextHelper : MicrosoftCompositionContextHelperT< MicrosoftCompositionContextHelper, implementation::MicrosoftCompositionContextHelper> {}; -#endif } // namespace winrt::Microsoft::ReactNative::Composition::Experimental::factory_implementation diff --git a/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionContextHelper_emptyimpl.cpp b/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionContextHelper_emptyimpl.cpp index 15395e447e3..83f36faaef9 100644 --- a/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionContextHelper_emptyimpl.cpp +++ b/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionContextHelper_emptyimpl.cpp @@ -4,11 +4,9 @@ #if __has_include("Composition.Experimental.SystemCompositionContextHelper.g.cpp") #include "Composition.Experimental.SystemCompositionContextHelper.g.cpp" #endif -#ifdef USE_WINUI3 #if __has_include("Composition.Experimental.MicrosoftCompositionContextHelper.g.cpp") #include "Composition.Experimental.MicrosoftCompositionContextHelper.g.cpp" #endif -#endif namespace winrt::Microsoft::ReactNative::Composition::Experimental::implementation { @@ -43,7 +41,6 @@ winrt::Windows::UI::Composition::ICompositionSurface SystemCompositionContextHel return nullptr; } -#ifdef USE_WINUI3 ICompositionContext MicrosoftCompositionContextHelper::CreateContext( winrt::Microsoft::UI::Composition::Compositor const &) noexcept { return nullptr; @@ -74,6 +71,5 @@ winrt::Microsoft::UI::Composition::ICompositionSurface MicrosoftCompositionConte IDrawingSurfaceBrush) noexcept { return nullptr; } -#endif } // namespace winrt::Microsoft::ReactNative::Composition::Experimental::implementation diff --git a/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.cpp b/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.cpp index 9bb904ec04a..f4c261de2f8 100644 --- a/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.cpp +++ b/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.cpp @@ -117,7 +117,6 @@ struct CompositionKeyboardSource CompositionEventHandler *m_outer{nullptr}; }; -#ifdef USE_WINUI3 struct CompositionInputKeyboardSource : winrt::implements< CompositionInputKeyboardSource, winrt::Microsoft::ReactNative::Composition::Input::KeyboardSource> { @@ -137,7 +136,6 @@ struct CompositionInputKeyboardSource : winrt::implements< private: winrt::Microsoft::UI::Input::InputKeyboardSource m_source{nullptr}; }; -#endif CompositionEventHandler::CompositionEventHandler( const winrt::Microsoft::ReactNative::ReactContext &context, @@ -145,7 +143,6 @@ CompositionEventHandler::CompositionEventHandler( : m_context(context), m_wkRootView(reactNativeIsland) {} void CompositionEventHandler::Initialize() noexcept { -#ifdef USE_WINUI3 if (auto island = m_wkRootView.get().Island()) { auto pointerSource = winrt::Microsoft::UI::Input::InputPointerSource::GetForIsland(island); @@ -323,11 +320,9 @@ void CompositionEventHandler::Initialize() noexcept { } }); } -#endif } CompositionEventHandler::~CompositionEventHandler() { -#ifdef USE_WINUI3 if (auto strongRootView = m_wkRootView.get()) { if (auto island = strongRootView.Island()) { auto pointerSource = winrt::Microsoft::UI::Input::InputPointerSource::GetForIsland(island); @@ -342,7 +337,6 @@ CompositionEventHandler::~CompositionEventHandler() { keyboardSource.CharacterReceived(m_characterReceivedToken); } } -#endif if (m_hcursorOwned) { ::DestroyCursor(m_hcursor); diff --git a/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.h b/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.h index acddeac866f..810b2872fb9 100644 --- a/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.h +++ b/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.h @@ -166,7 +166,6 @@ class CompositionEventHandler : public std::enable_shared_from_this #include -#endif WINUSERAPI UINT WINAPI GetDpiForWindow(_In_ HWND hwnd); @@ -35,7 +33,6 @@ void CompositionHwndHost::Initialize(uint64_t hwnd) noexcept { auto compositionContext = winrt::Microsoft::ReactNative::Composition::implementation::CompositionUIService::GetCompositionContext( ReactViewHost().ReactNativeHost().InstanceSettings().Properties()); -#if USE_WINUI3 if (auto liftedCompositor = winrt::Microsoft::ReactNative::Composition::Experimental::MicrosoftCompositionContextHelper::InnerCompositor( compositionContext)) { @@ -56,7 +53,6 @@ void CompositionHwndHost::Initialize(uint64_t hwnd) noexcept { m_compRootView.as() .SetWindow(reinterpret_cast(m_hwnd)); -#endif auto compositor = winrt::Microsoft::ReactNative::Composition::Experimental::SystemCompositionContextHelper::InnerCompositor( compositionContext); @@ -78,9 +74,7 @@ void CompositionHwndHost::Initialize(uint64_t hwnd) noexcept { winrt::Microsoft::ReactNative::Composition::Experimental::SystemCompositionContextHelper::CreateVisual( target.Root())); -#if USE_WINUI3 } -#endif m_compRootView.ReactViewHost(std::move(m_reactViewHost)); m_compRootView.ScaleFactor(ScaleFactor()); @@ -122,9 +116,7 @@ LRESULT CompositionHwndHost::TranslateMessage(int msg, uint64_t wParam, int64_t } if (m_compRootView) { -#if USE_WINUI3 if (!m_compRootView.Island()) // When using Island hosting we dont need to forward window messages -#endif return static_cast( m_compRootView.as() .SendMessage(msg, wParam, lParam)); diff --git a/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionRootAutomationProvider.cpp b/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionRootAutomationProvider.cpp index e254eb4c367..c90cab69147 100644 --- a/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionRootAutomationProvider.cpp +++ b/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionRootAutomationProvider.cpp @@ -3,10 +3,8 @@ #include #include "UiaHelpers.h" -#ifdef USE_WINUI3 #include #include -#endif #include @@ -59,7 +57,6 @@ HRESULT __stdcall CompositionRootAutomationProvider::GetEmbeddedFragmentRoots(SA } HRESULT __stdcall CompositionRootAutomationProvider::SetFocus(void) { -#ifdef USE_WINUI3 if (m_island) { auto focusController = winrt::Microsoft::UI::Input::InputFocusController::GetForIsland(m_island); @@ -69,7 +66,6 @@ HRESULT __stdcall CompositionRootAutomationProvider::SetFocus(void) { } } } -#endif if (m_hwnd) { ::SetFocus(m_hwnd); @@ -107,13 +103,11 @@ HRESULT __stdcall CompositionRootAutomationProvider::get_HostRawElementProvider( if (pRetVal == nullptr) return E_POINTER; -#ifdef USE_WINUI3 if (m_island) { winrt::Windows::Foundation::IInspectable host = m_island.GetAutomationHostProvider(); *pRetVal = host.as().detach(); return S_OK; } -#endif // TODO: assumes windowed if (!IsWindow(m_hwnd)) { @@ -130,7 +124,6 @@ HRESULT __stdcall CompositionRootAutomationProvider::get_BoundingRectangle(UiaRe if (pRetVal == nullptr) return E_POINTER; -#ifdef USE_WINUI3 if (m_island) { auto cc = m_island.CoordinateConverter(); auto origin = cc.ConvertLocalToScreen(winrt::Windows::Foundation::Point{0, 0}); @@ -143,7 +136,6 @@ HRESULT __stdcall CompositionRootAutomationProvider::get_BoundingRectangle(UiaRe return S_OK; } -#endif // TODO: Need host site offsets // Assume we're hosted in some other visual-based hosting site @@ -265,11 +257,9 @@ void CompositionRootAutomationProvider::SetHwnd(HWND hwnd) noexcept { m_hwnd = hwnd; } -#ifdef USE_WINUI3 void CompositionRootAutomationProvider::SetIsland(winrt::Microsoft::UI::Content::ContentIsland &island) noexcept { m_island = island; } -#endif HRESULT __stdcall CompositionRootAutomationProvider::Navigate( NavigateDirection direction, diff --git a/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionRootAutomationProvider.h b/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionRootAutomationProvider.h index 374b4c95f43..5e37b4aa517 100644 --- a/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionRootAutomationProvider.h +++ b/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionRootAutomationProvider.h @@ -42,9 +42,7 @@ class CompositionRootAutomationProvider : public winrt::implements< CompositionRootAutomationProvider(const winrt::Microsoft::ReactNative::ReactNativeIsland &rootView) noexcept; void SetHwnd(HWND hwnd) noexcept; -#ifdef USE_WINUI3 void SetIsland(winrt::Microsoft::UI::Content::ContentIsland &island) noexcept; -#endif bool WasPropertyAdvised(PROPERTYID prop) noexcept; bool WasEventAdvised(EVENTID event) noexcept; @@ -75,9 +73,7 @@ class CompositionRootAutomationProvider : public winrt::implements< std::vector m_advisedProperties{}; winrt::weak_ref m_wkRootView; HWND m_hwnd{nullptr}; -#ifdef USE_WINUI3 winrt::Microsoft::UI::Content::ContentIsland m_island{nullptr}; -#endif }; } // namespace winrt::Microsoft::ReactNative::implementation diff --git a/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp b/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp index 268d0a0727d..03f4bb0cb2c 100644 --- a/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +++ b/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include diff --git a/vnext/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.cpp b/vnext/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.cpp index 6a7685b2877..6e7b6ac7b1c 100644 --- a/vnext/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.cpp +++ b/vnext/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.cpp @@ -8,7 +8,6 @@ #include #include -#include #include #include #include diff --git a/vnext/Microsoft.ReactNative/Fabric/Composition/ImageComponentView.cpp b/vnext/Microsoft.ReactNative/Fabric/Composition/ImageComponentView.cpp index 782f17fcf62..6c1c99f65db 100644 --- a/vnext/Microsoft.ReactNative/Fabric/Composition/ImageComponentView.cpp +++ b/vnext/Microsoft.ReactNative/Fabric/Composition/ImageComponentView.cpp @@ -6,7 +6,6 @@ #include "ImageComponentView.h" -#include #include #include diff --git a/vnext/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp b/vnext/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp index 89f1a8b097f..54b9ff491b1 100644 --- a/vnext/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp +++ b/vnext/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp @@ -33,10 +33,8 @@ #include "RootComponentView.h" #include "TextDrawing.h" -#ifdef USE_WINUI3 #include #include -#endif namespace winrt::Microsoft::ReactNative::implementation { @@ -172,7 +170,6 @@ ReactNativeIsland::ReactNativeIsland() noexcept : ReactNativeIsland(winrt::Microsoft::UI::Composition::Compositor{nullptr}) {} ReactNativeIsland::~ReactNativeIsland() noexcept { -#ifdef USE_WINUI3 if (m_island) { m_island.AutomationProviderRequested(m_islandAutomationProviderRequestedToken); m_island.StateChanged(m_islandStateChangedToken); @@ -181,7 +178,6 @@ ReactNativeIsland::~ReactNativeIsland() noexcept { m_island.Disconnected(m_islandDisconnectedToken); #endif } -#endif if (m_uiDispatcher) { assert(m_uiDispatcher.HasThreadAccess()); @@ -261,12 +257,10 @@ void ReactNativeIsland::RemoveRenderedVisual( } bool ReactNativeIsland::TrySetFocus() noexcept { -#ifdef USE_WINUI3 if (m_island && m_island.IsConnected()) { auto focusController = winrt::Microsoft::UI::Input::InputFocusController::GetForIsland(m_island); return focusController.TrySetFocus(); } -#endif return false; } diff --git a/vnext/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.h b/vnext/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.h index bfdae77958e..3428495527b 100644 --- a/vnext/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.h +++ b/vnext/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.h @@ -146,7 +146,6 @@ struct ReactNativeIsland void UninitRootView() noexcept; private: -#ifdef USE_WINUI3 winrt::Microsoft::UI::Composition::Compositor m_compositor{nullptr}; winrt::Microsoft::UI::Content::ContentIsland m_island{nullptr}; winrt::event_token m_islandFrameworkClosedToken; @@ -154,7 +153,6 @@ struct ReactNativeIsland winrt::event_token m_islandStateChangedToken; winrt::event_token m_islandConnectedToken; winrt::event_token m_islandDisconnectedToken; -#endif HWND m_hwnd{0}; bool m_isFragment{false}; diff --git a/vnext/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.cpp b/vnext/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.cpp index 3915bfd78d4..b26bc65e3d2 100644 --- a/vnext/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.cpp +++ b/vnext/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.cpp @@ -6,7 +6,6 @@ #include "ScrollViewComponentView.h" -#include #include #pragma warning(push) diff --git a/vnext/Microsoft.ReactNative/Fabric/Composition/Theme.cpp b/vnext/Microsoft.ReactNative/Fabric/Composition/Theme.cpp index f194e8bca69..679d5ad00b8 100644 --- a/vnext/Microsoft.ReactNative/Fabric/Composition/Theme.cpp +++ b/vnext/Microsoft.ReactNative/Fabric/Composition/Theme.cpp @@ -13,13 +13,6 @@ #include "ReactPropertyBag.h" #include "winrt/Microsoft.ReactNative.Composition.h" -#ifndef CORE_ABI -#include -#include -#include - -#endif // CORE_ABI - #include "Composition.Theme.g.cpp" namespace winrt::Microsoft::ReactNative::Composition::implementation { @@ -122,27 +115,6 @@ bool Theme::TryGetPlatformColor(const std::string &platformColor, winrt::Windows } } -#ifndef CORE_ABI - // If XAML is loaded, look in application resources - if (xaml::TryGetCurrentUwpXamlApplication()) { - const auto appResources{xaml::Application::Current().Resources()}; - const auto boxedResourceName{winrt::box_value(winrt::to_hstring(platformColor))}; - if (appResources.HasKey(boxedResourceName)) { - winrt::IInspectable resource{appResources.Lookup(boxedResourceName)}; - - if (auto brush = resource.try_as()) { - color = brush.Color(); - m_colorCache[platformColor] = std::make_pair(true, brush.Color()); - return true; - } else if (auto maybeColor = resource.try_as()) { - color = maybeColor.value(); - m_colorCache[platformColor] = std::make_pair(true, color); - return true; - } - } - } -#endif // CORE_ABI - // Accent colors // https://learn.microsoft.com/en-us/uwp/api/windows.ui.viewmanagement.uicolortype?view=winrt-22621 static std::unordered_map< @@ -469,12 +441,10 @@ winrt::Microsoft::ReactNative::Composition::Experimental::IBrush Theme::Internal return PlatformBrush(winrt::to_string(platformColor)); } -#ifdef USE_WINUI3 winrt::Microsoft::UI::Composition::CompositionBrush Theme::PlatformBrush(winrt::hstring platformColor) noexcept { return winrt::Microsoft::ReactNative::Composition::Experimental::MicrosoftCompositionContextHelper::InnerBrush( PlatformBrush(winrt::to_string(platformColor))); } -#endif winrt::Microsoft::ReactNative::Composition::Experimental::IBrush Theme::PlatformBrush( const std::string &platformColor) noexcept { diff --git a/vnext/Microsoft.ReactNative/Fabric/Composition/Theme.h b/vnext/Microsoft.ReactNative/Fabric/Composition/Theme.h index 707fde5d29a..678e946a039 100644 --- a/vnext/Microsoft.ReactNative/Fabric/Composition/Theme.h +++ b/vnext/Microsoft.ReactNative/Fabric/Composition/Theme.h @@ -19,9 +19,7 @@ struct Theme : ThemeT { const winrt::Microsoft::ReactNative::Composition::ICustomResourceLoader &customResourceLoader) noexcept; // Public APIs -#ifdef USE_WINUI3 winrt::Microsoft::UI::Composition::CompositionBrush PlatformBrush(winrt::hstring platformColor) noexcept; -#endif bool TryGetPlatformColor(winrt::hstring platformColor, winrt::Windows::UI::Color &color) noexcept; bool IsEmpty() const noexcept; diff --git a/vnext/Microsoft.ReactNative/Fabric/FabricUIManagerModule.cpp b/vnext/Microsoft.ReactNative/Fabric/FabricUIManagerModule.cpp index 13c9d242388..d36245c83a5 100644 --- a/vnext/Microsoft.ReactNative/Fabric/FabricUIManagerModule.cpp +++ b/vnext/Microsoft.ReactNative/Fabric/FabricUIManagerModule.cpp @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include diff --git a/vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/PlatformColorUtils.cpp b/vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/PlatformColorUtils.cpp index 5e386857062..0bc38cd6d81 100644 --- a/vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/PlatformColorUtils.cpp +++ b/vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/PlatformColorUtils.cpp @@ -2,7 +2,6 @@ // Licensed under the MIT License. #include "PlatformColorUtils.h" -#include #include #include #ifndef CORE_ABI @@ -17,15 +16,6 @@ namespace facebook::react { winrt::Windows::UI::Color ResolvePlatformColor(const std::vector &semanticItems) { if (!semanticItems.empty()) { for (auto platformColor : semanticItems) { -#ifndef CORE_ABI - // If XAML is loaded, look in application resources - if (xaml::TryGetCurrentUwpXamlApplication()) { - xaml::Media::Brush brush{Microsoft::ReactNative::BrushFromColorObject(platformColor)}; - if (auto scb{brush.try_as()}) { - return scb.Color(); - } - } -#endif // CORE_ABI // Accent colors // https://learn.microsoft.com/en-us/uwp/api/windows.ui.viewmanagement.uicolortype?view=winrt-22621 diff --git a/vnext/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj b/vnext/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj index d86bd1a1ca9..c7e8956734c 100644 --- a/vnext/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +++ b/vnext/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj @@ -187,7 +187,6 @@ - IJSValueReader.idl @@ -303,7 +302,6 @@ - @@ -334,7 +332,6 @@ - @@ -376,11 +373,9 @@ - - XamlUIService.idl diff --git a/vnext/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj.filters b/vnext/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj.filters index d4376a3bae0..48c7c78f62f 100644 --- a/vnext/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj.filters +++ b/vnext/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj.filters @@ -144,9 +144,6 @@ Utils - - Utils - Utils @@ -156,15 +153,9 @@ Utils - - Utils - Modules - - Utils - @@ -386,9 +377,6 @@ Utils - - Utils - Utils @@ -422,9 +410,6 @@ - - Utils - ReactHost diff --git a/vnext/Microsoft.ReactNative/Modules/Animated/NativeAnimatedNodeManager.cpp b/vnext/Microsoft.ReactNative/Modules/Animated/NativeAnimatedNodeManager.cpp index dc4f34a8356..9ec20d3dc02 100644 --- a/vnext/Microsoft.ReactNative/Modules/Animated/NativeAnimatedNodeManager.cpp +++ b/vnext/Microsoft.ReactNative/Modules/Animated/NativeAnimatedNodeManager.cpp @@ -584,14 +584,18 @@ void NativeAnimatedNodeManager::RunUpdates(winrt::TimeSpan renderingTime) { } void NativeAnimatedNodeManager::EnsureRendering() { + /* + * Reenable to enable composition = false animations m_renderingRevoker = xaml::Media::CompositionTarget::Rendering(winrt::auto_revoke, {this, &NativeAnimatedNodeManager::OnRendering}); + */ } void NativeAnimatedNodeManager::OnRendering(winrt::IInspectable const &sender, winrt::IInspectable const &args) { // The `UpdateActiveAnimationIds` method only tracks animations where // composition is not used, so if only UI.Composition animations are active, // this rendering callback will not run. + /* UpdateActiveAnimationIds(); if (m_activeAnimationIds.size() > 0 || m_updatedNodes.size() > 0) { if (const auto renderingArgs = args.try_as()) { @@ -600,6 +604,7 @@ void NativeAnimatedNodeManager::OnRendering(winrt::IInspectable const &sender, w } else { m_renderingRevoker.revoke(); } + */ } void NativeAnimatedNodeManager::StopAnimationsForNode(int64_t tag) { diff --git a/vnext/Microsoft.ReactNative/Modules/Animated/NativeAnimatedNodeManager.h b/vnext/Microsoft.ReactNative/Modules/Animated/NativeAnimatedNodeManager.h index cd55812304e..d397704906c 100644 --- a/vnext/Microsoft.ReactNative/Modules/Animated/NativeAnimatedNodeManager.h +++ b/vnext/Microsoft.ReactNative/Modules/Animated/NativeAnimatedNodeManager.h @@ -5,7 +5,6 @@ // Licensed under the MIT License. #include -#include #include "AnimatedNode.h" #include "AnimationDriver.h" #include "EventAnimationDriver.h" diff --git a/vnext/Microsoft.ReactNative/Modules/AppStateModule.cpp b/vnext/Microsoft.ReactNative/Modules/AppStateModule.cpp index c6ac8d0b539..ba712e6b1d1 100644 --- a/vnext/Microsoft.ReactNative/Modules/AppStateModule.cpp +++ b/vnext/Microsoft.ReactNative/Modules/AppStateModule.cpp @@ -17,59 +17,6 @@ void AppState::Initialize(winrt::Microsoft::ReactNative::ReactContext const &rea m_context = reactContext; m_deactivated = false; m_enteredBackground = false; - - // We need to register for notifications from the XAML thread. - if (auto dispatcher = reactContext.UIDispatcher()) { - dispatcher.Post([this]() { - auto currentApp = xaml::TryGetCurrentUwpXamlApplication(); - - if (!IsWinUI3Island() && currentApp != nullptr) { -#ifndef USE_WINUI3 - CoreWindow window = CoreWindow::GetForCurrentThread(); - - m_enteredBackgroundRevoker = currentApp.EnteredBackground( - winrt::auto_revoke, - [weakThis = weak_from_this()]( - winrt::IInspectable const & /*sender*/, - winrt::Windows::ApplicationModel::EnteredBackgroundEventArgs const & /*e*/) noexcept { - if (auto strongThis = weakThis.lock()) { - strongThis->SetEnteredBackground(true); - } - }); - - m_leavingBackgroundRevoker = currentApp.LeavingBackground( - winrt::auto_revoke, - [weakThis = weak_from_this()]( - winrt::IInspectable const & /*sender*/, - winrt::Windows::ApplicationModel::LeavingBackgroundEventArgs const & /*e*/) noexcept { - if (auto strongThis = weakThis.lock()) { - strongThis->SetEnteredBackground(false); - } - }); - if (window != nullptr && - winrt::Microsoft::ReactNative::implementation::QuirkSettings::GetMapWindowDeactivatedToAppStateInactive( - m_context.Properties())) { - m_activatedEventRevoker = window.Activated( - winrt::auto_revoke, - [weakThis = weak_from_this()]( - winrt::Windows::UI::Core::CoreWindow /*sender*/, - winrt::Windows::UI::Core::WindowActivatedEventArgs args) { - if (auto strongThis = weakThis.lock()) { - if (args.WindowActivationState() == - winrt::Windows::UI::Core::CoreWindowActivationState::Deactivated) { - strongThis->SetDeactivated(true); - } else { - strongThis->SetDeactivated(false); - } - } - }); - } -#endif - } else { - assert(IsXamlIsland()); - } - }); - } } void AppState::GetCurrentAppState( diff --git a/vnext/Microsoft.ReactNative/Modules/AppStateModule.h b/vnext/Microsoft.ReactNative/Modules/AppStateModule.h index e401435c136..9c40294d330 100644 --- a/vnext/Microsoft.ReactNative/Modules/AppStateModule.h +++ b/vnext/Microsoft.ReactNative/Modules/AppStateModule.h @@ -46,11 +46,6 @@ struct AppState : public std::enable_shared_from_this { std::atomic m_enteredBackground; char const *m_lastState{nullptr}; winrt::Microsoft::ReactNative::ReactContext m_context; -#ifndef USE_WINUI3 - xaml::Application::EnteredBackground_revoker m_enteredBackgroundRevoker; - xaml::Application::LeavingBackground_revoker m_leavingBackgroundRevoker; - winrt::Windows::UI::Core::CoreWindow::Activated_revoker m_activatedEventRevoker; -#endif }; } // namespace Microsoft::ReactNative diff --git a/vnext/Microsoft.ReactNative/Modules/AppThemeModuleUwp.cpp b/vnext/Microsoft.ReactNative/Modules/AppThemeModuleUwp.cpp index e72b02b8f35..d5ba7a1bc88 100644 --- a/vnext/Microsoft.ReactNative/Modules/AppThemeModuleUwp.cpp +++ b/vnext/Microsoft.ReactNative/Modules/AppThemeModuleUwp.cpp @@ -42,18 +42,10 @@ static const React::ReactPropertyIdNotifications()), WM_THEMECHANGED, [this](const auto &, const auto &) { - NotifyHighContrastChanged(); - }); - } else { - m_highContrastChangedRevoker = m_accessibilitySettings.HighContrastChanged( - winrt::auto_revoke, [this](const auto &, const auto &) { NotifyHighContrastChanged(); }); - } - } + m_wmSubscription = SubscribeToWindowMessage( + ReactNotificationService(m_context->Notifications()), WM_THEMECHANGED, [this](const auto &, const auto &) { + NotifyHighContrastChanged(); + }); } ReactNativeSpecs::AppThemeSpec_AppThemeData AppThemeHolder::GetConstants() noexcept { @@ -75,8 +67,7 @@ void AppThemeHolder::SetCallback( } void AppThemeHolder::NotifyHighContrastChanged() noexcept { - m_appThemeData.isHighContrast = - xaml::TryGetCurrentUwpXamlApplication() ? m_accessibilitySettings.HighContrast() : IsInHighContrastWin32(); + m_appThemeData.isHighContrast = IsInHighContrastWin32(); m_appThemeData.highContrastColors.ButtonFaceColor = FormatRGB(m_uiSettings.UIElementColor(winrt::UIElementType::ButtonFace)); m_appThemeData.highContrastColors.ButtonTextColor = diff --git a/vnext/Microsoft.ReactNative/Modules/AppThemeModuleUwp.h b/vnext/Microsoft.ReactNative/Modules/AppThemeModuleUwp.h index 12655d29e56..06668b93e9b 100644 --- a/vnext/Microsoft.ReactNative/Modules/AppThemeModuleUwp.h +++ b/vnext/Microsoft.ReactNative/Modules/AppThemeModuleUwp.h @@ -32,8 +32,6 @@ class AppThemeHolder { Mso::CntPtr m_context; Mso::Functor m_notifyCallback; ReactNativeSpecs::AppThemeSpec_AppThemeData m_appThemeData; - winrt::Windows::UI::ViewManagement::AccessibilitySettings m_accessibilitySettings{}; - winrt::Windows::UI::ViewManagement::AccessibilitySettings::HighContrastChanged_revoker m_highContrastChangedRevoker{}; winrt::Windows::UI::ViewManagement::UISettings m_uiSettings{}; winrt::Microsoft::ReactNative::ReactNotificationSubscription m_wmSubscription; }; diff --git a/vnext/Microsoft.ReactNative/Modules/AppearanceModule.cpp b/vnext/Microsoft.ReactNative/Modules/AppearanceModule.cpp index 5a2791c2bd6..aaf5ca8a20d 100644 --- a/vnext/Microsoft.ReactNative/Modules/AppearanceModule.cpp +++ b/vnext/Microsoft.ReactNative/Modules/AppearanceModule.cpp @@ -50,10 +50,6 @@ ApplicationTheme CurrentThemeFromUISettings(const winrt::Windows::UI::ViewManage ApplicationTheme Appearance::GetCurrentTheme() noexcept { assert(m_context.UIDispatcher().HasThreadAccess()); // xaml::Application is only accessible on the UI thread - if (auto currentApp = xaml::TryGetCurrentUwpXamlApplication()) { - return currentApp.RequestedTheme(); - } - return CurrentThemeFromUISettings(m_uiSettings); } @@ -74,11 +70,7 @@ void Appearance::RequeryTheme() noexcept { void Appearance::InitOnUIThread(const Mso::React::IReactContext &context) noexcept { xaml::ApplicationTheme theme = ApplicationTheme::Light; - if (auto currentApp = xaml::TryGetCurrentUwpXamlApplication()) { - theme = currentApp.RequestedTheme(); - } else { - theme = CurrentThemeFromUISettings(winrt::Windows::UI::ViewManagement::UISettings()); - } + theme = CurrentThemeFromUISettings(winrt::Windows::UI::ViewManagement::UISettings()); winrt::Microsoft::ReactNative::ReactPropertyBag pb{context.Properties()}; pb.Set(AppearanceCurrentThemePropertyId(), theme); diff --git a/vnext/Microsoft.ReactNative/Modules/DeviceInfoModule.cpp b/vnext/Microsoft.ReactNative/Modules/DeviceInfoModule.cpp index 81b7908788e..7ff583346f2 100644 --- a/vnext/Microsoft.ReactNative/Modules/DeviceInfoModule.cpp +++ b/vnext/Microsoft.ReactNative/Modules/DeviceInfoModule.cpp @@ -6,9 +6,6 @@ #include #include #include -#ifndef USE_WINUI3 -#include -#endif #include #include #include @@ -34,50 +31,14 @@ DeviceInfoHolder::DeviceInfoHolder(const Mso::React::IReactContext &context) : m } void DeviceInfoHolder::InitDeviceInfoHolder(const Mso::React::IReactContext &context) noexcept { - if (xaml::TryGetCurrentUwpXamlApplication() || IsFabricEnabled(context.Properties())) { + if (IsFabricEnabled(context.Properties())) { auto deviceInfoHolder = std::make_shared(context); deviceInfoHolder->updateDeviceInfo(); winrt::Microsoft::ReactNative::ReactPropertyBag pb{context.Properties()}; pb.Set(DeviceInfoHolderPropertyId(), std::move(deviceInfoHolder)); - uint64_t hwnd = 0; - - if (IsFabricEnabled(context.Properties())) { - hwnd = winrt::Microsoft::ReactNative::implementation::ReactCoreInjection::GetTopLevelWindowId(pb.Handle()); - } - - if (xaml::TryGetCurrentUwpXamlApplication()) { - if (auto window = xaml::Window::Current()) { - auto const &coreWindow = window.CoreWindow(); - - deviceInfoHolder->m_sizeChangedRevoker = coreWindow.SizeChanged( - winrt::auto_revoke, [weakHolder = std::weak_ptr(deviceInfoHolder)](auto &&, auto &&) { - if (auto strongHolder = weakHolder.lock()) { - strongHolder->updateDeviceInfo(); - } - }); - } else { - assert(IsXamlIsland()); - // This is either a WinUI 3 island or a system XAML island - // system XAML islands have a CoreWindow so we want to use the GetForCurrentView APIs - // For WinUI 3 islands we require the app to forward window messages as ReactNotifications - } - - if (!IsWinUI3Island()) { - // UWP or system XAML island - auto const &displayInfo = winrt::Windows::Graphics::Display::DisplayInformation::GetForCurrentView(); - - deviceInfoHolder->m_dpiChangedRevoker = displayInfo.DpiChanged( - winrt::auto_revoke, [weakHolder = std::weak_ptr(deviceInfoHolder)](const auto &, const auto &) { - if (auto strongHolder = weakHolder.lock()) { - strongHolder->updateDeviceInfo(); - } - }); - } else { - hwnd = XamlUIService::GetIslandWindowHandle(deviceInfoHolder->m_context->Properties()); - } - } + uint64_t hwnd = winrt::Microsoft::ReactNative::implementation::ReactCoreInjection::GetTopLevelWindowId(pb.Handle()); if (hwnd) { deviceInfoHolder->m_wmSubscription = SubscribeToWindowMessage( @@ -153,53 +114,26 @@ void DeviceInfoHolder::SetCallback( } void DeviceInfoHolder::updateDeviceInfo() noexcept { - if (xaml::TryGetCurrentUwpXamlApplication() && xaml::Window::Current()) { - auto const window = xaml::Window::Current().CoreWindow(); + auto hwnd = XamlUIService::GetIslandWindowHandle(m_context->Properties()); - m_windowWidth = window.Bounds().Width; - m_windowHeight = window.Bounds().Height; - } else { - auto hwnd = XamlUIService::GetIslandWindowHandle(m_context->Properties()); - - if (IsFabricEnabled(m_context->Properties())) { - winrt::Microsoft::ReactNative::ReactPropertyBag pb{m_context->Properties()}; - hwnd = winrt::Microsoft::ReactNative::implementation::ReactCoreInjection::GetTopLevelWindowId(pb.Handle()); - } + if (IsFabricEnabled(m_context->Properties())) { + winrt::Microsoft::ReactNative::ReactPropertyBag pb{m_context->Properties()}; + hwnd = winrt::Microsoft::ReactNative::implementation::ReactCoreInjection::GetTopLevelWindowId(pb.Handle()); + } - if (hwnd) { - RECT rect{}; - if (CALL_INDIRECT(L"user32.dll", GetWindowRect, reinterpret_cast(hwnd), &rect)) { - m_windowWidth = (float)(rect.right - rect.left); - m_windowHeight = (float)(rect.bottom - rect.top); - } + if (hwnd) { + RECT rect{}; + if (CALL_INDIRECT(L"user32.dll", GetWindowRect, reinterpret_cast(hwnd), &rect)) { + m_windowWidth = (float)(rect.right - rect.left); + m_windowHeight = (float)(rect.bottom - rect.top); + m_screenWidth = static_cast(rect.right - rect.left); + m_screenHeight = static_cast(rect.bottom - rect.top); + m_dpi = static_cast(CALL_INDIRECT(L"user32.dll", GetDpiForWindow, reinterpret_cast(hwnd))); } } winrt::Windows::UI::ViewManagement::UISettings uiSettings; m_textScaleFactor = uiSettings.TextScaleFactor(); - if (!IsWinUI3Island()) { - auto const displayInfo = winrt::Windows::Graphics::Display::DisplayInformation::GetForCurrentView(); - m_scale = static_cast(displayInfo.ResolutionScale()) / 100; - m_dpi = displayInfo.LogicalDpi(); - m_screenWidth = displayInfo.ScreenWidthInRawPixels(); - m_screenHeight = displayInfo.ScreenHeightInRawPixels(); - notifyChanged(); - } else { - RECT desktopRect{}; - - auto hwnd = XamlUIService::GetIslandWindowHandle(m_context->Properties()); - - if (IsFabricEnabled(m_context->Properties())) { - winrt::Microsoft::ReactNative::ReactPropertyBag pb{m_context->Properties()}; - hwnd = winrt::Microsoft::ReactNative::implementation::ReactCoreInjection::GetTopLevelWindowId(pb.Handle()); - } - - if (hwnd && CALL_INDIRECT(L"user32.dll", GetWindowRect, reinterpret_cast(hwnd), &desktopRect)) { - m_screenWidth = static_cast(desktopRect.right - desktopRect.left); - m_screenHeight = static_cast(desktopRect.bottom - desktopRect.top); - m_dpi = static_cast(CALL_INDIRECT(L"user32.dll", GetDpiForWindow, reinterpret_cast(hwnd))); - } - } } ReactNativeSpecs::DeviceInfoSpec_DeviceInfoConstants DeviceInfo::GetConstants() noexcept { diff --git a/vnext/Microsoft.ReactNative/Modules/I18nManagerModule.cpp b/vnext/Microsoft.ReactNative/Modules/I18nManagerModule.cpp index de8c5e01fba..b3d530645d3 100644 --- a/vnext/Microsoft.ReactNative/Modules/I18nManagerModule.cpp +++ b/vnext/Microsoft.ReactNative/Modules/I18nManagerModule.cpp @@ -28,14 +28,9 @@ static const React::ReactPropertyId &ForceRTLPropertyId() noexcept { } void I18nManager::InitI18nInfo(const winrt::Microsoft::ReactNative::ReactPropertyBag &propertyBag) noexcept { - if (xaml::TryGetCurrentUwpXamlApplication() && !IsXamlIsland()) { - // TODO: Figure out packaged win32 app story for WinUI 3 - auto layoutDirection = winrt::Windows::ApplicationModel::Resources::Core::ResourceContext() - .GetForCurrentView() - .QualifierValues() - .Lookup(L"LayoutDirection"); - - propertyBag.Set(SystemIsRTLPropertyId(), layoutDirection != L"LTR"); + DWORD dw; + if (GetProcessDefaultLayout(&dw)) { + propertyBag.Set(SystemIsRTLPropertyId(), dw == LAYOUT_RTL); } } diff --git a/vnext/Microsoft.ReactNative/Modules/ImageViewManagerModule.cpp b/vnext/Microsoft.ReactNative/Modules/ImageViewManagerModule.cpp index 2ce93a7fbb9..c5e9c0b132f 100644 --- a/vnext/Microsoft.ReactNative/Modules/ImageViewManagerModule.cpp +++ b/vnext/Microsoft.ReactNative/Modules/ImageViewManagerModule.cpp @@ -11,18 +11,15 @@ #include "ImageViewManagerModule.h" #include -#include #include #include #include #include #include "Unicode.h" -#include "XamlUtils.h" namespace winrt { using namespace Windows::Foundation; using namespace Windows::Storage::Streams; -using namespace xaml::Media::Imaging; } // namespace winrt namespace Microsoft::ReactNative { diff --git a/vnext/Microsoft.ReactNative/Modules/Timing.cpp b/vnext/Microsoft.ReactNative/Modules/Timing.cpp index fd4b5ceea82..b243b3f416f 100644 --- a/vnext/Microsoft.ReactNative/Modules/Timing.cpp +++ b/vnext/Microsoft.ReactNative/Modules/Timing.cpp @@ -7,7 +7,6 @@ #include "Timing.h" #include -#include #include #include @@ -120,7 +119,7 @@ void TimerRegistry::setTimerManager(std::weak_ptr void Timing::Initialize(winrt::Microsoft::ReactNative::ReactContext const &reactContext) noexcept { m_context = reactContext; m_properties = reactContext.Properties().Handle(); - m_usePostForRendering = !xaml::TryGetCurrentUwpXamlApplication(); + m_usePostForRendering = true; m_uiDispatcher = m_context.UIDispatcher().Handle(); } @@ -129,7 +128,7 @@ void Timing::InitializeBridgeless( const winrt::Microsoft::ReactNative::IReactPropertyBag &properties) noexcept { m_timerRegistry = timerRegistry; m_properties = properties; - m_usePostForRendering = !xaml::TryGetCurrentUwpXamlApplication(); + m_usePostForRendering = true; m_uiDispatcher = {properties.Get(winrt::Microsoft::ReactNative::ReactDispatcherHelper::UIDispatcherProperty()) .try_as()}; } @@ -216,16 +215,20 @@ void Timing::StartRendering() { PostRenderFrame(); return; } + + // TODO use composition rendering callback here + /* m_rendering.revoke(); m_usingRendering = true; m_rendering = xaml::Media::CompositionTarget::Rendering( winrt::auto_revoke, [wkThis = std::weak_ptr(this->shared_from_this())]( - const winrt::IInspectable &, const winrt::IInspectable & /*args*/) { + const winrt::IInspectable &, const winrt::IInspectable & args) { if (auto pThis = wkThis.lock()) { pThis->OnTick(); } }); + */ } void Timing::StartDispatcherTimer() { diff --git a/vnext/Microsoft.ReactNative/ReactNativeIsland.idl b/vnext/Microsoft.ReactNative/ReactNativeIsland.idl index d200a6b3fb0..f0ba4a28e91 100644 --- a/vnext/Microsoft.ReactNative/ReactNativeIsland.idl +++ b/vnext/Microsoft.ReactNative/ReactNativeIsland.idl @@ -83,12 +83,10 @@ namespace Microsoft.ReactNative DOC_STRING("Creates a new instance of @ReactNativeIsland. Can be implemented with a ReactViewHost or a ComponentView with reactContext") ReactNativeIsland(); -#ifdef USE_WINUI3 ReactNativeIsland(Microsoft.UI.Composition.Compositor compositor); DOC_STRING("Used to create react portals, such as a native modal component.") static ReactNativeIsland CreatePortal(Microsoft.ReactNative.Composition.PortalComponentView portal); -#endif DOC_STRING( "A ReactViewHost specifies the root UI component and initial properties to render in this RootView" @@ -122,9 +120,7 @@ namespace Microsoft.ReactNative DOC_STRING("Initial props should be set on ReactViewHost. This is used to update props after the initial props are set") void SetProperties(JSValueArgWriter props); -#ifdef USE_WINUI3 Microsoft.UI.Content.ContentIsland Island { get; }; -#endif event Windows.Foundation.EventHandler SizeChanged; } diff --git a/vnext/Microsoft.ReactNative/RedBox.cpp b/vnext/Microsoft.ReactNative/RedBox.cpp index 5be98195973..f491e8f09b0 100644 --- a/vnext/Microsoft.ReactNative/RedBox.cpp +++ b/vnext/Microsoft.ReactNative/RedBox.cpp @@ -18,12 +18,6 @@ #include #include -#include -#include -#include -#include -#include -#include #include #include #include @@ -54,25 +48,16 @@ struct RedBox : public std::enable_shared_from_this { m_onClosedCallback(std::move(onClosedCallback)), m_errorInfo(std::move(errorInfo)) {} - void Dismiss() noexcept { - if (m_popup) { - m_popup.IsOpen(false); - } - } - void Reload() noexcept { if (auto reactHost = m_weakReactHost.GetStrongPtr()) { reactHost->ReloadInstance(); } } - void WindowSizeChanged(winrt::Windows::UI::Core::WindowSizeChangedEventArgs const &args) noexcept { - if (m_redboxContent) { - m_redboxContent.MaxHeight(args.Size().Height); - m_redboxContent.Height(args.Size().Height); - m_redboxContent.MaxWidth(args.Size().Width); - m_redboxContent.Width(args.Size().Width); - } + void Dismiss() noexcept + { + if (m_dialogAsync) + m_dialogAsync.Cancel(); } void ShowNewJsErrorUsingMessageDialog() noexcept { @@ -128,132 +113,16 @@ struct RedBox : public std::enable_shared_from_this { reactHost->ReloadInstance(); } })); - msg.ShowAsync(); - } - - void ShowNewJSErrorUsingXaml() noexcept { - m_popup = xaml::Controls::Primitives::Popup{}; - - const winrt::hstring xamlString = - LR"( - - - - - - - - - - - - - - - - - - - - - - )"; - - m_redboxContent = winrt::unbox_value(xaml::Markup::XamlReader::Load(xamlString)); - m_errorMessageText = m_redboxContent.FindName(L"ErrorMessageText").as(); - m_errorStackText = m_redboxContent.FindName(L"ErrorStackText").as(); - m_stackPanel = m_redboxContent.FindName(L"StackPanel").as(); - m_stackPanelUpper = m_redboxContent.FindName(L"StackPanelUpper").as(); - m_dismissButton = m_redboxContent.FindName(L"DismissButton").as(); - m_reloadButton = m_redboxContent.FindName(L"ReloadButton").as(); - - m_tokenDismiss = m_dismissButton.Click( - [&](IInspectable const & /*sender*/, xaml::RoutedEventArgs const & /*args*/) noexcept { Dismiss(); }); - - m_tokenReload = m_reloadButton.Click([&](auto const & /*sender*/, xaml::RoutedEventArgs const & /*args*/) noexcept { - Dismiss(); - Reload(); - }); - - PopulateFrameStackUI(); - UpdateErrorMessageUI(); - - xaml::FrameworkElement root{nullptr}; - - if (Microsoft::ReactNative::Is19H1OrHigher()) { - // XamlRoot added in 19H1 - if (auto reactHost = m_weakReactHost.GetStrongPtr()) { - if (auto xamlRoot = - winrt::Microsoft::ReactNative::XamlUIService::GetXamlRoot(reactHost->Options().Properties)) { - m_popup.XamlRoot(xamlRoot); - root = xamlRoot.Content().as(); - } - } - } - - if (!root) { - if (auto window = xaml::Window::Current()) { - root = window.Content().as(); - } - } - - if (root) { - m_redboxContent.MaxHeight(root.ActualHeight()); - m_redboxContent.Height(root.ActualHeight()); - m_redboxContent.MaxWidth(root.ActualWidth()); - m_redboxContent.Width(root.ActualWidth()); - - m_sizeChangedRevoker = root.SizeChanged( - winrt::auto_revoke, - [wkThis = weak_from_this()](auto const & /*sender*/, xaml::SizeChangedEventArgs const &args) { - if (auto strongThis = wkThis.lock()) { - strongThis->m_redboxContent.MaxHeight(args.NewSize().Height); - strongThis->m_redboxContent.Height(args.NewSize().Height); - strongThis->m_redboxContent.MaxWidth(args.NewSize().Width); - strongThis->m_redboxContent.Width(args.NewSize().Width); - } - }); - } - - m_tokenClosed = m_popup.Closed( - [wkThis = std::weak_ptr(shared_from_this())](auto const & /*sender*/, IInspectable const & /*args*/) noexcept { - if (auto pthis = wkThis.lock()) { - pthis->OnPopupClosed(); - } - }); - - m_popup.Child(m_redboxContent); - m_popup.IsOpen(true); + m_dialogAsync = msg.ShowAsync(); } void ShowNewJSError() noexcept { m_showing = true; - - if (Microsoft::ReactNative::IsFabricEnabled(m_propBag.Handle())) { - ShowNewJsErrorUsingMessageDialog(); - } else { - ShowNewJSErrorUsingXaml(); - } + ShowNewJsErrorUsingMessageDialog(); } void UpdateError(const ErrorInfo &&info) noexcept { m_errorInfo = std::move(info); - if (m_showing) { - PopulateFrameStackUI(); - } - } - - void OnPopupClosed() noexcept { - m_showing = false; - m_dismissButton.Click(m_tokenDismiss); - m_reloadButton.Click(m_tokenReload); - m_sizeChangedRevoker.revoke(); - m_popup.Closed(m_tokenClosed); - m_redboxContent = nullptr; - m_onClosedCallback(GetId()); } uint32_t GetId() const noexcept { @@ -261,221 +130,8 @@ struct RedBox : public std::enable_shared_from_this { } private: - static bool IsMetroBundlerError(const std::string &message, const std::string &type) { - // This string must be kept in sync with the one in formatBundlingError in - // node_modules\metro\src\lib\formatBundlingError.js - if (message.find_first_of("Metro Bundler has encountered an error") != message.npos) { - return true; - } - return false; - } - -#define METRO_TROUBLESHOOTING_URL "http://aka.ms/RNWTroubleshootMetro" -#define _MAKE_WIDE_STR(x) L##x -#define MAKE_WIDE_STR(x) _MAKE_WIDE_STR(x) - - void CreateWebView(xaml::Controls::Panel parent, const winrt::hstring &content) { -#ifndef USE_WINUI3 - xaml::Controls::WebView webView; -#else - xaml::Controls::WebView2 webView; -#endif - - webView.HorizontalAlignment(xaml::HorizontalAlignment::Stretch); - webView.VerticalAlignment(xaml::VerticalAlignment::Stretch); - webView.MinWidth(400); - auto dispatcher = winrt::dispatching::DispatcherQueue::GetForCurrentThread(); - // XAML doesn't currently provide a way to measure a WebView control, - // So we're going to tell the WebView to measure itself by running some javascript, - // and then we'll post a task back to XAML to set the XAML WebView minimum height. - // The HTML we get from Metro doesn't have any styling, so we'll take advantage of - // the fact that we're running javascript in the WebView, to set the - // foreground/background to match the rest of the RedBox. - // setProperty returns undefined so we continue the first expression with a comma - // whereas the height expression gets executed because of the || - // (since the setProperty calls resulted in undefined). - // Finally, it's important to note that JS expressions of that are not of string type - // need to be manually converted to string for them to get marshaled properly back here. - webView.NavigationCompleted([=](IInspectable const &, auto const &) { - std::wstring jsExpression = - L"(document.body.style.setProperty('color', 'white'), " - L"document.body.style.setProperty('background', '#d01926')) " - L"|| document.documentElement.scrollHeight.toString()"; - -#ifndef USE_WINUI3 - auto async = webView.InvokeScriptAsync(L"eval", std::vector{winrt::hstring { jsExpression }}); -#else - auto async = webView.ExecuteScriptAsync(std::wstring(L"eval(") + jsExpression + L")"); -#endif - - async.Completed([=](IAsyncOperation const &op, auto &&) { - auto result = op.GetResults(); - int documentHeight = _wtoi(result.c_str()); - dispatcher.TryEnqueue([=]() { - // Ensure the webview has a min height of the content it wants to show, - // and that the horizontal scrollbar that might exist, doesn't occlude the webview. - constexpr int horizontalScrollbarHeight = 12; - webView.MinHeight(documentHeight + horizontalScrollbarHeight); - }); - }); - }); - - m_stackPanel.Children().Clear(); - m_stackPanel.Children().Append(webView); -#ifdef USE_WINUI3 - webView.EnsureCoreWebView2Async().Completed( - [content, webView](auto &&sender, auto &&args) { webView.NavigateToString(content); }); -#else - webView.NavigateToString(content); -#endif - } - - void UpdateErrorMessageUI() noexcept { - const std::regex colorsRegex( - "\\x1b\\[[0-9;]*m"); // strip out console colors which is often added to JS error messages - const std::string plain = std::regex_replace(m_errorInfo.Message, colorsRegex, ""); - - if (!plain.empty() && plain[0] == '{') { - try { - auto json = folly::parseJson(plain); - if (json.count("type") && json["type"] == "InternalError") { - auto message = json["message"].asString(); - m_errorMessageText.Text(Microsoft::Common::Unicode::Utf8ToUtf16(message)); - - if (IsMetroBundlerError(message, json["type"].asString())) { - xaml::Documents::Hyperlink link; - link.NavigateUri(Uri(MAKE_WIDE_STR(METRO_TROUBLESHOOTING_URL))); - xaml::Documents::Run linkRun; - - linkRun.Text(Microsoft::Common::Unicode::Utf8ToUtf16(METRO_TROUBLESHOOTING_URL)); - link.Foreground(xaml::Media::SolidColorBrush(xaml::FromArgb(0xff, 0xff, 0xff, 0xff))); - link.Inlines().Append(linkRun); - xaml::Documents::Run normalRun; - normalRun.Text(Microsoft::Common::Unicode::Utf8ToUtf16(json["type"].asString() + (" ─ See "))); - m_errorStackText.Inlines().Append(normalRun); - m_errorStackText.Inlines().Append(link); - } else { - m_errorStackText.Text(Microsoft::Common::Unicode::Utf8ToUtf16(json["type"].asString())); - } - return; - } else if (json.count("name") && boost::ends_with(json["name"].asString(), "Error")) { - auto message = std::regex_replace(json["message"].asString(), colorsRegex, ""); - const auto originalStack = std::regex_replace(json["stack"].asString(), colorsRegex, ""); - - const auto errorName = json["name"].asString(); - std::string stack; - - const auto prefix = errorName + ": " + message; - if (boost::starts_with(originalStack, prefix)) { - stack = originalStack.substr(prefix.length()); - } else { - constexpr char startOfStackTrace[] = "\n at "; - stack = originalStack.substr(originalStack.find(startOfStackTrace) + 1); - } - - m_errorMessageText.Text(Microsoft::Common::Unicode::Utf8ToUtf16(message)); - // Some messages (like SyntaxError) rely on fixed-width font to be properly formatted and indented. - m_errorMessageText.FontFamily(xaml::Media::FontFamily(L"Consolas")); - - m_errorStackText.Text(Microsoft::Common::Unicode::Utf8ToUtf16(stack)); - return; - } - } catch (...) { - } - } - std::string doctype = ""; - if (boost::istarts_with(plain, doctype)) { - winrt::hstring content(Microsoft::Common::Unicode::Utf8ToUtf16(plain.substr(doctype.length()).c_str())); - - CreateWebView(m_stackPanel, content); - - m_stackPanel.Margin(xaml::ThicknessHelper::FromUniformLength(0)); - m_stackPanelUpper.Visibility(xaml::Visibility::Collapsed); - - return; - } - - // fall back to displaying the raw message string - m_errorMessageText.Text(Microsoft::Common::Unicode::Utf8ToUtf16(plain)); - m_errorStackText.Text(L""); - } - - void PopulateFrameStackUI() noexcept { - if (!m_stackPanel) - return; - - m_stackPanel.Children().Clear(); - for (const auto &frame : m_errorInfo.Callstack) { - const winrt::hstring xamlFrameString = - LR"( - - - - )"; - auto frameContent = - winrt::unbox_value(xaml::Markup::XamlReader::Load(xamlFrameString)); - auto methodText = frameContent.FindName(L"MethodText").as(); - auto frameText = frameContent.FindName(L"FrameText").as(); - methodText.Text(Microsoft::Common::Unicode::Utf8ToUtf16(frame.Method)); - - // When the user taps on a stack frame, tell the bundler to load that source in the users editor of choice - frameContent.Tapped([weakReactHost = m_weakReactHost, f = frame]( - IInspectable const & /*sender*/, xaml::Input::TappedRoutedEventArgs const & /*e*/) { - if (auto reactHost = weakReactHost.GetStrongPtr()) { - auto devSettings = reactHost->Options().DeveloperSettings; - Uri uri{ - Microsoft::Common::Unicode::Utf8ToUtf16(facebook::react::DevServerHelper::get_PackagerOpenStackFrameUrl( - devSettings.SourceBundleHost, devSettings.SourceBundlePort))}; - winrt::Windows::Web::Http::HttpClient httpClient{}; - winrt::Windows::Data::Json::JsonObject payload{}; - - auto fileSanitized = f.File; - // Bundler will not launch filenames containing :'s, so strip off the : - if (fileSanitized[1] == ':') { - fileSanitized.erase(fileSanitized.begin()); - fileSanitized.erase(fileSanitized.begin()); - } - payload.SetNamedValue( - L"file", - winrt::Windows::Data::Json::JsonValue::CreateStringValue( - Microsoft::Common::Unicode::Utf8ToUtf16(fileSanitized))); - payload.SetNamedValue( - L"methodName", - winrt::Windows::Data::Json::JsonValue::CreateStringValue( - Microsoft::Common::Unicode::Utf8ToUtf16(f.Method))); - payload.SetNamedValue(L"lineNumber", winrt::Windows::Data::Json::JsonValue::CreateNumberValue(f.Line)); - payload.SetNamedValue(L"column", winrt::Windows::Data::Json::JsonValue::CreateNumberValue(f.Column)); - winrt::Windows::Web::Http::HttpStringContent content( - payload.ToString(), - winrt::Windows::Storage::Streams::UnicodeEncoding::Utf8, - L"application/json; charset=utf-8"); - httpClient.TryPostAsync(uri, content); - } - }); - - std::stringstream stackFrameInfo; - stackFrameInfo << frame.File << ":" << frame.Line << ":" << frame.Column; - frameText.Text(Microsoft::Common::Unicode::Utf8ToUtf16(stackFrameInfo.str())); - m_stackPanel.Children().Append(frameContent); - } - } - xaml::Controls::StackPanel m_stackPanelUpper{nullptr}; - xaml::Controls::StackPanel m_stackPanel{nullptr}; - xaml::Controls::Primitives::Popup m_popup{nullptr}; - xaml::Controls::Grid m_redboxContent{nullptr}; - xaml::Controls::Button m_dismissButton{nullptr}; - xaml::Controls::Button m_reloadButton{nullptr}; - xaml::Controls::TextBlock m_errorMessageText{nullptr}; - xaml::Controls::TextBlock m_errorStackText{nullptr}; - - xaml::FrameworkElement::SizeChanged_revoker m_sizeChangedRevoker; - winrt::event_token m_tokenClosed; - winrt::event_token m_tokenDismiss; - winrt::event_token m_tokenReload; + winrt::Windows::Foundation::IAsyncOperation m_dialogAsync { nullptr }; winrt::Microsoft::ReactNative::ReactPropertyBag m_propBag; bool m_showing = false; diff --git a/vnext/Microsoft.ReactNative/Theme.idl b/vnext/Microsoft.ReactNative/Theme.idl index 7dc4d62f981..b03846dd2e5 100644 --- a/vnext/Microsoft.ReactNative/Theme.idl +++ b/vnext/Microsoft.ReactNative/Theme.idl @@ -50,9 +50,7 @@ namespace Microsoft.ReactNative.Composition runtimeclass Theme { Theme(Microsoft.ReactNative.IReactContext reactContext, ICustomResourceLoader resourceLoader); -#ifdef USE_WINUI3 Microsoft.UI.Composition.CompositionBrush PlatformBrush(String platformColor); -#endif Boolean TryGetPlatformColor(String platformColor, out Windows.UI.Color color); DOC_STRING("An empty theme is used when the final theme is not yet known. It will generally return transparent colors.") diff --git a/vnext/Microsoft.ReactNative/Utils/BatchingEventEmitter.cpp b/vnext/Microsoft.ReactNative/Utils/BatchingEventEmitter.cpp deleted file mode 100644 index b2dc71062fd..00000000000 --- a/vnext/Microsoft.ReactNative/Utils/BatchingEventEmitter.cpp +++ /dev/null @@ -1,171 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -#include "pch.h" -#include "BatchingEventEmitter.h" -#include -#include "DynamicWriter.h" -#include "JSValueWriter.h" - -namespace winrt::Microsoft::ReactNative { - -BatchingEventEmitter::BatchingEventEmitter(Mso::CntPtr &&context) noexcept - : m_context(std::move(context)) { - m_uiDispatcher = m_context->Properties().Get(ReactDispatcherHelper::UIDispatcherProperty()).as(); -} - -void BatchingEventEmitter::DispatchEvent( - int64_t tag, - winrt::hstring &&eventName, - const JSValueArgWriter &eventDataWriter) noexcept { - return EmitJSEvent( - L"RCTEventEmitter", - L"receiveEvent", - [tag, eventName = std::move(eventName), eventDataWriter](const IJSValueWriter ¶msWriter) mutable { - paramsWriter.WriteArrayBegin(); - WriteValue(paramsWriter, tag); - WriteValue(paramsWriter, std::move(eventName)); - eventDataWriter(paramsWriter); - paramsWriter.WriteArrayEnd(); - }); -} - -void BatchingEventEmitter::EmitJSEvent( - winrt::hstring &&eventEmitterName, - winrt::hstring &&emitterMethod, - const JSValueArgWriter &eventDataWriter) noexcept { - VerifyElseCrash(m_uiDispatcher.HasThreadAccess()); - - implementation::BatchedEvent newEvent{ - std::move(eventEmitterName), std::move(emitterMethod), L"", 0, DynamicWriter::ToDynamic(eventDataWriter)}; - bool isFirstEventInBatch = false; - - { - std::scoped_lock lock(m_eventQueueMutex); - - isFirstEventInBatch = m_eventQueue.size() == 0; - m_eventQueue.push_back(std::move(newEvent)); - } - - if (isFirstEventInBatch) { - RegisterFrameCallback(); - } -} - -void BatchingEventEmitter::DispatchCoalescingEvent( - int64_t tag, - winrt::hstring &&eventName, - const JSValueArgWriter &eventDataWriter) noexcept { - EmitCoalescingJSEvent( - L"RCTEventEmitter", - L"receiveEvent", - std::move(eventName), - tag, - [tag, eventName, &eventDataWriter](const IJSValueWriter ¶msWriter) { - paramsWriter.WriteArrayBegin(); - WriteValue(paramsWriter, tag); - WriteValue(paramsWriter, std::move(eventName)); - eventDataWriter(paramsWriter); - paramsWriter.WriteArrayEnd(); - }); -} - -void BatchingEventEmitter::EmitCoalescingJSEvent( - winrt::hstring &&eventEmitterName, - winrt::hstring &&emitterMethod, - winrt::hstring &&eventName, - int64_t coalescingKey, - const JSValueArgWriter ¶ms) noexcept { - VerifyElseCrash(m_uiDispatcher.HasThreadAccess()); - - implementation::BatchedEvent newEvent{ - std::move(eventEmitterName), - std::move(emitterMethod), - std::move(eventName), - coalescingKey, - DynamicWriter::ToDynamic(params)}; - bool isFirstEventInBatch = false; - - { - std::scoped_lock lock(m_eventQueueMutex); - - isFirstEventInBatch = m_eventQueue.size() == 0; - - AddOrCoalesceEvent(std::move(newEvent)); - } - - if (isFirstEventInBatch) { - RegisterFrameCallback(); - } -} - -void BatchingEventEmitter::RegisterFrameCallback() noexcept { - VerifyElseCrash(!m_renderingRevoker); - - m_renderingRevoker = xaml::Media::CompositionTarget::Rendering( - winrt::auto_revoke, [weakThis{weak_from_this()}](auto const &, auto const &) { - if (auto strongThis = weakThis.lock()) { - strongThis->OnFrameUI(); - } - }); -} - -size_t BatchingEventEmitter::GetCoalescingEventKey( - const winrt::hstring &eventEmitterName, - const winrt::hstring &emitterMethod, - const winrt::hstring &eventName) { - const auto iter = m_coalescingEventIds.find(std::forward_as_tuple(eventEmitterName, emitterMethod, eventName)); - if (iter == m_coalescingEventIds.end()) { - const auto size = m_coalescingEventIds.size(); - m_coalescingEventIds.insert({std::make_tuple(eventEmitterName, emitterMethod, eventName), size}); - return size; - } - - return iter->second; -} - -void BatchingEventEmitter::AddOrCoalesceEvent(implementation::BatchedEvent &&evt) { - const auto eventId = GetCoalescingEventKey(evt.eventEmitterName, evt.emitterMethod, evt.eventName); - const std::tuple lastEventKey{evt.coalescingKey, eventId}; - const auto iter = m_lastEventIndex.find(lastEventKey); - if (iter == m_lastEventIndex.end()) { - const auto index = m_eventQueue.size(); - m_eventQueue.push_back(std::move(evt)); - m_lastEventIndex.insert({lastEventKey, index}); - } else { - m_eventQueue.at(iter->second).params = std::move(evt.params); - } -} - -void BatchingEventEmitter::OnFrameUI() noexcept { - auto jsDispatcher = m_context->Properties().Get(ReactDispatcherHelper::JSDispatcherProperty()).as(); - - jsDispatcher.Post([weakThis{weak_from_this()}]() noexcept { - if (auto strongThis = weakThis.lock()) { - strongThis->OnFrameJS(); - } - }); - - // Don't leave the callback continuously registered as it can waste power. - // See https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.media.compositiontarget.rendering?view=winrt-22621 - m_renderingRevoker.revoke(); -} - -void BatchingEventEmitter::OnFrameJS() noexcept { - std::deque currentBatch; - - { - std::scoped_lock lock(m_eventQueueMutex); - currentBatch.swap(m_eventQueue); - m_lastEventIndex.clear(); - } - - while (!currentBatch.empty()) { - auto &evt = currentBatch.front(); - m_context->CallJSFunction( - winrt::to_string(evt.eventEmitterName), winrt::to_string(evt.emitterMethod), std::move(evt.params)); - currentBatch.pop_front(); - } -} - -} // namespace winrt::Microsoft::ReactNative diff --git a/vnext/Microsoft.ReactNative/Utils/BatchingEventEmitter.h b/vnext/Microsoft.ReactNative/Utils/BatchingEventEmitter.h deleted file mode 100644 index dc2b47e7fea..00000000000 --- a/vnext/Microsoft.ReactNative/Utils/BatchingEventEmitter.h +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -#pragma once - -#include "JSValue.h" -#include "ReactHost/React.h" -#include "ReactPropertyBag.h" -#include "winrt/Microsoft.ReactNative.h" - -#include -#include - -namespace winrt::Microsoft::ReactNative::implementation { -struct BatchedEvent { - winrt::hstring eventEmitterName; - winrt::hstring emitterMethod; - winrt::hstring eventName; - int64_t coalescingKey; - folly::dynamic params; -}; -} // namespace winrt::Microsoft::ReactNative::implementation - -namespace winrt::Microsoft::ReactNative { - -//! Emits events from native to JS in queued batches (at most once per-native frame). Events within a batch may be -//! coalesced. The batch is finished at the time the JS thread starts to process it. I.e. it is possible for a batch to -//! last for multiple frames if the JS thread is blocked. This is by-design as it allows our coalescing strategy to -//! account for long operations on the JS thread. -struct BatchingEventEmitter : public std::enable_shared_from_this { - public: - BatchingEventEmitter(Mso::CntPtr &&context) noexcept; - - //! Dispatches an event from a view manager. - void DispatchEvent(int64_t tag, winrt::hstring &&eventName, const JSValueArgWriter &eventDataWriter) noexcept; - //! Queues an event to be fired. - void EmitJSEvent( - winrt::hstring &&eventEmitterName, - winrt::hstring &&emitterMethod, - const JSValueArgWriter ¶ms) noexcept; - - //! Dispatches an event from a view manager. Existing events in the batch with the same name and tag will be removed. - void - DispatchCoalescingEvent(int64_t tag, winrt::hstring &&eventName, const JSValueArgWriter &eventDataWriter) noexcept; - //! Queues an event to be fired. Existing events in the batch with the same name and tag will be removed. - void EmitCoalescingJSEvent( - winrt::hstring &&eventEmitterName, - winrt::hstring &&emitterMethod, - winrt::hstring &&eventName, - int64_t coalescingKey, - const JSValueArgWriter ¶ms) noexcept; - - private: - size_t GetCoalescingEventKey( - const winrt::hstring &eventEmitterName, - const winrt::hstring &emitterMethod, - const winrt::hstring &eventName); - void AddOrCoalesceEvent(implementation::BatchedEvent &&event); - void RegisterFrameCallback() noexcept; - void OnFrameUI() noexcept; - void OnFrameJS() noexcept; - - Mso::CntPtr m_context; - std::deque m_eventQueue; - std::map, size_t> m_coalescingEventIds; - std::map, size_t> m_lastEventIndex; - std::mutex m_eventQueueMutex; - xaml::Media::CompositionTarget::Rendering_revoker m_renderingRevoker; - IReactDispatcher m_uiDispatcher; -}; - -} // namespace winrt::Microsoft::ReactNative diff --git a/vnext/Microsoft.ReactNative/Utils/Helpers.cpp b/vnext/Microsoft.ReactNative/Utils/Helpers.cpp index c142bf0baa1..6640bd1ee4f 100644 --- a/vnext/Microsoft.ReactNative/Utils/Helpers.cpp +++ b/vnext/Microsoft.ReactNative/Utils/Helpers.cpp @@ -30,14 +30,6 @@ bool IsAPIContractVxAvailable() { return isAPIContractVxAvailable; } -bool IsAPIContractV5Available() { - return IsAPIContractVxAvailable<5>(); -} - -bool IsAPIContractV6Available() { - return IsAPIContractVxAvailable<6>(); -} - bool IsAPIContractV7Available() { return IsAPIContractVxAvailable<7>(); } @@ -46,18 +38,6 @@ bool IsAPIContractV8Available() { return IsAPIContractVxAvailable<8>(); } -bool IsAPIContractV12Available() { - return IsAPIContractVxAvailable<12>(); -} - -bool IsRS3OrHigher() { - return IsAPIContractV5Available(); -} - -bool IsRS4OrHigher() { - return IsAPIContractV6Available(); -} - bool IsRS5OrHigher() { return IsAPIContractV7Available(); } @@ -66,27 +46,6 @@ bool Is19H1OrHigher() { return IsAPIContractV8Available(); } -bool Is21H1OrHigher() { - return IsAPIContractV12Available(); -} - -bool IsXamlIsland() { - AppPolicyWindowingModel e; - if (FAILED(AppPolicyGetWindowingModel(GetCurrentThreadEffectiveToken(), &e)) || - e == AppPolicyWindowingModel_ClassicDesktop) { - return true; - } - return false; -} - -bool IsWinUI3Island() { -#ifndef USE_WINUI3 - return false; -#else - return IsXamlIsland(); -#endif -} - bool IsFabricEnabled(winrt::Microsoft::ReactNative::IReactPropertyBag const &properties) { return winrt::Microsoft::ReactNative::Composition::implementation::CompositionUIService::GetCompositionContext( properties) != nullptr; diff --git a/vnext/Microsoft.ReactNative/Utils/Helpers.h b/vnext/Microsoft.ReactNative/Utils/Helpers.h index 4aefcd45455..a327dbb6847 100644 --- a/vnext/Microsoft.ReactNative/Utils/Helpers.h +++ b/vnext/Microsoft.ReactNative/Utils/Helpers.h @@ -17,14 +17,9 @@ inline T asEnum(winrt::Microsoft::ReactNative::JSValue const &obj) { return static_cast(obj.AsInt64()); } -bool IsRS3OrHigher(); -bool IsRS4OrHigher(); bool IsRS5OrHigher(); bool Is19H1OrHigher(); -bool Is21H1OrHigher(); -bool IsXamlIsland(); -bool IsWinUI3Island(); bool IsFabricEnabled(winrt::Microsoft::ReactNative::IReactPropertyBag const &properties); } // namespace Microsoft::ReactNative diff --git a/vnext/Microsoft.ReactNative/Utils/KeyboardUtils.cpp b/vnext/Microsoft.ReactNative/Utils/KeyboardUtils.cpp index bc09da471ba..7b5b1987855 100644 --- a/vnext/Microsoft.ReactNative/Utils/KeyboardUtils.cpp +++ b/vnext/Microsoft.ReactNative/Utils/KeyboardUtils.cpp @@ -5,9 +5,7 @@ #include -#ifdef USE_WINUI3 #include -#endif namespace Microsoft::ReactNative { @@ -374,14 +372,7 @@ std::string FromVirtualKey(winrt::Windows::System::VirtualKey virtualKey, bool f } bool IsModifiedKeyPressed(winrt::CoreWindow const &coreWindow, winrt::Windows::System::VirtualKey virtualKey) { -#ifndef USE_WINUI3 - if (!coreWindow) { - return GetKeyState(static_cast(virtualKey)) < 0; - } - auto const &keyState = coreWindow.GetKeyState(virtualKey); -#else auto const &keyState = winrt::Microsoft::UI::Input::InputKeyboardSource::GetKeyStateForCurrentThread(virtualKey); -#endif // USE_WINUI3 return (keyState & winrt::CoreVirtualKeyStates::Down) == winrt::CoreVirtualKeyStates::Down; } diff --git a/vnext/Microsoft.ReactNative/Utils/PropertyHandlerUtils.h b/vnext/Microsoft.ReactNative/Utils/PropertyHandlerUtils.h deleted file mode 100644 index cf1c12b7e11..00000000000 --- a/vnext/Microsoft.ReactNative/Utils/PropertyHandlerUtils.h +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -#pragma once - -#include -#include -#include -#include -#include - -#ifdef _M_IX86 - -#define CALL_MEMBER(FUNC) \ - FUNC(__cdecl) \ - FUNC(__stdcall) \ - FUNC(__thiscall) \ - FUNC(__vectorcall) -#define CALL_NON_MEMBER(FUNC) \ - FUNC(__cdecl) \ - FUNC(__stdcall) \ - FUNC(__vectorcall) -#else -#define CALL_MEMBER(FUNC) FUNC(__cdecl) -#define CALL_NON_MEMBER(FUNC) FUNC(__cdecl) -#endif - -template -struct get_argument_type_impl; - -#define GET_ARGUMENT_TYPE_IMPL(CALL_OPT) \ - template \ - struct get_argument_type_impl { \ - typedef typename std::tuple_element>::type type; \ - }; - -CALL_NON_MEMBER(GET_ARGUMENT_TYPE_IMPL) -#undef GET_ARGUMENT_TYPE_IMPL - -#define GET_ARGUMENT_TYPE_IMPL(CALL_OPT) \ - template \ - struct get_argument_type_impl { \ - typedef typename std::tuple_element>::type type; \ - }; - -CALL_MEMBER(GET_ARGUMENT_TYPE_IMPL) -#undef GET_ARGUMENT_TYPE_IMPL - -template -struct get_argument_type { - typedef typename get_argument_type_impl::type type; -}; - -template -struct json_type_traits; - -template -struct json_type_traits> { - static std::vector parseJson(const winrt::Microsoft::ReactNative::JSValue &obj) { - std::vector result; - for (const auto &item : obj.AsArray()) { - result.push_back(json_type_traits::parseJson(item)); - } - return result; - } -}; - -template <> -struct json_type_traits { - static const winrt::Microsoft::ReactNative::JSValue &parseJson(const winrt::Microsoft::ReactNative::JSValue &obj) { - return obj; - } -}; - -template <> -struct json_type_traits { - static double parseJson(const winrt::Microsoft::ReactNative::JSValue &obj) { - return obj.AsDouble(); - } -}; - -template <> -struct json_type_traits { - static std::string parseJson(const winrt::Microsoft::ReactNative::JSValue &obj) { - return obj.AsString(); - } -}; diff --git a/vnext/Microsoft.ReactNative/Utils/PropertyUtils.h b/vnext/Microsoft.ReactNative/Utils/PropertyUtils.h deleted file mode 100644 index c9c5e87f27d..00000000000 --- a/vnext/Microsoft.ReactNative/Utils/PropertyUtils.h +++ /dev/null @@ -1,568 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -#pragma once - -#include -#include -#include - -#include -#include -#include -#include - -#include - -namespace Microsoft::ReactNative { - -static double DefaultOrOverride(double defaultValue, double x) { - return x != c_UndefinedEdge ? x : defaultValue; -}; - -static double DefaultOrOverrideWithClamp(double defaultValue, double x, double clamp) { - return std::min(DefaultOrOverride(defaultValue, x), clamp); -}; - -static const std::unordered_map edgeTypeMap = { - {"borderLeftWidth", ShadowEdges::Left}, - {"borderTopWidth", ShadowEdges::Top}, - {"borderRightWidth", ShadowEdges::Right}, - {"borderBottomWidth", ShadowEdges::Bottom}, - {"borderStartWidth", ShadowEdges::Start}, - {"borderEndWidth", ShadowEdges::End}, - {"borderWidth", ShadowEdges::AllEdges}, -}; - -inline xaml::Thickness GetThickness(double thicknesses[(int)ShadowEdges::CountEdges]) { - const double defaultWidth = std::max(0, thicknesses[(int)ShadowEdges::AllEdges]); - double startWidth = DefaultOrOverride(thicknesses[(int)ShadowEdges::Left], thicknesses[(int)ShadowEdges::Start]); - double endWidth = DefaultOrOverride(thicknesses[(int)ShadowEdges::Right], thicknesses[(int)ShadowEdges::End]); - - // Compute each edge. Most specific setting wins, so fill from broad to - // narrow: all, horiz/vert, start/end, left/right - xaml::Thickness thickness = {defaultWidth, defaultWidth, defaultWidth, defaultWidth}; - - if (thicknesses[(int)ShadowEdges::Horizontal] != c_UndefinedEdge) - thickness.Left = thickness.Right = thicknesses[(int)ShadowEdges::Horizontal]; - if (thicknesses[(int)ShadowEdges::Vertical] != c_UndefinedEdge) - thickness.Top = thickness.Bottom = thicknesses[(int)ShadowEdges::Vertical]; - - if (startWidth != c_UndefinedEdge) - thickness.Left = startWidth; - if (endWidth != c_UndefinedEdge) - thickness.Right = endWidth; - if (thicknesses[(int)ShadowEdges::Top] != c_UndefinedEdge) - thickness.Top = thicknesses[(int)ShadowEdges::Top]; - if (thicknesses[(int)ShadowEdges::Bottom] != c_UndefinedEdge) - thickness.Bottom = thicknesses[(int)ShadowEdges::Bottom]; - - return thickness; -} - -inline xaml::CornerRadius GetCornerRadius( - double cornerRadii[(int)ShadowCorners::CountCorners], - double maxCornerRadius) { - xaml::CornerRadius cornerRadius; - const double defaultRadius = std::max(0, cornerRadii[(int)ShadowCorners::AllCorners]); - double topStartRadius = - DefaultOrOverride(cornerRadii[(int)ShadowCorners::TopLeft], cornerRadii[(int)ShadowCorners::TopStart]); - double topEndRadius = - DefaultOrOverride(cornerRadii[(int)ShadowCorners::TopRight], cornerRadii[(int)ShadowCorners::TopEnd]); - double bottomStartRadius = - DefaultOrOverride(cornerRadii[(int)ShadowCorners::BottomLeft], cornerRadii[(int)ShadowCorners::BottomStart]); - double bottomEndRadius = - DefaultOrOverride(cornerRadii[(int)ShadowCorners::BottomRight], cornerRadii[(int)ShadowCorners::BottomEnd]); - - // These values are clamped to 50% of the minimum of width or height - // dimension for cross-platform consistency with iOS, Android, and Web. We - // should revisit this clamping behavior if RN ever supports percentage - // values for the borderRadius prop as the default XAML behavior is - // consistent with Web behavior in this case. - cornerRadius.TopLeft = DefaultOrOverrideWithClamp(defaultRadius, topStartRadius, maxCornerRadius); - cornerRadius.TopRight = DefaultOrOverrideWithClamp(defaultRadius, topEndRadius, maxCornerRadius); - cornerRadius.BottomLeft = DefaultOrOverrideWithClamp(defaultRadius, bottomStartRadius, maxCornerRadius); - cornerRadius.BottomRight = DefaultOrOverrideWithClamp(defaultRadius, bottomEndRadius, maxCornerRadius); - - return cornerRadius; -} - -template -void UpdatePadding(ShadowNodeBase *node, const T &element, ShadowEdges edge, double margin) { - node->m_padding[(int)edge] = margin; - xaml::Thickness thickness = GetThickness(node->m_padding); - element.Padding(thickness); -} - -template -void SetBorderThickness(ShadowNodeBase *node, const T &element, ShadowEdges edge, double margin) { - node->m_border[(int)edge] = margin; - xaml::Thickness thickness = GetThickness(node->m_border); - element.BorderThickness(thickness); -} - -template -void SetBorderBrush(const T &element, const xaml::Media::Brush &brush) { - element.BorderBrush(brush); -} - -template -bool TryUpdateBackgroundBrush( - const T &element, - const std::string &propertyName, - const winrt::Microsoft::ReactNative::JSValue &propertyValue) { - if (propertyName == "backgroundColor") { - if (IsValidColorValue(propertyValue)) { - const auto brush = BrushFrom(propertyValue); - element.Background(brush); - UpdateControlBackgroundResourceBrushes(element, brush); - } else if (propertyValue.IsNull()) { - element.ClearValue(T::BackgroundProperty()); - UpdateControlBackgroundResourceBrushes(element, nullptr); - } - - return true; - } - - return false; -} - -inline void UpdateCornerRadiusValueOnNode( - ShadowNodeBase *node, - ShadowCorners corner, - const winrt::Microsoft::ReactNative::JSValue &propertyValue) { - if (propertyValue.Type() == winrt::Microsoft::ReactNative::JSValueType::Double || - propertyValue.Type() == winrt::Microsoft::ReactNative::JSValueType::Int64) - node->m_cornerRadius[(int)corner] = propertyValue.AsDouble(); - else - node->m_cornerRadius[(int)corner] = c_UndefinedEdge; -} - -template -void UpdateCornerRadiusOnElement(ShadowNodeBase *node, const T &element, double maxCornerRadius) { - xaml::CornerRadius cornerRadius = GetCornerRadius(node->m_cornerRadius, maxCornerRadius); - element.CornerRadius(cornerRadius); -} - -template -void UpdateCornerRadiusOnElement(ShadowNodeBase *node, const T &element) { - auto maxCornerRadius = std::numeric_limits::max(); - if (element.ReadLocalValue(xaml::FrameworkElement::WidthProperty()) != xaml::DependencyProperty::UnsetValue() && - element.ReadLocalValue(xaml::FrameworkElement::HeightProperty()) != xaml::DependencyProperty::UnsetValue()) { - // Clamp CornerRadius to 50% of the minimum dimension between width and height. - maxCornerRadius = std::min(element.Width(), element.Height()) / 2; - } - UpdateCornerRadiusOnElement(node, element, maxCornerRadius); -} - -template -bool TryUpdateForeground( - const T &element, - const std::string &propertyName, - const winrt::Microsoft::ReactNative::JSValue &propertyValue) { - if (propertyName == "color") { - auto uielement = element.try_as(); - if (IsValidColorValue(propertyValue)) { - const auto brush = BrushFrom(propertyValue); - element.Foreground(brush); - UpdateControlForegroundResourceBrushes(element, brush); - if (uielement) { - uielement.HighContrastAdjustment(xaml::ElementHighContrastAdjustment::None); - } - } else if (propertyValue.IsNull()) { - element.ClearValue(T::ForegroundProperty()); - if (uielement) { - uielement.HighContrastAdjustment(xaml::ElementHighContrastAdjustment::Application); - } - UpdateControlForegroundResourceBrushes(element, nullptr); - } - - return true; - } - - return false; -} - -template -bool TryUpdateBorderProperties( - ShadowNodeBase *node, - const T &element, - const std::string &propertyName, - const winrt::Microsoft::ReactNative::JSValue &propertyValue) { - bool isBorderProperty = true; - - if (propertyName == "borderColor") { - if (IsValidColorValue(propertyValue)) { - const auto brush = BrushFrom(propertyValue); - element.BorderBrush(brush); - UpdateControlBorderResourceBrushes(element, brush); - } else if (propertyValue.IsNull()) { - // If there's still a border thickness, use the default border brush. - if (element.BorderThickness() != xaml::ThicknessHelper::FromUniformLength(0.0)) { - element.BorderBrush(DefaultBrushStore::Instance().GetDefaultBorderBrush()); - } else { - element.ClearValue(T::BorderBrushProperty()); - } - UpdateControlBorderResourceBrushes(element, nullptr); - } - } else { - auto iter = edgeTypeMap.find(propertyName); - if (iter != edgeTypeMap.end()) { - if (propertyValue.Type() == winrt::Microsoft::ReactNative::JSValueType::Double || - propertyValue.Type() == winrt::Microsoft::ReactNative::JSValueType::Int64) { - SetBorderThickness(node, element, iter->second, propertyValue.AsDouble()); - if (propertyValue.AsDouble() != 0 && !element.BorderBrush()) { - // Borders with no brush draw something other than transparent on other platforms. - // To match, we'll use a default border brush if one isn't already set. - // Note: Keep this in sync with code in ViewPanel::FinalizeProperties(). - element.BorderBrush(DefaultBrushStore::Instance().GetDefaultBorderBrush()); - } - } else if (propertyValue.IsNull()) { - SetBorderThickness(node, element, iter->second, 0); - } - } else { - isBorderProperty = false; - } - } - - return isBorderProperty; -} - -template -bool TryUpdatePadding( - ShadowNodeBase *node, - const T &element, - const std::string &propertyName, - const winrt::Microsoft::ReactNative::JSValue &propertyValue) { - bool isPaddingProperty = true; - - if (propertyName == "paddingLeft") { - if (propertyValue.Type() == winrt::Microsoft::ReactNative::JSValueType::Double || - propertyValue.Type() == winrt::Microsoft::ReactNative::JSValueType::Int64) - UpdatePadding(node, element, ShadowEdges::Left, propertyValue.AsDouble()); - } else if (propertyName == "paddingTop") { - if (propertyValue.Type() == winrt::Microsoft::ReactNative::JSValueType::Double || - propertyValue.Type() == winrt::Microsoft::ReactNative::JSValueType::Int64) - UpdatePadding(node, element, ShadowEdges::Top, propertyValue.AsDouble()); - } else if (propertyName == "paddingRight") { - if (propertyValue.Type() == winrt::Microsoft::ReactNative::JSValueType::Double || - propertyValue.Type() == winrt::Microsoft::ReactNative::JSValueType::Int64) - UpdatePadding(node, element, ShadowEdges::Right, propertyValue.AsDouble()); - } else if (propertyName == "paddingBottom") { - if (propertyValue.Type() == winrt::Microsoft::ReactNative::JSValueType::Double || - propertyValue.Type() == winrt::Microsoft::ReactNative::JSValueType::Int64) - UpdatePadding(node, element, ShadowEdges::Bottom, propertyValue.AsDouble()); - } else if (propertyName == "paddingStart") { - if (propertyValue.Type() == winrt::Microsoft::ReactNative::JSValueType::Double || - propertyValue.Type() == winrt::Microsoft::ReactNative::JSValueType::Int64) - UpdatePadding(node, element, ShadowEdges::Start, propertyValue.AsDouble()); - } else if (propertyName == "paddingEnd") { - if (propertyValue.Type() == winrt::Microsoft::ReactNative::JSValueType::Double || - propertyValue.Type() == winrt::Microsoft::ReactNative::JSValueType::Int64) - UpdatePadding(node, element, ShadowEdges::End, propertyValue.AsDouble()); - } else if (propertyName == "paddingHorizontal") { - if (propertyValue.Type() == winrt::Microsoft::ReactNative::JSValueType::Double || - propertyValue.Type() == winrt::Microsoft::ReactNative::JSValueType::Int64) - UpdatePadding(node, element, ShadowEdges::Horizontal, propertyValue.AsDouble()); - } else if (propertyName == "paddingVertical") { - if (propertyValue.Type() == winrt::Microsoft::ReactNative::JSValueType::Double || - propertyValue.Type() == winrt::Microsoft::ReactNative::JSValueType::Int64) - UpdatePadding(node, element, ShadowEdges::Vertical, propertyValue.AsDouble()); - } else if (propertyName == "padding") { - if (propertyValue.Type() == winrt::Microsoft::ReactNative::JSValueType::Double || - propertyValue.Type() == winrt::Microsoft::ReactNative::JSValueType::Int64) - UpdatePadding(node, element, ShadowEdges::AllEdges, propertyValue.AsDouble()); - } else { - isPaddingProperty = false; - } - - return isPaddingProperty; -} - -template -bool TryUpdateCornerRadiusOnNode( - ShadowNodeBase *node, - const T & /*element*/, - const std::string &propertyName, - const winrt::Microsoft::ReactNative::JSValue &propertyValue) { - if (propertyName == "borderTopLeftRadius") { - UpdateCornerRadiusValueOnNode(node, ShadowCorners::TopLeft, propertyValue); - } else if (propertyName == "borderTopRightRadius") { - UpdateCornerRadiusValueOnNode(node, ShadowCorners::TopRight, propertyValue); - } else if (propertyName == "borderTopStartRadius") { - UpdateCornerRadiusValueOnNode(node, ShadowCorners::TopStart, propertyValue); - } else if (propertyName == "borderTopEndRadius") { - UpdateCornerRadiusValueOnNode(node, ShadowCorners::TopEnd, propertyValue); - } else if (propertyName == "borderBottomRightRadius") { - UpdateCornerRadiusValueOnNode(node, ShadowCorners::BottomRight, propertyValue); - } else if (propertyName == "borderBottomLeftRadius") { - UpdateCornerRadiusValueOnNode(node, ShadowCorners::BottomLeft, propertyValue); - } else if (propertyName == "borderBottomStartRadius") { - UpdateCornerRadiusValueOnNode(node, ShadowCorners::BottomStart, propertyValue); - } else if (propertyName == "borderBottomEndRadius") { - UpdateCornerRadiusValueOnNode(node, ShadowCorners::BottomEnd, propertyValue); - } else if (propertyName == "borderRadius") { - UpdateCornerRadiusValueOnNode(node, ShadowCorners::AllCorners, propertyValue); - } else { - return false; - } - - return true; -} - -template -bool TryUpdateFontProperties( - const T &element, - const std::string &propertyName, - const winrt::Microsoft::ReactNative::JSValue &propertyValue) { - bool isFontProperty = true; - - if (propertyName == "fontSize") { - if (propertyValue.Type() == winrt::Microsoft::ReactNative::JSValueType::Double || - propertyValue.Type() == winrt::Microsoft::ReactNative::JSValueType::Int64) - element.FontSize(propertyValue.AsDouble()); - else if (propertyValue.IsNull()) - element.ClearValue(T::FontSizeProperty()); - } else if (propertyName == "fontFamily") { - if (propertyValue.Type() == winrt::Microsoft::ReactNative::JSValueType::String) - element.FontFamily(xaml::Media::FontFamily(Microsoft::Common::Unicode::Utf8ToUtf16(propertyValue.AsString()))); - else if (propertyValue.IsNull()) - element.ClearValue(T::FontFamilyProperty()); - } else if (propertyName == "fontWeight") { - if (propertyValue.Type() == winrt::Microsoft::ReactNative::JSValueType::String) { - const std::string &value = propertyValue.AsString(); - winrt::Windows::UI::Text::FontWeight fontWeight; - if (value == "normal") - fontWeight = text::FontWeights::Normal(); - else if (value == "bold") - fontWeight = text::FontWeights::Bold(); - else if (value == "100") - fontWeight.Weight = 100; - else if (value == "200") - fontWeight.Weight = 200; - else if (value == "300") - fontWeight.Weight = 300; - else if (value == "400") - fontWeight.Weight = 400; - else if (value == "500") - fontWeight.Weight = 500; - else if (value == "600") - fontWeight.Weight = 600; - else if (value == "700") - fontWeight.Weight = 700; - else if (value == "800") - fontWeight.Weight = 800; - else if (value == "900") - fontWeight.Weight = 900; - else - fontWeight = text::FontWeights::Normal(); - - element.FontWeight(fontWeight); - } else if (propertyValue.IsNull()) { - element.ClearValue(T::FontWeightProperty()); - } - } else if (propertyName == "fontStyle") { - if (propertyValue.Type() == winrt::Microsoft::ReactNative::JSValueType::String) { - element.FontStyle((propertyValue.AsString() == "italic") ? text::FontStyle::Italic : text::FontStyle::Normal); - } else if (propertyValue.IsNull()) { - element.ClearValue(T::FontStyleProperty()); - } - - } else { - isFontProperty = false; - } - - return isFontProperty; -} - -template -void SetTextAlignment(const T &element, const std::string &value) { - if (value == "left") - element.TextAlignment(xaml::TextAlignment::Left); - else if (value == "right") - element.TextAlignment(xaml::TextAlignment::Right); - else if (value == "center") - element.TextAlignment(xaml::TextAlignment::Center); - else if (value == "justify") - element.TextAlignment(xaml::TextAlignment::Justify); - else - element.TextAlignment(xaml::TextAlignment::DetectFromContent); -} - -template -bool TryUpdateTextAlignment( - const T &element, - const std::string &propertyName, - const winrt::Microsoft::ReactNative::JSValue &propertyValue) { - if (propertyName == "textAlign") { - if (propertyValue.Type() == winrt::Microsoft::ReactNative::JSValueType::String) { - const std::string &value = propertyValue.AsString(); - SetTextAlignment(element, value); - } else if (propertyValue.IsNull()) { - element.ClearValue(T::TextAlignmentProperty()); - } - - return true; - } - - return false; -} - -template -void SetTextTrimming(const T &element, const std::string &value) { - if (value == "clip") - element.TextTrimming(xaml::TextTrimming::Clip); - else if (value == "head" || value == "middle" || value == "tail") { - // "head" and "middle" not supported by UWP, but "tail" - // behavior is the most similar - element.TextTrimming(xaml::TextTrimming::CharacterEllipsis); - } else - element.TextTrimming(xaml::TextTrimming::None); -} - -template -bool TryUpdateTextTrimming( - const T &element, - const std::string &propertyName, - const winrt::Microsoft::ReactNative::JSValue &propertyValue) { - if (propertyName == "ellipsizeMode") { - if (propertyValue.Type() == winrt::Microsoft::ReactNative::JSValueType::String) { - const std::string &value = propertyValue.AsString(); - SetTextTrimming(element, value); - } else if (propertyValue.IsNull()) { - element.ClearValue(T::TextTrimmingProperty()); - } - - return true; - } - - return false; -} - -template -bool TryUpdateTextDecorationLine( - const T &element, - const std::string &propertyName, - const winrt::Microsoft::ReactNative::JSValue &propertyValue) { - if (propertyName == "textDecorationLine") { - // FUTURE: remove when SDK target minVer >= 10.0.15063.0 - static bool isTextDecorationsSupported = -#ifndef USE_WINUI3 - winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent( - XAML_NAMESPACE_STR L".Controls.TextBlock", L"TextDecorations"); -#else - true; -#endif - if (!isTextDecorationsSupported) - return true; - - if (propertyValue.Type() == winrt::Microsoft::ReactNative::JSValueType::String) { - using winrt::Windows::UI::Text::TextDecorations; - - const std::string &value = propertyValue.AsString(); - TextDecorations decorations = TextDecorations::None; - if (value == "none") { - decorations = TextDecorations::None; - } else if (value == "underline") { - decorations = TextDecorations::Underline; - } else if (value == "line-through") { - decorations = TextDecorations::Strikethrough; - } else if (value == "underline line-through") { - decorations = TextDecorations::Underline | TextDecorations::Strikethrough; - } - - element.TextDecorations(decorations); - } else if (propertyValue.IsNull()) { - element.ClearValue(T::TextDecorationsProperty()); - } - - return true; - } - - return false; -} - -template -void SetFlowDirection(const T &element, const std::string &value) { - if (value == "rtl") - element.FlowDirection(xaml::FlowDirection::RightToLeft); - else if (value == "ltr") - element.FlowDirection(xaml::FlowDirection::LeftToRight); - else // 'auto', 'inherit' - element.ClearValue(xaml::FrameworkElement::FlowDirectionProperty()); -} - -template -bool TryUpdateFlowDirection( - const T &element, - const std::string &propertyName, - const winrt::Microsoft::ReactNative::JSValue &propertyValue) { - if ((propertyName == "writingDirection") || (propertyName == "direction")) { - if (propertyValue.Type() == winrt::Microsoft::ReactNative::JSValueType::String) { - const std::string &value = propertyValue.AsString(); - SetFlowDirection(element, value); - } else if (propertyValue.IsNull()) { - element.ClearValue(T::FlowDirectionProperty()); - } - - return true; - } - - return false; -} - -template -bool TryUpdateCharacterSpacing( - const T &element, - const std::string &propertyName, - const winrt::Microsoft::ReactNative::JSValue &propertyValue) { - if (propertyName == "letterSpacing" || propertyName == "characterSpacing") { - if (propertyValue.Type() == winrt::Microsoft::ReactNative::JSValueType::Double || - propertyValue.Type() == winrt::Microsoft::ReactNative::JSValueType::Int64) - element.CharacterSpacing(propertyValue.AsInt32()); - else if (propertyValue.IsNull()) - element.ClearValue(T::CharacterSpacingProperty()); - - return true; - } - - return false; -} - -template -bool TryUpdateOrientation( - const T &element, - const std::string &propertyName, - const winrt::Microsoft::ReactNative::JSValue &propertyValue) { - if (propertyName == "orientation") { - if (propertyValue.IsNull()) { - element.ClearValue(T::OrientationProperty()); - } else if (propertyValue.Type() == winrt::Microsoft::ReactNative::JSValueType::String) { - const std::string &valueString = propertyValue.AsString(); - if (valueString == "horizontal") - element.Orientation(xaml::Controls::Orientation::Horizontal); - else if (valueString == "vertical") - element.Orientation(xaml::Controls::Orientation::Vertical); - } - - return true; - } - - return false; -} - -inline bool TryUpdateMouseEvents( - ShadowNodeBase *node, - const std::string &propertyName, - const winrt::Microsoft::ReactNative::JSValue &propertyValue) { - if (propertyName == "onMouseEnter") - node->m_onMouseEnterRegistered = propertyValue.AsBoolean(); - else if (propertyName == "onMouseLeave") - node->m_onMouseLeaveRegistered = propertyValue.AsBoolean(); - else - return false; - - return true; -} - -} // namespace Microsoft::ReactNative diff --git a/vnext/Microsoft.ReactNative/Utils/ResourceBrushUtils.cpp b/vnext/Microsoft.ReactNative/Utils/ResourceBrushUtils.cpp deleted file mode 100644 index 0ee6b4cde20..00000000000 --- a/vnext/Microsoft.ReactNative/Utils/ResourceBrushUtils.cpp +++ /dev/null @@ -1,182 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -#include "pch.h" -#include -#include - -namespace Microsoft::ReactNative { - -DefaultBrushStore::DefaultBrushStore() {} - -DefaultBrushStore &DefaultBrushStore::Instance() { - thread_local static DefaultBrushStore instance; - return instance; -} - -void DefaultBrushStore::Reset() { - m_defaultBorderBrush = nullptr; -} - -xaml::Media::Brush DefaultBrushStore::GetDefaultBorderBrush() { - if (!m_defaultBorderBrush) { - m_defaultBorderBrush = xaml::Application::Current() - .Resources() - .Lookup(winrt::box_value(L"DefaultTextForegroundThemeBrush")) - .as(); - } - - return m_defaultBorderBrush; -} - -void UpdateResourceBrush( - const xaml::FrameworkElement &element, - const std::wstring &resourceName, - const xaml::Media::Brush brush) { - const auto resources = element.Resources(); - if (resources != nullptr) { - if (brush != nullptr) { - resources.Insert(winrt::box_value(resourceName), brush); - } else { - resources.Remove(winrt::box_value(resourceName)); - } - } -} - -void UpdateToggleResourceBrush( - const xaml::FrameworkElement &element, - const std::wstring &resourceName, - const xaml::Media::Brush brush) { - // check for null pointers - if (const auto resources = element.Resources()) { - if (brush) { - // check if resources has key - if (resources.HasKey(winrt::box_value(resourceName))) { - auto resourceBrush = resources.Lookup(winrt::box_value(resourceName)); - // if both the old Resource Brush and new Resource Brush is a SolidColorBrush, change the color of the brush to - // support runtime changes - auto colorBrush = brush.try_as(); - auto resourceColorBrush = resourceBrush.try_as(); - if (colorBrush && resourceColorBrush) - resourceColorBrush.Color(colorBrush.Color()); - else - resources.Insert(winrt::box_value(resourceName), brush); - } else { - // else, add the new brush to the resource directory (will need to reload component to see changes) - resources.Insert(winrt::box_value(resourceName), brush); - } - // if the brush is null, remove the resource - } else { - resources.Remove(winrt::box_value(resourceName)); - } - } -} - -void UpdateTextControlBackgroundResourceBrushes(const xaml::FrameworkElement &element, const xaml::Media::Brush brush) { - UpdateResourceBrush(element, c_textControlBackground, brush); - UpdateResourceBrush(element, c_textControlBackgroundPointerOver, brush); - UpdateResourceBrush(element, c_textControlBackgroundFocused, brush); - UpdateResourceBrush(element, c_textControlBackgroundDisabled, brush); - - UpdateResourceBrush(element, c_textControlButtonForegroundPressed, brush); -} - -void UpdateTextControlForegroundResourceBrushes(const xaml::FrameworkElement element, const xaml::Media::Brush brush) { - UpdateResourceBrush(element, c_textControlForeground, brush); - UpdateResourceBrush(element, c_textControlForegroundPointerOver, brush); - UpdateResourceBrush(element, c_textControlForegroundFocused, brush); - UpdateResourceBrush(element, c_textControlForegroundDisabled, brush); - - UpdateResourceBrush(element, c_textControlButtonForeground, brush); - UpdateResourceBrush(element, c_textControlButtonForegroundPointerOver, brush); - UpdateResourceBrush(element, c_textControlButtonBackgroundPressed, brush); -} - -void UpdateTextControlBorderResourceBrushes(const xaml::FrameworkElement &element, const xaml::Media::Brush &b) { - // Workaround for bug https://microsoft.visualstudio.com/OS/_workitems/edit/26118890. - // Remove when the bug gets fixed. - xaml::Media::Brush brush = b; - if (auto solidBrush = b.as()) { - brush = xaml::Media::SolidColorBrush{solidBrush.Color()}; - } - - UpdateResourceBrush(element, c_textControlBorderBrush, brush); - UpdateResourceBrush(element, c_textControlBorderBrushPointerOver, brush); - UpdateResourceBrush(element, c_textControlBorderBrushFocused, brush); - UpdateResourceBrush(element, c_textControlBorderBrushDisabled, brush); -} - -void UpdateToggleSwitchBorderResourceBrushes( - const xaml::Controls::ToggleSwitch &toggleSwitch, - const xaml::Media::Brush brush) { - UpdateResourceBrush(toggleSwitch, c_toggleSwitchStrokeOff, brush); - UpdateResourceBrush(toggleSwitch, c_toggleSwitchStrokeOffPointerOver, brush); - UpdateResourceBrush(toggleSwitch, c_toggleSwitchStrokeOffPressed, brush); - UpdateResourceBrush(toggleSwitch, c_toggleSwitchStrokeOffDisabled, brush); - UpdateResourceBrush(toggleSwitch, c_toggleSwitchStrokeOn, brush); - UpdateResourceBrush(toggleSwitch, c_toggleSwitchStrokeOnPointerOver, brush); - UpdateResourceBrush(toggleSwitch, c_toggleSwitchStrokeOnPressed, brush); - UpdateResourceBrush(toggleSwitch, c_toggleSwitchStrokeOnDisabled, brush); -} - -void UpdateToggleSwitchThumbResourceBrushes( - const xaml::Controls::ToggleSwitch &toggleSwitch, - const xaml::Media::Brush thumbBrush) { - UpdateToggleResourceBrush(toggleSwitch, c_toggleSwitchKnobFillOff, thumbBrush); - UpdateToggleResourceBrush(toggleSwitch, c_toggleSwitchKnobFillOffPointerOver, thumbBrush); - UpdateToggleResourceBrush(toggleSwitch, c_toggleSwitchKnobFillOffPressed, thumbBrush); - UpdateToggleResourceBrush(toggleSwitch, c_toggleSwitchKnobFillOffDisabled, thumbBrush); - - UpdateToggleResourceBrush(toggleSwitch, c_toggleSwitchKnobFillOn, thumbBrush); - UpdateToggleResourceBrush(toggleSwitch, c_toggleSwitchKnobFillOnPointerOver, thumbBrush); - UpdateToggleResourceBrush(toggleSwitch, c_toggleSwitchKnobFillOnPressed, thumbBrush); - UpdateToggleResourceBrush(toggleSwitch, c_toggleSwitchKnobFillOnDisabled, thumbBrush); -} - -void UpdateToggleSwitchTrackResourceBrushesOn( - const xaml::Controls::ToggleSwitch &toggleSwitch, - const xaml::Media::Brush onTrackBrush) { - UpdateToggleResourceBrush(toggleSwitch, c_toggleSwitchFillOn, onTrackBrush); - UpdateToggleResourceBrush(toggleSwitch, c_toggleSwitchFillOnPointerOver, onTrackBrush); - UpdateToggleResourceBrush(toggleSwitch, c_toggleSwitchFillOnPressed, onTrackBrush); - UpdateToggleResourceBrush(toggleSwitch, c_toggleSwitchFillOnDisabled, onTrackBrush); -} - -void UpdateToggleSwitchTrackResourceBrushesOff( - const xaml::Controls::ToggleSwitch &toggleSwitch, - const xaml::Media::Brush offTrackBrush) { - UpdateToggleResourceBrush(toggleSwitch, c_toggleSwitchFillOff, offTrackBrush); - UpdateToggleResourceBrush(toggleSwitch, c_toggleSwitchFillOffPointerOver, offTrackBrush); - UpdateToggleResourceBrush(toggleSwitch, c_toggleSwitchFillOffPressed, offTrackBrush); - UpdateToggleResourceBrush(toggleSwitch, c_toggleSwitchFillOffDisabled, offTrackBrush); -} - -bool IsObjectATextControl(const xaml::DependencyObject &object) { - return object.try_as() != nullptr || - object.try_as() != nullptr || - object.try_as() != nullptr || - object.try_as() != nullptr; -} - -void UpdateControlBackgroundResourceBrushes(const xaml::FrameworkElement &element, const xaml::Media::Brush brush) { - if (IsObjectATextControl(element)) { - UpdateTextControlBackgroundResourceBrushes(element, brush); - } -} - -void UpdateControlForegroundResourceBrushes(const xaml::DependencyObject object, const xaml::Media::Brush brush) { - if (IsObjectATextControl(object)) { - const auto element = object.try_as(); - UpdateTextControlForegroundResourceBrushes(element, brush); - } -} - -void UpdateControlBorderResourceBrushes(const xaml::FrameworkElement &element, const xaml::Media::Brush brush) { - if (IsObjectATextControl(element)) { - UpdateTextControlBorderResourceBrushes(element, brush); - } else if (const auto toggleSwitch = element.try_as()) { - UpdateToggleSwitchBorderResourceBrushes(toggleSwitch, brush); - } -} - -} // namespace Microsoft::ReactNative diff --git a/vnext/Microsoft.ReactNative/Utils/ResourceBrushUtils.h b/vnext/Microsoft.ReactNative/Utils/ResourceBrushUtils.h deleted file mode 100644 index d63724e44fe..00000000000 --- a/vnext/Microsoft.ReactNative/Utils/ResourceBrushUtils.h +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -#pragma once -#include -#include "CppWinRTIncludes.h" - -namespace Microsoft::ReactNative { - -// Helper per-UI-thread singleton class to cache brushes used as defaults. -class DefaultBrushStore { - public: - static DefaultBrushStore &Instance(); - void Reset(); - - xaml::Media::Brush GetDefaultBorderBrush(); - - private: - DefaultBrushStore(); - DefaultBrushStore(const DefaultBrushStore &) = delete; - void operator=(const DefaultBrushStore &) = delete; - - xaml::Media::Brush m_defaultBorderBrush = nullptr; -}; - -// Some XAML controls use additional resource-brushes that need to be -// kept in sync with the Background, Foreground, and BorderBrush -// DependencyProperties. RN clients (windows-included) that -// want different backgroundColor, color, or borderColor -// depending on interactive states (e.g. PointerOver, Focused, -// and Disabled), expect to handle these state changes in js by -// re-rendering with different props in response to state -// change events (onFocus, onBlur, onMouseEnter, onMouseLeave) -// or when changing enabled/disabled props. -void UpdateControlBackgroundResourceBrushes(const xaml::FrameworkElement &element, const xaml::Media::Brush brush); - -void UpdateControlForegroundResourceBrushes(const xaml::DependencyObject object, const xaml::Media::Brush brush); - -void UpdateControlBorderResourceBrushes(const xaml::FrameworkElement &element, const xaml::Media::Brush brush); - -void UpdateToggleSwitchThumbResourceBrushes( - const xaml::Controls::ToggleSwitch &toggleSwitch, - const xaml::Media::Brush thumbBrush); - -void UpdateToggleSwitchTrackResourceBrushesOn( - const xaml::Controls::ToggleSwitch &toggleSwitch, - const xaml::Media::Brush onTrackBrush); - -void UpdateToggleSwitchTrackResourceBrushesOff( - const xaml::Controls::ToggleSwitch &toggleSwitch, - const xaml::Media::Brush offTrackBrush); - -void UpdateResourceBrush( - const xaml::FrameworkElement &element, - const std::wstring &resourceName, - const xaml::Media::Brush brush); - -} // namespace Microsoft::ReactNative diff --git a/vnext/Microsoft.ReactNative/Utils/ValueUtils.cpp b/vnext/Microsoft.ReactNative/Utils/ValueUtils.cpp index 4c968ff5f89..497b17bc582 100644 --- a/vnext/Microsoft.ReactNative/Utils/ValueUtils.cpp +++ b/vnext/Microsoft.ReactNative/Utils/ValueUtils.cpp @@ -4,8 +4,6 @@ #include "pch.h" #include -#include -#include #include #include #include @@ -49,147 +47,6 @@ struct ColorComp { } }; -xaml::Media::Brush BrushFromTheme(winrt::hstring resourceName) { - winrt::hstring xamlString = - L"" - L" " - L""; - - auto dictionary{winrt::unbox_value(winrt::Markup::XamlReader::Load(xamlString))}; - - auto brush{winrt::unbox_value(dictionary.Lookup(winrt::box_value(resourceName)))}; - return brush; -} - -struct BrushCache { - std::map m_map; - winrt::Windows::UI::ViewManagement::UISettings m_uiSettings{nullptr}; - BrushCache() { - m_map = { - {L"SystemAccentColor", {nullptr}}, - {L"SystemAccentColorLight1", {nullptr}}, - {L"SystemAccentColorLight2", {nullptr}}, - {L"SystemAccentColorLight3", {nullptr}}, - {L"SystemAccentColorDark1", {nullptr}}, - {L"SystemAccentColorDark2", {nullptr}}, - {L"SystemAccentColorDark3", {nullptr}}, - {L"SystemListAccentLowColor", {nullptr}}, - {L"SystemListAccentMediumColor", {nullptr}}, - {L"SystemListAccentHighColor", {nullptr}}}; - - m_uiSettings = winrt::Windows::UI::ViewManagement::UISettings(); - auto dq = winrt::dispatching::DispatcherQueue::GetForCurrentThread(); - m_uiSettings.ColorValuesChanged([this, dq](auto &&sender, auto &&args) { - dq.TryEnqueue([this]() { - for (auto &entry : m_map) { - winrt::IInspectable resource{winrt::Application::Current().Resources().Lookup(winrt::box_value(entry.first))}; - if (auto oldSCBrush = entry.second.try_as()) { - if (auto newSCBrush = resource.try_as()) { - oldSCBrush.Color(newSCBrush.Color()); - } - } - // Similar logic can be applied to copy Acrylic or Reveal brushes - /* - else if (auto oldAcBrush = entry.second.try_as()) { - if (auto newAcBrush = resource.try_as()) { - // ... - } - } - */ - } - }); - }); - } - - xaml::Media::Brush BrushFromResourceName(const std::vector &resources) { - for (auto resource : resources) { - auto resourceName{winrt::to_hstring(resource)}; - if (m_map.find(resourceName) != m_map.end()) { - if (auto brush = m_map.at(resourceName)) { - return brush; - } - - auto brush = BrushFromTheme(resourceName); - return RegisterBrush(resourceName, brush); - } - - const auto appResources{winrt::Application::Current().Resources()}; - const auto boxedResourceName{winrt::box_value(resourceName)}; - if (appResources.HasKey(boxedResourceName)) { - winrt::IInspectable resource{appResources.Lookup(boxedResourceName)}; - - if (auto brush = resource.try_as()) { - return RegisterBrush(resourceName, brush); - } else if (auto color = resource.try_as()) { - auto brush = xaml::Media::SolidColorBrush(color.value()); - return RegisterBrush(resourceName, brush); - } - } - } - - assert(false && "Resource is not a Color or Brush"); - return xaml::Media::SolidColorBrush(winrt::Colors::Transparent()); - } - - xaml::Media::Brush RegisterBrush(winrt::hstring resourceName, const xaml::Media::Brush &brush) { - if (auto scb = brush.try_as()) { - auto scb2 = xaml::Media::SolidColorBrush{scb.Color()}; - m_map.emplace(resourceName, scb2); - return scb2; - } else { - m_map.emplace(resourceName, brush); - return brush; - } - } -}; - -xaml::Media::Brush BrushFromColorObject(const std::string &resourceName) { - return BrushFromColorObject(std::vector{resourceName}); -} - -xaml::Media::Brush BrushFromColorObject(const std::vector &resourceNames) { - thread_local static BrushCache accentColorMap; - - return accentColorMap.BrushFromResourceName(resourceNames); -} - -xaml::Media::Brush BrushFromColorObject(const folly::dynamic &d) { - std::vector resources; - - auto value{d.find("windowsbrush")->second}; - if (value.isArray()) { - for (const auto &resource : value) { - resources.emplace_back(resource.asString()); - } - } else { - resources.emplace_back(value.asString()); - } - - return BrushFromColorObject(resources); -} - -xaml::Media::Brush BrushFromColorObject(const winrt::Microsoft::ReactNative::JSValue &v) { - std::vector resources; - - if (v["windowsbrush"].Type() == winrt::Microsoft::ReactNative::JSValueType::Array) { - for (const auto &resource : v["windowsbrush"].AsArray()) { - resources.emplace_back(resource.AsString()); - } - } else { - resources.emplace_back(v["windowsbrush"].AsString()); - } - - return BrushFromColorObject(resources); -} - winrt::Color ColorFromNumber(DWORD argb) noexcept { return xaml::FromArgb(GetAFromArgb(argb), GetRFromArgb(argb), GetGFromArgb(argb), GetBFromArgb(argb)); } @@ -207,108 +64,6 @@ REACTWINDOWS_API_(winrt::Color) ColorFrom(const winrt::Microsoft::ReactNative::J return ColorFromNumber(v.AsUInt32()); } -xaml::Media::SolidColorBrush SolidBrushFromColor(winrt::Color color) { - thread_local static std::map, ColorComp> - solidColorBrushCache; - - if (solidColorBrushCache.count(color) != 0) { - if (auto brush = solidColorBrushCache[color].get()) { - return brush; - } - } - - xaml::Media::SolidColorBrush brush(color); - solidColorBrushCache[color] = winrt::make_weak(brush); - return brush; -} - -REACTWINDOWS_API_(xaml::Media::SolidColorBrush) -SolidColorBrushFrom(const winrt::Microsoft::ReactNative::JSValue &v) { - if (v.Type() == winrt::Microsoft::ReactNative::JSValueType::Object) { - return BrushFromColorObject(v).as(); - } - - return SolidBrushFromColor(ColorFrom(v)); -} - -REACTWINDOWS_API_(xaml::Media::SolidColorBrush) -SolidColorBrushFrom(const folly::dynamic &d) { - if (d.isObject()) { - return BrushFromColorObject(d).as(); - } - - return SolidBrushFromColor(ColorFrom(d)); -} - -REACTWINDOWS_API_(winrt::Brush) BrushFrom(const folly::dynamic &d) { - if (d.isObject()) { - return BrushFromColorObject(d); - } - - return SolidColorBrushFrom(d); -} - -REACTWINDOWS_API_(xaml::Media::Brush) -BrushFrom(const winrt::Microsoft::ReactNative::JSValue &v) { - if (v.Type() == winrt::Microsoft::ReactNative::JSValueType::Object) { - return BrushFromColorObject(v); - } - return SolidColorBrushFrom(v); -} - -REACTWINDOWS_API_(xaml::HorizontalAlignment) -HorizontalAlignmentFrom(const folly::dynamic &d) { - auto valueString = d.asString(); - if (valueString == "center") - return xaml::HorizontalAlignment::Center; - else if (valueString == "left") - return xaml::HorizontalAlignment::Left; - else if (valueString == "right") - return xaml::HorizontalAlignment::Right; - else if (valueString == "stretch") - return xaml::HorizontalAlignment::Stretch; - - // ASSERT: Invalid value for VerticalAlignment. Shouldn't get this far. - assert(false); - return xaml::HorizontalAlignment::Stretch; -} - -REACTWINDOWS_API_(xaml::VerticalAlignment) -VerticalAlignmentFrom(const folly::dynamic &d) { - auto valueString = d.asString(); - if (valueString == "bottom") - return xaml::VerticalAlignment::Bottom; - else if (valueString == "center") - return xaml::VerticalAlignment::Center; - else if (valueString == "stretch") - return xaml::VerticalAlignment::Stretch; - else if (valueString == "top") - return xaml::VerticalAlignment::Top; - - // ASSERT: Invalid value for VerticalAlignment. Shouldn't get this far. - assert(false); - return xaml::VerticalAlignment::Stretch; -} - -REACTWINDOWS_API_(winrt::DateTime) -DateTimeFrom(int64_t timeInMilliSeconds, int64_t timeZoneOffsetInSeconds) { - auto timeInSeconds = (int64_t)timeInMilliSeconds / 1000; - time_t ttWithTimeZoneOffset = (time_t)(timeInSeconds + timeZoneOffsetInSeconds); - winrt::DateTime dateTime = winrt::clock::from_time_t(ttWithTimeZoneOffset); - - return dateTime; -} - -REACTWINDOWS_API_(folly::dynamic) -DateTimeToDynamic(winrt::DateTime dateTime, int64_t timeZoneOffsetInSeconds) { - time_t ttInSeconds = winrt::clock::to_time_t(dateTime); - auto timeInUtc = ttInSeconds - timeZoneOffsetInSeconds; - auto ttInMilliseconds = (int64_t)timeInUtc * 1000; - auto strDateTime = folly::dynamic(std::to_string(ttInMilliseconds)); - - return strDateTime; -} - REACTWINDOWS_API_(std::wstring) asWStr(const folly::dynamic &d) { return Microsoft::Common::Unicode::Utf8ToUtf16(d.getString()); } diff --git a/vnext/Microsoft.ReactNative/Utils/ValueUtils.h b/vnext/Microsoft.ReactNative/Utils/ValueUtils.h index 9830c085739..d02202a7a7c 100644 --- a/vnext/Microsoft.ReactNative/Utils/ValueUtils.h +++ b/vnext/Microsoft.ReactNative/Utils/ValueUtils.h @@ -20,31 +20,8 @@ struct JSValue; namespace Microsoft::ReactNative { -xaml::Media::Brush BrushFromColorObject(const std::string &resourceName); -xaml::Media::Brush BrushFromColorObject(const std::vector &resourceNames); -xaml::Media::Brush BrushFromColorObject(const folly::dynamic &d); -xaml::Media::Brush BrushFromColorObject(const winrt::Microsoft::ReactNative::JSValue &v); -xaml::Media::SolidColorBrush SolidBrushFromColor(winrt::Windows::UI::Color color); - REACTWINDOWS_API_(winrt::Windows::UI::Color) ColorFrom(const folly::dynamic &d); REACTWINDOWS_API_(winrt::Windows::UI::Color) ColorFrom(const winrt::Microsoft::ReactNative::JSValue &v); -REACTWINDOWS_API_(xaml::Media::Brush) BrushFrom(const folly::dynamic &d); - -REACTWINDOWS_API_(xaml::Media::Brush) -BrushFrom(const winrt::Microsoft::ReactNative::JSValue &v); - -REACTWINDOWS_API_(xaml::Media::SolidColorBrush) -SolidColorBrushFrom(const folly::dynamic &d); -REACTWINDOWS_API_(xaml::Media::SolidColorBrush) -SolidColorBrushFrom(const winrt::Microsoft::ReactNative::JSValue &v); -REACTWINDOWS_API_(xaml::VerticalAlignment) -VerticalAlignmentFrom(const folly::dynamic &d); -REACTWINDOWS_API_(xaml::HorizontalAlignment) -HorizontalAlignmentFrom(const folly::dynamic &d); -REACTWINDOWS_API_(winrt::Windows::Foundation::DateTime) -DateTimeFrom(int64_t timeInMilliSeconds, int64_t timeZoneOffsetInSeconds); -REACTWINDOWS_API_(folly::dynamic) -DateTimeToDynamic(winrt::Windows::Foundation::DateTime dateTime, int64_t timeZoneOffsetInSeconds); REACTWINDOWS_API_(std::wstring) asWStr(const folly::dynamic &d); REACTWINDOWS_API_(winrt::hstring) asHstring(const folly::dynamic &d); diff --git a/vnext/Microsoft.ReactNative/Utils/XamlIslandUtils.cpp b/vnext/Microsoft.ReactNative/Utils/XamlIslandUtils.cpp deleted file mode 100644 index 92fa238dec8..00000000000 --- a/vnext/Microsoft.ReactNative/Utils/XamlIslandUtils.cpp +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -#include "Utils/XamlIslandUtils.h" - -#include - -namespace Microsoft::ReactNative { - -struct CustomAppBarButton : xaml::Controls::AppBarButtonT { - void OnPointerExited(xaml::Input::PointerRoutedEventArgs const &e) { - // This method crashes in the superclass, so we purposely don't call super. But the superclass - // implementation likely cancels a timer that will show the submenu shortly after pointer enter. - // Since we don't have access to that timer, instead we reset the Flyout property, which resets - // the timer. This also fixes a crash where you can get a zombie submenu showing if the app - // loses focus while this timer is scheduled to show the submenu. - if (auto flyout = this->Flyout()) { - this->Flyout(nullptr); - this->Flyout(flyout); - } - - // The superclass implementation resets the button to the normal state, so we do this ourselves. - this->SetValue(xaml::Controls::Primitives::ButtonBase::IsPointerOverProperty(), winrt::box_value(false)); - xaml::VisualStateManager::GoToState(*this, L"Normal", false); - } - - void OnPointerPressed(xaml::Input::PointerRoutedEventArgs const &e) { - // Clicking AppBarButton by default will dismiss the menu, but since we only use this class for - // submenus we override it to be a no-op so it behaves like MenuFlyoutSubItem. - } -}; - -void FixProofingMenuCrashForXamlIsland(xaml::Controls::Primitives::FlyoutBase const &flyout) { - flyout.Opening([](winrt::IInspectable const &sender, auto &&) { - const auto &flyout = sender.as(); - if (const auto &textBox = flyout.Target().try_as()) { - const auto &commands = flyout.SecondaryCommands(); - for (uint32_t i = 0; i < commands.Size(); ++i) { - if (const auto &appBarButton = commands.GetAt(i).try_as()) { - if (!appBarButton.Flyout()) { - // This works around a loss of focus from the target element when clicking on - // on the menu items. - // https://github.com/microsoft/microsoft-ui-xaml/issues/5818 - appBarButton.Click([weakCommandBarFlyout = winrt::make_weak(flyout)](auto &&...) { - if (auto flyout = weakCommandBarFlyout.get()) { - xaml::Input::FocusManager::TryFocusAsync(flyout.Target(), xaml::FocusState::Programmatic); - } - }); - } else if (appBarButton.Flyout() == textBox.ProofingMenuFlyout()) { - if (textBox.IsSpellCheckEnabled()) { - // Replace the AppBarButton for the proofing menu with one that doesn't crash - const auto customAppBarButton = winrt::make(); - customAppBarButton.Label(appBarButton.Label()); - customAppBarButton.Icon(appBarButton.Icon()); - customAppBarButton.Flyout(appBarButton.Flyout()); - commands.RemoveAt(i); - commands.InsertAt(i, customAppBarButton); - } else { - // Remove proofing menu option if spell-check is disabled - commands.RemoveAt(i); - } - - // There is only one proofing menu option - break; - } - } - } - } - }); -} - -void FixMenuThemeForXamlIsland(xaml::Controls::Primitives::FlyoutBase const &flyout) { - flyout.Opening([](winrt::IInspectable const &sender, auto &&) { - const auto &flyout = sender.as(); - auto theme = xaml::ElementTheme::Default; - if (const auto targetElement = flyout.Target().try_as()) { - if (const auto content = targetElement.XamlRoot().Content().try_as()) { - theme = content.ActualTheme(); - } - } - - const auto commands = flyout.SecondaryCommands(); - for (uint32_t i = 0; i < commands.Size(); ++i) { - if (const auto &appBarButton = commands.GetAt(i).try_as()) { - // Workaround Xaml Islands bug with dark theme and CommandBarFlyout: - // https://github.com/microsoft/microsoft-ui-xaml/issues/5320 - appBarButton.RequestedTheme(theme); - } - } - }); -} - -} // namespace Microsoft::ReactNative diff --git a/vnext/Microsoft.ReactNative/Utils/XamlIslandUtils.h b/vnext/Microsoft.ReactNative/Utils/XamlIslandUtils.h deleted file mode 100644 index 63f6ee5cd9a..00000000000 --- a/vnext/Microsoft.ReactNative/Utils/XamlIslandUtils.h +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -#pragma once - -#include "Utils/Helpers.h" - -#include -#include - -#include - -namespace Microsoft::ReactNative { - -void FixProofingMenuCrashForXamlIsland(xaml::Controls::Primitives::FlyoutBase const &flyout); -void FixMenuThemeForXamlIsland(xaml::Controls::Primitives::FlyoutBase const &flyout); - -template -inline void EnsureUniqueTextFlyoutForXamlIsland(T const &textView) { - // This works around a XAML Islands bug where the XamlRoot of the first - // window the flyout is shown on takes ownership of the flyout and attempts - // to show the flyout on other windows cause the first window to get focus. - // https://github.com/microsoft/microsoft-ui-xaml/issues/5341 - if (IsXamlIsland()) { - winrt::Microsoft::UI::Xaml::Controls::TextCommandBarFlyout flyout; - FixMenuThemeForXamlIsland(flyout); - flyout.Placement(xaml::Controls::Primitives::FlyoutPlacementMode::BottomEdgeAlignedLeft); - - // This works around a XAML Islands bug where the Proofing sub-menu for - // TextBox causes a crash while animating to open / close before 21H1. - // https://github.com/microsoft/microsoft-ui-xaml/issues/3529 - if constexpr (std::is_same_v) { - if (!Is21H1OrHigher()) { - FixProofingMenuCrashForXamlIsland(flyout); - } - } - - textView.ContextFlyout(flyout); - textView.SelectionFlyout(flyout); - } -} - -inline void ClearUniqueTextFlyoutForXamlIsland(xaml::Controls::TextBlock const &textBlock) { - textBlock.ClearValue(xaml::UIElement::ContextFlyoutProperty()); - textBlock.ClearValue(xaml::Controls::TextBlock::SelectionFlyoutProperty()); -} - -} // namespace Microsoft::ReactNative diff --git a/vnext/Microsoft.ReactNative/ViewProps.idl b/vnext/Microsoft.ReactNative/ViewProps.idl index 577bb33af71..a22cab0648a 100644 --- a/vnext/Microsoft.ReactNative/ViewProps.idl +++ b/vnext/Microsoft.ReactNative/ViewProps.idl @@ -20,9 +20,7 @@ namespace Microsoft.ReactNative { [experimental] runtimeclass Color { Windows.UI.Color AsWindowsColor(Microsoft.ReactNative.Composition.Theme theme); -#ifdef USE_WINUI3 Microsoft.UI.Composition.CompositionBrush AsBrush(Microsoft.ReactNative.Composition.Theme theme); -#endif Boolean Equals(Color color); diff --git a/vnext/Mso.UnitTests/dispatchQueue/dispatchQueueTest.cpp b/vnext/Mso.UnitTests/dispatchQueue/dispatchQueueTest.cpp index c2be9e4ff5d..e71f3a1e12c 100644 --- a/vnext/Mso.UnitTests/dispatchQueue/dispatchQueueTest.cpp +++ b/vnext/Mso.UnitTests/dispatchQueue/dispatchQueueTest.cpp @@ -11,13 +11,8 @@ using namespace winrt; using namespace Windows::Foundation; -#ifndef USE_WINUI3 -#include "winrt/Windows.System.h" -using namespace Windows::System; -#else #include "winrt/Microsoft.UI.Dispatching.h" using namespace Microsoft::UI::Dispatching; -#endif namespace Mso { extern void Test_ThreadPoolSchedulerWin_EnableThreadPoolWorkTracking(bool enable) noexcept; diff --git a/vnext/Mso/src/dispatchQueue/uiScheduler_winrt.cpp b/vnext/Mso/src/dispatchQueue/uiScheduler_winrt.cpp index 9cc091cdbc0..4dcd878862d 100644 --- a/vnext/Mso/src/dispatchQueue/uiScheduler_winrt.cpp +++ b/vnext/Mso/src/dispatchQueue/uiScheduler_winrt.cpp @@ -11,9 +11,7 @@ using namespace winrt; using namespace Windows::Foundation; #include "winrt/Windows.System.h" -#ifdef USE_WINUI3 #include "winrt/Microsoft.UI.Dispatching.h" -#endif namespace Mso { @@ -86,7 +84,6 @@ struct DispatcherTraits { }; using WindowsDispatcherTraits = DispatcherTraits; -#ifdef USE_WINUI3 struct MicrosoftTypeTag; using MicrosoftTaskDispatcherHandler = TaskDispatcherHandler>; @@ -100,7 +97,6 @@ struct DispatcherTraits { }; using MicrosoftDispatcherTraits = DispatcherTraits; -#endif //! TaskDispatcherHandler is a DispatcherQueueHandler delegate that we pass to DispatcherQueue. //! We use custom ref counting to avoid extra memory allocations and to handle reference to DispatchTask. @@ -419,14 +415,10 @@ void UISchedulerWinRT::CleanupContext::CheckTermination() noe DispatchQueue DispatchQueueStatic::GetCurrentUIThreadQueue() noexcept { DispatchQueue queue{nullptr}; -#if USE_WINUI3 queue = UISchedulerWinRT::GetOrCreateUIThreadQueue(); if (!queue) { -#endif queue = UISchedulerWinRT::GetOrCreateUIThreadQueue(); -#if USE_WINUI3 } -#endif return queue; } diff --git a/vnext/fmt/packages.lock.json b/vnext/fmt/packages.lock.json new file mode 100644 index 00000000000..a31237b580e --- /dev/null +++ b/vnext/fmt/packages.lock.json @@ -0,0 +1,13 @@ +{ + "version": 1, + "dependencies": { + "native,Version=v0.0": {}, + "native,Version=v0.0/win10-arm": {}, + "native,Version=v0.0/win10-arm-aot": {}, + "native,Version=v0.0/win10-arm64-aot": {}, + "native,Version=v0.0/win10-x64": {}, + "native,Version=v0.0/win10-x64-aot": {}, + "native,Version=v0.0/win10-x86": {}, + "native,Version=v0.0/win10-x86-aot": {} + } +} \ No newline at end of file From 504d71c7720111fce26669f256fd4ee567b0abc6 Mon Sep 17 00:00:00 2001 From: Andrew Coates <30809111+acoates-ms@users.noreply.github.com> Date: Wed, 19 Nov 2025 12:29:57 -0800 Subject: [PATCH 2/8] format --- .../Fabric/Composition/Composition.Input.h | 2 +- .../Fabric/Composition/CompositionHwndHost.cpp | 1 - vnext/Microsoft.ReactNative/Fabric/Composition/Theme.h | 2 +- .../platform/react/renderer/graphics/PlatformColorUtils.cpp | 1 - vnext/Microsoft.ReactNative/RedBox.cpp | 6 ++---- vnext/Mso/src/dispatchQueue/uiScheduler_winrt.cpp | 1 - 6 files changed, 4 insertions(+), 9 deletions(-) diff --git a/vnext/Microsoft.ReactNative/Fabric/Composition/Composition.Input.h b/vnext/Microsoft.ReactNative/Fabric/Composition/Composition.Input.h index 8cce9170ecd..3a8bb6f042d 100644 --- a/vnext/Microsoft.ReactNative/Fabric/Composition/Composition.Input.h +++ b/vnext/Microsoft.ReactNative/Fabric/Composition/Composition.Input.h @@ -9,9 +9,9 @@ #include #include #include +#include #include #include -#include namespace winrt::Microsoft::ReactNative::Composition::Input::implementation { diff --git a/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionHwndHost.cpp b/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionHwndHost.cpp index eec11e5ec6f..d13b392e723 100644 --- a/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionHwndHost.cpp +++ b/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionHwndHost.cpp @@ -73,7 +73,6 @@ void CompositionHwndHost::Initialize(uint64_t hwnd) noexcept { .InternalRootVisual( winrt::Microsoft::ReactNative::Composition::Experimental::SystemCompositionContextHelper::CreateVisual( target.Root())); - } m_compRootView.ReactViewHost(std::move(m_reactViewHost)); diff --git a/vnext/Microsoft.ReactNative/Fabric/Composition/Theme.h b/vnext/Microsoft.ReactNative/Fabric/Composition/Theme.h index 678e946a039..8416ba0855d 100644 --- a/vnext/Microsoft.ReactNative/Fabric/Composition/Theme.h +++ b/vnext/Microsoft.ReactNative/Fabric/Composition/Theme.h @@ -18,7 +18,7 @@ struct Theme : ThemeT { const winrt::Microsoft::ReactNative::ReactContext &reactContext, const winrt::Microsoft::ReactNative::Composition::ICustomResourceLoader &customResourceLoader) noexcept; -// Public APIs + // Public APIs winrt::Microsoft::UI::Composition::CompositionBrush PlatformBrush(winrt::hstring platformColor) noexcept; bool TryGetPlatformColor(winrt::hstring platformColor, winrt::Windows::UI::Color &color) noexcept; bool IsEmpty() const noexcept; diff --git a/vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/PlatformColorUtils.cpp b/vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/PlatformColorUtils.cpp index 0bc38cd6d81..6ee8cef788c 100644 --- a/vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/PlatformColorUtils.cpp +++ b/vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/PlatformColorUtils.cpp @@ -16,7 +16,6 @@ namespace facebook::react { winrt::Windows::UI::Color ResolvePlatformColor(const std::vector &semanticItems) { if (!semanticItems.empty()) { for (auto platformColor : semanticItems) { - // Accent colors // https://learn.microsoft.com/en-us/uwp/api/windows.ui.viewmanagement.uicolortype?view=winrt-22621 static std::unordered_map< diff --git a/vnext/Microsoft.ReactNative/RedBox.cpp b/vnext/Microsoft.ReactNative/RedBox.cpp index f491e8f09b0..d5bf9c752c9 100644 --- a/vnext/Microsoft.ReactNative/RedBox.cpp +++ b/vnext/Microsoft.ReactNative/RedBox.cpp @@ -54,8 +54,7 @@ struct RedBox : public std::enable_shared_from_this { } } - void Dismiss() noexcept - { + void Dismiss() noexcept { if (m_dialogAsync) m_dialogAsync.Cancel(); } @@ -130,8 +129,7 @@ struct RedBox : public std::enable_shared_from_this { } private: - - winrt::Windows::Foundation::IAsyncOperation m_dialogAsync { nullptr }; + winrt::Windows::Foundation::IAsyncOperation m_dialogAsync{nullptr}; winrt::Microsoft::ReactNative::ReactPropertyBag m_propBag; bool m_showing = false; diff --git a/vnext/Mso/src/dispatchQueue/uiScheduler_winrt.cpp b/vnext/Mso/src/dispatchQueue/uiScheduler_winrt.cpp index 4dcd878862d..06db219aeb8 100644 --- a/vnext/Mso/src/dispatchQueue/uiScheduler_winrt.cpp +++ b/vnext/Mso/src/dispatchQueue/uiScheduler_winrt.cpp @@ -97,7 +97,6 @@ struct DispatcherTraits { }; using MicrosoftDispatcherTraits = DispatcherTraits; - //! TaskDispatcherHandler is a DispatcherQueueHandler delegate that we pass to DispatcherQueue. //! We use custom ref counting to avoid extra memory allocations and to handle reference to DispatchTask. template From e084bcf072a8d0af0ecda8d4c9f49afb49948a74 Mon Sep 17 00:00:00 2001 From: Andrew Coates <30809111+acoates-ms@users.noreply.github.com> Date: Wed, 19 Nov 2025 12:30:10 -0800 Subject: [PATCH 3/8] Change files --- ...ative-windows-5ee5175f-f197-4f2f-8c71-049c3331e2e6.json | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 change/react-native-windows-5ee5175f-f197-4f2f-8c71-049c3331e2e6.json diff --git a/change/react-native-windows-5ee5175f-f197-4f2f-8c71-049c3331e2e6.json b/change/react-native-windows-5ee5175f-f197-4f2f-8c71-049c3331e2e6.json new file mode 100644 index 00000000000..5d39f3f1d5a --- /dev/null +++ b/change/react-native-windows-5ee5175f-f197-4f2f-8c71-049c3331e2e6.json @@ -0,0 +1,7 @@ +{ + "type": "prerelease", + "comment": "Remove code related to USE_WINUI3 which is now always true", + "packageName": "react-native-windows", + "email": "30809111+acoates-ms@users.noreply.github.com", + "dependentChangeType": "patch" +} From 076314525f811fdec108d83db284beeac3933546 Mon Sep 17 00:00:00 2001 From: Andrew Coates <30809111+acoates-ms@users.noreply.github.com> Date: Wed, 19 Nov 2025 15:37:43 -0800 Subject: [PATCH 4/8] fix --- vnext/Microsoft.ReactNative/Pch/pch.h | 28 --------------------------- 1 file changed, 28 deletions(-) diff --git a/vnext/Microsoft.ReactNative/Pch/pch.h b/vnext/Microsoft.ReactNative/Pch/pch.h index 34b0b02b9be..5ec8404bc65 100644 --- a/vnext/Microsoft.ReactNative/Pch/pch.h +++ b/vnext/Microsoft.ReactNative/Pch/pch.h @@ -22,34 +22,6 @@ // When WINAPI_FAMILY is DESKTOP_APP, windows.h creates a macro for GetCurrentTime, which conflicts with other headers #undef GetCurrentTime -// Define environment variable RNW_FASTBUILD=true to improve compilation speed on your PC. -#ifdef RNW_FASTBUILD -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "Base/CxxReactIncludes.h" - -#include -#endif // RNW_FASTBUILD - #include "CppWinRTIncludes.h" #include "HResult.h" From 417d947d2cd9b40b46cf947fffc1633e63a72781 Mon Sep 17 00:00:00 2001 From: Andrew Coates <30809111+acoates-ms@users.noreply.github.com> Date: Thu, 20 Nov 2025 09:50:57 -0800 Subject: [PATCH 5/8] fix --- vnext/Desktop/React.Windows.Desktop.vcxproj | 4 +- ...icrosoft.ReactNative.Cxx.UnitTests.vcxproj | 3 + .../ReactContextTest.cpp | 7 - .../ReactModuleBuilderMock.h | 6 - .../packages.lock.json | 179 +++++++++++++++++- .../CppWinRTIncludes.h | 2 - .../Microsoft.ReactNative.Cxx/ReactContext.h | 3 - vnext/Microsoft.ReactNative/Timer.cpp | 5 +- 8 files changed, 183 insertions(+), 26 deletions(-) diff --git a/vnext/Desktop/React.Windows.Desktop.vcxproj b/vnext/Desktop/React.Windows.Desktop.vcxproj index 0e032b33cce..99c72f88ca9 100644 --- a/vnext/Desktop/React.Windows.Desktop.vcxproj +++ b/vnext/Desktop/React.Windows.Desktop.vcxproj @@ -92,7 +92,7 @@ - + @@ -273,7 +273,7 @@ - + diff --git a/vnext/Microsoft.ReactNative.Cxx.UnitTests/Microsoft.ReactNative.Cxx.UnitTests.vcxproj b/vnext/Microsoft.ReactNative.Cxx.UnitTests/Microsoft.ReactNative.Cxx.UnitTests.vcxproj index c5d803595bf..c3434415e94 100644 --- a/vnext/Microsoft.ReactNative.Cxx.UnitTests/Microsoft.ReactNative.Cxx.UnitTests.vcxproj +++ b/vnext/Microsoft.ReactNative.Cxx.UnitTests/Microsoft.ReactNative.Cxx.UnitTests.vcxproj @@ -43,6 +43,7 @@ true + @@ -157,6 +158,8 @@ + diff --git a/vnext/Microsoft.ReactNative.Cxx.UnitTests/ReactContextTest.cpp b/vnext/Microsoft.ReactNative.Cxx.UnitTests/ReactContextTest.cpp index bcbbdbde524..4bf48c1bddb 100644 --- a/vnext/Microsoft.ReactNative.Cxx.UnitTests/ReactContextTest.cpp +++ b/vnext/Microsoft.ReactNative.Cxx.UnitTests/ReactContextTest.cpp @@ -36,13 +36,6 @@ struct ReactContextStub : implements { VerifyElseCrashSz(false, "Not implemented"); } - void DispatchEvent( - xaml::FrameworkElement const & /*view*/, - hstring const & /*eventName*/, - JSValueArgWriter const & /*eventDataArgWriter*/) noexcept { - VerifyElseCrashSz(false, "Not implemented"); - } - void CallJSFunction( hstring const &moduleName, hstring const &functionName, diff --git a/vnext/Microsoft.ReactNative.Cxx.UnitTests/ReactModuleBuilderMock.h b/vnext/Microsoft.ReactNative.Cxx.UnitTests/ReactModuleBuilderMock.h index 80c15e52f32..23a3df940c9 100644 --- a/vnext/Microsoft.ReactNative.Cxx.UnitTests/ReactModuleBuilderMock.h +++ b/vnext/Microsoft.ReactNative.Cxx.UnitTests/ReactModuleBuilderMock.h @@ -7,7 +7,6 @@ #include "future/future.h" #include -#include "CppWinRTIncludes.h" #include "JSValue.h" #include "NativeModules.h" @@ -142,11 +141,6 @@ struct ReactContextMock : implements { VerifyElseCrashSz(false, "Not implemented"); } - void DispatchEvent( - xaml::FrameworkElement const & /*view*/, - hstring const & /*eventName*/, - JSValueArgWriter const & /*eventDataArgWriter*/) noexcept {} - void CallJSFunction( hstring const &moduleName, hstring const &functionName, diff --git a/vnext/Microsoft.ReactNative.Cxx.UnitTests/packages.lock.json b/vnext/Microsoft.ReactNative.Cxx.UnitTests/packages.lock.json index 9f5f394ce46..0d89dcb297e 100644 --- a/vnext/Microsoft.ReactNative.Cxx.UnitTests/packages.lock.json +++ b/vnext/Microsoft.ReactNative.Cxx.UnitTests/packages.lock.json @@ -13,11 +13,182 @@ "requested": "[2.0.230706.1, )", "resolved": "2.0.230706.1", "contentHash": "l0D7oCw/5X+xIKHqZTi62TtV+1qeSz7KVluNFdrJ9hXsst4ghvqQ/Yhura7JqRdZWBXAuDS0G0KwALptdoxweQ==" + }, + "Microsoft.WindowsAppSDK": { + "type": "Direct", + "requested": "[1.8.251106002, )", + "resolved": "1.8.251106002", + "contentHash": "IiDYOHJahku9GuajXLCNWkrhsG+Fbd2GsWpINLXhm3nF8mXzGPmFtateotJWnE0BKCa4Ua1+O4nYJ4gUC9+NXg==", + "dependencies": { + "Microsoft.WindowsAppSDK.AI": "[1.8.39]", + "Microsoft.WindowsAppSDK.Base": "[1.8.250831001]", + "Microsoft.WindowsAppSDK.DWrite": "[1.8.25090401]", + "Microsoft.WindowsAppSDK.Foundation": "[1.8.251104000]", + "Microsoft.WindowsAppSDK.InteractiveExperiences": "[1.8.251104001]", + "Microsoft.WindowsAppSDK.ML": "[1.8.2109]", + "Microsoft.WindowsAppSDK.Runtime": "[1.8.251106002]", + "Microsoft.WindowsAppSDK.Widgets": "[1.8.250904007]", + "Microsoft.WindowsAppSDK.WinUI": "[1.8.251105000]" + } + }, + "Microsoft.Web.WebView2": { + "type": "Transitive", + "resolved": "1.0.3179.45", + "contentHash": "3pokSH5CnN0G6rGhGFo1y87inxYhNxBQ2Vdf0wlvBj99KHxQJormjDACmqRnFeUsmuNFIhWwfAL1ztq7wD5qRA==" + }, + "Microsoft.Windows.SDK.BuildTools": { + "type": "Transitive", + "resolved": "10.0.26100.4654", + "contentHash": "2mgcOlj/t2RfSyyw+pVESfO+Tk1RkfQzto9Vrq42M1lUQIfQEwbi8QLha9GXWIOj+TFzeHIEJckIoF25mgiM8A==" + }, + "Microsoft.Windows.SDK.BuildTools.MSIX": { + "type": "Transitive", + "resolved": "1.7.20250829.1", + "contentHash": "IMdvRmCIZnBS5GkYnv0po1bcx6U1OF39pqA4TphQ9evDzpCRoSE19/PkDvlUNNrBavTsLIEJgd/TAIFner75ow==" + }, + "Microsoft.WindowsAppSDK.AI": { + "type": "Transitive", + "resolved": "1.8.39", + "contentHash": "jYx8PqQZjB59MU+/IcelwWa0iUnNYkSIWyirDLb50/6uaSVK+FMKsdvV5ZxVuQmBIBUjqReOLRAdlsxxOVAE1Q==", + "dependencies": { + "Microsoft.WindowsAppSDK.Base": "1.8.250831001", + "Microsoft.WindowsAppSDK.Foundation": "1.8.251104000" + } + }, + "Microsoft.WindowsAppSDK.Base": { + "type": "Transitive", + "resolved": "1.8.250831001", + "contentHash": "8LlfXBS2Hpw+OoVXViJmIOPXl0nMbqMaFR3j6+QHFNc62VULwPEcXiMRcP2WbV/+mtC7W2LH6yx6uu/Hrr9lVw==", + "dependencies": { + "Microsoft.Windows.SDK.BuildTools": "10.0.26100.4654", + "Microsoft.Windows.SDK.BuildTools.MSIX": "1.7.20250829.1" + } + }, + "Microsoft.WindowsAppSDK.DWrite": { + "type": "Transitive", + "resolved": "1.8.25090401", + "contentHash": "WJ0p9yMgiNYqU2O5ZKCXcb7FBjryIUUopgeYMvnlf1yBUYgdjMFMkoJqYVqkz866wnntiB2IZhLxEzhFzvVs1A==", + "dependencies": { + "Microsoft.WindowsAppSDK.Base": "1.8.250831001" + } + }, + "Microsoft.WindowsAppSDK.Foundation": { + "type": "Transitive", + "resolved": "1.8.251104000", + "contentHash": "vvL3zpC8klGcaxUA7RbMuUMVAABD7jEMFhNKGAewOvey18i64mslbU0aIQM3+Bu4tQKsaGXSWYrJFsAU/Op4OA==", + "dependencies": { + "Microsoft.WindowsAppSDK.Base": "1.8.250831001", + "Microsoft.WindowsAppSDK.InteractiveExperiences": "1.8.251104001" + } + }, + "Microsoft.WindowsAppSDK.InteractiveExperiences": { + "type": "Transitive", + "resolved": "1.8.251104001", + "contentHash": "t4Vs1eMJqUpa5CbZ5SvO4j5VdyhNwtarNfYJAWar8dHejpNol3g+/t0l0ovKye+DKQpinWdGkuQSUX8Oc8M3ug==", + "dependencies": { + "Microsoft.WindowsAppSDK.Base": "1.8.250831001" + } + }, + "Microsoft.WindowsAppSDK.ML": { + "type": "Transitive", + "resolved": "1.8.2109", + "contentHash": "gfsSXBJrlsfnl1IID3AEasUvZXFFZk6n4iD2JP5BfheySaoWr/1JJVbqKYyRr7APe2kRzyztVW3eaj7KMfgR5A==", + "dependencies": { + "Microsoft.WindowsAppSDK.Base": "1.8.250831001", + "Microsoft.WindowsAppSDK.Foundation": "1.8.251104000" + } + }, + "Microsoft.WindowsAppSDK.Runtime": { + "type": "Transitive", + "resolved": "1.8.251106002", + "contentHash": "5piaqsoXOTFXdtiGoqLhVPkG0HE3UD0g/S4D2i7I8MPO48eoaESJ4y/oUHzZFmSaqLQROWe8NJ9rXXNxxiL/gw==", + "dependencies": { + "Microsoft.WindowsAppSDK.Base": "1.8.250831001" + } + }, + "Microsoft.WindowsAppSDK.Widgets": { + "type": "Transitive", + "resolved": "1.8.250904007", + "contentHash": "sgwdXYhb8S4JjBmWWiFxALT1xK0fJeAbisolctmodMX7tlvBXDgUyvl/GHfTQ61DGIiW+kokX61WR46L2YlhAA==", + "dependencies": { + "Microsoft.WindowsAppSDK.Base": "1.8.250831001" + } + }, + "Microsoft.WindowsAppSDK.WinUI": { + "type": "Transitive", + "resolved": "1.8.251105000", + "contentHash": "G/f0Z27ALjjrrfjCUPxPSBkG6eLB20pBja8AFIOI87oYMGUKGwuMuZn7LqPkeQJMFPo04FonfljdJCIpsfnnbw==", + "dependencies": { + "Microsoft.Web.WebView2": "1.0.3179.45", + "Microsoft.WindowsAppSDK.Base": "1.8.250831001", + "Microsoft.WindowsAppSDK.Foundation": "1.8.251104000", + "Microsoft.WindowsAppSDK.InteractiveExperiences": "1.8.251104001" + } + } + }, + "native,Version=v0.0/win": { + "Microsoft.Web.WebView2": { + "type": "Transitive", + "resolved": "1.0.3179.45", + "contentHash": "3pokSH5CnN0G6rGhGFo1y87inxYhNxBQ2Vdf0wlvBj99KHxQJormjDACmqRnFeUsmuNFIhWwfAL1ztq7wD5qRA==" + }, + "Microsoft.WindowsAppSDK.Foundation": { + "type": "Transitive", + "resolved": "1.8.251104000", + "contentHash": "vvL3zpC8klGcaxUA7RbMuUMVAABD7jEMFhNKGAewOvey18i64mslbU0aIQM3+Bu4tQKsaGXSWYrJFsAU/Op4OA==", + "dependencies": { + "Microsoft.WindowsAppSDK.Base": "1.8.250831001", + "Microsoft.WindowsAppSDK.InteractiveExperiences": "1.8.251104001" + } + } + }, + "native,Version=v0.0/win-arm64": { + "Microsoft.Web.WebView2": { + "type": "Transitive", + "resolved": "1.0.3179.45", + "contentHash": "3pokSH5CnN0G6rGhGFo1y87inxYhNxBQ2Vdf0wlvBj99KHxQJormjDACmqRnFeUsmuNFIhWwfAL1ztq7wD5qRA==" + }, + "Microsoft.WindowsAppSDK.Foundation": { + "type": "Transitive", + "resolved": "1.8.251104000", + "contentHash": "vvL3zpC8klGcaxUA7RbMuUMVAABD7jEMFhNKGAewOvey18i64mslbU0aIQM3+Bu4tQKsaGXSWYrJFsAU/Op4OA==", + "dependencies": { + "Microsoft.WindowsAppSDK.Base": "1.8.250831001", + "Microsoft.WindowsAppSDK.InteractiveExperiences": "1.8.251104001" + } + } + }, + "native,Version=v0.0/win-x64": { + "Microsoft.Web.WebView2": { + "type": "Transitive", + "resolved": "1.0.3179.45", + "contentHash": "3pokSH5CnN0G6rGhGFo1y87inxYhNxBQ2Vdf0wlvBj99KHxQJormjDACmqRnFeUsmuNFIhWwfAL1ztq7wD5qRA==" + }, + "Microsoft.WindowsAppSDK.Foundation": { + "type": "Transitive", + "resolved": "1.8.251104000", + "contentHash": "vvL3zpC8klGcaxUA7RbMuUMVAABD7jEMFhNKGAewOvey18i64mslbU0aIQM3+Bu4tQKsaGXSWYrJFsAU/Op4OA==", + "dependencies": { + "Microsoft.WindowsAppSDK.Base": "1.8.250831001", + "Microsoft.WindowsAppSDK.InteractiveExperiences": "1.8.251104001" + } } }, - "native,Version=v0.0/win": {}, - "native,Version=v0.0/win-arm64": {}, - "native,Version=v0.0/win-x64": {}, - "native,Version=v0.0/win-x86": {} + "native,Version=v0.0/win-x86": { + "Microsoft.Web.WebView2": { + "type": "Transitive", + "resolved": "1.0.3179.45", + "contentHash": "3pokSH5CnN0G6rGhGFo1y87inxYhNxBQ2Vdf0wlvBj99KHxQJormjDACmqRnFeUsmuNFIhWwfAL1ztq7wD5qRA==" + }, + "Microsoft.WindowsAppSDK.Foundation": { + "type": "Transitive", + "resolved": "1.8.251104000", + "contentHash": "vvL3zpC8klGcaxUA7RbMuUMVAABD7jEMFhNKGAewOvey18i64mslbU0aIQM3+Bu4tQKsaGXSWYrJFsAU/Op4OA==", + "dependencies": { + "Microsoft.WindowsAppSDK.Base": "1.8.250831001", + "Microsoft.WindowsAppSDK.InteractiveExperiences": "1.8.251104001" + } + } + } } } \ No newline at end of file diff --git a/vnext/Microsoft.ReactNative.Cxx/CppWinRTIncludes.h b/vnext/Microsoft.ReactNative.Cxx/CppWinRTIncludes.h index 1c4efb9ad90..965ffe890ee 100644 --- a/vnext/Microsoft.ReactNative.Cxx/CppWinRTIncludes.h +++ b/vnext/Microsoft.ReactNative.Cxx/CppWinRTIncludes.h @@ -7,7 +7,6 @@ #include #include -#include #include #define XAML_CPPWINRT_NAMESPACE winrt::Microsoft::UI::Xaml @@ -15,7 +14,6 @@ namespace xaml = winrt::Microsoft::UI::Xaml; namespace comp = winrt::Microsoft::UI::Composition; namespace ui = winrt::Microsoft::UI; namespace winrt { -namespace dispatching = winrt::Microsoft::UI::Dispatching; using Colors = winrt::Microsoft::UI::Colors; } // namespace winrt diff --git a/vnext/Microsoft.ReactNative.Cxx/ReactContext.h b/vnext/Microsoft.ReactNative.Cxx/ReactContext.h index c79822fae80..863fe002999 100644 --- a/vnext/Microsoft.ReactNative.Cxx/ReactContext.h +++ b/vnext/Microsoft.ReactNative.Cxx/ReactContext.h @@ -8,9 +8,6 @@ #ifndef MICROSOFT_REACTNATIVE_REACTCONTEXT #define MICROSOFT_REACTNATIVE_REACTCONTEXT -#if !defined(CORE_ABI) && !defined(__APPLE__) -#include -#endif #include #include #include "JSValueWriter.h" diff --git a/vnext/Microsoft.ReactNative/Timer.cpp b/vnext/Microsoft.ReactNative/Timer.cpp index 726823731ed..0fc6042eacd 100644 --- a/vnext/Microsoft.ReactNative/Timer.cpp +++ b/vnext/Microsoft.ReactNative/Timer.cpp @@ -7,13 +7,14 @@ #include #include "ReactCoreInjection.h" +#include namespace winrt::Microsoft::ReactNative::implementation { // Implementation of ITimer based on Windows' DispatcherQueue struct ReactTimer : winrt::implements { ReactTimer(const IReactPropertyBag &properties) { - const auto queue = winrt::dispatching::DispatcherQueue::GetForCurrentThread(); + const auto queue = winrt::Microsoft::UI::Dispatching::DispatcherQueue::GetForCurrentThread(); m_dispatcherQueueTimer = queue.CreateTimer(); } @@ -42,7 +43,7 @@ struct ReactTimer : winrt::implements { } private: - winrt::dispatching::DispatcherQueueTimer m_dispatcherQueueTimer{nullptr}; + winrt::Microsoft::UI::Dispatching::DispatcherQueueTimer m_dispatcherQueueTimer{nullptr}; }; Timer::Timer() noexcept {} From 20fad059196e32fd929bce697a43fa1ba484c36e Mon Sep 17 00:00:00 2001 From: Andrew Coates <30809111+acoates-ms@users.noreply.github.com> Date: Thu, 20 Nov 2025 16:24:59 -0800 Subject: [PATCH 6/8] fix --- .../SampleCustomComponent/DrawingIsland.cpp | 1 + vnext/FollyWin32/packages.lock.json | 26 +++++++++++++++++++ .../JsiSimpleTurboModuleTests.cpp | 6 ++--- vnext/Microsoft.ReactNative/Timer.cpp | 2 +- 4 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 vnext/FollyWin32/packages.lock.json diff --git a/packages/sample-custom-component/windows/SampleCustomComponent/DrawingIsland.cpp b/packages/sample-custom-component/windows/SampleCustomComponent/DrawingIsland.cpp index 795c1b33274..983b7928a6d 100644 --- a/packages/sample-custom-component/windows/SampleCustomComponent/DrawingIsland.cpp +++ b/packages/sample-custom-component/windows/SampleCustomComponent/DrawingIsland.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include diff --git a/vnext/FollyWin32/packages.lock.json b/vnext/FollyWin32/packages.lock.json new file mode 100644 index 00000000000..8b50ae9b2c3 --- /dev/null +++ b/vnext/FollyWin32/packages.lock.json @@ -0,0 +1,26 @@ +{ + "version": 1, + "dependencies": { + "native,Version=v0.0": { + "boost": { + "type": "Transitive", + "resolved": "1.83.0", + "contentHash": "cy53VNMzysEMvhBixDe8ujPk67Fcj3v6FPHQnH91NYJNLHpc6jxa2xq9ruCaaJjE4M3YrGSHDi4uUSTGBWw6EQ==" + }, + "fmt": { + "type": "Project" + }, + "folly": { + "type": "Project", + "dependencies": { + "boost": "[1.83.0, )", + "fmt": "[1.0.0, )" + } + } + }, + "native,Version=v0.0/win": {}, + "native,Version=v0.0/win-arm64": {}, + "native,Version=v0.0/win-x64": {}, + "native,Version=v0.0/win-x86": {} + } +} \ No newline at end of file diff --git a/vnext/Microsoft.ReactNative.IntegrationTests/JsiSimpleTurboModuleTests.cpp b/vnext/Microsoft.ReactNative.IntegrationTests/JsiSimpleTurboModuleTests.cpp index 91e81684b4e..2ff960803ef 100644 --- a/vnext/Microsoft.ReactNative.IntegrationTests/JsiSimpleTurboModuleTests.cpp +++ b/vnext/Microsoft.ReactNative.IntegrationTests/JsiSimpleTurboModuleTests.cpp @@ -55,18 +55,18 @@ TEST_CLASS (JsiSimpleTurboModuleTests) { // See that all events are raised in JSDispatcher thread. host.InstanceSettings().InstanceCreated( - [&](IInspectable const & /*sender*/, InstanceCreatedEventArgs const &args) { + [&](winrt::Windows::Foundation::IInspectable const & /*sender*/, InstanceCreatedEventArgs const &args) { TestEventService::LogEvent("Instance created event", nullptr); // Save this thread as the js thread jsThreadId = std::this_thread::get_id(); }); host.InstanceSettings().InstanceLoaded( - [&](IInspectable const & /*sender*/, InstanceLoadedEventArgs const &args) { + [&](winrt::Windows::Foundation::IInspectable const & /*sender*/, InstanceLoadedEventArgs const &args) { TestEventService::LogEvent("Instance loaded event", nullptr); TestCheck(jsThreadId == std::this_thread::get_id()); }); host.InstanceSettings().InstanceDestroyed( - [&](IInspectable const & /*sender*/, InstanceDestroyedEventArgs const &args) { + [&](winrt::Windows::Foundation::IInspectable const & /*sender*/, InstanceDestroyedEventArgs const &args) { TestEventService::LogEvent("Instance destroyed event", nullptr); TestCheck(jsThreadId == std::this_thread::get_id()); }); diff --git a/vnext/Microsoft.ReactNative/Timer.cpp b/vnext/Microsoft.ReactNative/Timer.cpp index 0fc6042eacd..f7587eaf9fc 100644 --- a/vnext/Microsoft.ReactNative/Timer.cpp +++ b/vnext/Microsoft.ReactNative/Timer.cpp @@ -6,8 +6,8 @@ #include "Timer.g.cpp" #include -#include "ReactCoreInjection.h" #include +#include "ReactCoreInjection.h" namespace winrt::Microsoft::ReactNative::implementation { From 2f03ff9e5e8ed9ce3fcd1d61425d49ac400c77ab Mon Sep 17 00:00:00 2001 From: Andrew Coates <30809111+acoates-ms@users.noreply.github.com> Date: Thu, 20 Nov 2025 17:48:25 -0800 Subject: [PATCH 7/8] fix --- .../Playground-Composition.cpp | 1 + .../TurboModuleTests.cpp | 50 +++++++++---------- 2 files changed, 26 insertions(+), 25 deletions(-) diff --git a/packages/playground/windows/playground-composition/Playground-Composition.cpp b/packages/playground/windows/playground-composition/Playground-Composition.cpp index 41ba497ad27..562e3a4eb00 100644 --- a/packages/playground/windows/playground-composition/Playground-Composition.cpp +++ b/packages/playground/windows/playground-composition/Playground-Composition.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include diff --git a/vnext/Microsoft.ReactNative.IntegrationTests/TurboModuleTests.cpp b/vnext/Microsoft.ReactNative.IntegrationTests/TurboModuleTests.cpp index 287104d97f8..78f25614919 100644 --- a/vnext/Microsoft.ReactNative.IntegrationTests/TurboModuleTests.cpp +++ b/vnext/Microsoft.ReactNative.IntegrationTests/TurboModuleTests.cpp @@ -656,12 +656,12 @@ TEST_CLASS (TurboModuleTests) { host.PackageProviders().Append(winrt::make()); ReactPropertyBag(host.InstanceSettings().Properties()) .Set(CppTurboModule::TestName, L"JSDispatcherAfterInstanceUnload"); - host.InstanceSettings().InstanceDestroyed( - [&](IInspectable const & /*sender*/, InstanceDestroyedEventArgs const & /*args*/) { - TestNotificationService::Set("Instance destroyed event"); - }); + host.InstanceSettings().InstanceDestroyed([&](winrt::Windows::Foundation::IInspectable const & /*sender*/, + InstanceDestroyedEventArgs const & /*args*/) { + TestNotificationService::Set("Instance destroyed event"); + }); host.InstanceSettings().InstanceCreated( - [&](IInspectable const & /*sender*/, InstanceCreatedEventArgs const &args) { + [&](winrt::Windows::Foundation::IInspectable const & /*sender*/, InstanceCreatedEventArgs const &args) { callInvoker = args.Context().CallInvoker(); }); }); @@ -700,10 +700,10 @@ TEST_CLASS (TurboModuleTests) { auto properties = ReactPropertyBag(host.InstanceSettings().Properties()); properties.Set(CppTurboModule::TestName, L"DeferCallbackAfterInstanceUnload"); properties.Set(CppTurboModule::TestDispatcher, testDispatcher.Handle()); - host.InstanceSettings().InstanceDestroyed( - [&](IInspectable const & /*sender*/, InstanceDestroyedEventArgs const & /*args*/) { - TestNotificationService::Set("Instance destroyed event"); - }); + host.InstanceSettings().InstanceDestroyed([&](winrt::Windows::Foundation::IInspectable const & /*sender*/, + InstanceDestroyedEventArgs const & /*args*/) { + TestNotificationService::Set("Instance destroyed event"); + }); }); TestNotificationService::Wait("NegateDeferredCallback called"); @@ -729,10 +729,10 @@ TEST_CLASS (TurboModuleTests) { auto properties = ReactPropertyBag(host.InstanceSettings().Properties()); properties.Set(CppTurboModule::TestName, L"DeferResolveCallbackAfterInstanceUnload"); properties.Set(CppTurboModule::TestDispatcher, testDispatcher.Handle()); - host.InstanceSettings().InstanceDestroyed( - [&](IInspectable const & /*sender*/, InstanceDestroyedEventArgs const & /*args*/) { - TestNotificationService::Set("Instance destroyed event"); - }); + host.InstanceSettings().InstanceDestroyed([&](winrt::Windows::Foundation::IInspectable const & /*sender*/, + InstanceDestroyedEventArgs const & /*args*/) { + TestNotificationService::Set("Instance destroyed event"); + }); }); TestNotificationService::Wait("NegateDeferredTwoCallbacks called"); @@ -758,10 +758,10 @@ TEST_CLASS (TurboModuleTests) { auto properties = ReactPropertyBag(host.InstanceSettings().Properties()); properties.Set(CppTurboModule::TestName, L"DeferRejectCallbackAfterInstanceUnload"); properties.Set(CppTurboModule::TestDispatcher, testDispatcher.Handle()); - host.InstanceSettings().InstanceDestroyed( - [&](IInspectable const & /*sender*/, InstanceDestroyedEventArgs const & /*args*/) { - TestNotificationService::Set("Instance destroyed event"); - }); + host.InstanceSettings().InstanceDestroyed([&](winrt::Windows::Foundation::IInspectable const & /*sender*/, + InstanceDestroyedEventArgs const & /*args*/) { + TestNotificationService::Set("Instance destroyed event"); + }); }); TestNotificationService::Wait("NegateDeferredTwoCallbacks called"); @@ -787,10 +787,10 @@ TEST_CLASS (TurboModuleTests) { auto properties = ReactPropertyBag(host.InstanceSettings().Properties()); properties.Set(CppTurboModule::TestName, L"DeferPromiseResolveAfterInstanceUnload"); properties.Set(CppTurboModule::TestDispatcher, testDispatcher.Handle()); - host.InstanceSettings().InstanceDestroyed( - [&](IInspectable const & /*sender*/, InstanceDestroyedEventArgs const & /*args*/) { - TestNotificationService::Set("Instance destroyed event"); - }); + host.InstanceSettings().InstanceDestroyed([&](winrt::Windows::Foundation::IInspectable const & /*sender*/, + InstanceDestroyedEventArgs const & /*args*/) { + TestNotificationService::Set("Instance destroyed event"); + }); }); TestNotificationService::Wait("NegateDeferredPromise called"); @@ -816,10 +816,10 @@ TEST_CLASS (TurboModuleTests) { auto properties = ReactPropertyBag(host.InstanceSettings().Properties()); properties.Set(CppTurboModule::TestName, L"DeferPromiseRejectAfterInstanceUnload"); properties.Set(CppTurboModule::TestDispatcher, testDispatcher.Handle()); - host.InstanceSettings().InstanceDestroyed( - [&](IInspectable const & /*sender*/, InstanceDestroyedEventArgs const & /*args*/) { - TestNotificationService::Set("Instance destroyed event"); - }); + host.InstanceSettings().InstanceDestroyed([&](winrt::Windows::Foundation::IInspectable const & /*sender*/, + InstanceDestroyedEventArgs const & /*args*/) { + TestNotificationService::Set("Instance destroyed event"); + }); }); TestNotificationService::Wait("NegateDeferredPromise called"); From f1cf336a32189a8123206deb0e4738cffacb12e8 Mon Sep 17 00:00:00 2001 From: Andrew Coates <30809111+acoates-ms@users.noreply.github.com> Date: Thu, 20 Nov 2025 19:05:49 -0800 Subject: [PATCH 8/8] remove test for paper types --- .../JSValueReaderTest.cpp | 44 ------------------- 1 file changed, 44 deletions(-) diff --git a/vnext/Microsoft.ReactNative.Cxx.UnitTests/JSValueReaderTest.cpp b/vnext/Microsoft.ReactNative.Cxx.UnitTests/JSValueReaderTest.cpp index a6185b26f5c..299eb00b493 100644 --- a/vnext/Microsoft.ReactNative.Cxx.UnitTests/JSValueReaderTest.cpp +++ b/vnext/Microsoft.ReactNative.Cxx.UnitTests/JSValueReaderTest.cpp @@ -480,50 +480,6 @@ TEST_CLASS (JSValueReaderTest) { TestCheck(jsValue["NullValue"] == nullptr); TestCheck(jsValue["NullValue"] == JSValue::Null); } - - TEST_METHOD(TestReadValueXamlTypes) { - const wchar_t *json = - LR"JSON({ - "Thickness1": 2, - "Thickness2": 2.5, - "Thickness3": [1,2,3,4], - "Thickness4": {"left": 1, "top": 2, "right": 3, "bottom": 4}, - "CornerRadius1": 2, - "CornerRadius2": 2.5, - "CornerRadius3": [1,2,3,4], - "CornerRadius4": {"topLeft": 1, "topRight": 2, "bottomRight": 3, "bottomLeft": 4}, - "Uri1": "https://bing.com", - })JSON"; - - IJSValueReader reader = make(json); - - TestCheck(reader.ValueType() == JSValueType::Object); - hstring propertyName; - while (reader.GetNextObjectProperty(/*out*/ propertyName)) { - if (propertyName == L"Thickness1") { - TestCheck(ReadValue(reader) == xaml::ThicknessHelper::FromUniformLength(2)); - } else if (propertyName == L"Thickness2") { - TestCheck(ReadValue(reader) == xaml::ThicknessHelper::FromUniformLength(2.5)); - } else if (propertyName == L"Thickness3") { - TestCheck(ReadValue(reader) == xaml::ThicknessHelper::FromLengths(1, 2, 3, 4)); - } else if (propertyName == L"Thickness4") { - TestCheck(ReadValue(reader) == xaml::ThicknessHelper::FromLengths(1, 2, 3, 4)); - } else if (propertyName == L"CornerRadius1") { - TestCheck(ReadValue(reader) == xaml::CornerRadiusHelper::FromUniformRadius(2)); - } else if (propertyName == L"CornerRadius2") { - TestCheck(ReadValue(reader) == xaml::CornerRadiusHelper::FromUniformRadius(2.5)); - } else if (propertyName == L"CornerRadius3") { - TestCheck(ReadValue(reader) == xaml::CornerRadiusHelper::FromRadii(1, 2, 3, 4)); - } else if (propertyName == L"CornerRadius4") { - TestCheck(ReadValue(reader) == xaml::CornerRadiusHelper::FromRadii(1, 2, 3, 4)); - } else if (propertyName == L"Uri1") { - // Uri has no default ctor, so instead we read this way: - auto jsValue = JSValue::ReadFrom(reader); - auto uri = jsValue.To(); - TestCheck(uri.RawUri() == L"https://bing.com"); - } - } - } }; } // namespace winrt::Microsoft::ReactNative