Skip to content

Commit e973612

Browse files
authored
Parley: cleanups (#9995)
* parley: Move the code for creating the ranged builders into a separate struct This makes it easier to see what's needed for create the builders and reduces the lines of code for the layout function. * parley: Move the parley::Layout building into LayoutWithoutLineBreaksBuilder That way we can make sure that the text applied to the ranged_builder and the final layout is the same. * parley: Separate creation of parley layouts from applying the line breaks and positioning In the future, once fully separated, we can cache the layout without the line breaks. * parley: Simplify LayoutWithoutLineBreaksBuilder::build We only need the contexts within, so remove the argument. * parley: Move pixel size computation into LayoutWithoutLineBreaksBuilder constructor That's the only place where we need to compute it. * parley: Reduce fields in LayoutOptions Remove font_request and stroke, as that's only needed in LayoutWithoutLineBreaksBuilder, which is now passed into layout(). This is, again, in preparation of further separating the creation of the layouts (mainly shaping) and the line breaking and positioning. * parley: Separate text layout steps further With this PR, text layout is now split into three phrases: 1. Set up parley 2. Create paragraphs of text with formatting applied - stored in essentially a vec of parley layouts. This step includes shaping. 3. Apply line breaking to the layouts. This step includes glyph positioning. * parley: Move selection handling into LayoutWithoutLineBreaksBuilder It's only needed there, and only set from draw_text_input. * parley: Move text wrap into LayoutWithoutLineBreaksBuilder * parley: Move LayoutOptions creations right to the call where needed * parley: In draw_text() initialize variables closes to their use-site * parley: In draw_text_input() initialize variables closer to their use-site This is done with the exceptions of opportunities for early returns, as those can then also avoid unnecessary property dependencies. * parley: In text_size(), improve localty if variable declaration and use-site slightly * parley: Improve variable locality in link_under_cursor * parley: Improve variable locality in text_input_cursor_rect_for_byte_offset * parley: Improve variable locality in text_input_byte_offset_for_position * parley: Avoid unnecessary pixel_size computation in text_input_cursor_rect_for_byte_offset * parley: Simplify cursor drawing code
1 parent 1997584 commit e973612

File tree

1 file changed

+310
-247
lines changed

1 file changed

+310
-247
lines changed

0 commit comments

Comments
 (0)