Skip to content

Commit a17189e

Browse files
committed
remove old arch impl
1 parent 8ec3967 commit a17189e

3 files changed

Lines changed: 13 additions & 74 deletions

File tree

packages/react-native/Libraries/Text/React-RCTText.podspec

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,4 @@ Pod::Spec.new do |s|
3434

3535
s.dependency "Yoga"
3636
s.dependency "React-Core/RCTTextHeaders", version
37-
add_dependency(s, "React-featureflags")
3837
end

packages/react-native/Libraries/Text/Text/RCTTextShadowView.mm

Lines changed: 11 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
#import <React/RCTTextView.h>
1616
#import "NSTextStorage+FontScaling.h"
1717

18-
#import <react/featureflags/ReactNativeFeatureFlags.h>
19-
2018
@implementation RCTTextShadowView {
2119
__weak RCTBridge *_bridge;
2220
BOOL _needsUpdateView;
@@ -379,38 +377,17 @@ - (void)layoutSubviewsWithContext:(RCTLayoutContext)layoutContext
379377
attribute:NSFontAttributeName
380378
atIndex:0
381379
effectiveRange:nil];
382-
383-
if (facebook::react::ReactNativeFeatureFlags::enableLineHeightCenteringOnIOS()) {
384-
CGFloat ascender = font.ascender;
385-
CGFloat descender = fabs(font.descender);
386-
CGFloat textHeight = ascender + descender;
387-
CGFloat leading = usedRect.size.height - textHeight;
388-
CGFloat adjustedAscender = ascender + ceil(leading / 2.0);
389-
CGFloat adjustedDescender = descender + floor(leading / 2.0);
390-
[lineData addObject:@{
391-
@"text" : renderedString,
392-
@"x" : @(usedRect.origin.x),
393-
@"y" : @(usedRect.origin.y),
394-
@"width" : @(usedRect.size.width),
395-
@"height" : @(usedRect.size.height),
396-
@"descender" : @(adjustedDescender),
397-
@"capHeight" : @(font.capHeight),
398-
@"ascender" : @(adjustedAscender),
399-
@"xHeight" : @(font.xHeight),
400-
}];
401-
} else {
402-
[lineData addObject:@{
403-
@"text" : renderedString,
404-
@"x" : @(usedRect.origin.x),
405-
@"y" : @(usedRect.origin.y),
406-
@"width" : @(usedRect.size.width),
407-
@"height" : @(usedRect.size.height),
408-
@"descender" : @(-font.descender),
409-
@"capHeight" : @(font.capHeight),
410-
@"ascender" : @(font.ascender),
411-
@"xHeight" : @(font.xHeight),
412-
}];
413-
}
380+
[lineData addObject:@{
381+
@"text" : renderedString,
382+
@"x" : @(usedRect.origin.x),
383+
@"y" : @(usedRect.origin.y),
384+
@"width" : @(usedRect.size.width),
385+
@"height" : @(usedRect.size.height),
386+
@"descender" : @(-font.descender),
387+
@"capHeight" : @(font.capHeight),
388+
@"ascender" : @(font.ascender),
389+
@"xHeight" : @(font.xHeight),
390+
}];
414391
}];
415392
NSDictionary *payload = @{
416393
@"lines" : lineData,

packages/react-native/Libraries/Text/Text/RCTTextView.mm

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
#import <React/RCTUtils.h>
1313
#import <React/UIView+React.h>
14-
#import <react/featureflags/ReactNativeFeatureFlags.h>
1514

1615
#import <React/RCTTextShadowView.h>
1716

@@ -99,35 +98,6 @@ - (void)setTextStorage:(NSTextStorage *)textStorage
9998
[self setNeedsDisplay];
10099
}
101100

102-
- (CGPoint)calculateDrawingPointWithTextStorage:(NSTextStorage *)textStorage
103-
contentFrame:(CGRect)contentFrame {
104-
if ([textStorage length] == 0) {
105-
return contentFrame.origin;
106-
}
107-
108-
UIFont *font = [textStorage attribute:NSFontAttributeName atIndex:0 effectiveRange:NULL];
109-
if (!font) {
110-
font = [UIFontMetrics.defaultMetrics scaledFontForFont:[UIFont systemFontOfSize:14]];
111-
}
112-
113-
NSParagraphStyle *paragraphStyle = [textStorage attribute:NSParagraphStyleAttributeName atIndex:0 effectiveRange:NULL];
114-
115-
if (!paragraphStyle || paragraphStyle.minimumLineHeight == 0) {
116-
return CGPointMake(contentFrame.origin.x, contentFrame.origin.y);
117-
}
118-
119-
CGFloat lineHeight = paragraphStyle.minimumLineHeight;
120-
CGFloat ascent = font.ascender;
121-
CGFloat descent = fabs(font.descender);
122-
CGFloat textHeight = ascent + descent;
123-
124-
// Adjust vertical offset to ensure text is vertically centered relative to the line height.
125-
CGFloat difference = MAX(0, textHeight - lineHeight);
126-
CGFloat verticalOffset = difference / 2.0;
127-
128-
return CGPointMake(contentFrame.origin.x, contentFrame.origin.y + verticalOffset);
129-
}
130-
131101
- (void)drawRect:(CGRect)rect
132102
{
133103
[super drawRect:rect];
@@ -148,15 +118,8 @@ - (void)drawRect:(CGRect)rect
148118
#endif
149119

150120
NSRange glyphRange = [layoutManager glyphRangeForTextContainer:textContainer];
151-
152-
if (facebook::react::ReactNativeFeatureFlags::enableLineHeightCenteringOnIOS()) {
153-
CGPoint drawingPoint = [self calculateDrawingPointWithTextStorage:_textStorage contentFrame:_contentFrame];
154-
[layoutManager drawBackgroundForGlyphRange:glyphRange atPoint:drawingPoint];
155-
[layoutManager drawGlyphsForGlyphRange:glyphRange atPoint:drawingPoint];
156-
} else {
157-
[layoutManager drawBackgroundForGlyphRange:glyphRange atPoint:_contentFrame.origin];
158-
[layoutManager drawGlyphsForGlyphRange:glyphRange atPoint:_contentFrame.origin];
159-
}
121+
[layoutManager drawBackgroundForGlyphRange:glyphRange atPoint:_contentFrame.origin];
122+
[layoutManager drawGlyphsForGlyphRange:glyphRange atPoint:_contentFrame.origin];
160123

161124
__block UIBezierPath *highlightPath = nil;
162125
NSRange characterRange = [layoutManager characterRangeForGlyphRange:glyphRange actualGlyphRange:NULL];

0 commit comments

Comments
 (0)