Skip to content

script: Render caret inside of contenteditable elements - #48253

Merged
mrobinson merged 1 commit into
servo:mainfrom
Psychpsyo:contentEditble-render-selection
Nov 7, 2026
Merged

mrobinson merged 1 commit into
servo:mainfrom
Psychpsyo:contentEditble-render-selection

Conversation

@Psychpsyo

@Psychpsyo Psychpsyo commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

This makes 0-length selections show up as a blinking cursor if they are placed within a contenteditable region of the page.

Part of #25005

@mrobinson

Copy link
Copy Markdown
Member

@Psychpsyo You should be able to test this because caret don't blink when WPT tests are running. Create a contenteditable region and make a mismatch reftest ensuring that the version with the caret doesn't look like one without it.

@Psychpsyo
Psychpsyo force-pushed the contentEditble-render-selection branch from dfcaf5b to 9fb4f8a Compare September 28, 2026 11:15
@mrobinson mrobinson added the T-linux-wpt Do a try run of the WPT label Oct 5, 2026
@github-actions github-actions Bot removed the T-linux-wpt Do a try run of the WPT label Oct 5, 2026
@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown

🔨 Triggering try run (#37313130798) for Linux (WPT)

@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown

⚠️ Try run (#37313130798) failed!

@Psychpsyo
Psychpsyo force-pushed the contentEditble-render-selection branch 2 times, most recently from 61563cd to 3740af5 Compare October 20, 2026 11:44
@mrobinson mrobinson added the T-linux-wpt Do a try run of the WPT label Oct 21, 2026
@github-actions github-actions Bot removed the T-linux-wpt Do a try run of the WPT label Oct 21, 2026
@github-actions

Copy link
Copy Markdown

🔨 Triggering try run (#39589883154) for Linux (WPT)

@github-actions

Copy link
Copy Markdown

Test results for linux-wpt from try job (#39589883154):

Flaky unexpected result (18)
  • CRASH [expected OK] /IndexedDB/idbdatabase_deleteObjectStore.any.sharedworker.html
  • CRASH [expected OK] /_webgl/conformance2/wasm/readpixels-2gb-in-4gb-wasm-memory.html
  • TIMEOUT [expected CRASH] /content-security-policy/inheritance/blob-url-in-main-window-self-navigate-inherits.sub.html (#41490)
  • TIMEOUT [expected OK] /content-security-policy/navigation/to-javascript-parent-initiated-parent-csp.html (#46400)
    • TIMEOUT [expected PASS] subtest: Should not have executed the javascript url for area[target=iframe].href

      Test timed out
      

    • NOTRUN [expected PASS] subtest: Should not have executed the javascript url for area[target=otherTab].href
    • NOTRUN [expected PASS] subtest: Should not have executed the javascript url for a[target=otherTab].href
    • NOTRUN [expected PASS] subtest: Should not have executed the javascript url for a[target=iframe].href
  • OK /css/css-animations/event-order.tentative.html (#39000)
    • PASS [expected FAIL] subtest: Same events on pseudo-elements follow the prescribed order
  • OK /dom/nodes/moveBefore/iframe-document-preserve.window.html (#43152)
    • FAIL [expected PASS] subtest: moveBefore(): cross-origin iframe is preserved: remove new parent

      assert_equals: iframe does not fire a second load event expected 1 but got 0
      

    • FAIL [expected PASS] subtest: moveBefore(): cross-origin iframe is preserved: remove self via replaceChildren()

      assert_equals: iframe does not fire a second load event expected 1 but got 0
      

  • OK [expected TIMEOUT] /fetch/api/redirect/redirect-keepalive.https.any.html (#32153)
    • PASS [expected TIMEOUT] subtest: [keepalive][iframe][load] mixed content redirect; setting up
  • OK [expected TIMEOUT] /html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/form-submit.html (#44028)
  • CRASH [expected OK] /html/browsers/history/the-location-interface/assign-replace-from-iframe.html (#47679)
  • TIMEOUT /html/semantics/embedded-content/media-elements/autoplay-default-permissions-policy.https.sub.html (#46805)
    • PASS [expected TIMEOUT] subtest: Default "autoplay" feature policy ["self"] allows the top-level document.
  • OK /html/semantics/forms/form-submission-0/jsurl-form-submit.tentative.html (#36489)
    • PASS [expected FAIL] subtest: Verifies that form submissions scheduled inside javascript: urls take precedence over the javascript: url's return value.
  • CRASH [expected FAIL] /html/semantics/interestfor/interestfor-plain-inline-element.tentative.html
  • OK /html/semantics/scripting-1/the-script-element/execution-timing/077.html (#22139)
    • FAIL [expected PASS] subtest: adding several types of scripts through the DOM and removing some of them confuses scheduler

      assert_array_equals: expected property 1 to be "Script #1 ran" but got "Script #3 ran" (expected array ["Script #2 ran", "Script #1 ran", "Script #3 ran", "Script #4 ran"] got ["Script #2 ran", "Script #3 ran", "Script #4 ran", "Script #1 ran"])
      

  • CRASH [expected OK] /html/webappapis/dynamic-markup-insertion/opening-the-input-stream/remove-initial-about-blankness.window.html (#47638)
  • OK /mixed-content/tentative/autoupgrades/video-upgrade.https.sub.html (#41135)
    • FAIL [expected PASS] subtest: Video of other host autoupgraded

      assert_equals: Length. Other host expected 1 but got Infinity
      

  • TIMEOUT [expected OK] /pointerevents/compat/pointerevent_touch-action_two-finger_interaction.html
    • NOTRUN [expected PASS] subtest: touch two-finger pan on 'touch-action: pan-x pan-y'
    • NOTRUN [expected FAIL] subtest: touch two-finger pan on 'touch-action: pinch-zoom'
  • OK /user-timing/measure_associated_with_navigation_timing.html (#47273)
    • PASS [expected FAIL] subtest: loadTime plus loadEventEnd to a mark "a" should equal to navigationStart to "a".
  • OK /xhr/send-redirect.htm (#32026)
    • FAIL [expected PASS] subtest: XMLHttpRequest: send() - Redirects (basics) (303, GET, content.py)

      assert_equals: expected (string) "GET" but got (object) null
      

Stable unexpected results that are known to be intermittent (8)
  • OK /beacon/beacon-basic.https.window.html (#41723)
    • FAIL [expected PASS] subtest: Payload size restriction should be accumulated: type = string

      assert_false: expected false got true
      

    • FAIL [expected PASS] subtest: Payload size restriction should be accumulated: type = arraybuffer

      assert_false: expected false got true
      

    • FAIL [expected PASS] subtest: Payload size restriction should be accumulated: type = blob

      assert_false: expected false got true
      

  • OK /css/css-fonts/variations/at-font-face-font-matching.html (#20684)
    • FAIL [expected PASS] subtest: Matching font-weight: '500' should prefer '450 460' over '400'

      assert_equals: Unexpected font on test element expected 487 but got 532
      

    • FAIL [expected PASS] subtest: Matching font-style: 'italic' should prefer 'oblique 30deg 60deg' over 'oblique 40deg 50deg'

      assert_equals: Unexpected font on test element expected 487 but got 532
      

    • FAIL [expected PASS] subtest: Matching font-style: 'oblique 10deg' should prefer 'oblique 5deg' over 'oblique 15deg 20deg'

      assert_equals: Unexpected font on test element expected 487 but got 532
      

    • FAIL [expected PASS] subtest: Matching font-style: 'oblique 0deg' should prefer 'oblique -50deg -20deg' over 'oblique -40deg -30deg'

      assert_equals: Unexpected font on test element expected 487 but got 532
      

  • CRASH [expected TIMEOUT] /html/browsers/history/the-location-interface/location_replace_session_history.html (#41896)
  • CRASH [expected OK] /html/browsers/history/the-location-interface/security_location_0.htm (#48200)
  • TIMEOUT /html/browsers/sandboxing/sandbox-window-open-srcdoc.html (#48863)
    • TIMEOUT [expected PASS] subtest: window.open('about:srcdoc') from sandboxed srcdoc doesn't crash.

      Test timed out
      

    • NOTRUN [expected PASS] subtest: popup is isolated from an isolated iframe
  • TIMEOUT [expected OK] /html/semantics/embedded-content/media-elements/autoplay-allowed-by-permissions-policy.https.sub.html (#46803)
    • TIMEOUT [expected PASS] subtest: Permissions-Policy header: autoplay * allows same-origin iframes.

      Test timed out
      

  • OK /html/semantics/embedded-content/media-elements/media_fragment_seek.html (#24114)
    • PASS [expected FAIL] subtest: Video should seek to time specified in media fragment syntax
  • OK /html/semantics/forms/form-submission-0/form-submit-iframe-then-location-navigate.html (#29634)
    • FAIL [expected PASS] subtest: Verifies that location navigations take precedence when following form submissions.

      assert_equals: expected "/html/semantics/forms/form-submission-0/resources/location.html" but got "/html/semantics/forms/form-submission-0/resources/form.html"
      

Stable unexpected results (9)
  • FAIL [expected PASS] /css/css-ui/caret-color-bar-shape-text-color.html
  • FAIL [expected PASS] /css/css-ui/caret-color-underscore-shape-text-color.html
  • OK /editing/other/empty-elements-insertion.html
    • PASS [expected FAIL] subtest: Insert text into the unstyled inline element with the styled ::after pseudoelement
  • OK /editing/run/delete-to-make-editing-host-empty.html
    • FAIL [expected PASS] subtest: Backspace when "a[]"

      assert_equals: Comparing editing host height expected 37.3 but got 18.65
      

    • FAIL [expected PASS] subtest: Delete when "[]a"

      assert_equals: Comparing editing host height expected 37.3 but got 18.65
      

    • FAIL [expected PASS] subtest: Backspace when "{a}"

      assert_equals: Comparing editing host height expected 37.3 but got 18.65
      

    • FAIL [expected PASS] subtest: Delete when "{a}"

      assert_equals: Comparing editing host height expected 37.3 but got 18.65
      

  • FAIL [expected PASS] /html/editing/editing-0/spelling-and-grammar-checking/spelling-markers-002.html
  • FAIL [expected PASS] /html/editing/editing-0/spelling-and-grammar-checking/spelling-markers-003.html
  • FAIL [expected PASS] /html/editing/editing-0/spelling-and-grammar-checking/spelling-markers-004.html
  • FAIL [expected PASS] /html/editing/editing-0/spelling-and-grammar-checking/spelling-markers-005.html
  • FAIL [expected PASS] /html/editing/editing-0/spelling-and-grammar-checking/spelling-markers-006.html

@github-actions

Copy link
Copy Markdown

⚠️ Try run (#39589883154) failed!

@Psychpsyo
Psychpsyo force-pushed the contentEditble-render-selection branch 2 times, most recently from 055da28 to 594f226 Compare October 30, 2026 15:37
@Psychpsyo
Psychpsyo marked this pull request as ready for review October 30, 2026 15:37
@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Oct 30, 2026
@servo-highfive

Copy link
Copy Markdown

Someone thinks this change could be added to the monthly blog post! To help with this, we need someone to answer the following questions: 😄

  1. Who is most impacted by this change: users, Servo developers, embedders, or some other group?
  2. What observable difference does this change make?
  3. What preferences (if any) need to be enabled to observe this difference?
  4. What (if any) specific URLs are affected?

If this change is part of a broader feature/project please make sure the PR description contains a Fixes: #12345 or Part of: #12345 issue reference.

Please add @servo-highfive monthly update answer when answering these questions so the bot notices your answer (or just quote this comment).

Thanks for helping us prepare the monthly blog post! ❤️

@Psychpsyo

Copy link
Copy Markdown
Contributor Author

I've taken a look at the failed tests now:
The css-ui ones are because we don't have support for the 2-color syntax of caret-color. That seems to be missing from stylo and is unrelated to this PR.
The spelling-marker tests are more interesting. They programmatically remove the contenteditable attribute, which causes us to invalidate the selection. When loading it up manually, that makes the caret disappear, but I'm guessing the test runner maybe takes the screenshot too early?

@Psychpsyo

Psychpsyo commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor Author

@servo-highfive monthly update answer

  • Who is most impacted by this change: users, Servo developers, embedders, or some other group?

Mainly users, although embedders might be interested for that reason as well.

  • What observable difference does this change make?

The text editing caret shows up in contenteditable elements. This makes rich text editors way more usable.

  • What preferences (if any) need to be enabled to observe this difference?

dom_exec_command_enabled

  • What (if any) specific URLs are affected?

Anything that uses a WYSIWYG text editor, I tend to use https://www.tiny.cloud/docs/tinymce/latest/basic-example/ in testing.

@servo-wpt-sync

Copy link
Copy Markdown
Collaborator

🤖 Opened new upstream WPT pull request (web-platform-tests/wpt#64640) with upstreamable changes.

@servo-wpt-sync

Copy link
Copy Markdown
Collaborator

📝 Transplanted new upstreamable changes to existing upstream WPT pull request (web-platform-tests/wpt#64640).

@servo-wpt-sync

Copy link
Copy Markdown
Collaborator

📝 Transplanted new upstreamable changes to existing upstream WPT pull request (web-platform-tests/wpt#64640).

1 similar comment
@servo-wpt-sync

Copy link
Copy Markdown
Collaborator

📝 Transplanted new upstreamable changes to existing upstream WPT pull request (web-platform-tests/wpt#64640).

@mrobinson mrobinson added the T-linux-wpt Do a try run of the WPT label Nov 4, 2026
@github-actions github-actions Bot removed the T-linux-wpt Do a try run of the WPT label Nov 4, 2026
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

🔨 Triggering try run (#41803669577) for Linux (WPT)

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

⚠️ Try run (#41803669577) failed!

@servo-wpt-sync

Copy link
Copy Markdown
Collaborator

📝 Transplanted new upstreamable changes to existing upstream WPT pull request (web-platform-tests/wpt#64640).

@mrobinson mrobinson added the T-linux-wpt Do a try run of the WPT label Nov 6, 2026
@github-actions github-actions Bot removed the T-linux-wpt Do a try run of the WPT label Nov 6, 2026
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

🔨 Triggering try run (#42278501999) for Linux (WPT)

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

Test results for linux-wpt from try job (#42278501999):

Flaky unexpected result (14)
  • OK /beacon/beacon-basic.https.window.html (#41723)
    • FAIL [expected PASS] subtest: Payload size restriction should be accumulated: type = string

      assert_false: expected false got true
      

  • OK /css/css-animations/event-order.tentative.html (#39000)
    • PASS [expected FAIL] subtest: Same events on pseudo-elements follow the prescribed order
  • FAIL [expected PASS] /css/css-backgrounds/background-size-042.html
  • OK /css/css-fonts/variations/at-font-face-font-matching.html (#20684)
    • FAIL [expected PASS] subtest: Matching font-weight: '399' should prefer '340 360' over '200 300'

      assert_equals: Unexpected font on test element expected 487 but got 532
      

  • OK /html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/a-click.html (#28697)
    • PASS [expected FAIL] subtest: aElement.click() before the load event must NOT replace
  • TIMEOUT [expected OK] /html/browsers/windows/consume-user-activation/window-open-multi-global.html (#47399)
    • TIMEOUT [expected FAIL] subtest: window.open() and consuming user activation with multiple globals in play

      Test timed out
      

  • TIMEOUT [expected OK] /html/semantics/embedded-content/media-elements/src_object_blob.html (#40340)
    • TIMEOUT [expected PASS] subtest: HTMLMediaElement.srcObject blob

      Test timed out
      

  • TIMEOUT [expected OK] /html/user-activation/navigation-state-reset-sameorigin.html (#45151)
    • TIMEOUT [expected FAIL] subtest: Post-navigation state reset.

      Test timed out
      

  • OK /infrastructure/testdriver/click_window.html (#47303)
    • FAIL [expected PASS] subtest: TestDriver click method in window

      Unhandled rejection: assert_unreached: click failed Reached unreachable code
      

  • FAIL [expected PASS] /mathml/presentation-markup/operators/mo-lspace-rspace-dynamic.html (#49168)
  • ERROR [expected TIMEOUT] /performance-timeline/not-restored-reasons/abort-block-bfcache.window.html (#42802)
  • OK /sanitizer-api/sanitizer-inert-document.html (#45260)
    • PASS [expected FAIL] subtest: Test whether setHTML loads the image.
    • FAIL [expected PASS] subtest: Test whether setHTMLUnsafe loads the image.

      promise_test: Unhandled rejection with value: "The server observed a request. It shouldn't have."
      

  • OK /upgrade-insecure-requests/gen/sharedworker-module-data.meta/unset/fetch.https.html
    • FAIL [expected PASS] subtest: Upgrade-Insecure-Requests: Expects blocked for fetch to cross-http-downgrade origin and downgrade redirection from https context.

      assert_equals: The resource request should be 'blocked'. expected "blocked" but got "allowed"
      

    • FAIL [expected PASS] subtest: Upgrade-Insecure-Requests: Expects blocked for fetch to cross-http-downgrade origin and no-redirect redirection from https context.

      assert_equals: The resource request should be 'blocked'. expected "blocked" but got "allowed"
      

    • FAIL [expected PASS] subtest: Upgrade-Insecure-Requests: Expects blocked for fetch to cross-https origin and downgrade redirection from https context.

      assert_equals: The resource request should be 'blocked'. expected "blocked" but got "allowed"
      

    • FAIL [expected PASS] subtest: Upgrade-Insecure-Requests: Expects blocked for fetch to same-http-downgrade origin and downgrade redirection from https context.

      assert_equals: The resource request should be 'blocked'. expected "blocked" but got "allowed"
      

    • FAIL [expected PASS] subtest: Upgrade-Insecure-Requests: Expects blocked for fetch to same-http-downgrade origin and no-redirect redirection from https context.

      assert_equals: The resource request should be 'blocked'. expected "blocked" but got "allowed"
      

    • FAIL [expected PASS] subtest: Upgrade-Insecure-Requests: Expects blocked for fetch to same-https origin and downgrade redirection from https context.

      assert_equals: The resource request should be 'blocked'. expected "blocked" but got "allowed"
      

  • OK /user-timing/measure_associated_with_navigation_timing.html (#47273)
    • PASS [expected FAIL] subtest: loadTime plus loadEventEnd to a mark "a" should equal to navigationStart to "a".
Stable unexpected results that are known to be intermittent (5)
  • OK /html/browsers/browsing-the-web/navigating-across-documents/navigation-unload-same-origin-fragment.html (#20768)
    • FAIL [expected PASS] subtest: Tests that a fragment navigation in the unload handler will not block the initial navigation

      assert_equals: expected "" but got "#fragment"
      

  • TIMEOUT [expected OK] /html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/form-submit.html (#44028)
  • TIMEOUT /html/browsers/history/the-history-interface/001.html (#12580)
    • PASS [expected FAIL] subtest: traversing history must also traverse hash changes
  • OK /html/webappapis/user-prompts/print-during-unload.html (#35944)
    • FAIL [expected PASS] subtest: print() during unload

      assert_array_equals: expected property 1 to be "destination" but got "error: window.print is not a function" (expected array ["start", "destination"] got ["start", "error: window.print is not a function"])
      

  • OK /preload/prefetch-document.html (#37210)
    • FAIL [expected PASS] subtest: different-site document prefetch with 'as=document' should not be consumed

      assert_equals: expected 2 but got 1
      

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

✨ Try run (#42278501999) succeeded.

@Psychpsyo
Psychpsyo force-pushed the contentEditble-render-selection branch from 84ee469 to 8ffc89d Compare November 6, 2026 20:57
@Psychpsyo

Copy link
Copy Markdown
Contributor Author

That force-push was only me adding the signoff on the commit that was missing it. No code changes.

@servo-wpt-sync

Copy link
Copy Markdown
Collaborator

📝 Transplanted new upstreamable changes to existing upstream WPT pull request (web-platform-tests/wpt#64640).

@mrobinson
mrobinson force-pushed the contentEditble-render-selection branch from 8ffc89d to ba42462 Compare November 7, 2026 11:00

@mrobinson mrobinson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a few nits with this such as the mismatch test still missing, but maybe that can be handled as a followup. This PR has probably waited long enough!

@servo-highfive servo-highfive removed the S-awaiting-review There is new code that needs to be reviewed. label Nov 7, 2026
@mrobinson
mrobinson enabled auto-merge November 7, 2026 11:01
@servo-wpt-sync

Copy link
Copy Markdown
Collaborator

📝 Transplanted new upstreamable changes to existing upstream WPT pull request (web-platform-tests/wpt#64640).

@mrobinson
mrobinson added this pull request to the merge queue Nov 7, 2026
@servo-highfive servo-highfive added the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Nov 7, 2026
Merged via the queue into servo:main with commit cd33216 Nov 7, 2026
35 checks passed
@servo-highfive servo-highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Nov 7, 2026
kvnloo pushed a commit to kvnloo/servo that referenced this pull request Nov 8, 2026
New test file that makes sure that a caret is actually visible in a
focused contenteditable element.
As requested by @mrobinson in
servo#48253 (review)

Signed-off-by: Psychpsyo (Cameron) <[email protected]>
aphrody-dev pushed a commit to aphrody-labs/browser that referenced this pull request Nov 16, 2026
New test file that makes sure that a caret is actually visible in a
focused contenteditable element.
As requested by @mrobinson in
servo/servo#48253 (review)

Signed-off-by: Psychpsyo (Cameron) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants