The ultimate goal is to make InlineBoxes oblivious to TextIterator, so that TextIterator can emit everything in a TextNode at once, instead of iterating over the text boxes and emitting the text box by box.
Rough plan:
1. Clean up the maintenance of certain variables in TextIterator, so that they are maintained and used by text-node-handling functions (or chunks of code) that do not call TextIterator functions.
A tentative list of variables:
- offset_
- text_box_
- remaining_text_box_
- first_letter_text_
- last_text_node_
- last_text_node_ended_with_collapsed_space_
- sorted_text_boxes_
- sorted_text_boxes_position_
- handled_first_letter
- first_letter_start_offset_
- remaining_text_start_offset_
2. Create a wrapper class for text node handling. It should contain at least the following functions:
- HandleTextNode
- HandleTextBox
- HandleTextNodeFirstLetter
- PrepareForFirstLetterInitialization
- HasNotAdvancedToStartPosition
- EmitText
SpliceBuffer is currently kind-of shared by both text and non-text node handling. Still need to figure out the correct place to put this function.
3. Make the wrapper class concatenate strings of text boxes, and add positions mapping between DOM and plain text offsets.
Comment 1 by xiaoche...@chromium.org
, May 12 2017