Back out "Font size in Text now respects preferredContentSizeCategory"

Summary:
Original commit changeset: 3965a127069a

Changelog: [Internal]

Reviewed By: makovkastar

Differential Revision: D20246919

fbshipit-source-id: d2238f279f44ac4394557949c8f148f08a60647e
This commit is contained in:
Samuel Susla
2020-03-04 05:01:53 -08:00
committed by Facebook Github Bot
parent 0baac1ccfc
commit 74034ba23a
6 changed files with 7 additions and 41 deletions
-2
View File
@@ -44,8 +44,6 @@ RCT_EXTERN void RCTUnsafeExecuteOnMainQueueSync(dispatch_block_t block);
RCT_EXTERN CGFloat RCTScreenScale(void);
RCT_EXTERN CGSize RCTScreenSize(void);
RCT_EXTERN CGFloat RCTFontSizeMultiplier(void);
// Round float coordinates to nearest whole screen pixel (not point)
RCT_EXTERN CGFloat RCTRoundPixelValue(CGFloat value);
RCT_EXTERN CGFloat RCTCeilPixelValue(CGFloat value);
-24
View File
@@ -301,30 +301,6 @@ CGFloat RCTScreenScale()
return scale;
}
CGFloat RCTFontSizeMultiplier()
{
static NSDictionary<NSString *, NSNumber *> *mapping;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
mapping = @{
UIContentSizeCategoryExtraSmall: @0.823,
UIContentSizeCategorySmall: @0.882,
UIContentSizeCategoryMedium: @0.941,
UIContentSizeCategoryLarge: @1.0,
UIContentSizeCategoryExtraLarge: @1.118,
UIContentSizeCategoryExtraExtraLarge: @1.235,
UIContentSizeCategoryExtraExtraExtraLarge: @1.353,
UIContentSizeCategoryAccessibilityMedium: @1.786,
UIContentSizeCategoryAccessibilityLarge: @2.143,
UIContentSizeCategoryAccessibilityExtraLarge: @2.643,
UIContentSizeCategoryAccessibilityExtraExtraLarge: @3.143,
UIContentSizeCategoryAccessibilityExtraExtraExtraLarge: @3.571
};
});
return mapping[RCTSharedApplication().preferredContentSizeCategory].floatValue;
}
CGSize RCTScreenSize()
{
// FIXME: this caches the bounds at app start, whatever those were, and then
-1
View File
@@ -39,7 +39,6 @@ using namespace facebook::react;
static LayoutContext RCTCurrentLayoutContext() {
return {
.pointScaleFactor = RCTScreenScale(),
.fontSizeMultiplier = RCTFontSizeMultiplier()
};
}
@@ -15,10 +15,9 @@ namespace react {
char const ParagraphComponentName[] = "Paragraph";
AttributedString ParagraphShadowNode::getAttributedString(Float fontSizeMultiplier) const {
AttributedString ParagraphShadowNode::getAttributedString() const {
if (!cachedAttributedString_.has_value()) {
auto textAttributes = TextAttributes::defaultTextAttributes();
textAttributes.fontSizeMultiplier = fontSizeMultiplier;
textAttributes.apply(getConcreteProps().textAttributes);
cachedAttributedString_ =
@@ -34,10 +33,10 @@ void ParagraphShadowNode::setTextLayoutManager(
textLayoutManager_ = textLayoutManager;
}
void ParagraphShadowNode::updateStateIfNeeded(LayoutContext layoutContext) {
void ParagraphShadowNode::updateStateIfNeeded() {
ensureUnsealed();
auto attributedString = getAttributedString(layoutContext.fontSizeMultiplier);
auto attributedString = getAttributedString();
auto const &state = getStateData();
assert(textLayoutManager_);
@@ -58,8 +57,7 @@ void ParagraphShadowNode::updateStateIfNeeded(LayoutContext layoutContext) {
#pragma mark - LayoutableShadowNode
Size ParagraphShadowNode::measureContent(LayoutConstraints layoutConstraints, LayoutContext layoutContext) const {
AttributedString attributedString = getAttributedString(layoutContext.fontSizeMultiplier);
AttributedString attributedString = getAttributedString();
if (attributedString.isEmpty()) {
return layoutConstraints.clamp({0, 0});
}
@@ -71,7 +69,7 @@ Size ParagraphShadowNode::measureContent(LayoutConstraints layoutConstraints, La
}
void ParagraphShadowNode::layout(LayoutContext layoutContext) {
updateStateIfNeeded(layoutContext);
updateStateIfNeeded();
ConcreteViewShadowNode::layout(layoutContext);
}
@@ -47,7 +47,7 @@ class ParagraphShadowNode : public ConcreteViewShadowNode<
/*
* Returns a `AttributedString` which represents text content of the node.
*/
AttributedString getAttributedString(Float fontSizeMultiplier) const;
AttributedString getAttributedString() const;
/*
* Associates a shared TextLayoutManager with the node.
@@ -66,7 +66,7 @@ class ParagraphShadowNode : public ConcreteViewShadowNode<
* Creates a `State` object (with `AttributedText` and
* `TextLayoutManager`) if needed.
*/
void updateStateIfNeeded(LayoutContext layoutContext);
void updateStateIfNeeded();
SharedTextLayoutManager textLayoutManager_;
@@ -33,11 +33,6 @@ struct LayoutContext {
*/
Float pointScaleFactor{1.0};
/*
* Multiplier used to change size of the font in surface.
*/
Float fontSizeMultiplier{1.0};
/*
* A raw pointer to list of raw pointers to `LayoutableShadowNode`s that were
* affected by the re-layout pass. If the field is not `nullptr`, a particular