mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 08:28:11 +00:00
LibWeb: Refactor TextNode::ChunkIterator
This commit refactors the text chunking algorithm used in TextNode::ChunkIterator. The m_start_of_chunk member parameter has been replaced with a local variable that's anchored to the current iterator at the start of every next() call, and the algorithm is made a little more clear by explicitly separating what can and cannot peek into the next character during iteration.
This commit is contained in:
parent
48a1a3c0ce
commit
0342fe4e0c
2 changed files with 48 additions and 28 deletions
|
@ -41,7 +41,7 @@ public:
|
|||
Optional<Chunk> next();
|
||||
|
||||
private:
|
||||
Optional<Chunk> try_commit_chunk(Utf8View::Iterator const&, bool has_breaking_newline, bool must_commit = false);
|
||||
Optional<Chunk> try_commit_chunk(Utf8View::Iterator const& start, Utf8View::Iterator const& end, bool has_breaking_newline, bool must_commit = false);
|
||||
|
||||
const LayoutMode m_layout_mode;
|
||||
const bool m_wrap_lines;
|
||||
|
@ -49,7 +49,6 @@ public:
|
|||
bool m_last_was_space { false };
|
||||
bool m_last_was_newline { false };
|
||||
Utf8View m_utf8_view;
|
||||
Utf8View::Iterator m_start_of_chunk;
|
||||
Utf8View::Iterator m_iterator;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue