Skip to content

layout: implement pointer and hover media features - #45681

Merged
nicoburns merged 1 commit into
servo:mainfrom
nicoburns:pointer-media-queries
Jun 15, 2026
Merged

nicoburns merged 1 commit into
servo:mainfrom
nicoburns:pointer-media-queries

Conversation

@nicoburns

@nicoburns nicoburns commented Jun 14, 2026 •

Copy link
Copy Markdown
Contributor

Implements the pointer, any-pointer,hover, and any-hover media features.

Actually detecting pointer capabilities from the system is left as a follow-up (this is tricky as Winit doesn't expose this information). This PR just configures Stylo with sensible defaults (mouse-like pointer on desktop platforms, touch-like pointer on mobile platforms).

Testing: WPT tests
Part of: #39068

@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Jun 14, 2026
@nicoburns
nicoburns force-pushed the pointer-media-queries branch 2 times, most recently from 54c758e to f6fb296 Compare June 15, 2026 11:28
@codecov-commenter

Copy link
Copy Markdown

⚠️ JUnit XML file not found

The CLI was unable to find any JUnit XML files to upload.
For more help, visit our troubleshooting guide.

@servo-highfive servo-highfive removed the S-awaiting-review There is new code that needs to be reviewed. label Jun 15, 2026
@nicoburns
nicoburns force-pushed the pointer-media-queries branch from f6fb296 to 9624630 Compare June 15, 2026 11:43
@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Jun 15, 2026
@nicoburns nicoburns added the T-linux-wpt Do a try run of the WPT label Jun 15, 2026
@github-actions github-actions Bot removed the T-linux-wpt Do a try run of the WPT label Jun 15, 2026
@github-actions

Copy link
Copy Markdown

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

@github-actions

Copy link
Copy Markdown

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

Flaky unexpected result (60)
  • OK /IndexedDB/idbdatabase_deleteObjectStore.any.html (#43823)
    • PASS [expected FAIL] subtest: Deleted object store's name should be removed from database's list. Attempting to use a deleted IDBObjectStore should throw an InvalidStateError
  • TIMEOUT [expected OK] /_mozilla/input-events/spacebar-and-enter-in-input-text.html
  • ERROR [expected OK] /_mozilla/mozilla/focus-scroll-when-visible.html
  • TIMEOUT [expected OK] /content-security-policy/inheritance/document-write-iframe.html (#41195)
    • TIMEOUT [expected PASS] subtest: document.open() keeps inherited CSPs on transient about:blank.

      Test timed out
      

  • CRASH [expected OK] /content-security-policy/meta/sandbox-iframe.html (#43478)
  • TIMEOUT [expected OK] /content-security-policy/navigation/to-javascript-parent-initiated-parent-csp.html
    • TIMEOUT [expected PASS] subtest: Should not have executed the javascript url for a[target=iframe].href

      Test timed out
      

  • OK [expected TIMEOUT] /credential-management/credentialscontainer-frame-basics.https.html (#39430)
    • FAIL [expected TIMEOUT] subtest: navigator.credentials should be undefined in documents generated from data: URLs.

      assert_equals: expected "undefined" but got "[object CredentialsContainer]"
      

  • 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-041.html
  • PASS [expected FAIL] /css/css-fonts/font-feature-settings-descriptor-01.html (#45418)
  • FAIL [expected PASS] /css/filter-effects/kernel-unit-length-001.html
  • OK [expected ERROR] /fetch/fetch-later/quota/same-origin-iframe/multiple-iframes.https.window.html (#35176)
  • OK [expected ERROR] /fetch/fetch-later/quota/same-origin-iframe/sandboxed-iframe.https.window.html (#41704)
  • CRASH [expected OK] /html/anonymous-iframe/require-corp-embed-anonymous-iframe.tentative.https.window.html
  • OK [expected TIMEOUT] /html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/form-submit-button-click.html (#44099)
    • FAIL [expected TIMEOUT] subtest: Replace before load, triggered by submitButton.click()

      assert_equals: expected "http://web-platform.test:8000/common/blank.html?thereplacement=" but got "http://web-platform.test:8000/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/resources/code-injector.html?pipe=sub(none)&code=%0A%20%20%20%20const%20form%20%3D%20document.createElement(%22form%22)%3B%0A%20%20%20%20form.action%20%3D%20%22%2Fcommon%2Fblank.html%22%3B%0A%0A%20%20%20%20const%20input%20%3D%20document.createElement(%22input%22)%3B%0A%20%20%20%20input.type%20%3D%20%22hidden%22%3B%0A%20%20%20%20input.name%20%3D%20%22thereplacement%22%3B%0A%20%20%20%20form.append(input)%3B%0A%0A%20%20%20%20const%20button%20%3D%20document.createElement(%22button%22)%3B%0A%20%20%20%20button.type%20%3D%20%22submit%22%3B%0A%20%20%20%20form.append(button)%3B%0A%0A%20%20%20%20document.currentScript.before(form)%3B%0A%20%20%20%20button.click()%3B%0A%20%20"
      

  • OK [expected TIMEOUT] /html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/form-submit.html (#44028)
  • OK /html/browsers/history/the-history-interface/traverse_the_history_3.html (#21383)
    • PASS [expected FAIL] subtest: Multiple history traversals, last would be aborted
  • CRASH [expected OK] /html/browsers/history/the-location-interface/assign-replace-from-iframe.html
  • OK /html/browsers/windows/browsing-context-names/duplicate-name-order.html (#34623)
    • PASS [expected FAIL] subtest: Duplicate name lookup order
  • OK [expected TIMEOUT] /html/semantics/embedded-content/media-elements/src_object_blob.html (#40340)
    • PASS [expected TIMEOUT] subtest: HTMLMediaElement.srcObject blob
  • OK /html/semantics/embedded-content/the-iframe-element/iframe-loading-lazy-nav-location-replace.html (#32604)
    • FAIL [expected PASS] subtest: Navigating iframe loading='lazy' before it is loaded: location.replace

      uncaught exception: Error: assert_equals: expected "http://web-platform.test:8000/html/semantics/embedded-content/the-iframe-element/support/blank.htm?nav" but got "http://web-platform.test:8000/html/semantics/embedded-content/the-iframe-element/support/blank.htm?src"
      

  • OK /html/semantics/scripting-1/the-script-element/execution-timing/077.html (#22139)
    • PASS [expected FAIL] subtest: adding several types of scripts through the DOM and removing some of them confuses scheduler
  • OK /html/semantics/scripting-1/the-script-element/module/dynamic-import/blob-url.any.worker-module.html (#43510)
    • FAIL [expected PASS] subtest: Revoking a blob URL immediately after calling import will not fail

      promise_test: Unhandled rejection with value: object "TypeError: Module fetching failed"
      

  • OK [expected TIMEOUT] /infrastructure/testdriver/click_nested.html (#43887)
    • FAIL [expected NOTRUN] subtest: TestDriver click method with multiple windows and nested iframe

      can't access property "document", child.frames[2] is undefined
      

  • 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 /pointerevents/compat/pointerevent_touch_target_after_pointerdown_target_removed.tentative.html (#42813)
    • PASS [expected FAIL] subtest: After a pointerdown listener moves the target to different position, touch events should be fired on the pointerdown target, but pointer events should be fired on the pointerdown target parent
    • PASS [expected FAIL] subtest: After a pointerdown listener moves the target to different position, touchmove event should be fired on the pointerdown target parent
  • OK /preload/prefetch-document.html (#37210)
    • PASS [expected FAIL] subtest: different-site document prefetch with 'as=document' should not be consumed
  • OK /resize-observer/observer-in-cross-origin-frame.sub.html
    • FAIL [expected PASS] subtest: Cross-origin observer responds to explicitly set physical size

      assert_equals: expected 200 but got 284
      

  • OK [expected TIMEOUT] /trusted-types/trusted-types-navigation.html?06-10 (#37920)
    • PASS [expected FAIL] subtest: Navigate a frame via anchor with javascript:-urls in report-only mode.
    • PASS [expected TIMEOUT] 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!\""
      

  • OK /trusted-types/trusted-types-navigation.html?16-20 (#44835)
    • FAIL [expected PASS] subtest: Navigate a frame via area with javascript:-urls in report-only mode.

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

  • OK [expected TIMEOUT] /trusted-types/trusted-types-navigation.html?26-30 (#38807)
    • PASS [expected TIMEOUT] subtest: Navigate a window via form-submission with javascript:-urls in report-only mode.
    • PASS [expected NOTRUN] subtest: Navigate a window via form-submission with javascript:-urls w/ default policy in report-only mode.
    • PASS [expected NOTRUN] subtest: Navigate a frame via form-submission with javascript:-urls in enforcing mode.
    • PASS [expected NOTRUN] subtest: Navigate a frame via form-submission with javascript:-urls w/ default policy in enforcing mode.
  • OK /visual-viewport/resize-event-order.html (#41981)
    • PASS [expected FAIL] subtest: Popup: DOMWindow resize fired before VisualViewport.
  • CRASH [expected ERROR] /workers/Worker-base64.any.serviceworker.html
  • CRASH [expected OK] /workers/Worker-constructor-proto.any.worker.html
  • CRASH [expected OK] /workers/Worker-formdata.any.worker.html
  • CRASH [expected OK] /workers/Worker-timeout-increasing-order.html
  • CRASH [expected OK] /workers/WorkerLocation-origin.sub.window.html
  • CRASH [expected OK] /workers/WorkerLocation_port.htm
  • CRASH [expected OK] /workers/WorkerLocation_search_fragment.htm
  • CRASH [expected OK] /workers/WorkerNavigator.any.worker.html
  • CRASH [expected OK] /workers/constructors/SharedWorker/dummy-shared-worker.html
  • CRASH [expected OK] /workers/constructors/SharedWorker/global-members.html
  • CRASH [expected OK] /workers/constructors/SharedWorker/null-arguments.html
  • CRASH [expected OK] /workers/constructors/SharedWorker/port-readonly.html
  • CRASH [expected TIMEOUT] /workers/data-url-shared.html
  • CRASH [expected OK] /workers/examples/fetch_tests_from_worker.html
  • CRASH [expected ERROR] /workers/examples/onconnect.any.sharedworker.html
  • CRASH [expected ERROR] /workers/importscripts_mime.any.serviceworker.html
  • CRASH [expected OK] /workers/interfaces/DedicatedWorkerGlobalScope/EventTarget.worker.html
  • CRASH [expected OK] /workers/interfaces/DedicatedWorkerGlobalScope/postMessage/second-argument-undefined.html
  • CRASH [expected OK] /workers/interfaces/WorkerGlobalScope/location/redirect-module.html
  • CRASH [expected ERROR] /workers/interfaces/WorkerGlobalScope/location/returns-same-object.any.sharedworker.html
  • CRASH [expected OK] /workers/interfaces/WorkerGlobalScope/location/worker-separate-file.html
  • CRASH [expected TIMEOUT] /workers/interfaces/WorkerGlobalScope/onerror/message-classic-DOMException.html
  • CRASH [expected TIMEOUT] /workers/interfaces/WorkerGlobalScope/onerror/message-classic-Error.html
  • CRASH [expected ERROR] /workers/interfaces/WorkerGlobalScope/self.any.serviceworker.html
  • CRASH [expected OK] /workers/interfaces/WorkerUtils/WindowTimers/003.html
  • CRASH [expected OK] /workers/nested_worker.worker.html
  • CRASH [expected OK] /workers/same-site-cookies/third-party.default.tentative.sub.https.window.html
  • CRASH [expected OK] /xhr/open-method-case-sensitive.htm
Stable unexpected results that are known to be intermittent (14)
  • OK /_webgl/conformance/textures/misc/texture-upload-size.html (#21770)
    • FAIL [expected PASS] subtest: WebGL test #45

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

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

      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 #49

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

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

      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 #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
      

    • And 6 more unexpected results...
  • OK /dom/nodes/moveBefore/iframe-document-preserve.window.html (#43152)
    • FAIL [expected PASS] subtest: moveBefore(): cross-origin iframe is preserved: remove self

      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 innerHTML

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

  • ERROR [expected OK] /fetch/fetch-later/quota/same-origin-iframe/accumulated-oversized-payload.https.window.html (#41705)
  • TIMEOUT /fetch/metadata/generated/css-images.sub.tentative.html (#29047)
    • TIMEOUT [expected PASS] subtest: background-image sec-fetch-site - Not sent to non-trustworthy same-origin destination

      Test timed out
      

    • FAIL [expected PASS] subtest: content sec-fetch-site - HTTPS downgrade-upgrade

      assert_unreached: Reached unreachable code
      

  • OK /html/browsers/history/the-history-interface/traverse_the_history_5.html (#21383)
    • PASS [expected FAIL] subtest: Multiple history traversals, last would be aborted
  • TIMEOUT [expected CRASH] /html/browsers/history/the-location-interface/location_replace_session_history.html (#41896)
  • TIMEOUT [expected OK] /html/infrastructure/urls/base-url/document-base-url-window-initiator-is-not-opener.https.window.html (#30970)
  • OK [expected TIMEOUT] /html/interaction/focus/the-autofocus-attribute/supported-elements.html (#24145)
    • FAIL [expected NOTRUN] subtest: Area element should support autofocus

      assert_equals: expected Element node <area autofocus="" href="/common/blank.html"></area> but got Element node <body>
      <img src="/media/poster.png" usemap="#map">
      <map n...
      

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

      Test timed out
      

  • OK /resource-timing/test_resource_timing.html (#25720)
    • PASS [expected FAIL] subtest: PerformanceEntry has correct name, initiatorType, startTime, and duration (iframe)
  • OK /resource-timing/test_resource_timing.https.html (#25216)
    • PASS [expected FAIL] subtest: PerformanceEntry has correct name, initiatorType, startTime, and duration (link)
  • OK /touch-events/single-tap-when-touchend-listener-use-sync-xhr.html (#41175)
    • FAIL [expected PASS] subtest: Click event should be fired when touchend opens synchronous XHR

      assert_equals: expected "touchend@div, mousedown@div, mouseup@div, click@div" but got "touchend@div"
      

  • OK [expected TIMEOUT] /trusted-types/trusted-types-navigation.html?01-05 (#38975)
    • PASS [expected TIMEOUT] subtest: Navigate a window via anchor with javascript:-urls in report-only mode.
    • PASS [expected NOTRUN] subtest: Navigate a window via anchor with javascript:-urls w/ default policy in report-only mode.
    • PASS [expected NOTRUN] subtest: Navigate a frame via anchor with javascript:-urls in enforcing mode.
  • TIMEOUT [expected OK] /webstorage/localstorage-about-blank-3P-iframe-opens-3P-window.partitioned.html (#29053)
    • TIMEOUT [expected FAIL] subtest: StorageKey: test 3P about:blank window opened from a 3P iframe

      Test timed out
      

@github-actions

Copy link
Copy Markdown

✨ Try run (#27544040638) succeeded.

@nicoburns
nicoburns force-pushed the pointer-media-queries branch from 9624630 to 04a6627 Compare June 15, 2026 12:29
@nicoburns
nicoburns enabled auto-merge June 15, 2026 12:29
@nicoburns
nicoburns added this pull request to the merge queue Jun 15, 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 Jun 15, 2026
Merged via the queue into servo:main with commit 414dc78 Jun 15, 2026
31 checks passed
@nicoburns
nicoburns deleted the pointer-media-queries branch June 15, 2026 13:31
@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 Jun 15, 2026
Psychpsyo pushed a commit to Psychpsyo/stylo that referenced this pull request Jun 15, 2026
Fixes servo#390

This feature is quite impactful as it is required for Tailwind's hover
styles to work.

Servo PR: servo/servo#45681

Signed-off-by: Nico Burns <[email protected]>
TG199 pushed a commit to TG199/servo that referenced this pull request Jun 21, 2026
Implements the `pointer`, `any-pointer`,`hover`, and `any-hover` media
features.

Actually detecting pointer capabilities from the system is left as a
follow-up (this is tricky as Winit doesn't expose this information).
This PR just configures Stylo with sensible defaults (mouse-like pointer
on desktop platforms, touch-like pointer on mobile platforms).

- ~Builds on: servo#44978 This has been
reordered - this PR is now first.
- Stylo PR: servo/stylo#391

Testing: WPT tests
Part of: servo#39068

Signed-off-by: Nico Burns <[email protected]>
Loirooriol pushed a commit to servo/stylo that referenced this pull request Jul 1, 2026
Fixes #390

This feature is quite impactful as it is required for Tailwind's hover
styles to work.

Servo PR: servo/servo#45681

Signed-off-by: Nico Burns <[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.

4 participants