From fdc471b7007b59fab2f0f53e76a17239d0eaab24 Mon Sep 17 00:00:00 2001 From: Andrew Coates <30809111+acoates-ms@users.noreply.github.com> Date: Tue, 19 May 2026 17:01:49 -0700 Subject: [PATCH 1/2] Remove stale ValueUtils unify bundle load for MS.RN and win32 dll --- .../Fabric/Composition/CompositionHelpers.cpp | 1 - .../CompositionViewComponentView.cpp | 1 - .../ContentIslandComponentView.cpp | 1 - .../Fabric/Composition/ImageComponentView.cpp | 2 - .../Composition/ParagraphComponentView.cpp | 1 - .../Composition/ScrollViewComponentView.cpp | 1 - .../Fabric/Composition/TextDrawing.cpp | 1 - .../WindowsTextInputComponentView.cpp | 1 - .../renderer/graphics/PlatformColorUtils.cpp | 1 - .../Microsoft.ReactNative.vcxproj | 3 - .../Microsoft.ReactNative.vcxproj.filters | 6 - .../Modules/AppThemeModuleUwp.cpp | 1 - .../Modules/LinkingManagerModule.cpp | 1 - .../Microsoft.ReactNative/Modules/Timing.cpp | 1 - .../Utils/ValueUtils.cpp | 103 ---------- .../Microsoft.ReactNative/Utils/ValueUtils.h | 39 ---- .../Impl/ScrollViewUWPImplementation.cpp | 106 ----------- .../Views/Impl/ScrollViewUWPImplementation.h | 43 ----- .../Impl/SnapPointManagingContentControl.cpp | 178 ------------------ .../Impl/SnapPointManagingContentControl.h | 77 -------- vnext/Shared/OInstance.cpp | 27 +-- vnext/Shared/Shared.vcxitems | 1 + 22 files changed, 3 insertions(+), 593 deletions(-) delete mode 100644 vnext/Microsoft.ReactNative/Utils/ValueUtils.cpp delete mode 100644 vnext/Microsoft.ReactNative/Utils/ValueUtils.h delete mode 100644 vnext/Microsoft.ReactNative/Views/Impl/ScrollViewUWPImplementation.cpp delete mode 100644 vnext/Microsoft.ReactNative/Views/Impl/ScrollViewUWPImplementation.h delete mode 100644 vnext/Microsoft.ReactNative/Views/Impl/SnapPointManagingContentControl.cpp delete mode 100644 vnext/Microsoft.ReactNative/Views/Impl/SnapPointManagingContentControl.h diff --git a/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionHelpers.cpp b/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionHelpers.cpp index 27c1b5c0607..a4e8f4028c5 100644 --- a/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionHelpers.cpp +++ b/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionHelpers.cpp @@ -5,7 +5,6 @@ #pragma once #include "CompositionHelpers.h" -#include #include #include #include diff --git a/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp b/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp index 727a3cb4fa6..870b96cb9c2 100644 --- a/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +++ b/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp @@ -14,7 +14,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 46f404be61f..b7fa9560e35 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 b1fbb6a8596..6b21e5fe513 100644 --- a/vnext/Microsoft.ReactNative/Fabric/Composition/ImageComponentView.cpp +++ b/vnext/Microsoft.ReactNative/Fabric/Composition/ImageComponentView.cpp @@ -6,8 +6,6 @@ #include "ImageComponentView.h" -#include - #include #include diff --git a/vnext/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.cpp b/vnext/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.cpp index 63de15cb3af..bdc06099f39 100644 --- a/vnext/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.cpp +++ b/vnext/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include diff --git a/vnext/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.cpp b/vnext/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.cpp index 2c58e04c42b..444eee5447a 100644 --- a/vnext/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.cpp +++ b/vnext/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.cpp @@ -7,7 +7,6 @@ #include "ScrollViewComponentView.h" #include -#include #pragma warning(push) #pragma warning(disable : 4305) diff --git a/vnext/Microsoft.ReactNative/Fabric/Composition/TextDrawing.cpp b/vnext/Microsoft.ReactNative/Fabric/Composition/TextDrawing.cpp index 29a33dff048..d21adca498f 100644 --- a/vnext/Microsoft.ReactNative/Fabric/Composition/TextDrawing.cpp +++ b/vnext/Microsoft.ReactNative/Fabric/Composition/TextDrawing.cpp @@ -7,7 +7,6 @@ #include "TextDrawing.h" #include -#include #include #include #include diff --git a/vnext/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp b/vnext/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp index d78ab76afab..e950e98b523 100644 --- a/vnext/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +++ b/vnext/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp @@ -9,7 +9,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 d16d0d24c83..ee661dacd50 100644 --- a/vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/PlatformColorUtils.cpp +++ b/vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/PlatformColorUtils.cpp @@ -3,7 +3,6 @@ #include "PlatformColorUtils.h" #include -#include #include #include #include "HostPlatformColor.h" diff --git a/vnext/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj b/vnext/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj index e767733e54e..f3ba1e0c319 100644 --- a/vnext/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +++ b/vnext/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj @@ -305,7 +305,6 @@ - @@ -329,8 +328,6 @@ Create - - diff --git a/vnext/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj.filters b/vnext/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj.filters index e308cba30f0..71e0a649d87 100644 --- a/vnext/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj.filters +++ b/vnext/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj.filters @@ -137,9 +137,6 @@ Utils - - Utils - Modules @@ -363,9 +360,6 @@ Utils - - Utils - Utils diff --git a/vnext/Microsoft.ReactNative/Modules/AppThemeModuleUwp.cpp b/vnext/Microsoft.ReactNative/Modules/AppThemeModuleUwp.cpp index c3cc3eac72b..b1ce0429d78 100644 --- a/vnext/Microsoft.ReactNative/Modules/AppThemeModuleUwp.cpp +++ b/vnext/Microsoft.ReactNative/Modules/AppThemeModuleUwp.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include diff --git a/vnext/Microsoft.ReactNative/Modules/LinkingManagerModule.cpp b/vnext/Microsoft.ReactNative/Modules/LinkingManagerModule.cpp index b25f58f93fa..a3a12ffd9fb 100644 --- a/vnext/Microsoft.ReactNative/Modules/LinkingManagerModule.cpp +++ b/vnext/Microsoft.ReactNative/Modules/LinkingManagerModule.cpp @@ -3,7 +3,6 @@ #include "pch.h" -#include #include #include "LinkingManagerModule.h" #include "Unicode.h" diff --git a/vnext/Microsoft.ReactNative/Modules/Timing.cpp b/vnext/Microsoft.ReactNative/Modules/Timing.cpp index 77275f75090..77c70730701 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 diff --git a/vnext/Microsoft.ReactNative/Utils/ValueUtils.cpp b/vnext/Microsoft.ReactNative/Utils/ValueUtils.cpp deleted file mode 100644 index 8400d42c7d5..00000000000 --- a/vnext/Microsoft.ReactNative/Utils/ValueUtils.cpp +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -#include "pch.h" - -#include -#include -#include -#include -#include "Unicode.h" -#include "XamlUtils.h" - -#include -#include -#include - -#include - -namespace winrt { -using namespace Windows::Foundation; -using namespace Windows::UI; -using namespace xaml; -using namespace xaml::Input; -using namespace xaml::Media; -} // namespace winrt - -namespace Microsoft::ReactNative { - -inline BYTE GetAFromArgb(DWORD v) { - return ((BYTE)((v & 0xFF000000) >> 24)); -} -inline BYTE GetRFromArgb(DWORD v) { - return ((BYTE)((v & 0x00FF0000) >> 16)); -} -inline BYTE GetGFromArgb(DWORD v) { - return ((BYTE)((v & 0x0000FF00) >> 8)); -} -inline BYTE GetBFromArgb(DWORD v) { - return ((BYTE)((v & 0x000000FF))); -} - -struct ColorComp { - bool operator()(const winrt::Color &lhs, const winrt::Color &rhs) const { - return ( - lhs.A < rhs.A || - lhs.A == rhs.A && (lhs.R < rhs.R || lhs.R == rhs.R && (lhs.G < rhs.G || lhs.G == rhs.G && lhs.B < rhs.B))); - } -}; - -winrt::Color ColorFromNumber(DWORD argb) noexcept { - return winrt::Windows::UI::Color{GetAFromArgb(argb), GetRFromArgb(argb), GetGFromArgb(argb), GetBFromArgb(argb)}; -} - -REACTWINDOWS_API_(winrt::Color) ColorFrom(const folly::dynamic &d) { - if (!d.isNumber()) - return winrt::Colors::Transparent(); - return ColorFromNumber(static_cast(d.asInt())); -} - -REACTWINDOWS_API_(winrt::Color) ColorFrom(const winrt::Microsoft::ReactNative::JSValue &v) { - if (v.Type() != winrt::Microsoft::ReactNative::JSValueType::Int64 && - v.Type() != winrt::Microsoft::ReactNative::JSValueType::Double) - return winrt::Colors::Transparent(); - return ColorFromNumber(v.AsUInt32()); -} - -REACTWINDOWS_API_(std::wstring) asWStr(const folly::dynamic &d) { - return Microsoft::Common::Unicode::Utf8ToUtf16(d.getString()); -} - -REACTWINDOWS_API_(folly::dynamic) HstringToDynamic(winrt::hstring hstr) { - return folly::dynamic(Microsoft::Common::Unicode::Utf16ToUtf8(hstr.c_str(), hstr.size())); -} - -REACTWINDOWS_API_(winrt::hstring) asHstring(const folly::dynamic &d) { - return winrt::hstring(asWStr(d)); -} - -winrt::hstring asHstring(const winrt::Microsoft::ReactNative::JSValue &v) { - return winrt::hstring(Microsoft::Common::Unicode::Utf8ToUtf16(v.AsString())); -} - -REACTWINDOWS_API_(bool) IsValidColorValue(const folly::dynamic &d) { - return d.isObject() ? (d.find("windowsbrush") != d.items().end()) : d.isNumber(); -} - -REACTWINDOWS_API_(bool) IsValidColorValue(const winrt::Microsoft::ReactNative::JSValue &v) { - if (v.Type() == winrt::Microsoft::ReactNative::JSValueType::Object) { - return !v.AsObject()["windowsbrush"].IsNull(); - } - return v.Type() == winrt::Microsoft::ReactNative::JSValueType::Double || - v.Type() == winrt::Microsoft::ReactNative::JSValueType::Int64; -} - -bool IsValidOptionalColorValue(const winrt::Microsoft::ReactNative::JSValue &v) { - return v.Type() == winrt::Microsoft::ReactNative::JSValueType::Null || IsValidColorValue(v); -} - -std::optional OptionalColorFrom(const winrt::Microsoft::ReactNative::JSValue &v) { - return v.IsNull() ? std::optional{} : ColorFrom(v); -} - -} // namespace Microsoft::ReactNative diff --git a/vnext/Microsoft.ReactNative/Utils/ValueUtils.h b/vnext/Microsoft.ReactNative/Utils/ValueUtils.h deleted file mode 100644 index d02202a7a7c..00000000000 --- a/vnext/Microsoft.ReactNative/Utils/ValueUtils.h +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -#pragma once - -#include - -#include -#include "CppWinRTIncludes.h" - -#include - -namespace folly { -struct dynamic; -} - -namespace winrt::Microsoft::ReactNative { -struct JSValue; -} - -namespace Microsoft::ReactNative { - -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_(std::wstring) asWStr(const folly::dynamic &d); -REACTWINDOWS_API_(winrt::hstring) asHstring(const folly::dynamic &d); -winrt::hstring asHstring(const winrt::Microsoft::ReactNative::JSValue &v); -REACTWINDOWS_API_(folly::dynamic) HstringToDynamic(winrt::hstring hstr); -REACTWINDOWS_API_(bool) IsValidColorValue(const folly::dynamic &d); -REACTWINDOWS_API_(bool) -IsValidColorValue(const winrt::Microsoft::ReactNative::JSValue &v); - -winrt::Windows::UI::Color ColorFromNumber(DWORD argb) noexcept; - -bool IsValidOptionalColorValue(const winrt::Microsoft::ReactNative::JSValue &v); -std::optional OptionalColorFrom(const winrt::Microsoft::ReactNative::JSValue &v); - -} // namespace Microsoft::ReactNative diff --git a/vnext/Microsoft.ReactNative/Views/Impl/ScrollViewUWPImplementation.cpp b/vnext/Microsoft.ReactNative/Views/Impl/ScrollViewUWPImplementation.cpp deleted file mode 100644 index ade44097765..00000000000 --- a/vnext/Microsoft.ReactNative/Views/Impl/ScrollViewUWPImplementation.cpp +++ /dev/null @@ -1,106 +0,0 @@ -#include "pch.h" - -#include -#include "ScrollViewUWPImplementation.h" - -namespace Microsoft::ReactNative { - -ScrollViewUWPImplementation::ScrollViewUWPImplementation(const winrt::ScrollViewer &scrollViewer) { - assert(scrollViewer); - const auto scrollViewContent = scrollViewer.Content(); - assert(scrollViewContent); - const auto snapPointManager = scrollViewContent.as(); - assert(snapPointManager); - - m_scrollViewer = winrt::make_weak(scrollViewer); -} - -void ScrollViewUWPImplementation::SetHorizontal(bool horizontal) { - ScrollViewerSnapPointManager()->SetHorizontal(horizontal); -} - -void ScrollViewUWPImplementation::SnapToInterval(float interval) { - ScrollViewerSnapPointManager()->SnapToInterval(interval); -} - -void ScrollViewUWPImplementation::PagingEnabled(bool pagingEnabled) { - ScrollViewerSnapPointManager()->PagingEnabled(pagingEnabled); -} - -void ScrollViewUWPImplementation::SnapToStart(bool snapToStart) { - ScrollViewerSnapPointManager()->SnapToStart(snapToStart); -} - -void ScrollViewUWPImplementation::SnapToEnd(bool snapToEnd) { - ScrollViewerSnapPointManager()->SnapToEnd(snapToEnd); -} - -void ScrollViewUWPImplementation::SnapToOffsets(const winrt::IVectorView &offsets) { - ScrollViewerSnapPointManager()->SnapToOffsets(offsets); -} - -void ScrollViewUWPImplementation::SnapPointAlignment(const winrt::SnapPointsAlignment alignment) { - if (const auto scrollViewer = m_scrollViewer.get()) { - scrollViewer.HorizontalSnapPointsAlignment(alignment); - scrollViewer.VerticalSnapPointsAlignment(alignment); - UpdateScrollableSize(); - ScrollViewerSnapPointManager()->NotifySnapPointsUpdated(); - } -} - -void ScrollViewUWPImplementation::UpdateScrollableSize() const { - if (const auto scrollViewer = m_scrollViewer.get()) { - const auto zoomFactor = scrollViewer.ZoomFactor(); - const auto scaledViewportWidth = static_cast(scrollViewer.ViewportWidth() / zoomFactor); - const auto scaledviewportHeight = static_cast(scrollViewer.ViewportHeight() / zoomFactor); - const auto scrollViewContent = scrollViewer.Content().as(); - const auto contentWidth = scrollViewContent.ActualWidth(); - const auto contentHeight = scrollViewContent.ActualHeight(); - - ScrollViewerSnapPointManager()->SetViewportSize(scaledViewportWidth, scaledviewportHeight); - - switch (scrollViewer.HorizontalSnapPointsAlignment()) { - case winrt::SnapPointsAlignment::Near: - ScrollViewerSnapPointManager()->SetWidthBounds(0.0f, static_cast(contentWidth) - scaledViewportWidth); - break; - case winrt::SnapPointsAlignment::Center: - ScrollViewerSnapPointManager()->SetWidthBounds( - scaledViewportWidth / 2.0f, static_cast(contentWidth) - scaledViewportWidth / 2.0f); - break; - case winrt::SnapPointsAlignment::Far: - ScrollViewerSnapPointManager()->SetWidthBounds(scaledViewportWidth, static_cast(contentWidth)); - break; - } - - switch (scrollViewer.VerticalSnapPointsAlignment()) { - case winrt::SnapPointsAlignment::Near: - ScrollViewerSnapPointManager()->SetHeightBounds(0.0f, static_cast(contentHeight) - scaledviewportHeight); - break; - case winrt::SnapPointsAlignment::Center: - ScrollViewerSnapPointManager()->SetHeightBounds( - scaledviewportHeight / 2.0f, static_cast(contentHeight) - scaledviewportHeight / 2.0f); - break; - case winrt::SnapPointsAlignment::Far: - ScrollViewerSnapPointManager()->SetHeightBounds( - static_cast(scaledViewportWidth), static_cast(contentHeight)); - break; - } - } -} - -winrt::ScrollViewer ScrollViewUWPImplementation::ScrollViewer() const { - return m_scrollViewer.get(); -} - -// privates // - -winrt::com_ptr ScrollViewUWPImplementation::ScrollViewerSnapPointManager() const { - if (const auto scrollViewer = ScrollViewer()) { - if (const auto content = scrollViewer.Content()) { - return content.as(); - } - } - return nullptr; -} - -} // namespace Microsoft::ReactNative diff --git a/vnext/Microsoft.ReactNative/Views/Impl/ScrollViewUWPImplementation.h b/vnext/Microsoft.ReactNative/Views/Impl/ScrollViewUWPImplementation.h deleted file mode 100644 index c62b7bd0800..00000000000 --- a/vnext/Microsoft.ReactNative/Views/Impl/ScrollViewUWPImplementation.h +++ /dev/null @@ -1,43 +0,0 @@ -#pragma once - -#include "SnapPointManagingContentControl.h" - -#include -#include - -#include - -#include - -namespace winrt { -using namespace Windows::Foundation; -using namespace Windows::Foundation::Collections; -using namespace xaml; -using namespace xaml::Controls; -using namespace xaml::Controls::Primitives; -} // namespace winrt - -namespace Microsoft::ReactNative { - -class ScrollViewUWPImplementation { - public: - ScrollViewUWPImplementation(const winrt::ScrollViewer &scrollViewer); - - void SetHorizontal(bool isHorizontal); - void SnapToInterval(float interval); - void SnapToStart(bool snapToStart); - void SnapToEnd(bool snapToEnd); - void SnapToOffsets(const winrt::IVectorView &offsets); - void SnapPointAlignment(const winrt::SnapPointsAlignment alignment); - void PagingEnabled(bool pagingEnabled); - - void UpdateScrollableSize() const; - - winrt::ScrollViewer ScrollViewer() const; - winrt::com_ptr ScrollViewerSnapPointManager() const; - - private: - winrt::weak_ref m_scrollViewer{}; -}; - -} // namespace Microsoft::ReactNative diff --git a/vnext/Microsoft.ReactNative/Views/Impl/SnapPointManagingContentControl.cpp b/vnext/Microsoft.ReactNative/Views/Impl/SnapPointManagingContentControl.cpp deleted file mode 100644 index 702fe8976b6..00000000000 --- a/vnext/Microsoft.ReactNative/Views/Impl/SnapPointManagingContentControl.cpp +++ /dev/null @@ -1,178 +0,0 @@ -#include "pch.h" - -#include "SnapPointManagingContentControl.h" - -namespace Microsoft::ReactNative { - -SnapPointManagingContentControl::SnapPointManagingContentControl() { - IsTabStop(false); -} - -/*static*/ winrt::com_ptr SnapPointManagingContentControl::Create() { - return winrt::make_self(); -} - -void SnapPointManagingContentControl::SnapToInterval(float interval) { - if (interval != m_interval) { - m_interval = interval; - NotifySnapPointsUpdated(); - } -} - -void SnapPointManagingContentControl::SnapToStart(bool snapToStart) { - m_snapToStart = snapToStart; - NotifySnapPointsUpdated(); -} - -void SnapPointManagingContentControl::SnapToEnd(bool snapToEnd) { - m_snapToEnd = snapToEnd; - NotifySnapPointsUpdated(); -} - -void SnapPointManagingContentControl::PagingEnabled(bool pagingEnabled) { - m_pagingEnabled = pagingEnabled; - NotifySnapPointsUpdated(); -} - -void SnapPointManagingContentControl::SnapToOffsets(const winrt::IVectorView &offsets) { - m_offsets = offsets; - if (m_offsets.Size() > 0) { - m_interval = 0.0f; - m_pagingEnabled = false; - } - NotifySnapPointsUpdated(); -} - -void SnapPointManagingContentControl::SetViewportSize(float scaledViewportWidth, float scaledviewportHeight) { - m_viewportWidth = scaledViewportWidth; - m_viewportHeight = scaledviewportHeight; -} - -void SnapPointManagingContentControl::NotifySnapPointsUpdated() { - m_horizontalSnapPointsChangedEventSource(*this, nullptr); - m_verticalSnapPointsChangedEventSource(*this, nullptr); -} - -bool SnapPointManagingContentControl::AreHorizontalSnapPointsRegular() { - return (m_interval != 0.0f || m_pagingEnabled); -} - -bool SnapPointManagingContentControl::AreVerticalSnapPointsRegular() { - return (m_interval != 0.0f || m_pagingEnabled); -} - -winrt::event_token SnapPointManagingContentControl::HorizontalSnapPointsChanged( - winrt::EventHandler const &value) { - return m_horizontalSnapPointsChangedEventSource.add(value); -} -void SnapPointManagingContentControl::HorizontalSnapPointsChanged(winrt::event_token const &token) { - m_horizontalSnapPointsChangedEventSource.remove(token); -} - -winrt::event_token SnapPointManagingContentControl::VerticalSnapPointsChanged( - winrt::EventHandler const &value) { - return m_verticalSnapPointsChangedEventSource.add(value); -} -void SnapPointManagingContentControl::VerticalSnapPointsChanged(winrt::event_token const &token) { - m_verticalSnapPointsChangedEventSource.remove(token); -} - -winrt::IVectorView SnapPointManagingContentControl::GetIrregularSnapPoints( - xaml::Controls::Orientation /*orientation*/, - winrt::SnapPointsAlignment /*alignment*/) { - const auto retVal = winrt::single_threaded_vector(); - - if (m_offsets && m_offsets.Size()) { - if (m_snapToStart) { - retVal.Append(m_horizontal ? m_startWidth : m_startHeight); - } - for (const auto offset : m_offsets) { - retVal.Append(offset); - } - if (m_snapToEnd) { - retVal.Append(m_horizontal ? m_endWidth : m_endHeight); - } - } - - return retVal.GetView(); -} - -float SnapPointManagingContentControl::GetRegularSnapPoints( - xaml::Controls::Orientation /*orientation*/, - winrt::SnapPointsAlignment /*alignment*/, - float /*offset*/) { - if (m_interval > 0.0f) { - return m_interval; - } else if (m_pagingEnabled) { - return m_horizontal ? m_viewportWidth : m_viewportHeight; - } - - return 0; -} - -void SnapPointManagingContentControl::SetHorizontal(bool horizontal) { - if (m_horizontal != horizontal) { - m_horizontal = horizontal; - - if (m_endHeight != m_endWidth) { - if (horizontal) { - m_horizontalSnapPointsChangedEventSource(*this, nullptr); - } else { - m_verticalSnapPointsChangedEventSource(*this, nullptr); - } - } - } -} - -void SnapPointManagingContentControl::SetWidthBounds(float startWidth, float endWidth) { - const auto update = [this, startWidth, endWidth]() { - const auto endUpdated = [this, endWidth]() { - if (m_endWidth != endWidth) { - m_endWidth = endWidth; - return true; - } - return false; - }(); - - const auto startUpdated = [this, startWidth]() { - if (m_startWidth != startWidth) { - m_startWidth = startWidth; - return true; - } - return false; - }(); - - return endUpdated || startUpdated; - }(); - - if (update && m_horizontal && m_offsets && m_offsets.Size()) { - m_horizontalSnapPointsChangedEventSource(*this, nullptr); - } -} - -void SnapPointManagingContentControl::SetHeightBounds(float startHeight, float endHeight) { - const auto update = [this, startHeight, endHeight]() { - const auto endUpdated = [this, endHeight]() { - if (m_endHeight != endHeight) { - m_endHeight = endHeight; - return true; - } - return false; - }(); - const auto startUpdated = [this, startHeight]() { - if (m_startHeight != startHeight) { - m_startHeight = startHeight; - return true; - } - return false; - }(); - - return endUpdated || startUpdated; - }(); - - if (!m_horizontal && m_offsets && m_offsets.Size()) { - m_verticalSnapPointsChangedEventSource(*this, nullptr); - } -} - -} // namespace Microsoft::ReactNative diff --git a/vnext/Microsoft.ReactNative/Views/Impl/SnapPointManagingContentControl.h b/vnext/Microsoft.ReactNative/Views/Impl/SnapPointManagingContentControl.h deleted file mode 100644 index 609b27c2c42..00000000000 --- a/vnext/Microsoft.ReactNative/Views/Impl/SnapPointManagingContentControl.h +++ /dev/null @@ -1,77 +0,0 @@ -#pragma once - -#include -#include -#include -#include - -namespace winrt { -using namespace Windows::Foundation; -using namespace Windows::Foundation::Collections; -using namespace xaml; -using namespace xaml::Controls; -using namespace xaml::Controls::Primitives; -} // namespace winrt - -namespace Microsoft::ReactNative { - -class SnapPointManagingContentControl - : public xaml::Controls::ContentControlT { - public: - SnapPointManagingContentControl(); - - static winrt::com_ptr Create(); - - // ScrollView Implementation - void SnapToInterval(float interval); - void SnapToOffsets(const winrt::IVectorView &offsets); - void SnapToStart(bool snapToStart); - void SnapToEnd(bool snapToEnd); - void NotifySnapPointsUpdated(); - void PagingEnabled(bool pagingEnabled); - - // IScrollSnapPointsInfo Implementation - bool AreHorizontalSnapPointsRegular(); - bool AreVerticalSnapPointsRegular(); - - winrt::event_token HorizontalSnapPointsChanged(winrt::EventHandler const &value); - void HorizontalSnapPointsChanged(winrt::event_token const &token); - - winrt::event_token VerticalSnapPointsChanged(winrt::EventHandler const &value); - void VerticalSnapPointsChanged(winrt::event_token const &token); - - winrt::IVectorView GetIrregularSnapPoints( - xaml::Controls::Orientation orientation, - winrt::SnapPointsAlignment alignment); - - float - GetRegularSnapPoints(xaml::Controls::Orientation orientation, winrt::SnapPointsAlignment alignment, float offset); - - // Helpers - void SetHorizontal(bool horizontal); - void SetHeightBounds(float startHeight, float endHeight); - void SetWidthBounds(float startWidth, float endWidth); - void SetViewportSize(float scaledViewportWidth, float scaledviewportHeight); - - bool IsHorizontal() { - return m_horizontal; - } - - private: - float m_interval{0.0f}; - winrt::IVectorView m_offsets{}; - bool m_snapToStart{true}; - bool m_snapToEnd{true}; - bool m_pagingEnabled{false}; - winrt::event> m_horizontalSnapPointsChangedEventSource; - winrt::event> m_verticalSnapPointsChangedEventSource; - - bool m_horizontal{false}; - float m_startHeight{0}; - float m_startWidth{0}; - float m_endHeight{INFINITY}; - float m_endWidth{INFINITY}; - float m_viewportHeight{0}; - float m_viewportWidth{0}; -}; -} // namespace Microsoft::ReactNative diff --git a/vnext/Shared/OInstance.cpp b/vnext/Shared/OInstance.cpp index 33cb9bc7279..99a776f5bb0 100644 --- a/vnext/Shared/OInstance.cpp +++ b/vnext/Shared/OInstance.cpp @@ -15,9 +15,7 @@ #include -#if (defined(_MSC_VER) && (defined(WINRT))) #include -#endif #if _MSC_VER #pragma warning(push) @@ -235,11 +233,6 @@ FileMappingBigString::FileMappingBigString(const std::wstring &filename, uint32_ m_data{nullptr, nullptr}, m_size{0}, m_fileSize{0} { -#if (defined(WINRT)) - std::unique_ptr fileHandle{ - CreateFile2(filename.c_str(), GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, nullptr /* pCreateExParams */), - &CloseHandle}; -#else std::unique_ptr fileHandle{ CreateFileW( filename.c_str(), @@ -250,7 +243,6 @@ FileMappingBigString::FileMappingBigString(const std::wstring &filename, uint32_ FILE_ATTRIBUTE_NORMAL, nullptr /* hTemplateFile */), &CloseHandle}; -#endif if (fileHandle.get() == INVALID_HANDLE_VALUE) { return; @@ -271,10 +263,6 @@ FileMappingBigString::FileMappingBigString(const std::wstring &filename, uint32_ } m_size = m_fileSize - offset; -#if (defined(WINRT)) - m_fileMapping.reset(CreateFileMappingFromApp( - fileHandle.get(), nullptr /* SecurityAttributes */, PAGE_READONLY, m_fileSize, nullptr /* Name */)); -#else m_fileMapping.reset(CreateFileMapping( fileHandle.get(), nullptr /* lpAttributes */, @@ -282,24 +270,18 @@ FileMappingBigString::FileMappingBigString(const std::wstring &filename, uint32_ 0 /* dwMaximumSizeHigh */, m_fileSize, nullptr /* lpName */)); -#endif if (!m_fileMapping) { m_size = 0; return; } -#if (defined(WINRT)) - m_fileData.reset( - MapViewOfFileFromApp(m_fileMapping.get(), FILE_MAP_READ, 0 /* FileOffset */, 0 /* NumberOfBytesToMap */)); -#else m_fileData.reset(MapViewOfFile( m_fileMapping.get(), FILE_MAP_READ, 0 /* dwFileOffsetHigh */, 0 /* dwFileOffsetLow */, 0 /* dwNumberOfBytesToMap */)); -#endif if (!m_fileData) { m_size = 0; @@ -331,21 +313,16 @@ std::unique_ptr FileMappingBigString::fromPath(const std::unique_ptr JsBigStringFromPath( std::shared_ptr devSettings, const std::string &jsBundleRelativePath) noexcept { -#if (defined(_MSC_VER) && !defined(WINRT)) - std::wstring bundlePath = (fs::u8path(devSettings->bundleRootPath) / jsBundleRelativePath).wstring(); - return FileMappingBigString::fromPath(bundlePath); -#else std::wstring bundlePath; if (devSettings->bundleRootPath.starts_with("resource://")) { auto uri = winrt::Windows::Foundation::Uri( winrt::to_hstring(devSettings->bundleRootPath), winrt::to_hstring(jsBundleRelativePath)); bundlePath = uri.ToString(); + return std::make_unique<::Microsoft::ReactNative::StorageFileBigString>(bundlePath); } else { bundlePath = (fs::u8path(devSettings->bundleRootPath) / (jsBundleRelativePath + ".bundle")).wstring(); + return FileMappingBigString::fromPath(bundlePath); } - - return std::make_unique<::Microsoft::ReactNative::StorageFileBigString>(bundlePath); -#endif } } // namespace Microsoft::ReactNative diff --git a/vnext/Shared/Shared.vcxitems b/vnext/Shared/Shared.vcxitems index 14afc5a6b13..41480dfd376 100644 --- a/vnext/Shared/Shared.vcxitems +++ b/vnext/Shared/Shared.vcxitems @@ -414,6 +414,7 @@ + From d1ef765fa5578298782c1cc0cf24c56e47fca536 Mon Sep 17 00:00:00 2001 From: Andrew Coates <30809111+acoates-ms@users.noreply.github.com> Date: Tue, 19 May 2026 17:02:26 -0700 Subject: [PATCH 2/2] Change files --- ...ative-windows-87ba1472-7cf5-4a35-8e67-ee722ef8b51b.json | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 change/react-native-windows-87ba1472-7cf5-4a35-8e67-ee722ef8b51b.json diff --git a/change/react-native-windows-87ba1472-7cf5-4a35-8e67-ee722ef8b51b.json b/change/react-native-windows-87ba1472-7cf5-4a35-8e67-ee722ef8b51b.json new file mode 100644 index 00000000000..45a60f29b5b --- /dev/null +++ b/change/react-native-windows-87ba1472-7cf5-4a35-8e67-ee722ef8b51b.json @@ -0,0 +1,7 @@ +{ + "type": "prerelease", + "comment": "Remove stale ValueUtils unify bundle load for MS.RN and win32 dll", + "packageName": "react-native-windows", + "email": "30809111+acoates-ms@users.noreply.github.com", + "dependentChangeType": "patch" +}