From 8b62e7a5506f335c35ce3bd33dbf599426cb3fbf Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Fri, 8 Jun 2018 20:16:13 -0700 Subject: [PATCH] Fabric: Using Size instead of Point as textShadowOffset's type Summary: The current implementation of React Native uses `Size` as the underlying type of `textShadowOffset` which is clearly terribly wrong (especially because negative size values makes no sense). This mistake was borrowed from `NSShadow`, I believe. I don't have time to fix this in every implementation of RN now, so let's use `Size` in Fabric as well. Reviewed By: fkgozali Differential Revision: D8246714 fbshipit-source-id: 1f0bf9b9dfa83802ef3faef2971fed5510494bfd --- ReactCommon/fabric/attributedstring/TextAttributes.h | 3 ++- ReactCommon/fabric/textlayoutmanager/RCTAttributedTextUtils.mm | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ReactCommon/fabric/attributedstring/TextAttributes.h b/ReactCommon/fabric/attributedstring/TextAttributes.h index c474e7e2a..584387bf5 100644 --- a/ReactCommon/fabric/attributedstring/TextAttributes.h +++ b/ReactCommon/fabric/attributedstring/TextAttributes.h @@ -57,7 +57,8 @@ public: folly::Optional textDecorationLinePattern {}; // Shadow - folly::Optional textShadowOffset {}; + // TODO: Use `Point` type instead of `Size` for `textShadowOffset` attribute. + folly::Optional textShadowOffset {}; Float textShadowRadius {std::numeric_limits::quiet_NaN()}; SharedColor textShadowColor {nullptr}; diff --git a/ReactCommon/fabric/textlayoutmanager/RCTAttributedTextUtils.mm b/ReactCommon/fabric/textlayoutmanager/RCTAttributedTextUtils.mm index 11d4db50c..542b7859f 100644 --- a/ReactCommon/fabric/textlayoutmanager/RCTAttributedTextUtils.mm +++ b/ReactCommon/fabric/textlayoutmanager/RCTAttributedTextUtils.mm @@ -154,7 +154,7 @@ static NSDictionary *RCTNSTextAttributesFromTextAttri if (textAttributes.textShadowOffset.hasValue()) { auto textShadowOffset = textAttributes.textShadowOffset.value(); NSShadow *shadow = [NSShadow new]; - shadow.shadowOffset = CGSize {textShadowOffset.x, textShadowOffset.y}; + shadow.shadowOffset = CGSize {textShadowOffset.width, textShadowOffset.height}; shadow.shadowBlurRadius = textAttributes.textShadowRadius; shadow.shadowColor = RCTUIColorFromSharedColor(textAttributes.textShadowColor); attributes[NSShadowAttributeName] = shadow;