mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-20 06:59:47 +00:00
LibWeb: Ensure up/down arrow navigation is grapheme-aware
Previously, it was possible for an up/down arrow press to place the cursor in the middle of a multi-code point grapheme cluster. We want to prevent this in a way that matches the behavior of other browsers. Both Chrome and Firefox will map the starting position to a visually equivalent position in the target line with harfbuzz and ICU segmenters. The need for this is explained in a code comment. The result is a much more natural feeling of text navigation.
This commit is contained in:
parent
be5c52bfef
commit
0e4fb9ae73
Notes:
github-actions[bot]
2025-08-18 11:18:42 +00:00
Author: https://github.com/trflynn89
Commit: 0e4fb9ae73
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5868
Reviewed-by: https://github.com/AtkinsSJ ✅
Reviewed-by: https://github.com/gmta
5 changed files with 182 additions and 36 deletions
|
@ -391,6 +391,15 @@ TextNode::ChunkIterator::ChunkIterator(TextNode const& text_node, bool wrap_line
|
|||
{
|
||||
}
|
||||
|
||||
TextNode::ChunkIterator::ChunkIterator(TextNode const& text_node, Utf16View const& text, Unicode::Segmenter& grapheme_segmenter, bool wrap_lines, bool respect_linebreaks)
|
||||
: m_wrap_lines(wrap_lines)
|
||||
, m_respect_linebreaks(respect_linebreaks)
|
||||
, m_view(text)
|
||||
, m_font_cascade_list(text_node.computed_values().font_list())
|
||||
, m_grapheme_segmenter(grapheme_segmenter)
|
||||
{
|
||||
}
|
||||
|
||||
static Gfx::GlyphRun::TextType text_type_for_code_point(u32 code_point)
|
||||
{
|
||||
switch (Unicode::bidirectional_class(code_point)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue