Skip to content

script/layout: Add support for double/triple click selection extension - #48767

Merged
mrobinson merged 2 commits into
servo:mainfrom
mrobinson:selection-double-and-triple-click
Oct 13, 2026
Merged

mrobinson merged 2 commits into
servo:mainfrom
mrobinson:selection-double-and-triple-click

Conversation

@mrobinson

@mrobinson mrobinson commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

Add support for double and triple clicking to select a word and a line
in the document. This change also includes the ability to double and
triple click and then drag to select by word / line.

The dragging feature is not yet implemented for input elements, but will
be in a followup.

Testing: This change adds two Servo-specific WPT style tests
as well as causing a few WPT tests to start passing (as well
as one to start failing, likely due to an unimplemented feature).

@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Oct 9, 2026
@mrobinson mrobinson mentioned this pull request Oct 9, 2026
25 of 40 tasks
@mrobinson
mrobinson force-pushed the selection-double-and-triple-click branch from bf9f2ee to b868fc1 Compare October 11, 2026 08:59
Comment thread components/layout/dom.rs
Comment on lines +256 to +259
fn with_independent_formatting_context<T>(
&self,
callback: impl FnOnce(&IndependentFormattingContext) -> T,
) -> Option<T> {

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 my version of this I had this signature, with the callback always called exactly once but called with an option parameter. Which one looks more convenient for callers? (Maybe less need for map and flatten?)

Suggested change
fn with_independent_formatting_context<T>(
&self,
callback: impl FnOnce(&IndependentFormattingContext) -> T,
) -> Option<T> {
fn with_independent_formatting_context<T>(
&self,
callback: impl FnOnce(Option<&IndependentFormattingContext>) -> T,
) -> T {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Oh, interesting. I've toyed around with this a bit and I think having the callback return an Option serves both to remove the flatten() at the callsites and results in slightly less code.

Comment thread components/layout/dom.rs Outdated
callback(&positioned.borrow().context)
},
BlockLevelBox::OutOfFlowFloatBox(float) => callback(&float.contents),
_ => return None,

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.

Instead of a _ catch-all pattern, if all remaining cases are listed explicitly and the enum ever gains a new variant this code will stop compiling until updated explicitly. Maybe a new variant is extremely unlikely to happen though. (When I first write such a match, listing all variants also gives me more confidence I haven’t forgotten something.)

This is a very weak suggestion, up to you which one you like.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I've gone ahead and done this. I think it makes sense.

@servo-highfive servo-highfive removed the S-awaiting-review There is new code that needs to be reviewed. label Oct 12, 2026

@mrobinson mrobinson left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thank you for the review!

@mrobinson
mrobinson force-pushed the selection-double-and-triple-click branch from b868fc1 to cd7e102 Compare October 12, 2026 17:56
@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Oct 12, 2026
@mrobinson
mrobinson enabled auto-merge October 12, 2026 17:56
@mrobinson
mrobinson added this pull request to the merge queue Oct 12, 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 Oct 12, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 12, 2026
@servo-highfive servo-highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Oct 12, 2026
mrobinson and others added 2 commits October 13, 2026 09:17
Add support for double and triple clicking to select a word and a line
in the document. This change also includes the ability to double and
triple click and then drag to select by word / line.

The dragging feature is not yet implemented for input elements, but will
be in a followup.

Signed-off-by: Martin Robinson <[email protected]>
Co-authored-by: Simon Sapin <[email protected]>
Signed-off-by: Martin Robinson <[email protected]>
@mrobinson
mrobinson force-pushed the selection-double-and-triple-click branch from cd7e102 to a53f903 Compare October 13, 2026 07:17
@servo-highfive servo-highfive removed the S-tests-failed The changes caused existing tests to fail. label Oct 13, 2026
@mrobinson mrobinson added the T-linux-wpt Do a try run of the WPT label Oct 13, 2026
@github-actions github-actions Bot removed the T-linux-wpt Do a try run of the WPT label Oct 13, 2026
@github-actions

Copy link
Copy Markdown

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

@github-actions

Copy link
Copy Markdown

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

Flaky unexpected result (21)
  • TIMEOUT [expected OK] /IndexedDB/idbcursor-request-source.any.sharedworker.html
    • TIMEOUT [expected PASS] subtest: IDBObjectStore::openCursor's request source must be the IDBObjectStore instance that opened the cursor

      Test timed out
      

    • TIMEOUT [expected PASS] subtest: IDBObjectStore::openKeyCursor's request source must be the IDBObjectStore instance that opened the cursor

      Test timed out
      

  • FAIL [expected PASS] /css/css-backgrounds/background-size-042.html
  • FAIL [expected PASS] /css/css-image-animation/image-animation-img-running-to-normal.html (#46567)
  • OK /css/css-text-decor/parsing/text-decoration-inset-computed.html (#47617)
    • FAIL [expected PASS] subtest: Property text-decoration-inset value '0'

      assert_true: text-decoration-inset doesn't seem to be supported in the computed style expected true got false
      

    • FAIL [expected PASS] subtest: Property text-decoration-inset value '0px 0px'

      assert_true: text-decoration-inset doesn't seem to be supported in the computed style expected true got false
      

    • FAIL [expected PASS] subtest: Property text-decoration-inset value '0.5em'

      assert_true: text-decoration-inset doesn't seem to be supported in the computed style expected true got false
      

    • FAIL [expected PASS] subtest: Property text-decoration-inset value '-1em'

      assert_true: text-decoration-inset doesn't seem to be supported in the computed style expected true got false
      

    • FAIL [expected PASS] subtest: Property text-decoration-inset value '-1ch -1ch'

      assert_true: text-decoration-inset doesn't seem to be supported in the computed style expected true got false
      

    • FAIL [expected PASS] subtest: Property text-decoration-inset value '1px 2px'

      assert_true: text-decoration-inset doesn't seem to be supported in the computed style expected true got false
      

    • FAIL [expected PASS] subtest: Property text-decoration-inset value '1ch -1ch'

      assert_true: text-decoration-inset doesn't seem to be supported in the computed style expected true got false
      

    • FAIL [expected PASS] subtest: Property text-decoration-inset value 'calc(1em / 4) calc(-1ch)'

      assert_true: text-decoration-inset doesn't seem to be supported in the computed style expected true got false
      

    • FAIL [expected PASS] subtest: Property text-decoration-inset value 'auto'

      assert_true: text-decoration-inset doesn't seem to be supported in the computed style expected true got false
      

    • FAIL [expected PASS] subtest: Property text-decoration-inset value '10%'

      assert_true: text-decoration-inset doesn't seem to be supported in the computed style expected true got false
      

    • And 5 more unexpected results...
  • 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 /html/browsers/browsing-the-web/navigating-across-documents/005.html (#27062)
    • PASS [expected FAIL] subtest: Link with onclick navigation and href navigation
  • OK /html/browsers/browsing-the-web/navigating-across-documents/refresh/same-document-refresh.html (#34597)
    • PASS [expected FAIL] subtest: Same-Document Referrer from Refresh
  • OK [expected TIMEOUT] /html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/form-submit.html (#44028)
  • TIMEOUT [expected OK] /html/semantics/embedded-content/media-elements/track/track-element/cors/004.html
  • TIMEOUT [expected OK] /html/semantics/embedded-content/media-elements/track/track-element/track-remove-by-setting-innerHTML.html (#44132)
    • TIMEOUT [expected PASS] subtest: Removing a track by setting video.innerHTML doesn't crash

      Test timed out
      

  • OK [expected CRASH] /html/semantics/embedded-content/the-iframe-element/iframe-loading-lazy-reload-location-reload.html (#32595)
  • CRASH [expected FAIL] /html/semantics/interestfor/interestfor-plain-inline-element.tentative.html
  • TIMEOUT [expected OK] /html/user-activation/navigation-state-reset-sameorigin.html (#45151)
    • TIMEOUT [expected FAIL] subtest: Post-navigation state reset.

      Test timed out
      

  • 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
      

  • OK /resource-timing/buffer-full-add-then-clear.html (#40819)
    • PASS [expected FAIL] subtest: Test that if the buffer is cleared after entries were added to the secondary buffer, those entries make it into the primary one
  • OK /resource-timing/test_resource_timing.https.html (#25216)
    • PASS [expected FAIL] subtest: PerformanceEntry has correct name, initiatorType, startTime, and duration (xmlhttprequest)
  • OK /upgrade-insecure-requests/gen/sharedworker-classic-data.meta/upgrade/websocket.https.html
    • FAIL [expected PASS] subtest: Upgrade-Insecure-Requests: Expects allowed for websocket to cross-ws-downgrade origin and no-redirect redirection from https context.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  • 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 /webdriver/tests/classic/set_window_rect/user_prompts.py
    • ERROR [expected PASS] subtest: test_accept[alert-None]

      teardown error: ConnectionRefusedError: [Errno 111] Connection refused
      

    • ERROR [expected PASS] subtest: test_accept[confirm-True]

      setup error: ConnectionRefusedError: [Errno 111] Connection refused
      

    • ERROR [expected PASS] subtest: test_accept[prompt-]

      setup error: ConnectionRefusedError: [Errno 111] Connection refused
      

    • ERROR [expected PASS] subtest: test_accept_and_notify[alert-None]

      setup error: ConnectionRefusedError: [Errno 111] Connection refused
      

    • ERROR [expected PASS] subtest: test_accept_and_notify[confirm-True]

      setup error: ConnectionRefusedError: [Errno 111] Connection refused
      

    • ERROR [expected PASS] subtest: test_accept_and_notify[prompt-]

      setup error: ConnectionRefusedError: [Errno 111] Connection refused
      

    • ERROR [expected PASS] subtest: test_dismiss[alert-None]

      setup error: ConnectionRefusedError: [Errno 111] Connection refused
      

    • ERROR [expected PASS] subtest: test_dismiss[confirm-False]

      setup error: ConnectionRefusedError: [Errno 111] Connection refused
      

    • ERROR [expected PASS] subtest: test_dismiss[prompt-None]

      setup error: ConnectionRefusedError: [Errno 111] Connection refused
      

    • ERROR [expected PASS] subtest: test_dismiss_and_notify[alert-None]

      setup error: ConnectionRefusedError: [Errno 111] Connection refused
      

    • And 8 more unexpected results...
  • OK [expected TIMEOUT] /webstorage/localstorage-about-blank-3P-iframe-opens-3P-window.partitioned.html (#29053)
    • FAIL [expected TIMEOUT] subtest: StorageKey: test 3P about:blank window opened from a 3P iframe

      assert_true: about:blank window opened by 3P iframe does not inherit 3P iframe's StorageKey expected true got false
      

Stable unexpected results that are known to be intermittent (8)
  • TIMEOUT [expected OK] /_mozilla/mozilla/window-resize-event.html (#36741)
    • TIMEOUT [expected PASS] subtest: Popup onresize event fires after resizeTo

      Test timed out
      

  • OK /html/browsers/browsing-the-web/navigating-across-documents/navigation-unload-same-origin-fragment.html (#20768)
    • PASS [expected FAIL] subtest: Tests that a fragment navigation in the unload handler will not block the initial navigation
  • TIMEOUT /html/browsers/history/the-history-interface/001.html (#12580)
    • PASS [expected FAIL] subtest: traversing history must also traverse hash changes
  • 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 the top-level document.

      Test timed out
      

    • TIMEOUT [expected PASS] subtest: Permissions-Policy header: autoplay * allows same-origin iframes.

      Test timed out
      

  • OK [expected CRASH] /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"
      

  • OK /html/syntax/speculative-parsing/expect-no-linked-resources/no-speculative-fetch.tentative.optional.html (#47290)
    • PASS [expected FAIL] subtest: expect-no-linked-resources hint was ignored
  • 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 /resource-timing/test_resource_timing.html (#25720)
    • PASS [expected FAIL] subtest: PerformanceEntry has correct name, initiatorType, startTime, and duration (iframe)

@github-actions

Copy link
Copy Markdown

✨ Try run (#38361854412) succeeded.

@mrobinson
mrobinson added this pull request to the merge queue Oct 13, 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 Oct 13, 2026
Merged via the queue into servo:main with commit f040186 Oct 13, 2026
77 checks passed
@mrobinson
mrobinson deleted the selection-double-and-triple-click branch October 13, 2026 10:17
@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 Oct 13, 2026
log101 pushed a commit to log101/servo that referenced this pull request Oct 14, 2026
servo#48767)

Add support for double and triple clicking to select a word and a line
in the document. This change also includes the ability to double and
triple click and then drag to select by word / line.

The dragging feature is not yet implemented for input elements, but will
be in a followup.

Testing: This change adds two Servo-specific WPT style tests
as well as causing a few WPT tests to start passing (as well
as one to start failing, likely due to an unimplemented feature).

---------

Signed-off-by: Martin Robinson <[email protected]>
Co-authored-by: Simon Sapin <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-awaiting-review There is new code that needs to be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants