Skip to content

Abnormal caret height for enlarged text input element #36924

Closed

Description

@stevennovaryo

Describe the bug:

For an "editable" element, if we enlarge the line-height of the element, we will get quite an unexpected caret height.

For example, observe the following <input style="line-height: 500px; height: 500px;"></input> in Servo.
Image
Note that is a possible example in a current Servo due to the current implementation of HTMLInputElement.

As I perceive it, caret height seems to depend fully on inline block height right now. I suppose we could made it depends on font metrics as well, possibly font strut.

cc: @dklassic might be interested to look at this.

To Reproduce:

<input style="line-height: 500px; height: 500px;"></input>

Platform:
Ubuntu 24.04 LTS

Activity

  1. added
    C-untriaged
    on May 9, 2025
  2. added
    C-has-manual-testcase
    and removed
    C-untriaged
    on May 9, 2025
  3. dklassic commented on May 9, 2025

    @dklassic
    Contributor

    Yes it currently uses the full height. I think I implemented this way because due to how we currently render the caret alongside the text, and that each TextFragment might have different height and base offset, leading to jumping caret between different fonts.

    I’m not sure if this is something that should be changed on the font rendering side or maybe we should have a fixed caret range given somehow.

  4. mrobinson commented on Mar 10, 2026

    @mrobinson
    Member

    Probably what we should do here is when laying out a line, we should calculate a maximum length for the caret / selection.

  5. added a commit that references this issue on Sep 16, 2026
    9773ece
  6. added a commit that references this issue on Oct 6, 2026
    39c52f1
  7. added a commit that references this issue on Oct 12, 2026
    59bc769
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-formsA-layout/inlineA-platform/fontsC-has-manual-testcase

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions