Commit Graph

290 Commits

Author SHA1 Message Date
Abubakar Abdulazeez Usman
6c7fcd41bd script: Pass &mut JSContext to CSSKeyframeRule::Style (#43549)
Move `CSSKeyframeRule::Style` from `CanGc` to `&mut JSContext`.

Testing: Just a refactor, Existing tests suffice.
Fixes: Part of #42638

Signed-off-by: arabson99 <arabiusman99@gmail.com>
2026-03-23 02:54:31 +00:00
Domenico Rizzo
1e514bcfe9 webgl: Remove manual Drop implementation for WebGLQuery (#43544)
Moves the cleanup logic to a separate helper struct to comply with the
prohibition of manual `Drop` implementations for DOM types.

Testing: WebGL tests just cover its parts
Fixes: Partially #26488

Signed-off-by: Domenico Rizzo <domenico.rizzo@gmail.com>
2026-03-22 20:33:35 +00:00
Gae24
5152632f04 script_bindings: Pass &mut JSContext to CustomElementReaction::invoke (#43535)
Pass `&mut JSContext` to `CustomElementReaction::invoke` and
`upgrade_element` algorithm.

Testing: A successful build is enough
Part of #40600

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2026-03-22 11:11:52 +00:00
Gae24
1626450063 script: Propagate &mut JSContext from GlobalScope::start_message_port to stream code (#43525)
Pass `&mut JSContext` to more stream related code.

Testing: A successful build is enough.
Part of #42347

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2026-03-21 21:07:47 +00:00
Jerens Lensun
4199e050d9 script: add a check for a valid key path on idb object store (#42451)
Add a check for a valid key path when create index on idb object store

Testing: `./mach test-wpt
tests/wpt/tests/IndexedDB/keypath_invalid.any.js`
Fixes: #42434

---------

Signed-off-by: Jerens Lensun <jerensslensun@gmail.com>
2026-03-21 11:44:23 +00:00
Tim van der Lippe
dc9e442b17 script: Pass &mut JSContext to Location (#43481)
Part of #42638

Testing: It compiles

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2026-03-20 12:54:38 +00:00
Uiniel
730c827f67 script: Pass &mut JSContext to more functions in dom/stream (#43439)
Pass `&mut JsContext` to `TransformStreamDefaultController::enqueue`, in
preparation of porting the remaining BlobMethods.

Testing: Just a refactor, ./mach test-unit still passes.
Fixes: Part of #42638

---------

Signed-off-by: Uiniel <174327181+uiniel@users.noreply.github.com>
2026-03-19 12:40:11 +00:00
Uiniel
475eeccc8a script: Pass &mut JSContext to ReadableStream::cancel (#43432)
Pass `&mut JSContext` to `ReadableStream::cancel`, in preparation of
porting the remaining `BlobMethods`.

Testing: Just a refactor, ./mach test-unit still passes.
Fixes: Part of #42638

Signed-off-by: Uiniel <174327181+uiniel@users.noreply.github.com>
2026-03-18 16:33:45 +00:00
Tim van der Lippe
2dd5c38c8e script: Pass &mut JSContext in remaining parts of Trusted Types (#43365)
These are the remaining arguments of `CanGc`.

Part of #40600

Testing: it compiles

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2026-03-18 09:15:31 +00:00
Uiniel
fba95dcda9 script: Pass &mut JSContext to more functions in dom/stream (#43327)
Pass `&mut JSContext` and `&mut CurrentRealm` to more functions in
`dom/stream`, focusing on functions that need to be ported to finish
porting the remaining methods in `Blob`.

Testing: Just a refactor, ./mach test-unit still passes.
Fixes: Part of #42638

---------

Signed-off-by: Uiniel <174327181+uiniel@users.noreply.github.com>
2026-03-17 20:07:27 +00:00
Euclid Ye
41ad1b63a6 script: Port TreeWalker & NodeIterator to &mut JSContext (#43312)
Testing: It compiles.
Part of #40600
TODO: #43311

---------

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
2026-03-16 09:55:46 +00:00
Euclid Ye
fc76797034 script: Port Notification to mozjs JSContext (#43302)
Mission No.2

Divided into three parts
- Import `js::context::JSContext;` and use it. This is fine as we
already renamed the traditional one.
- Major mission of porting
- Add space between functions

Testing: It compiles

---------

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
2026-03-16 06:21:27 +00:00
Simon Wülker
16a6494db5 script: Let FontFaceSet be setlike<FontFace> (#43286)
Testing: New tests start to pass.

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2026-03-15 21:59:54 +00:00
Domenico Rizzo
b3c8c50af8 script: Move drop logic for several WebGPU types to helper structs (#43288)
Implementing `Drop` for DOM types is being forbidden. This moves the
resource cleanup logic for `GPUShaderModule`, `GPUTexture`, and
`GPUTextureView` to separate helper structs and removes the
`allowDropImpl` flag from the bindings configuration.

Testing: WebGpu tests just cover their cases
Fixes: Partially #26488

Signed-off-by: Domenico Rizzo <domenico.rizzo@gmail.com>
2026-03-15 20:33:07 +00:00
Euclid Ye
c9c8e22abd script: Use &mut JSContext in HTMLMapElement&HTMLImageElement (#43284)
I just want to be part of the campaign.

Testing: It compiles.

---------

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
Co-authored-by: Sam <16504129+sagudev@users.noreply.github.com>
2026-03-15 16:02:40 +00:00
Euclid Ye
0d764f0d20 script_bindings: Remove non-existent entries (#43282)
These methods do not exist in DOM.

Testing: It compiles.

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
2026-03-15 12:44:26 +00:00
Tim van der Lippe
d952864be0 script: Pass &mut JSContext to set_timeout_or_interval (#43278)
Part of #40600

Testing: It compiles

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2026-03-15 10:10:21 +00:00
Tim van der Lippe
3c852261b9 script: Pass &mut JSContext in CSP code (#43184)
Part of #40600

Testing: it compiles

---------

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Signed-off-by: Tim van der Lippe <TimvdLippe@users.noreply.github.com>
2026-03-14 21:42:02 +00:00
Tim van der Lippe
f660fd6d91 script: Pass &mut JSContext to TrustedHTML::get_trusted_type_compliant_string (#43268)
Part of #40600

Testing: It compiles

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2026-03-14 19:40:49 +00:00
Gae24
e8b581aaf0 script: Pass &mut JSContext in more places (#43252)
Continuation of #43220, removes many `temp_cx` calls introduced by that.

Testing: No behaviour change, a successful build is enough.
Fixes: #43241 #43240

---------

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2026-03-14 10:03:48 +00:00
Gae24
ef97d7e199 script: Pass &mut JSContext to VirtualMethods::bind_to_tree (#43220)
Testing: No behaviour change, a successful build is enough.
Fixes: #42838 #43239

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2026-03-14 07:37:47 +00:00
Tim van der Lippe
b6ba612a54 script: Pass &mut JSContext to TrustedScriptURL::get_trusted_type_compliant_string (#43245)
Also rename the method and consolidate the sink to be consistent with
both `TrustedHTML` and `TrustedScript`

Part of #42638

Testing: It compiles

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2026-03-13 13:56:46 +00:00
Gae24
048612fe84 script: Pass &mut JSContext to children_changed and adopting_steps (#43219)
Switch `VirtualMethods::children_changed` and
`VirtualMethods::adopting_steps` to `&mut JSContext`.

Testing: No behaviour change, a successful build is enough.
Part of #40600

---------

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2026-03-13 13:40:40 +00:00
Tim van der Lippe
7a383bcc43 script: Pass &mut JSContext in trusted types interfaces (#43183)
Part of #40600

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2026-03-13 11:04:34 +00:00
Tim van der Lippe
af256bd6e5 script: Check for render-blocking documents before continuing (#43150)
The spec expects us to check for render blocking (among some other
state) before we start procesing a document. Therefore, add those checks
and also check in the
stylesheet loader that we should only do so when we are allowed to do
so.

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2026-03-13 09:54:03 +00:00
Domenico Rizzo
b2ac181091 script: Move GPUSampler drop logic to a helper struct (#43222)
Implementing `Drop` for DOM types is being forbidden. This moves the
resource cleanup logic for `GPUSampler` to a separate
`DroppableGPUSampler` struct and removes the `allowDropImpl` flag from
the bindings configuration.

Testing: WebGpu tests just cover its cases
Fixes: Partially #26488

Signed-off-by: Domenico Rizzo <domenico.rizzo@gmail.com>
2026-03-13 05:36:23 +00:00
Uiniel
0f5e02099b script: Move BlobMethods to &mut JSContext (#43215)
Move from CanGc to &mut js::context:JSContext. `ArrayBuffer` and `Bytes`
require many changes in `dom/stream` for which I'm going to create a
seperate pull request before porting the two methods.

Testing: Just a refactor, `./mach test-unit` still passes.
Fixes: Part of #42638

---------

Signed-off-by: Uiniel <174327181+uiniel@users.noreply.github.com>
2026-03-12 21:58:56 +00:00
Jonathan Schwender
9069043477 Move ply and WebIDL into script_bindings (#43180)
This is required to publish script_bindings, since all files used during
codegen need to be there.
It might also be possible to generate the bindings ahead of time and
vendor them in-tree, but this seems painful to setup from a CI
perspective.
Since there don't seem to be any other users in-tree we can just vendor
into the script-bindings directory.

`ply` is licensed under the BSD 3 clause, and WebIDL under MPL-2.0, with
the licenses available in our cargo package. Both tools won't end up in
`servo` since they are build-time dependencies, so I believe we don't
need to adjust the crate license, or configure `about.toml`.

Testing: Should be covered by existing tests. We don't test if this
allows vendored builds or published builds.
Fixes: Partial fix for #43145

---------

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
2026-03-12 05:44:46 +00:00
Gae24
4ef22ed227 script: Pass &mut JSContext to VirtualMethods::cloning_steps and Node::clone (#43130)
Continuation of #43108, two new `temp_cx()` calls were required:
- inside `maybe_clone_an_option_into_selectedcontent` since it's part of
a markup5ever trait
- inside `serialize_and_cache_subtree` replacing a `CanGc::note()` call,
propagating it inside reflow code will require even more effort.

Testing: No behaviour change, a successful build is enough.
Part of #40600

---------

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2026-03-10 17:05:34 +00:00
Luke Warlow
62e72b027f script: Implement node.moveBefore() (#41238)
Implement node.moveBefore()

This implements the atomic move method for DOM nodes. This allows moving
elements within the DOM without running the full remove and insertion
steps, allowing more seamless behaviour such as CSS transitions
continuing from where they are rather than restarting.

Spec: https://dom.spec.whatwg.org/#dom-parentnode-movebefore

Testing: Existing WPTs

---------

Signed-off-by: Luke Warlow <lwarlow@igalia.com>
2026-03-09 16:39:56 +00:00
Narfinger
9062952bf9 script: Add UnrootedSimpleNodeIterator (#42978)
In the same vein as https://github.com/servo/servo/pull/42781 we
implement a UnrootedSimpleNodeIterator that takes a no_gc and does not
root the required nodes.

We include an example usage in 'dom/text.rs' WholeText.

This requires https://github.com/servo/servo/pull/42781 to be merged
first.

---------

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
2026-03-09 12:28:07 +00:00
Gae24
fa86bbedbe script: Pass &mut JSContext to DOM apis that call Element::create (#43108)
Testing: No behaviour change, a successful build is enough.
Part of #40600

---------

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2026-03-09 10:07:13 +00:00
Kingsley Yung
1c449ed53b script: Implement SubtleCrypto.getPublicKey method with X25519 support (#43073)
Implement the `getPublicKey` method of the `SubtleCrypto` interface.

This patch includes:

- Implementing the steps of the `getPublicKey` method.
- Adding the new "getPublicKey" operation to the internal object
`supportedAlgorithms`, for registering cryptographic algorithms that
support "getPublicKey" operation, and used by the `getPublicKey` method
to check whether the cryptographic algorithm supports "getPublicKey"
operation and perform the operation if it is supported.
- Implementing the "getPublicKey" operation of X25519 for demonstrating
and testing the functionality of the `getPublicKey` method.

Specification:
<https://wicg.github.io/webcrypto-modern-algos/#SubtleCrypto-method-getPublicKey>
Testing: Pass WPT tests that were expected to fail.
Fixes: Part of #43072

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
2026-03-07 09:13:40 +00:00
Domenico Rizzo
229d89042f script: Refactor GPURenderPipeline's drop implementation (#43071)
Moves the `Drop` logic for `GPURenderPipeline` into a dedicated helper
struct, `DroppableGPURenderPipeline`.
The associated `Bindings.conf` entry is
removed as direct `Drop` is no longer needed for this type.

Testing: WebGpu tests just cover its cases
Fixes: Partially #26488

Signed-off-by: Domenico Rizzo <domenico.rizzo@gmail.com>
2026-03-07 06:53:15 +00:00
Tim van der Lippe
0c4b185233 script: Fix lookup of properties of DOMStringMap (#43046)
The conversion of strings was wrong for `--foo` where it should become
`-Foo`. Instead, it was consuming both the `--` and then would encounter
a `f`.

This moves the relevant algorithms to DOMStringMap and adds
corresponding spec comments to explain what's going on.

This does make us closer to passing
`html/dom/elements/global-attributes/dataset-delete.html` but
unfortunately it still fails because of #12978

Prior to this fix, the value of `d.dataset['-foo']` wasn't undefined.
However, we now fail the assertion where the attribute should remain,
despite the call to delete.

That's because per `LegacyOverrideBuiltIns` we should be checking the
existence of which properties it can delete, before it actually deletes
the attribute. Right now, we do it regardless if it is a valid property
and thus we incorrectly delete the attribute.

Testing: No change in tests, since the test in question has more
assertions that require more fixes

---------

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Signed-off-by: Tim van der Lippe <TimvdLippe@users.noreply.github.com>
2026-03-06 09:58:33 +00:00
Tim van der Lippe
7c21cb5606 script: Fully implement delete_the_selection (#43016)
This continues implementation of the delete command for
document.execCommand. Unfortunately, since these algorithms are vast
(30+ steps) and partial implementation leads to lots of issues, this PR
is "draw the rest of the owl".

I have tried to keep things manageable, by only implementing a couple of
extra steps in the delete command, so that we can focus on the "Delete
the selection" part.

To do that, several algorithms had to be implemented. Most of these
algorithms are required both by commands and by algorithms themselves,
which is why they are now exposed on a trait.

Additionally, all code now uses `cx`, to make sure it is up-to-date with
the ongoing migration and since some of the DOM API's it needs to call
already require `cx`.

Part of #25005

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2026-03-05 19:38:44 +00:00
Domenico Rizzo
1f6037d022 script: Refactors GPURenderPassEncoder's drop implementation. (#43018)
Moves the `Drop` logic for `GPURenderPassEncoder` into a dedicated
helper struct, `DroppableGPURenderPassEncoder`. This ensures that DOM
types do not directly implement `Drop`, aligning with the policy for
resource management in the DOM. The associated `Bindings.conf` entry is
removed as direct `Drop` is no longer needed for this type.

Testing: WebGPU tests just cover its cases
Fixes: Partially #26488

Signed-off-by: Domenico Rizzo <domenico.rizzo@gmail.com>
2026-03-04 14:48:51 +00:00
Oriol Brufau
cd8973873d build(deps): bump Stylo to "Make preference system more robust" (#42741)
Bumps Stylo to https://github.com/servo/stylo/pull/314

In particular, we would now get a compile error because we were setting
`layout.flexbox.enabled` and `layout.css.transition-behavior.enabled`,
even if Stylo removed at some point. So stop setting them.

Testing: Not needed, no behavior change

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2026-03-03 22:28:59 +00:00
Domenico Rizzo
bff59c629a script: Refactors GPURenderBundle's drop implementation. (#42982)
Moves the `Drop` logic for `GPURenderBundle` into a dedicated helper
struct, `DroppableGPURenderBundle`. This change ensures that
`GPURenderBundle` itself does not directly implement `Drop`, aligning
with the policy to prevent direct `Drop` implementations on DOM types.

Removes the `allowDropImpl` configuration for `GPURenderBundle` from
script bindings.

Testing: WebGPU tests cover all related cases
Fixes: Partially #26488

Signed-off-by: Domenico Rizzo <domenico.rizzo@gmail.com>
2026-03-03 11:59:34 +00:00
Narfinger
b55bc205a7 script: jscontext-ify element aria methods and SetCrossOrigin (#42957)
Use &mut JSContext in element aria* methods and SetCrossOrigin methods.

Testing: Compilation is the test as this is part from
https://github.com/servo/servo/issues/40600

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
2026-03-02 17:23:33 +00:00
Domenico Rizzo
68284e4a38 script: Refactors GPUPipelineLayout to disallow direct Drop. (#42937)
Moves the `Drop` implementation for `GPUPipelineLayout` to a dedicated
private helper struct, `DroppableGPUPipelineLayout`. This ensures that
DOM types do not directly implement `Drop`, aligning with best practices
for resource management in the DOM. The associated `Bindings.conf` entry
is removed as direct `Drop` is no longer needed for this type.

Testing: WebGpu just coverages cases with  proper tests
Fixes: Partially #26488

Signed-off-by: Domenico Rizzo <domenico.rizzo@gmail.com>
2026-03-02 15:26:42 +00:00
Martin Robinson
f6e44fad29 script: Expose the tabIndex property on HTMLOrSVGElement (#42913)
This is exposes the `tabIndex` property for `HTMLOrSVGElement` according
to the HTML specification. This is the first step toward implementation
of tab navigation in Servo.

Testing: This causes many WPT subtests to start passing, but causes a
few to
start failing. This is likely because we do not have a full
implementation of
the `delegatesFocus` parameter of `attachShadow` yet.
Fixes: This is part of #25001 and #32169.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2026-02-27 19:03:54 +00:00
Gae24
49b13627b5 script: Propagate &mut JSContext inside evaluate_js_on_global (#42846)
Since `evaluate_js_on_global` called `enter_realm` and there were
already some callee that did it, I've actually passed `&mut
CurrentRealm`.
Also converted `Window::WebdriverException` to pass `&mut JSContext`
inside `javascript_error_info_from_error_info`.

Testing: A successful build is enough
Part of #40600

---------

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2026-02-27 11:49:44 +00:00
Onur Şahin
2a0b4606ab script: use &mut JSContext in MessagePort::PostMessage (#42880)
Replace crate::script_runtime::JSContext with js::context::JSContext in
`MessagePort::PostMessage`

Testing: Builds and runs fine
Fixes: part of https://github.com/servo/servo/issues/42347

Signed-off-by: Onur Sahin <sahinonur2000@hotmail.com>
2026-02-26 15:52:26 +00:00
Domenico Rizzo
e61ad2775e script: Encapsulates GPUDevice resource cleanup logic (#42851)
Moves the `Drop` implementation for `GPUDevice` into a private
`DroppableGPUDevice` struct.

Also updates `Bindings.conf` to prevent the generation of `Drop`
implementations for `GPUDevice`.

Testing: WebGpu tests just cover the cases
Fixes: Partially #26488

Signed-off-by: Domenico Rizzo <domenico.rizzo@gmail.com>
2026-02-26 13:03:05 +00:00
Narfinger
a122bde4b1 Script: Use &mut JSContext in CheckValidity and ReportValidity Methods (#42820)
This is part of replacing can_gc with the new &JSContext/&mut JSContext
method.
We modify CheckValidity and ReportValidity in various HTML Elements to
use the context instead of CanGc.

Testing: Compilation is the test as this is mostly mechanical.

---------

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
2026-02-25 10:34:21 +00:00
Sam
6c334f2811 script: Replace RAII of CallSetup and AutoEntryScript with a function wrapper (#42715)
As mentioned in #40600 we will need this to properly handle &mut
JSContext (we cannot pass it to drop) and I think this wrappers are
preferred ways of doing this in rust as it is safe to forget (not call
drop) which is unsound in this case (due to realm stack at least).

Revieable per commits.

Testing: Just a refactor, but should be covered by WPT

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2026-02-25 09:13:18 +00:00
Sam
3e2f14c455 script: Pass down &mut JSContext in servoparser and event loop. (#42635)
I only wanted to get `&mut JSContext` in microtask chunk and checkpoint,
but this in turn needed `&mut JSContext` in servoparser, which then
caused need for even more changes in script.

I tried to limit the size by putting some `temp_cx` in:
- drops of `LoadBlocker`, `GenericAutoEntryScript`
- methods of `VirtualMethods`
- methods of `FetchResponseListener`

Testing: Just refactor, but should be covered by WPT tests.
Part of #40600

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2026-02-25 07:14:23 +00:00
Onur Şahin
a4d98df1a9 script: use &mut JSContext inside History (#42805)
Replace `crate::script_runtime::JSContext` with `js::context::JSContext`
in:
- `History::PostMessage`
- `History::ReplaceState`
- `History::GetState`

Testing: Builds and runs locally. [WPT
passed](https://github.com/onsah/servo/actions/runs/22341528931)

Fixes: part of https://github.com/servo/servo/issues/42347

Signed-off-by: Onur Sahin <sahinonur2000@hotmail.com>
2026-02-25 02:37:39 +00:00
Kingsley Yung
5b3684e2ce script: Pass &mut JSContext to method of Crypto interface (#42809)
This patch changes the method of `Crypto` interface to use the new `&mut
JSContext`.

The method `crypto.subtle` calls `SubtleCrypto::new` to create an
instance of `SubtleCrypto` and the new `&mut JSContext` is passed to
`SubtleCrypto::new`. Therefore, the new `reflect_dom_object_with_cx`
method is also used in `SubtleCrypto::new`.

Testing: Refactoring. Existing tests suffice.
Fixes: Part of #42638

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
2026-02-24 19:24:46 +00:00