Skip to content

Measure text lines for onTextLayout - #60336

Open
markv wants to merge 1 commit into
react:mainfrom
markv:export-D134743317
Open

markv wants to merge 1 commit into
react:mainfrom
markv:export-D134743317

Conversation

@markv

@markv markv commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Summary:
Fantom didn't deliver onTextLayout: the platform-agnostic C++ TextLayoutManager had no measureLines, so ParagraphShadowNode only logged a warning.

This adds a virtual measureLines to that TextLayoutManager, whose base implementation returns no lines. Fantom's FantomTextLayoutManager overrides it with the layout it paints screenshots with, so onTextLayout reports the lines Fantom draws.

  • Text cut by numberOfLines ends with a tail ellipsis in the reported lines and the screenshot, except after an inline view or emoji on the last line.
  • Selectable text is now painted, and baseline alignment uses the measured lines.
  • Other users of the C++ TextLayoutManager measure no lines: they no longer log the warning and still send no onTextLayout event.

Changelog: [Internal]

Reviewed By: rubennorte

Differential Revision: D134743317

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 27, 2026
@github-actions github-actions Bot added the Meta Review Required This PR is considered risky and requires Meta to import it to do more testing before merging. label Nov 27, 2026
Summary:
Fantom didn't deliver `onTextLayout`: the platform-agnostic C++ `TextLayoutManager` had no `measureLines`, so `ParagraphShadowNode` only logged a warning.

This adds a virtual `measureLines` to that `TextLayoutManager`, whose base implementation returns no lines. Fantom's `FantomTextLayoutManager` overrides it with the layout it paints screenshots with, so `onTextLayout` reports the lines Fantom draws.
- Text cut by `numberOfLines` ends with a tail ellipsis in the reported lines and the screenshot, except after an inline view or emoji on the last line.
- Selectable text is now painted, and baseline alignment uses the measured lines.
- Other users of the C++ `TextLayoutManager` measure no lines: they no longer log the warning and still send no `onTextLayout` event.

Changelog: [Internal]

Reviewed By: rubennorte

Differential Revision: D134743317

@rubennorte rubennorte left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review automatically exported from Phabricator review in Meta.

@meta-codesync

meta-codesync Bot commented Nov 27, 2026

Copy link
Copy Markdown

@markv has exported this pull request. If you are a Meta employee, you can view the originating Diff in D134743317.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Meta Review Required This PR is considered risky and requires Meta to import it to do more testing before merging. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants