Skip to content

Commit

Permalink
Turn CXX implementation of TextLayoutManager into interface (facebook…
Browse files Browse the repository at this point in the history
…#39805)

Summary:
Pull Request resolved: facebook#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.

Differential Revision: D49907594

fbshipit-source-id: 565020f83a3f9e6af2f8b04580b519f9ecca26e5
  • Loading branch information
rshest authored and facebook-github-bot committed Oct 4, 2023
1 parent 353d8d3 commit 1c8776b
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 1c8776b

Please sign in to comment.