Commit graph

298 commits

Author SHA1 Message Date
Narfinger
18a1da0d80
Script: Remove last instances of Deref<str> and DerefMut<str> used for DOMString (#39504)
This removes the last instances of Deref<str> and DerefMut<str> used for
DOMString.
The goal is outlined in https://github.com/servo/servo/issues/39479.

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>

Testing: Compilation is the test as it just changes function names
essentially.

---------

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
2025-09-27 01:48:24 +00:00
Narfinger
a4c8ffe753
Script: Change script/dom/{bluetooth,canvas,html} to not rely on Deref<str> for DOMString (#39480)
This is part of the future work of implementing LazyDOMString as
outlined in https://github.com/servo/servo/issues/39479.

We use str() method or direct implementations on DOMString for these
methods. We also change some types.

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>


Testing: This is essentially just renaming a method and a type and
should not change functionality.

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
2025-09-25 15:53:21 +00:00
Narfinger
1e471b9b41
Script: Change the rest of script to not rely on Deref<str> for DOMString (#39481)
This is part of the future work of implementing LazyDOMString as
outlined in issue #39479.

We use str() method or direct implementations on DOMString for these
methods. We also change some types.
This is independent of https://github.com/servo/servo/pull/39480

Signed-off-by: Narfinger Narfinger@users.noreply.github.com

Testing: This is essentially just renaming a method and a type and
should not change functionality.

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
2025-09-25 12:27:42 +00:00
Rodion Borovyk
9713bb9e1b
script: Add message to NotFoundError (#39394)
Adding an optional message to be attached to a NotFoundError.

Testing: Just a refactor
Part of #39053

---------

Signed-off-by: Rodion Borovyk <rodion.borovyk@gmail.com>
2025-09-25 12:16:50 +00:00
Gae24
75e32ba5a4
script: implement ClipboardItem getType and supports (#39296)
Implement ClipboardItem's getType and supports

Testing: covered by existing tests

---------

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2025-09-25 08:05:01 +00:00
Simon Wülker
2ccaf86ff6
Invalidate iterator over elements of a XPathResult when the document changes (#39411)
Also includes a fix to not throw a type error in
`XPathResult.invalidIteratorState`.

Testing: Includes a new web platform test
Part of https://github.com/servo/servo/issues/34527

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-09-24 16:39:38 +00:00
Andrei Volykhin
f91dc33350
html: Add the reflected 'sizes' IDL attribute for <image> (#39466)
Add the reflected 'sizes' IDL attribute for <image> element's DOM
interface which defines image sizes for different page layouts.

See https://html.spec.whatwg.org/multipage/#dom-img-sizes

Testing: Improvements in the following tests
- custom-elements/reactions/customized-builtins/HTMLImageElement.html
- html/dom/idlharness.https.html
-
html/semantics/embedded-content/the-img-element/relevant-mutations.html

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
2025-09-24 09:29:44 +00:00
Wu Yuwei
bb70c35a96
WebGPU: expose GPUObjectBase to worker (#39463)
Label attribute in several WebGPU object should be available to worker
as well.
[Firefox](https://searchfox.org/firefox-main/source/dom/webidl/WebGPU.webidl#10)
doesn't limit it to window either.

Testing: CTS [try
run](https://github.com/wusyong/servo/actions/runs/17942843000) from my
fork

Signed-off-by: Wu Yu Wei <yuweiwu@pm.me>
2025-09-24 04:10:56 +00:00
Tim van der Lippe
02aab33987
Add AbortSignal support for event listeners (#39406)
Also fixes several issues with code generation when a dom type is part
of a dictionary.

Part of #34866
Fixes #39398

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2025-09-21 18:57:10 +00:00
Alex Touchet
5a0332f57e
Cargo.toml cleanup (#39403)
Cargo.toml cleanups. Mostly ordering fixes.

Testing: No tests for Cargo.toml edits.

---------

Signed-off-by: Alex Touchet <26315797+atouchet@users.noreply.github.com>
2025-09-20 03:09:37 +00:00
Kingsley Yung
e3818a33c0
script_bindings(python): Handle WebIDL methods named with Rust keywords (#39343)
Some WebIDL methods, attributes and dictionary members are named with
Rust keywords such as `type`, `use` and `continue`. Using those
identifiers directly in the generated Rust code would cause compilation
errors.

The code generator already addresses this issue for attributes and
dictionary members by adding a `_` suffix to the conflicting
identifiers, but does not yet apply the same treatment to methods. This
patch extends the handling to methods as well.

Fixes: #39286

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
2025-09-17 04:09:02 +00:00
Tim van der Lippe
22fbb3458b
Add signal to request (#39290)
The signal taken from the requestinit is now passed into
the request object with the relevant steps. I added all
spec comments to this method, as I had trouble figuring
out which steps I had to add.

This required implementing the algorithm to create
dependent signals, which is used in the `any()` method.
So that's now implemented as well.

All of that required the machinery to have dependent and
source signals on an AbortSignal. It uses an IndexSet
as the spec requires it to be an ordered set.

Part of #34866

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2025-09-16 20:41:12 +00:00
Kingsley Yung
f3d5617349
script: Check whether the generated crypto key has empty usages (#39328)
The WebCryptoAPI spec requires that when we generate crypto keys by the
generateKey method of SubtleCrypto interface we have to check whether
the usages is empty. If the usages is empty, throw a SyntaxError.

FYI, Step 9 of
https://w3c.github.io/webcrypto/#SubtleCrypto-method-generateKey

We have not yet implemented this logic, and this patch implements it.

Testing: Pass WPT tests that were expected to fail.

---------

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
2025-09-16 17:23:42 +00:00
Tim van der Lippe
3ef3ba9378
Add spec steps and comments for fetch abort steps (#39283)
While trying to figure out what the status of this implementation was, I
added steps and comments to
see what we are missing. Also updated some links,
since I couldn't find an implementation of
`window.fetch`, since the spec URL was pointing
to the chapter instead of the algorithm.

Part of #34866

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2025-09-13 18:34:14 +00:00
Tim van der Lippe
2f252c9b78
Remove the dom_trusted_types_enabled preference (#39281)
Everything related to Trusted Types has been implemented. Failing WPT
tests are related to other features such as SVG scripts.

Fixes #36258

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2025-09-13 09:57:15 +00:00
Kingsley Yung
250c4cda00
indexeddb: Implement openCursor and openKeyCursor for object store (#39080)
Continue on implementing indexeddb's cursor.

This patch focuses on implementing the `openCursor` [1] and
`openKeyCursor` [2] methods of the `IDBObjectStore` interface, which
create and initialize cursors by running the iterate-a-cursor algorithm
[3].

It also adds struct `IndexedDBRecord` to
`components/shared/net/indexeddb_thread.rs`. This struct can later be
used to implement the new `IDBRecord` interface [4].

[1] https://www.w3.org/TR/IndexedDB-2/#dom-idbobjectstore-opencursor
[2] https://www.w3.org/TR/IndexedDB-2/#dom-idbobjectstore-openkeycursor
[3] https://www.w3.org/TR/IndexedDB-2/#iterate-a-cursor
[4] https://w3c.github.io/IndexedDB/#record-interface

Testing: Pass WPT tests that were expected to fail.
Fixes: Part of #38111

---------

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
2025-09-12 16:54:07 +00:00
Ashwin Naren
97690b1cba
script: Ensure autoincrement and keypath are passed in correctly from IDBTransaction (#38738)
Previously, the correct autoincremented and keypath parameters were only
being passed if the object store is being created. This PR queries this
info from the backend and passes it onto the constructor in
IDBTransaction. Furthermore it exposes keypath and index_names from
IDBObjectStore, mainly for WPT.

Testing: WPT
Fixes: None

---------

Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
2025-09-11 09:13:15 +00:00
JasonHonKL
839878c743
script: Make root_from_handle_value a safe function by accepting SafeJSContext (#39193)
Change from unsafe pointer of root_from_handle_value  to SafeJSContext. 

#39131

---------

Signed-off-by: JasonHonKL <j2004nol@gmail.com>
Signed-off-by: Jason <jason@198-61-252-113-on-nets.com>
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Co-authored-by: Jason <jason@198-61-252-113-on-nets.com>
Co-authored-by: Josh Matthews <josh@joshmatthews.net>
2025-09-09 19:26:02 +00:00
lumiscosity
9584b9e57d
script: Add can_gc to WebIDL dictionary constructors (#39195)
More progress on can_gc!

Testing: Internal change only, shouldn't change behavior.
Fixes: #38708

---------

Signed-off-by: lumiscosity <averyrudelphe@gmail.com>
2025-09-08 09:21:42 +00:00
lumiscosity
088d16d634
script: Make set_dictionary_property a safe function (#39191)
Makes `set_dictionary_property` safe.

Testing: Changes are internal, this shouldn't affect behavior.
Fixes: #39128

Signed-off-by: lumiscosity <averyrudelphe@gmail.com>
2025-09-07 11:56:20 +00:00
Ashwin Naren
3ac8875697
script: Initial stubs for Credential Management API (#38839)
Stubs `Credential`, `CredentialContainer`, and `PasswordCredential` and
adds the credentials attribute to navigator.

Testing: WPT
Fixes: Partially #38788

---------

Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
2025-09-06 19:48:38 +00:00
Sam
643ac08cf0
canvas: Implement strokeText (#39183)
Mostly it's just reusing/copy&edit fillText stuff.

Testing: Existing WPT tests
Fixes: #29973

Try run: https://github.com/sagudev/servo/actions/runs/17511337550

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2025-09-06 18:01:21 +00:00
Ashwin Naren
b5d6555238
indexeddb: Implement getAll and getAllKeys (#38885)
Implement getAll and getAllKeys for IDBObjectStore.

Testing: WPT & Unit testing
Fixes: Part of #6963.

---------

Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
2025-09-06 05:48:11 +00:00
Sebastian C
7ce0bd8575
script: Remove CookieListItem fields that were removed in the spec (#39170)
The spec removed all fields from CookieListItem except for name and
value

Testing: WPT tests cover this already.

Signed-off-by: Sebastian C <sebsebmc@gmail.com>
2025-09-05 17:47:42 +00:00
lumiscosity
c7ca281f44
script: implement setMatrixValue for DOMMatrix (#39148)
Even more progress on the geometry suite. Almost there!

Testing: Covered by WPT (css/geometry).

Signed-off-by: lumiscosity <averyrudelphe@gmail.com>
2025-09-04 19:02:54 +00:00
Martin Robinson
2c7866eb24
script/layout: Implement HTMLElement.scrollParent (#39110)
This new API allows getting the element which establishes an element's
scroll container. This will be used to properly implement
`scrollIntoView`. There is still work to do for this API and
`offsetParent` to properly handle ancestors which are
closed-shadow-hidden from the original query element.

In addition, fix an issue where inline boxes were establishing scrolling
containers (they shouldn't do that).

Testing: There are tests for this change.
Fixes: #39096.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2025-09-03 18:52:15 +00:00
Martin Robinson
0ae9ee28d5
script: More consistently use f32 and have scrolling methods follow the specification more closely (#39104)
This clarifies the units for scrolling:

 - `f32` is used for internal Servo scrolling APIs as that is the unit
   used in WebRender.
 - `f64` is used for the web-exposed scrolling APIs as that is what the
   WebIDL code generator gives us.

Conversions are done consistently at the boundaries of the two APIs.

In addition, web-exposed scrolling methods are refactored a bit to more
closely follow the specification text. In addition, specification text
is added to those methods so that it is clearer that we are following
it.

Testing: This should not change behavior and is thus covered by existing
tests.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-09-03 17:29:56 +00:00
Jerens Lensun
4de84b0ca5
script_bindings(python): Fix all the rest of type annotation in script_bindings codegen (#39070)
This will complete the type annotation on `codegen.py` so we can safely
remove the ignore from `pyproject` configurataion

---------

Signed-off-by: Jerens Lensun <jerensslensun@gmail.com>
Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>
Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
2025-09-02 12:47:38 +00:00
Ashwin Naren
97c8c83cbb
script: Add message to SyntaxError (#39056)
Adding an optional message to be attached to a SyntaxError. Unblocks
#39050.

The enum definition of Syntax is now `Syntax(Option<String>)`. Future
PRs should probably add more appropriate messages to some of the
`Syntax(None)`s.

Testing: Just a refactor
Fixes: Partially #39053

Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
2025-09-02 05:51:36 +00:00
Jerens Lensun
fc5691a293
script_bindings(python): Add type around js jit class in codegen.py (#38998)
Add type around js jit class in codegen.py

Needed this PR: #38845

---------

Signed-off-by: Jerens Lensun <jerensslensun@gmail.com>
2025-09-01 07:00:03 +00:00
Josh Matthews
0481477f35
script_bindings: Remove Cell wrapper from thread-local RootCollection. (#39043)
This doesn't appear to make a big difference in speedometer results, but
this removes some code from the hot path of creating DomRoot values.

Before: `Score: 30.381097406624708 ± 2.0393225244958018`
After: `Score: 30.344639420871395 ± 1.9359337921154696`

Testing: Existing WPT coverage

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2025-08-30 19:47:26 +00:00
Josh Matthews
6565d982bd
servoshell: Support runtime preference manipulation (#38159)
These changes add a custom servo:preferences URL that allows modifying
selected preferences at runtime. The goal of this work is to make it
easy to test pages while toggling experimental web platform features,
and support quickly changing the User-Agent header.

Testing: Manually verified that spacex.com loads correctly after
changing the user agent, and that https://polygon.io/ displays grid
elements correctly and no console errors with the experimental prefs
enabled.
Fixes: #35862

<img width="1136" height="880" alt="Screenshot 2025-07-18 at 1 06 23 AM"
src="https://github.com/user-attachments/assets/2d27c321-6ca0-43c3-a347-7bc4b55272df"
/>

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2025-08-30 16:51:58 +00:00
Kingsley Yung
4571cc1b3b
script: Initialize IDBCursor and IDBCursorWithValue interfaces (#38850)
Testing: Update WPT test expectation
Fixes: Part of #38111

---------

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
2025-08-30 14:33:01 +00:00
Euclid Ye
8305064522
webdriver: Improve parsing of Frame and Window (#39012)
In #38745, we changed the id of Frame and Window as the result of
`ToString` trait. This PR
- adapts the parsing of frame/window accordingly.
- for frame, return the
[WindowProxy](https://developer.mozilla.org/en-US/docs/Web/API/WindowProxy)
object of the iframe as it's supposed to do.

Testing: `execute_{async_}script/arguments.py`

---------

Signed-off-by: Euclid Ye <euclid.ye@huawei.com>
2025-08-29 09:37:48 +00:00
Jerens Lensun
00c1f79a1d
script_bindings(python): Add type around CG class in codegen.py (#38845)
Add type around CG class for code generatio Web IDL in codegen.py


Testing: *Describe how this pull request is tested or why it doesn't
require tests*
Fixes: *Link to an issue this pull requests fixes or remove this line if
there is no issue*

---------

Signed-off-by: Jerens Lensun <jerensslensun@gmail.com>
Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>
Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
2025-08-29 04:32:14 +00:00
Simon Wülker
04dd74dddb
script: Support custom element states (#38564)
Also adds support for `:state`.

Testing: Covered by existing tests

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-08-27 17:25:16 +00:00
Tim van der Lippe
3708d493b9
script: Implement trusted types for Range.createContextualFragment (#38874)
Part of #36258

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2025-08-27 06:18:04 +00:00
Tim van der Lippe
d94929dbed
script: Implement trusted types for DOMParser.parseFromString (#38872)
Part of #36258

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2025-08-27 06:10:16 +00:00
Simon Wülker
de6feb469a
script: Move operations in window_named_properties::get_own_property_descriptor & webdriver_handlers::clone_an_object into unsafe blocks (#38951)
Testing: Covered by existing tests
Part of https://github.com/servo/servo/issues/35955

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-08-26 21:48:25 +00:00
criskell
9082217272
Move unsafe to the wrap method for global objects (#38896)
The method now doesn't need unsafe in its signature because it no longer
accepts unsafe pointers as arguments. We move the unsafe marker to the
method itself.

Testing: I opened the browser and went to google.com; I ran some WPT
(IndexedDB) tests.
Fixes: #38361

---------

Signed-off-by: criskell <96352451+criskell@users.noreply.github.com>
2025-08-25 22:02:55 +00:00
Josh Matthews
b7cdd88b8e
IndexedDB: Handle missing object stores in object store operations (#38115)
These changes fix a large number of panics that can manifest as
intermittent test failures. They also add more specification text to
various IDBObjectStore methods and implement missing steps that check
for whether an object store is deleted.

Testing: Existing test coverage.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2025-08-22 22:04:34 +00:00
Tim van der Lippe
f334a56b07
Remove event handlers when attribute is removed (#38734)
We wouldn't handle the AttributeMutation::Removed for
attribute event listeners and wouldn't remove the
corresponding event listener. Added the necessary
logic (using the newly EventTarget::is_content_event_handler
to correctly only do this for known event handlers) and
added links to the relevant parts of the spec.

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2025-08-22 19:43:04 +00:00
Tim van der Lippe
10ac177aa5
Propagate Trusted Types errors for Node.textContent (#38871)
Part of #36258

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2025-08-22 19:41:50 +00:00
Abdelrahman Hossam
176e42d36d
script: Add FocusOptions argument to Element.focus and implement FocusOptions.preventScroll (#38495)
This is an implementation of the `prevent_scroll` feature in the focus
transaction system. It allows to control whether focusing an element
should prevent scrolling or not.

Spec:
https://html.spec.whatwg.org/multipage/interaction.html#dom-focusoptions-preventscroll
Testing: Existing WPT tests

Signed-off-by: abdelrahman1234567 <abdelrahman.hossameldin.awadalla@huawei.com>
2025-08-22 14:05:32 +00:00
criskell
56ce19511c
Make transaction field non-null in IDBObjectStore (#38834)
In the `IDBObjectStore::new` constructor, the `transaction` field is
initialized to null, but when using this constructor, we always execute
`set_transaction` immediately afterward. Therefore, we refactored to
require the `transaction` field to be specified during construction and
thereby also removed some no longer necessary assertions.

We also updated the `transaction` field in WebIDL to remove the nullable
capability.

Testing: WPT
Fixes: #38814

---------

Signed-off-by: criskell <96352451+criskell@users.noreply.github.com>
2025-08-22 05:10:13 +00:00
lumiscosity
39f3ce7a2e
Make DOM geometry structs serializable (#38828)
Makes the following DOM geometry structs serializable:
- `DOMRect`
- `DOMRectReadOnly`
- `DOMQuad`
- `DOMMatrix`
- `DOMMatrixReadOnly`

Testing: Covered by WPT (`css/geometry/structured-serialization.html`).

---------

Signed-off-by: lumiscosity <averyrudelphe@gmail.com>
2025-08-21 23:19:42 +00:00
Ashwin Naren
f30be4e1ab
Stub out IDBIndex (#38813)
Stubs the IDBIndex interface.

Testing: Mostly stubbing. Eventually covered by WPT.
Fixes: Partially #38100

---------

Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
2025-08-21 22:54:19 +00:00
Jerens Lensun
48c2152f61
script_bindings(python): Add type to a function for codegen.py (#38771)
This PR focuses on adding type annotations to utility functions,
PropertyDefiner, and its child classes.

---------

Signed-off-by: Jerens Lensun <jerensslensun@gmail.com>
Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>
Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
2025-08-21 14:45:45 +00:00
lumiscosity
913066d2e5
Add legacy window aliases SVGMatrix/SVGPoint for DOMMatrix/DOMPoint (#38810)
Adds the legacy window aliases `SVGMatrix`/`SVGPoint` for
`DOMMatrix`/`DOMPoint`.

Testing: Covered by WPT (`css/geometry`).

---------

Signed-off-by: lumiscosity <averyrudelphe@gmail.com>
2025-08-21 07:19:25 +00:00
Tim van der Lippe
3c89763b77
Implement trusted types for remaining attribute sinks (#38784)
Additionally, several methods were updated with
spec comments. That's because the "adopt the document
from the element document" step was missing.

By adding these spec comments, I also restructured
some code to avoid duplication of mutation records
and custom element reaction queueing.

Node.textContent doesn't propagate the error yet,
as that method has a lot of separate callers of
elements that wouldn't fail. I will refactor those
in a follow-up PR to keep things manageable.

This implements part of the DOM integration from
https://github.com/whatwg/dom/pull/1268

Part of #36258

---------

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Signed-off-by: Tim van der Lippe <TimvdLippe@users.noreply.github.com>
2025-08-21 05:37:34 +00:00