Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move cancelRequest_ in move ctor in ImageRequest #37221

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ ImageRequest::ImageRequest(
ImageRequest::ImageRequest(ImageRequest &&other) noexcept
: imageSource_(std::move(other.imageSource_)),
telemetry_(std::move(other.telemetry_)),
coordinator_(std::move(other.coordinator_)) {
coordinator_(std::move(other.coordinator_)),
cancelRequest_(std::move(other.cancelRequest_)) {
other.coordinator_ = nullptr;
other.cancelRequest_ = nullptr;
other.telemetry_ = nullptr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ static RCTFontProperties RCTResolveFontProperties(
{
fontProperties.family = fontProperties.family.length ? fontProperties.family : baseFontProperties.family;
fontProperties.size = !isnan(fontProperties.size) ? fontProperties.size : baseFontProperties.size;
fontProperties.weight = !isnan(fontProperties.weight) ? fontProperties.weight : baseFontProperties.weight;
fontProperties.style =
fontProperties.style != RCTFontStyleUndefined ? fontProperties.style : baseFontProperties.style;
fontProperties.variant =
fontProperties.variant != RCTFontVariantUndefined ? fontProperties.variant : baseFontProperties.variant;
return fontProperties;
Expand Down Expand Up @@ -116,9 +113,15 @@ static RCTFontStyle RCTGetFontStyle(UIFont *font)
if ([fontProperties.family isEqualToString:defaultFontProperties.family]) {
// Handle system font as special case. This ensures that we preserve
// the specific metrics of the standard system font as closely as possible.
fontProperties.weight = !isnan(fontProperties.weight) ? fontProperties.weight : defaultFontProperties.weight;
fontProperties.style =
fontProperties.style != RCTFontStyleUndefined ? fontProperties.style : defaultFontProperties.style;

font = RCTDefaultFontWithFontProperties(fontProperties);
} else {
NSArray<NSString *> *fontNames = [UIFont fontNamesForFamilyName:fontProperties.family];
UIFontWeight fontWeight = fontProperties.weight;
RCTFontStyle fontStyle = fontProperties.style;

if (fontNames.count == 0) {
// Gracefully handle being given a font name rather than font family, for
Expand All @@ -129,18 +132,24 @@ static RCTFontStyle RCTGetFontStyle(UIFont *font)
// Failback to system font.
font = [UIFont systemFontOfSize:effectiveFontSize weight:fontProperties.weight];
}
} else {

fontNames = [UIFont fontNamesForFamilyName:font.familyName];
fontWeight = isnan(fontWeight) ? RCTGetFontWeight(font) : fontWeight;
fontStyle = fontStyle == RCTFontStyleUndefined ? RCTGetFontStyle(font) : fontStyle;
}

if (fontNames.count != 0) {
// Get the closest font that matches the given weight for the fontFamily
CGFloat closestWeight = INFINITY;
for (NSString *name in fontNames) {
UIFont *fontMatch = [UIFont fontWithName:name size:effectiveFontSize];

if (RCTGetFontStyle(fontMatch) != fontProperties.style) {
if (RCTGetFontStyle(fontMatch) != fontStyle) {
continue;
}

CGFloat testWeight = RCTGetFontWeight(fontMatch);
if (ABS(testWeight - fontProperties.weight) < ABS(closestWeight - fontProperties.weight)) {
if (ABS(testWeight - fontWeight) < ABS(closestWeight - fontWeight)) {
font = fontMatch;
closestWeight = testWeight;
}
Expand Down