Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGlyph count used a grapheme cluster count in text input hit testing #23399
Labels
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
From #23272 (comment)
The
script::textinput::TextInput::set_edit_point_indexmethod is called forclickevents on<input>elements to set the cursor’s position. It takes ausizeparameter that is interpreted as a number of grapheme clusters:servo/components/script/textinput.rs
Lines 990 to 996 in 576394b
This number ultimately comes from here:
servo/components/gfx/text/text_run.rs
Lines 369 to 385 in 576394b
servo/components/gfx/text/glyph.rs
Lines 576 to 600 in 576394b
… where is is computed as a number of glyphs.
Grapheme clusters only map to glyphs one to one in simple cases. This could cause the cursor to end up at an incorrect position, far from where click cursor was.
Instead, the gfx code should map positions in the glyph sequence back to UTF-8 positions in the original Unicode text, and
set_edit_point_indexinterpret its parameter as a UTF-8 byte count instead of a grapheme cluster count.