-
Notifications
You must be signed in to change notification settings - Fork 24.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pass LayoutContext to TextLayoutManager (#40873)
Summary: Pull Request resolved: #40873 Some host platforms may require the LayoutContext for computing the size of text, e.g. to read the pointScaleFactor value. This change passes the LayoutContext to TextLayoutManager so it can be used during text measurement. Please note, for now, this does not wire any fields from LayoutContext through to the TextMeasureCache, TextLayoutManager::getHostTextStorage, or TextLayoutManager::measureCachedSpannableById (on Android). ## Changelog: [General] [Internal] Reviewed By: rshest Differential Revision: D50227592 fbshipit-source-id: 37ec16a4828c6cef4a1c1f01d144a86dd29dec29
- Loading branch information
1 parent
6bf7a01
commit ab72950
Showing
12 changed files
with
77 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
packages/react-native/ReactCommon/react/renderer/textlayoutmanager/TextLayoutContext.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <react/renderer/graphics/Float.h> | ||
|
||
namespace facebook::react { | ||
|
||
/* | ||
* TextLayoutContext: Additional contextual information useful for text | ||
* measurement. | ||
*/ | ||
struct TextLayoutContext { | ||
/* | ||
* Reflects the scale factor needed to convert from the logical coordinate | ||
* space into the device coordinate space of the physical screen. | ||
* Some layout systems *might* use this to round layout metric values | ||
* to `pixel value`. | ||
*/ | ||
Float pointScaleFactor{1.0}; | ||
}; | ||
|
||
inline bool operator==( | ||
TextLayoutContext const& lhs, | ||
TextLayoutContext const& rhs) { | ||
return std::tie(lhs.pointScaleFactor) == std::tie(rhs.pointScaleFactor); | ||
} | ||
|
||
inline bool operator!=( | ||
TextLayoutContext const& lhs, | ||
TextLayoutContext const& rhs) { | ||
return !(lhs == rhs); | ||
} | ||
|
||
} // namespace facebook::react |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters