Skip to content

Add initial support for the user-select property - #48137

Merged
mrobinson merged 2 commits into
servo:mainfrom
SimonSapin:user-select
Sep 18, 2026
Merged

mrobinson merged 2 commits into
servo:mainfrom
SimonSapin:user-select

Conversation

@SimonSapin

@SimonSapin SimonSapin commented Sep 16, 2026 •

Copy link
Copy Markdown
Member

This adds initial support for the user-select property (specification). This adds support for various aspects of the property, yet there is still missing functionality:

  1. Checks for this property do not first ensure that style is up-to-date. This means that processing of this property during drags may be one style out-of-date.
  2. A single click on a user-select: all does not select it like in other browsers.

Yet, even with these caveats support is sometimes better and more consistent than other browsers.

Stylo PR: servo/stylo#462
Testing: Various WPT tests start to pass
Fixes: Part of #47896 (missing Selection.Stringifier changes)

@SimonSapin SimonSapin added the T-linux-wpt Do a try run of the WPT label Sep 16, 2026
@github-actions github-actions Bot removed the T-linux-wpt Do a try run of the WPT label Sep 16, 2026
@github-actions

Copy link
Copy Markdown

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

@github-actions

Copy link
Copy Markdown

⚠️ Try run (#35135363395) failed!

@SimonSapin SimonSapin added the T-linux-wpt Do a try run of the WPT label Sep 16, 2026
@github-actions github-actions Bot removed the T-linux-wpt Do a try run of the WPT label Sep 16, 2026
@github-actions

Copy link
Copy Markdown

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

@github-actions

Copy link
Copy Markdown

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

Flaky unexpected result (33)
  • FAIL [expected PASS] /_mozilla/css/image-percentage-dimen.html
  • CRASH [expected OK] /_webgl/conformance/reading/read-pixels-test.html
  • OK /_webgl/conformance/textures/misc/texture-upload-size.html (#21770)
    • PASS [expected FAIL] subtest: WebGL test #53
    • PASS [expected FAIL] subtest: WebGL test #55
    • PASS [expected FAIL] subtest: WebGL test #57
    • PASS [expected FAIL] subtest: WebGL test #59
    • FAIL [expected PASS] subtest: WebGL test #61

      assert_true: Texture was smaller than the expected size 2x2 expected true got false
      

    • FAIL [expected PASS] subtest: WebGL test #63

      assert_true: getError expected: INVALID_VALUE. Was NO_ERROR : when calling texSubImage2D with the same texture upload with offset 1, 1 expected true got false
      

    • FAIL [expected PASS] subtest: WebGL test #65

      assert_true: Texture was smaller than the expected size 2x2 expected true got false
      

    • FAIL [expected PASS] subtest: WebGL test #67

      assert_true: getError expected: INVALID_VALUE. Was NO_ERROR : when calling texSubImage2D with the same texture upload with offset 1, 1 expected true got false
      

    • PASS [expected FAIL] subtest: WebGL test #69
    • PASS [expected FAIL] subtest: WebGL test #71
    • And 6 more unexpected results...
  • TIMEOUT [expected OK] /_webgl/conformance/uniforms/no-over-optimization-on-uniform-array-06.html
  • CRASH [expected OK] /_webgl/conformance/uniforms/no-over-optimization-on-uniform-array-15.html
  • TIMEOUT [expected OK] /_webgl/conformance/uniforms/no-over-optimization-on-uniform-array-16.html
  • CRASH [expected OK] /_webgl/conformance2/sync/sync-webgl-specific.html
  • OK /beacon/beacon-basic.https.window.html (#41723)
    • FAIL [expected PASS] subtest: Payload size restriction should be accumulated: type = blob

      assert_false: expected false got true
      

  • CRASH [expected OK] /content-security-policy/frame-ancestors/frame-ancestors-nested-cross-in-sandboxed-cross-url-block.html
  • FAIL [expected PASS] /css/css-backgrounds/background-size-041.html
  • OK /css/css-flexbox/text-as-flexitem-size-001.html (#47104)
    • FAIL [expected PASS] subtest: .flexbox > div 1

      assert_equals: 
      <div data-expected-width="70" data-expected-height="35">
              <p>xx xxx</p>
              <p>xx</p>
            </div>
      width expected 70 but got 46
      

    • FAIL [expected PASS] subtest: .flexbox > div 2

      assert_equals: 
      <div data-expected-width="50" data-expected-height="45">
              <p>xx xxx</p>
              <p>xx</p>
            </div>
      width expected 50 but got 46
      

    • FAIL [expected PASS] subtest: .flexbox > div 5

      assert_equals: 
      <div style="height: 30px" data-expected-width="70" data-expected-height="30">
              <p>xx xxx</p>
              <p>xx</p>
            </div>
      width expected 70 but got 46
      

    • FAIL [expected PASS] subtest: .flexbox > div 8

      assert_equals: 
      <div style="min-height: 40px" data-expected-width="70" data-expected-height="40">
              <p>xx xxx</p>
              <p>xx</p>
            </div>
      width expected 70 but got 46
      

    • FAIL [expected PASS] subtest: .flexbox > div 11

      assert_equals: 
      <div style="max-height: 20px" data-expected-width="70" data-expected-height="20">
              <p>xx xxx</p>
              <p>xx</p>
            </div>
      width expected 70 but got 46
      

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

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

    • FAIL [expected PASS] subtest: Matching font-stretch: '100%' should prefer '100%' over '110% 120%'

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

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

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

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

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

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

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

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

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

  • OK [expected ERROR] /css/selectors/invalidation/media-loading-pseudo-classes-in-has.sub.html
  • TIMEOUT [expected OK] /fetch/content-encoding/zstd/big-zstd-body.https.any.worker.html
    • TIMEOUT [expected PASS] subtest: large zstd data should be decompressed successfully

      Test timed out
      

    • NOTRUN [expected FAIL] subtest: large zstd data should be decompressed successfully with byte stream
  • TIMEOUT /fetch/metadata/generated/css-images.https.sub.tentative.html (#42229)
    • FAIL [expected PASS] subtest: content sec-fetch-site - Cross-Site -> Same-Site

      assert_unreached: Reached unreachable code
      

    • FAIL [expected PASS] subtest: content sec-fetch-site - Same-Origin -> Same-Site

      assert_unreached: Reached unreachable code
      

  • OK /html/browsers/browsing-the-web/navigating-across-documents/navigation-unload-same-origin.window.html (#29049)
    • PASS [expected FAIL] subtest: Same-origin navigation started from unload handler must be ignored
  • 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 [expected ERROR] /html/browsers/history/the-location-interface/location_replace_session_history.html (#41896)
  • 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 ERROR] /html/semantics/forms/the-select-element/customizable-select/select-appearance-button-after-span.html
  • OK /html/semantics/interactive-elements/the-summary-element/interactive-content.html
    • FAIL [expected PASS] subtest: Clicking on non-interactive child of a <summary> opens its <details>

      assert_true: expected true got false
      

  • TIMEOUT [expected OK] /pointerevents/compat/pointerevent_touch-action_two-finger_interaction.html (#44693)
    • 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 /resource-timing/buffer-full-add-then-clear.html (#40819)
    • FAIL [expected PASS] subtest: Test that if the buffer is cleared after entries were added to the secondary buffer, those entries make it into the primary one

      assert_equals: Number of entries does not match the expected value. expected 3 but got 0
      

  • OK /resource-timing/buffer-full-then-increased.html (#44408)
    • FAIL [expected PASS] subtest: Test that overflowing the buffer and immediately increasing its limit does not trigger the resourcetimingbufferfull event

      assert_equals: Number of entries does not match the expected value. expected 3 but got 1
      

  • CRASH [expected OK] /streams/readable-byte-streams/templated.any.html
  • OK /touch-events/mouseevents-after-touchend.tentative.html (#46497)
    • PASS [expected FAIL] subtest: Tapping too far points should not cause a dblclick
  • 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 /visual-viewport/resize-event-order.html (#41981)
    • FAIL [expected PASS] subtest: Popup: DOMWindow resize fired before VisualViewport.

      assert_equals: expected "window-attribute,window-addEventListener,visualViewport-attribute,visualViewport-addEventListener" but got ""
      

  • OK /websockets/unload-a-document/001.html?default
    • FAIL [expected PASS] subtest: WebSockets: navigating top-level browsing context

      assert_unreached: document was not discarded Reached unreachable code
      

  • 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
      

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

      Test timed out
      

  • OK [expected TIMEOUT] /fetch/api/redirect/redirect-keepalive.https.any.html (#32153)
    • PASS [expected TIMEOUT] subtest: [keepalive][iframe][load] mixed content redirect; setting up
  • TIMEOUT /fetch/metadata/generated/css-images.sub.tentative.html (#29047)
    • TIMEOUT [expected PASS] subtest: background-image sec-fetch-site - Not sent to non-trustworthy cross-site destination

      Test timed out
      

    • TIMEOUT [expected PASS] subtest: background-image sec-fetch-mode - Not sent to non-trustworthy same-origin destination

      Test timed out
      

    • TIMEOUT [expected PASS] subtest: background-image sec-fetch-user - Not sent to non-trustworthy same-origin destination

      Test timed out
      

  • 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
      

  • TIMEOUT [expected OK] /html/semantics/embedded-content/media-elements/autoplay-disabled-by-permissions-policy.https.sub.html (#46012, #46804)
    • TIMEOUT [expected FAIL] subtest: Permissions-Policy header: autoplay "none" disallows 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 [expected CRASH] /html/semantics/scripting-1/the-script-element/module/choice-of-error-1.html (#44058)
    • FAIL [expected PASS] subtest: Parse errors in different files should be reported depending on different roots

      assert_not_equals: two different parse errors should be reported got disallowed value object "SyntaxError: expected expression, got '%'"
      

  • OK /infrastructure/testdriver/click_window.html (#47303)
    • PASS [expected FAIL] subtest: TestDriver click method in window
  • OK /pointerevents/pointerevent_pointercapture_in_frame.html?pen (#45536)
    • PASS [expected FAIL] subtest: Test penpointer capture in same-origin frame: Pointer down at inner frame and set pointer capture.
    • PASS [expected FAIL] subtest: Test penpointer capture in same-origin frame: Pointer down at inner frame and set pointer capture to outer frame should not capture.
  • OK /resource-timing/test_resource_timing.https.html (#25216)
    • PASS [expected FAIL] subtest: PerformanceEntry has correct name, initiatorType, startTime, and duration (script)
    • PASS [expected FAIL] subtest: PerformanceEntry has correct name, initiatorType, startTime, and duration (xmlhttprequest)
  • OK [expected TIMEOUT] /trusted-types/trusted-types-navigation.html?06-10 (#37920)
    • PASS [expected TIMEOUT] subtest: Navigate a frame via anchor with javascript:-urls in report-only mode.
    • PASS [expected NOTRUN] subtest: Navigate a frame via anchor with javascript:-urls w/ default policy in report-only mode.
    • FAIL [expected NOTRUN] subtest: Navigate a window via anchor with javascript:-urls w/ a default policy throwing an exception in enforcing mode.

      promise_test: Unhandled rejection with value: "Unexpected message received: \"No securitypolicyviolation reported!\""
      

    • FAIL [expected NOTRUN] subtest: Navigate a window via anchor with javascript:-urls w/ a default policy throwing an exception in report-only mode.

      promise_test: Unhandled rejection with value: "Unexpected message received: \"No securitypolicyviolation reported!\""
      

Stable unexpected results (3)
  • OK /_mozilla/css/css-property-listing.html
    • FAIL [expected PASS] subtest: Web-exposed CSS longhands

      assert_array_equals: lengths differ, expected array […, "transform", "transform-origin", "transform-style", "transition-behavior", "transition-delay", "transition-duration", "transition-property", "transition-timing-function", "translate", "unicode-bidi", "visibility", "white-space-collapse", "width", "will-change", "word-break", "word-spacing", "x", "y", "z-index", "-webkit-text-security"] length 242, got […, "transform-origin", "transform-style", "transition-behavior", "transition-delay", "transition-duration", "transition-property", "transition-timing-function", "translate", "unicode-bidi", "user-select", "visibility", "white-space-collapse", "width", "will-change", "word-break", "word-spacing", "x", "y", "z-index", "-webkit-text-security"] length 243
      

    • FAIL [expected PASS] subtest: Web-exposed CSS shorthands

      assert_object_equals: property "226" expected "animation-composition" got "user-select"
      

    • FAIL [expected PASS] subtest: Web-exposed CSS aliases

      assert_object_equals: unexpected property "-moz-user-select"
      

  • OK /html/rendering/widgets/the-select-element/select-as-listbox-default-styles.tentative.html
    • FAIL [expected PASS] subtest: <select multiple=""><option>1 - user-select

      assert_equals: expected "auto" but got "none"
      

  • OK /html/semantics/interestfor/interestfor-user-select.tentative.html
    • PASS [expected FAIL] subtest: Buttons with interestfor should not be user-selectable

@github-actions

Copy link
Copy Markdown

⚠️ Try run (#35140412413) failed!

@yezhizhen

This comment was marked as outdated.

@yezhizhen

Copy link
Copy Markdown
Member

@mrobinson Sorry for nagging but we should probably review this one with priority as Stylo PR has been merged. I hope I can do this but I am not capable😂

Oh sorry. I just realise you already say this in Stylo PR.

PupilTong pushed a commit to PupilTong/stylo that referenced this pull request Sep 18, 2026
 - Correct offset in call to compare_dom_positions
 - Minor typo fixes and doc adjustments
 - Move all `user-select` related code to `document_selection_drag.rs`
   (to avoid `node.rs` growing any more)

Signed-off-by: Martin Robinson <[email protected]>
@servo-highfive servo-highfive removed the S-awaiting-review There is new code that needs to be reviewed. label Sep 18, 2026
@mrobinson mrobinson changed the title Implement the user-select property Add initial support for the user-select property Sep 18, 2026
@mrobinson
mrobinson enabled auto-merge September 18, 2026 10:04
@mrobinson
mrobinson added this pull request to the merge queue Sep 18, 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 Sep 18, 2026
Merged via the queue into servo:main with commit ff4301c Sep 18, 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 Sep 18, 2026
@jasonwilliams

Copy link
Copy Markdown
Contributor

https://github.com/servo/servo/pull/48137/changes#diff-afeb6ea52b42751a9fb9e2fcd61cda34d7bb86ca9e4abc8cdfebab0415ea4838R249-R252

nooo 😆
i was hoping to use the last slot for container timing support, i assume we're ok with this widening to u32? In other browser engines its a u32 anyway.

@SimonSapin

Copy link
Copy Markdown
Member Author
  • I just checked that making NodeFlags 32 bits does not increase the size of Node (it’s 136 bytes before and after), the extra space was padding due to struct Node being aligned to 8 bytes
  • We don’t need to yet: bit offsets 3, 4, and 5 are unused. (Maybe they were used for something later removed?)

@SimonSapin
SimonSapin deleted the user-select branch September 21, 2026 10:11
@jasonwilliams

Copy link
Copy Markdown
Contributor
  • I just checked that making NodeFlags 32 bits does not increase the size of Node (it’s 136 bytes before and after), the extra space was padding due to struct Node being aligned to 8 bytes
  • We don’t need to yet: bit offsets 3, 4, and 5 are unused. (Maybe they were used for something later removed?)

ah yes thanks, good spot, i didn't notice there were unused bits in the middle, panic averted then!

Loirooriol pushed a commit to servo/stylo that referenced this pull request Sep 30, 2026
RichardTjokroutomo pushed a commit to RichardTjokroutomo/servo that referenced this pull request Oct 6, 2026
This adds initial support for the `user-select` property
([specification]). This adds support for various aspects of the
property, yet there is still missing functionality:

1. Checks for this property do not first ensure that style is
up-to-date. This means that processing of this property during drags may
be one style out-of-date.
2. A single click on a `user-select: all` does not select it like in
other browsers.

Yet, even with these caveats support is sometimes better and more
consistent than other browsers.

Stylo PR: servo/stylo#462
Testing: Various WPT tests start to pass
Fixes: Part of servo#47896 (missing `Selection.Stringifier` changes)

[specification]: https://drafts.csswg.org/css-ui-4/#content-selection

---------

Signed-off-by: Simon Sapin <[email protected]>
Signed-off-by: Martin Robinson <[email protected]>
Co-authored-by: Martin Robinson <[email protected]>
hhhwsqhhh pushed a commit to hhhwsqhhh/servo that referenced this pull request Oct 12, 2026
This adds initial support for the `user-select` property
([specification]). This adds support for various aspects of the
property, yet there is still missing functionality:

1. Checks for this property do not first ensure that style is
up-to-date. This means that processing of this property during drags may
be one style out-of-date.
2. A single click on a `user-select: all` does not select it like in
other browsers.

Yet, even with these caveats support is sometimes better and more
consistent than other browsers.

Stylo PR: servo/stylo#462
Testing: Various WPT tests start to pass
Fixes: Part of servo#47896 (missing `Selection.Stringifier` changes)

[specification]: https://drafts.csswg.org/css-ui-4/#content-selection

---------

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants