Removed placeholder image logic

Summary: To prevent layout popping, when inserting images inside text we would render a blank placeholder image while the real image was loading. It turns out that this isn't necessary, as we can just specify the size of the image without having an actual image to display.

Reviewed By: javache

Differential Revision: D3212766

fb-gh-sync-id: e98851b32a2d0ae809fc0a4be47e6b77f3b17996
fbshipit-source-id: e98851b32a2d0ae809fc0a4be47e6b77f3b17996
This commit is contained in:
Nick Lockwood
2016-04-25 03:30:54 -07:00
committed by Facebook Github Bot 2
parent 0bf737ff0a
commit 37f4ec6e16
5 changed files with 4 additions and 110 deletions

View File

@@ -217,12 +217,10 @@ static css_dim_t RCTMeasure(void *context, float width, css_measure_mode_t width
RCTShadowRawText *shadowRawText = (RCTShadowRawText *)child;
[attributedString appendAttributedString:[[NSAttributedString alloc] initWithString:shadowRawText.text ?: @""]];
} else if ([child conformsToProtocol:@protocol(RCTImageComponent)]) {
UIImage *image = ((id<RCTImageComponent>)child).image;
if (image) {
NSTextAttachment *imageAttachment = [NSTextAttachment new];
imageAttachment.image = image;
[attributedString appendAttributedString:[NSAttributedString attributedStringWithAttachment:imageAttachment]];
}
NSTextAttachment *imageAttachment = [NSTextAttachment new];
imageAttachment.image = ((id<RCTImageComponent>)child).image;
imageAttachment.bounds = (CGRect){CGPointZero, {RCTZeroIfNaN(child.width), RCTZeroIfNaN(child.height)}};
[attributedString appendAttributedString:[NSAttributedString attributedStringWithAttachment:imageAttachment]];
} else {
RCTLogError(@"<Text> can't have any children except <Text>, <Image> or raw strings");
}