From 83c76c257cd0a50b15ae5f5d4c7975809e97a71b Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Fri, 6 Mar 2020 12:21:34 -0800 Subject: [PATCH] Fix T61647031 - color comparison causing TextAttribute color to not update ParagraphState Summary: As documented in T61647031, Text colors were sometimes not being updated because the ParagraphState was not always updating with a new AttributedString. Turns out, it's because the equality comparator for Color had not been implemented, and so State was not being set in some cases. The confusing part is that now color comparisons return true **more often** than before (if you're comparing two smart pointers of opaque data without a custom comparator, in theory I assume they're comparing pointer values and returning false way more often... but maybe my understanding is off). This distracted us for a while in finding an other ~fairly simple solution. We should keep this in mind if we experience other, similar issues with text attributes not updating. Changelog: [Internal] Fabric Reviewed By: mdvacca Differential Revision: D20300307 fbshipit-source-id: 13d86495f4c4ef8a0219fec66d39a49b4f7e6c2a --- ReactCommon/fabric/graphics/platform/cxx/Color.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ReactCommon/fabric/graphics/platform/cxx/Color.h b/ReactCommon/fabric/graphics/platform/cxx/Color.h index 560d491582a..b4a2dd3cf30 100644 --- a/ReactCommon/fabric/graphics/platform/cxx/Color.h +++ b/ReactCommon/fabric/graphics/platform/cxx/Color.h @@ -42,6 +42,14 @@ class SharedColor { return color_; } + bool operator==(const SharedColor &otherColor) const { + return color_ == otherColor.color_; + } + + bool operator!=(const SharedColor &otherColor) const { + return color_ != otherColor.color_; + } + operator bool() const { return color_ != UndefinedColor; }