Skip to content

Commit 782335b

Browse files
authored
Property updates switching between PlatformColors would no-op (#14398)
* Property updates switching between PlatformColors would no-op * Change files * format
1 parent 8caf47c commit 782335b

File tree

4 files changed

+18
-19
lines changed

4 files changed

+18
-19
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "Property updates switching between PlatformColors would no-op",
4+
"packageName": "react-native-windows",
5+
"email": "30809111+acoates-ms@users.noreply.github.com",
6+
"dependentChangeType": "patch"
7+
}

vnext/Microsoft.ReactNative/Fabric/AbiViewProps.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,12 @@ winrt::Microsoft::ReactNative::Color Color::ReadValue(
7777
switch (reader.ValueType()) {
7878
case JSValueType::Int64: {
7979
auto argb = reader.GetInt64();
80-
return winrt::make<Color>(facebook::react::Color{
81-
/*m_isDefined*/ true,
82-
/*color*/
83-
{static_cast<uint8_t>((argb >> 24) & 0xFF),
84-
static_cast<uint8_t>((argb >> 16) & 0xFF),
85-
static_cast<uint8_t>((argb >> 8) & 0xFF),
86-
static_cast<uint8_t>(argb & 0xFF)},
87-
{}});
80+
return winrt::make<Color>(facebook::react::Color{/*color*/
81+
{static_cast<uint8_t>((argb >> 24) & 0xFF),
82+
static_cast<uint8_t>((argb >> 16) & 0xFF),
83+
static_cast<uint8_t>((argb >> 8) & 0xFF),
84+
static_cast<uint8_t>(argb & 0xFF)},
85+
{}});
8886
}
8987
case JSValueType::Object: {
9088
std::vector<std::string> platformColors;
@@ -96,10 +94,10 @@ winrt::Microsoft::ReactNative::Color Color::ReadValue(
9694
SkipValue<JSValue>(reader); // Skip this property
9795
}
9896
}
99-
return winrt::make<Color>(facebook::react::Color{/*m_isDefined*/ true, /*color*/ {}, std::move(platformColors)});
97+
return winrt::make<Color>(facebook::react::Color{/*color*/ {}, std::move(platformColors)});
10098
}
10199
default:
102-
return winrt::make<Color>(facebook::react::Color{/*m_isDefined*/ false, /*color*/ {0, 0, 0, 0}, {}});
100+
return winrt::make<Color>(facebook::react::Color{/*color*/ {0, 0, 0, 0}, {}});
103101
}
104102
}
105103

vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/HostPlatformColor.h

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,10 @@ namespace facebook::react {
1212

1313
struct Color {
1414
bool operator==(const Color &otherColor) const {
15-
return m_isUndefined && otherColor.m_isUndefined ||
16-
(m_isUndefined == otherColor.m_isUndefined && m_color == otherColor.m_color &&
17-
m_platformColor == otherColor.m_platformColor);
15+
return m_color == otherColor.m_color && m_platformColor == otherColor.m_platformColor;
1816
}
1917
bool operator!=(const Color &otherColor) const {
20-
return m_isUndefined != otherColor.m_isUndefined || m_color != otherColor.m_color ||
21-
m_platformColor != otherColor.m_platformColor;
18+
return m_color != otherColor.m_color || m_platformColor != otherColor.m_platformColor;
2219
}
2320

2421
winrt::Windows::UI::Color AsWindowsColor() const {
@@ -36,13 +33,12 @@ struct Color {
3633
return RGB(m_color.R, m_color.G, m_color.B) | (m_color.A << 24);
3734
}
3835

39-
bool m_isUndefined;
4036
winrt::Windows::UI::Color m_color;
4137
std::vector<std::string> m_platformColor;
4238
};
4339

4440
namespace HostPlatformColor {
45-
static const facebook::react::Color UndefinedColor{true};
41+
static const facebook::react::Color UndefinedColor{{0, 0, 0, 0} /*Black*/, {} /*Empty PlatformColors*/};
4642
} // namespace HostPlatformColor
4743

4844
inline Color hostPlatformColorFromComponents(ColorComponents components) {
@@ -53,7 +49,6 @@ inline Color hostPlatformColorFromComponents(ColorComponents components) {
5349
static_cast<uint8_t>((int)round(components.green * ratio) & 0xff),
5450
static_cast<uint8_t>((int)round(components.blue * ratio) & 0xff)};
5551
return {
56-
/* .m_isUndefined = */ false,
5752
/* .m_color = */ color,
5853
/* .m_platformColor = */ {}};
5954
}

vnext/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/PlatformColorParser.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ parsePlatformColor(const ContextContainer &contextContainer, int32_t surfaceId,
1919
auto map = (std::unordered_map<std::string, std::vector<std::string>>)value;
2020
if (map.find("windowsbrush") != map.end()) {
2121
facebook::react::Color color = {
22-
/* .m_isDefined = */ true,
2322
/* .m_color = */ {},
2423
/* .m_platformColor = */ std::move(map["windowsbrush"]),
2524
};

0 commit comments

Comments
 (0)