diff --git a/change/react-native-windows-ca0880f1-4d40-4ab6-9c95-d843aade3939.json b/change/react-native-windows-ca0880f1-4d40-4ab6-9c95-d843aade3939.json new file mode 100644 index 00000000000..2b54a89b9dd --- /dev/null +++ b/change/react-native-windows-ca0880f1-4d40-4ab6-9c95-d843aade3939.json @@ -0,0 +1,7 @@ +{ + "type": "prerelease", + "comment": "Property updates switching between PlatformColors would no-op", + "packageName": "react-native-windows", + "email": "30809111+acoates-ms@users.noreply.github.com", + "dependentChangeType": "patch" +} diff --git a/vnext/Microsoft.ReactNative/Fabric/AbiViewProps.cpp b/vnext/Microsoft.ReactNative/Fabric/AbiViewProps.cpp index 02263560c72..3751d99862b 100644 --- a/vnext/Microsoft.ReactNative/Fabric/AbiViewProps.cpp +++ b/vnext/Microsoft.ReactNative/Fabric/AbiViewProps.cpp @@ -77,14 +77,12 @@ winrt::Microsoft::ReactNative::Color Color::ReadValue( switch (reader.ValueType()) { case JSValueType::Int64: { auto argb = reader.GetInt64(); - return winrt::make(facebook::react::Color{ - /*m_isDefined*/ true, - /*color*/ - {static_cast((argb >> 24) & 0xFF), - static_cast((argb >> 16) & 0xFF), - static_cast((argb >> 8) & 0xFF), - static_cast(argb & 0xFF)}, - {}}); + return winrt::make(facebook::react::Color{/*color*/ + {static_cast((argb >> 24) & 0xFF), + static_cast((argb >> 16) & 0xFF), + static_cast((argb >> 8) & 0xFF), + static_cast(argb & 0xFF)}, + {}}); } case JSValueType::Object: { std::vector platformColors; @@ -96,10 +94,10 @@ winrt::Microsoft::ReactNative::Color Color::ReadValue( SkipValue(reader); // Skip this property } } - return winrt::make(facebook::react::Color{/*m_isDefined*/ true, /*color*/ {}, std::move(platformColors)}); + return winrt::make(facebook::react::Color{/*color*/ {}, std::move(platformColors)}); } default: - return winrt::make(facebook::react::Color{/*m_isDefined*/ false, /*color*/ {0, 0, 0, 0}, {}}); + return winrt::make(facebook::react::Color{/*color*/ {0, 0, 0, 0}, {}}); } } diff --git a/vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/HostPlatformColor.h b/vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/HostPlatformColor.h index e04e7e55ccb..3cbcc291e80 100644 --- a/vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/HostPlatformColor.h +++ b/vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/HostPlatformColor.h @@ -12,13 +12,10 @@ namespace facebook::react { struct Color { bool operator==(const Color &otherColor) const { - return m_isUndefined && otherColor.m_isUndefined || - (m_isUndefined == otherColor.m_isUndefined && m_color == otherColor.m_color && - m_platformColor == otherColor.m_platformColor); + return m_color == otherColor.m_color && m_platformColor == otherColor.m_platformColor; } bool operator!=(const Color &otherColor) const { - return m_isUndefined != otherColor.m_isUndefined || m_color != otherColor.m_color || - m_platformColor != otherColor.m_platformColor; + return m_color != otherColor.m_color || m_platformColor != otherColor.m_platformColor; } winrt::Windows::UI::Color AsWindowsColor() const { @@ -36,13 +33,12 @@ struct Color { return RGB(m_color.R, m_color.G, m_color.B) | (m_color.A << 24); } - bool m_isUndefined; winrt::Windows::UI::Color m_color; std::vector m_platformColor; }; namespace HostPlatformColor { -static const facebook::react::Color UndefinedColor{true}; +static const facebook::react::Color UndefinedColor{{0, 0, 0, 0} /*Black*/, {} /*Empty PlatformColors*/}; } // namespace HostPlatformColor inline Color hostPlatformColorFromComponents(ColorComponents components) { @@ -53,7 +49,6 @@ inline Color hostPlatformColorFromComponents(ColorComponents components) { static_cast((int)round(components.green * ratio) & 0xff), static_cast((int)round(components.blue * ratio) & 0xff)}; return { - /* .m_isUndefined = */ false, /* .m_color = */ color, /* .m_platformColor = */ {}}; } diff --git a/vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/PlatformColorParser.h b/vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/PlatformColorParser.h index 627fc35e599..609583546c5 100644 --- a/vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/PlatformColorParser.h +++ b/vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/PlatformColorParser.h @@ -19,7 +19,6 @@ parsePlatformColor(const ContextContainer &contextContainer, int32_t surfaceId, auto map = (std::unordered_map>)value; if (map.find("windowsbrush") != map.end()) { facebook::react::Color color = { - /* .m_isDefined = */ true, /* .m_color = */ {}, /* .m_platformColor = */ std::move(map["windowsbrush"]), };