diff --git a/ReactCommon/fabric/attributedstring/TextAttributes.cpp b/ReactCommon/fabric/attributedstring/TextAttributes.cpp index c30817a8ea8ad6..82052a7d7bec7c 100644 --- a/ReactCommon/fabric/attributedstring/TextAttributes.cpp +++ b/ReactCommon/fabric/attributedstring/TextAttributes.cpp @@ -94,7 +94,7 @@ void TextAttributes::apply(TextAttributes textAttributes) { layoutDirection = textAttributes.layoutDirection.hasValue() ? textAttributes.layoutDirection : layoutDirection; - accessibilityRole = textAttributes.accessibilityRole.hasValue() + accessibilityRole = !textAttributes.accessibilityRole.empty() ? textAttributes.accessibilityRole : accessibilityRole; } diff --git a/ReactCommon/fabric/attributedstring/TextAttributes.h b/ReactCommon/fabric/attributedstring/TextAttributes.h index 2589d89dfd9131..75937237492614 100644 --- a/ReactCommon/fabric/attributedstring/TextAttributes.h +++ b/ReactCommon/fabric/attributedstring/TextAttributes.h @@ -77,7 +77,7 @@ class TextAttributes : public DebugStringConvertible { // Currently, it is intentionally *not* being set as part of BaseTextProps // construction. folly::Optional layoutDirection{}; - folly::Optional accessibilityRole{}; + std::string accessibilityRole{""}; #pragma mark - Operations diff --git a/ReactCommon/fabric/attributedstring/conversions.h b/ReactCommon/fabric/attributedstring/conversions.h index 75a99e653f6935..3046e8f79830d3 100644 --- a/ReactCommon/fabric/attributedstring/conversions.h +++ b/ReactCommon/fabric/attributedstring/conversions.h @@ -412,34 +412,6 @@ inline std::string toString( } } -inline std::string toString(const AccessibilityRole &accessibilityRole) { - switch (accessibilityRole) { - case AccessibilityRole::Link: - return "link"; - case AccessibilityRole::Button: - return "button"; - case AccessibilityRole::Image: - return "image"; - } -} - -inline void fromRawValue(const RawValue &value, AccessibilityRole &result) { - auto string = (std::string)value; - if (string == "link") { - result = AccessibilityRole::Link; - return; - } - if (string == "button") { - result = AccessibilityRole::Button; - return; - } - if (string == "image") { - result = AccessibilityRole::Image; - return; - } - abort(); -} - inline ParagraphAttributes convertRawProp( RawProps const &rawProps, ParagraphAttributes const &sourceParagraphAttributes, diff --git a/ReactCommon/fabric/attributedstring/primitives.h b/ReactCommon/fabric/attributedstring/primitives.h index 0bcab853bdb283..c44538c546a550 100644 --- a/ReactCommon/fabric/attributedstring/primitives.h +++ b/ReactCommon/fabric/attributedstring/primitives.h @@ -87,12 +87,6 @@ enum class TextDecorationLinePattern { DashDotDot, }; -enum class AccessibilityRole { - Link, - Button, - Image, -}; - } // namespace react } // namespace facebook @@ -166,12 +160,4 @@ struct hash { return hash()(static_cast(v)); } }; - -template <> -struct hash { - size_t operator()(const facebook::react::AccessibilityRole &v) const { - return hash()(static_cast(v)); - } -}; - } // namespace std diff --git a/ReactCommon/fabric/textlayoutmanager/platform/ios/RCTAttributedTextUtils.mm b/ReactCommon/fabric/textlayoutmanager/platform/ios/RCTAttributedTextUtils.mm index a03f928f2c6c0d..df67fc85fedfb8 100644 --- a/ReactCommon/fabric/textlayoutmanager/platform/ios/RCTAttributedTextUtils.mm +++ b/ReactCommon/fabric/textlayoutmanager/platform/ios/RCTAttributedTextUtils.mm @@ -212,19 +212,9 @@ inline static CGFloat RCTEffectiveFontSizeMultiplierFromTextAttributes(const Tex attributes[RCTAttributedStringIsHighlightedAttributeName] = @YES; } - if (textAttributes.accessibilityRole.hasValue()) { - auto accessibilityRole = textAttributes.accessibilityRole.value(); - switch (accessibilityRole) { - case AccessibilityRole::Link: - attributes[RCTTextAttributesAccessibilityRoleAttributeName] = @("link"); - break; - case AccessibilityRole::Button: - attributes[RCTTextAttributesAccessibilityRoleAttributeName] = @("button"); - break; - case AccessibilityRole::Image: - attributes[RCTTextAttributesAccessibilityRoleAttributeName] = @("image"); - break; - }; + if (!textAttributes.accessibilityRole.empty()) { + attributes[RCTTextAttributesAccessibilityRoleAttributeName] = + [NSString stringWithCString:textAttributes.accessibilityRole.c_str() encoding:NSUTF8StringEncoding]; } return [attributes copy];