LibWeb: Layout text chunks based on their Unicode direction

Append text chunks to either the start or end of the text fragment,
depending on the text direction. The direction is determined by what
script its code points are from.
This commit is contained in:
BenJilks 2024-08-18 17:58:05 +01:00 committed by Andreas Kling
commit 11e7d72686
Notes: github-actions[bot] 2024-08-31 09:50:41 +00:00
18 changed files with 460 additions and 150 deletions

View file

@ -33,21 +33,26 @@ public:
size_t length { 0 };
bool has_breaking_newline { false };
bool is_all_whitespace { false };
Gfx::GlyphRun::TextType text_type;
};
class ChunkIterator {
public:
ChunkIterator(StringView text, bool wrap_lines, bool respect_linebreaks, Gfx::FontCascadeList const&);
Optional<Chunk> next();
Optional<Chunk> peek(size_t);
private:
Optional<Chunk> try_commit_chunk(Utf8View::Iterator const& start, Utf8View::Iterator const& end, bool has_breaking_newline, Gfx::Font const&) const;
Optional<Chunk> next_without_peek();
Optional<Chunk> try_commit_chunk(Utf8View::Iterator const& start, Utf8View::Iterator const& end, bool has_breaking_newline, Gfx::Font const&, Gfx::GlyphRun::TextType) const;
bool const m_wrap_lines;
bool const m_respect_linebreaks;
Utf8View m_utf8_view;
Utf8View::Iterator m_iterator;
Gfx::FontCascadeList const& m_font_cascade_list;
Vector<Chunk> m_peek_queue;
};
void invalidate_text_for_rendering();