Fabric: Using ManagedObjectWrapper in RCTTextLayoutManager

Summary:
While I was investigated the previous issue (T59430348) I found this place where we manipulate managed pointers manually. So, to make it error-prone this diff changes it to use `wrapManagedObject`.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross

Differential Revision: D21943010

fbshipit-source-id: ecaeffb419ae8d4880187027ca7ec9563e0dfd46
This commit is contained in:
Valentin Shergin
2020-06-09 12:40:43 -07:00
committed by Facebook GitHub Bot
parent 2a80579ea1
commit a28a52dd64
@@ -10,12 +10,13 @@
#import "NSTextStorage+FontScaling.h"
#import "RCTAttributedTextUtils.h"
#import <react/utils/ManagedObjectWrapper.h>
#import <react/utils/SimpleThreadSafeCache.h>
using namespace facebook::react;
@implementation RCTTextLayoutManager {
SimpleThreadSafeCache<AttributedString, std::shared_ptr<const void>, 256> _cache;
SimpleThreadSafeCache<AttributedString, std::shared_ptr<void>, 256> _cache;
}
static NSLineBreakMode RCTNSLineBreakModeFromEllipsizeMode(EllipsizeMode ellipsizeMode)
@@ -171,12 +172,11 @@ static NSLineBreakMode RCTNSLineBreakModeFromEllipsizeMode(EllipsizeMode ellipsi
- (NSAttributedString *)_nsAttributedStringFromAttributedString:(AttributedString)attributedString
{
auto sharedNSAttributedString = _cache.get(attributedString, [](const AttributedString attributedString) {
return std::shared_ptr<void>(
(__bridge_retained void *)RCTNSAttributedStringFromAttributedString(attributedString), CFRelease);
auto sharedNSAttributedString = _cache.get(attributedString, [](AttributedString attributedString) {
return wrapManagedObject(RCTNSAttributedStringFromAttributedString(attributedString));
});
return (__bridge NSAttributedString *)sharedNSAttributedString.get();
return unwrapManagedObject(sharedNSAttributedString);
}
@end