Skip to content

Commit

Permalink
Turn CXX implementation of TextLayoutManager into interface (#39805)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #39805

## Changelog:
[Internal] -

This makes corresponsing text measure methods inside `TextLayoutManager` overridable, so that it can be substituted with a custom implementation without introducing a new "platform".

Rationale: CXX platform is rather general and less specific than Android or iOS, so we may potentially have multiple alternative implementations of text layout there.

An alternative could be making `TextLayoutManager` an interface across all the platforms, and actual implementations called e.g. `TextLayoutManagerImpl` in each of them, however this would be quite a bit bigger blast radius without much added benefit for Android/iOS.

Reviewed By: christophpurrer

Differential Revision: D49907594

fbshipit-source-id: dc8213ddb2313adaa86c2852d23bb038d80ac244
  • Loading branch information
rshest authored and facebook-github-bot committed Oct 4, 2023
1 parent 7a320f1 commit c969d8c
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ class TextLayoutManager {
public:
TextLayoutManager(const ContextContainer::Shared& contextContainer) {}

virtual ~TextLayoutManager() = default;

/*
* Measures `attributedStringBox` using native text rendering infrastructure.
*/
TextMeasurement measure(
virtual TextMeasurement measure(
AttributedStringBox attributedStringBox,
ParagraphAttributes paragraphAttributes,
LayoutConstraints layoutConstraints,
Expand All @@ -42,7 +44,7 @@ class TextLayoutManager {
* Measures lines of `attributedString` using native text rendering
* infrastructure.
*/
LinesMeasurements measureLines(
virtual LinesMeasurements measureLines(
AttributedString attributedString,
ParagraphAttributes paragraphAttributes,
Size size) const;
Expand All @@ -53,7 +55,7 @@ class TextLayoutManager {
*/
void* getNativeTextLayoutManager() const;

std::shared_ptr<void> getHostTextStorage(
virtual std::shared_ptr<void> getHostTextStorage(
AttributedString attributedStringBox,
ParagraphAttributes paragraphAttributes,
LayoutConstraints layoutConstraints) const;
Expand Down

0 comments on commit c969d8c

Please sign in to comment.