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