Repository navigation
script: Add support for setting the edit point with the mouse in <input> and <textarea> - #41906
Merged
Merged
Conversation
mrobinson
requested review from
Loirooriol,
gterzian and
nicoburns
as code owners
January 14, 2026 11:07
mrobinson
force-pushed
the
glyph-index
branch
2 times, most recently
from
January 14, 2026 11:10
926a7cb to
cf24978
Compare
❌ 1 Tests Failed:
View the top 1 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
mrobinson
force-pushed
the
glyph-index
branch
from
January 14, 2026 11:23
cf24978 to
6acb432
Compare
Loirooriol
approved these changes
Jan 14, 2026
| ifc.possibly_flush_deferred_forced_line_break(); | ||
|
|
||
| // Advance the glyph offset of the current inline container. Note that this must | ||
| // be done before handling preserved newlines, as they count as glpyhs for the |
Contributor
There was a problem hiding this comment.
Suggested change
| // be done before handling preserved newlines, as they count as glpyhs for the | |
| // be done before handling preserved newlines, as they count as glyphs for the |
Comment on lines
+382
to
+385
| current_offset += glyph.advance(); | ||
| if current_offset - (glyph.advance().scale_by(0.5)) >= point.x { | ||
| return current_glyph; | ||
| } |
Contributor
There was a problem hiding this comment.
Can avoid calling glyph.advance() twice, and I think it looks better by increasing afterwards instead of subtracting in the condition
Suggested change
| current_offset += glyph.advance(); | |
| if current_offset - (glyph.advance().scale_by(0.5)) >= point.x { | |
| return current_glyph; | |
| } | |
| let advance = glyph.advance(); | |
| if current_offset + advance.scale_by(0.5) >= point.x { | |
| return current_glyph; | |
| } | |
| current_offset += advance; |
mrobinson
force-pushed
the
glyph-index
branch
from
January 14, 2026 12:05
6acb432 to
6a65964
Compare
…put>` and `<textarea>` This change updates and implements the old `query_text_index` layout query to properly look for the glyph index of a point within a node's `Fragment`s. This should work properly with the shadow DOM of both `<input>` and `<textarea>` elements. In particular, multiple lines are supported. Caveats: - `<input>` and `<textarea>` that are transformed are currently not supported. This will happen in a followup. - For multi-line inputs, we should be finding the text offset of the nearest line that is within the block range of the click. This will happen in a followup. Co-authored-by: Josh Matthews <[email protected]> Co-authored-by: Oriol Brufau <[email protected]> Signed-off-by: Martin Robinson <[email protected]>
mrobinson
force-pushed
the
glyph-index
branch
from
January 14, 2026 13:14
6a65964 to
466a874
Compare
mrobinson
enabled auto-merge
January 14, 2026 13:14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change updates and implements the old
query_text_indexlayoutquery to properly look for the glyph index of a point within a node's
Fragments. This should work properly with the shadow DOM of both<input>and<textarea>elements. In particular, multiple lines aresupported.
Caveats:
<input>and<textarea>that are transformed are currently notsupported. This will happen in a followup.
nearest line that is within the block range of the click. This will
happen in a followup.
Testing: This change adds two Servo-specific WPT-style tests. These are
Servo-specific because the behavior of clicking in text fields isn't
fully specified.
Fixes: #35432
Fixes: #10083