engine
engine copied to clipboard
[web] Separate text fragmenting from layout
Text layout used to be intertwined with text fragmenting. The idea originally was to do the entire layout in a single pass. But that led to extra complexity in the code and difficulty of maintenance.
With this PR, we are separating the fragmenting of the text from the layout. The high level algorithm looks roughly like this:
- Break the paragraph into fragments.
- Measure these fragments.
- Layout the fragments into lines.
- Calculate paragraph-level metrics (height, min intrinsic width, longest line, etc).
In addition to simplifying the code and making it more maintainable, this PR also opens up the door for a few other changes that we intend to make in the text area:
- Ability to reuse the fragmenting logic with the CanvasKit renderer.
- Adoption of
v8BreakIteratorin Chrome.
This PR is necessary towards removing ICU data from CanvasKit (issue).