#42681 did not actually allowed using cx in Constructor, but it did most
heavy lifting. Now we need to pass cx to Constructor call (and skip
CanGc) if cx is requested in Bindings.conf. This PR also test this on
testbindings.
Also we now always use `let cx = &mut cx`, so we can always use just cx
(compiler will automatically deref it into &cx if needed). This is
important because codegen stuff is called from many places to it make
sense/easier to just unify this.
Testing: It compiles
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
Moves the drop implementation for `GPUComputePipeline` to a separate
`DroppableGPUComputePipeline` struct.
Removes `allowDropImpl` from the bindings configuration.
Testing: No tests added because of webgpu tests existent coverage
Fixes: Partially #26488
Signed-off-by: Domenico Rizzo <domenico.rizzo@gmail.com>
The first step of `execCommand` commands is to figure out
if they are supported and enabled. Therefore, implement
these two pieces with only 1 command: delete.
The implementation of `delete` is currently mostly dummy,
to have at least something going. But the main part of
this change is to setup the infrastructure to figure out
when commands are supported and enabled.
For the first part, its simply the list of commands we
currently have implemented, which is only delete.
For the second part, we need to consider the active range
of the current selection and do various checks, as well as
check the presence of `contenteditable`.
Part of #25005
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
This is required for `document.execCommand`, since it needs to check the
active range of the selection whether it has the attribute or not.
It also turns on the relevant WPT tests, with 1
pre-existing failure for absolute positioned pseudo elements. These
currently do not render correctly, regardless of the existence of
contenteditable.
Fixes#12776
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Moves the drop logic for `GPUComputePassEncoder` to a separate
`DroppableGPUComputePassEncoder` struct.
Testing: Tests that coverages webgpu just exist
Fixes: Partially #26488
Signed-off-by: Domenico Rizzo <domenico.rizzo@gmail.com>
This is a first step to compile scripts using `&mut JSContext`.
Testing: Refactor, covered by existing WPT tests.
Part of #40600
---------
Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
Demonstrate how to change some methods:
- [from `InRealm` to `&mut
CurrentRealm`](0132fc0fbe)
- [from `CanGc` to `&mut
JSContext`](36e5b32ee1)
Testing: Just refactor, should be covered by WPT.
Part of #40600
---------
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
We should only do this for the `insertHTML` command.
All other commands are unaffected.
Part of #25005
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
In preparation of the actual implementation.
Also had to update the codegen to be able to handle default values for
DOMString.
Part of #25005
---------
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
I just wanted to do abort signal, but then this happend.
Testing: Just refactor, should be covered by WPT tests
Part of #40600
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This is companion to https://github.com/servo/mozjs/pull/703 which makes
mozjs to use CStr(ing) in the API (where we would silently do conversion
in mozjs). This way we can avoid rust string -> c string allocations.
In the followup PR we should switch Error::Type and Error::Range to also
use CStrings internally, as they are converted to CString for throwing
JS exceptions (other get thrown as DomException object, which uses rust
string internally - although this gets converted to JSString somewhere).
Testing: It should be just refactor without any side effects so there
should be no changes to WPT results.
Try run: https://github.com/sagudev/servo/actions/runs/21328878448
Part of #42126
---------
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
Moves the `Drop` implementation for `GPUCommandBuffer` to a separate
struct, `DroppableGPUCommandBuffer`. Updates bindings config to remove
`allowDropImpl` which is no longer needed.
Testing: No tests added
Fixes: Partially #26488
Signed-off-by: Domenico Rizzo <domenico.rizzo@gmail.com>
The implementation of `attr()` in Stylo is not complete, but this way we
can start testing for it.
Bumps Stylo to https://github.com/servo/stylo/pull/306
Testing: Various tests pass, also a few failures. No impact on users,
even with experimental features enabled.
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Implements `createIndex` and `deleteIndex`, they have already been
implemented in the backend.
Testing: WPT
Fixes: Partially #38100
---------
Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
Replace `crate::script_runtime::JSContext` with `js::context::JSContext`
in `BroadcastChannel::PostMessage` and update interface binding.
Testing: Builds and runs locally.
Part of: https://github.com/servo/servo/issues/42347
---------
Signed-off-by: BryanSmith00 <bryansmith8023@tuta.com>
when generating rust bindings for webidl typedef, the `<D>` generic Type
would not be added for record<Key, DomInterface> because
`containsDomInterface` does not take record into account. This change
add the is_Record check in `containsDomInterface`, so `typedef
record<Key, DomInterface>` can be successfully build.
Testing: Manually tested with
https://github.com/servo/servo/issues/42362, and building from scratch
with `./mach build` is successful.
Fixes: https://github.com/servo/servo/issues/42362
---------
Signed-off-by: rayguo17 <rayguo17@gmail.com>
Switch `PostMessage` of `Worker`, `DedicatedWorkerGlobalScope` and
`ServiceWoker` to use `&mut JSContext`, propagating it to
`post_message_impl`.
Testing: A successful build is enough
Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
User activation is a concept used to prevents annoying usage of specific
API (Fullscreen API, Virtual Keyboard) to the user by states that the
API needs to have in order to process. This PR implements the
`UserActivation` interface and keep track of the last user interaction.
Each `Window` will keep track the [last activation time
stamp](https://html.spec.whatwg.org/multipage/interaction.html#last-activation-timestamp),
which will be set if there are a triggering input event firing in the
`Window` and propagating across the browsing contexts ancestors and
descendants. These timestamp could be consumed, and the timestamp will
be set to negative infinite.
It is then used to gate some APIs within browser that is determined as
transient activation consuming-gated APIs, which needs transient
activation to be true and consumes the activation. For the purpose of
testing, this PR would implement this behavior on fullscreen API which
is used to test activation consuming behavior.
Spec:
https://html.spec.whatwg.org/multipage/interaction.html#the-useractivation-interface
Testing: Existing WPT
---------
Signed-off-by: Jo Steven Novaryo <steven.novaryo@gmail.com>
Support `errorCallback` in geolocation position request functions and
throw the necessary errors.
Testing: Passes 3 more WPT tests
Fixes: Partially #38903
Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
Reviewable per commits:
As noted in
https://github.com/servo/servo/pull/42180#discussion_r2749861902
transmuting `&Reflector<AssociatedMemory>` to `&Reflector<()>` will
ignore AssociatedMemory information and thus it will not remove extra
associated memory. By returning `&Reflector<Self::ReflectorType>` from
`DomObject::reflector()` we will preserve this information and thus
correctly handle cases with associated memory. We also do not need
`overrideMemoryUsage` in bindings.conf anymore. 🎉
Instead of removing associated memory in drop code we should do it as
part of finalizers, otherwise we have problems in nested (inherited)
structs, where drop is run for both parent and child, but we only added
associated memory for child (on init_reflector) which already included
size of parent. The only exception here is promise, because it is RCed
and not finalized.
Testing: Tested locally that it fixes speedometer.
Fixes#42269
---------
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
By reporting memory usage of rust objects back to SM it can trigger GC
sooner and release more memory (I hope that we could use this to avoid
OOB in webgpu in the future).
Currently we use simple `size_of::<DomStruct>() +
size_of::<Box<DomStruct>>()` but it's possible to override reported
memory with `update_memory_size(self, nbytes);` on reflector. This is
mostly useful for canvases and buffers which usually have large
associated data.
Testing: None, but I am wondering if we can connect this to
`about:memory`.
Fixes: #42168
---------
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
Moves the `Drop` implementation for `GPUCanvasContext` to a new
`DroppableGPUCanvasContext` struct.
This ensures the context destruction logic is correctly handled, as the
`GPUCanvasContext` struct itself is a DOM struct and should not have a
drop implementation. This change aligns with the requirement that DOM
types should not implement Drop.
Testing: No tests added
Fixes: #26488
Signed-off-by: Domenico Rizzo <domenico.rizzo@gmail.com>
Continuing the implementation of `VisualViewport`, the resizing of
`PinchZoom` should be notified to `ScriptThread` to update the
`VisualViewport` interface and to fire the appropriate JS event. Top
level `Window`/`Pipeline` would have a `VisualViewport` interface that
mirrors the `PinchZoom` viewport, while nested `Window` would have a
default value that represent layout viewport of the relevant iframe. The
`VisualViewport` of an iframe is updated after each reflow that
calculate the rectangle of the iframe.
The updates of DOM's `VisualViewport` occurs immediately (instead of
waiting for the event loop like the viewport) but integrates with the
event loop for the JS events. This behavior would helps with the fact
that `VisualViewport` needs to be updated both when it is scrolled or
resized.
Testing: Existing WPTs and new unit test.
Part of: https://github.com/servo/servo/issues/41341
---------
Signed-off-by: Jo Steven Novaryo <steven.novaryo@gmail.com>
It's stupid to create rust strings in the first place to only convert
them into C-style for SM anyway. Furthermore most of those strings are
const literals (comp time strings), so now we will just store additional
null byte within them and able to avoid any runtime conversions.
We should do this in more places.
Testing: Just refactor.
---------
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
Welp, this just happened while I tried to so something else. cc
@arihant2math and @janvarga just so you are aware of these changes.
Testing: Just refactor, but should be covered by WPT tests.
Part of #40600
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit remove more unused code from `script_module`,
`inline_module_map` and `dynamic_modules` fields from `GlobalScope` and
the now unused custom interface `DynamicModuleOwner`.
Testing: No functional change, a successful build is enough.
---------
Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
This replaces uses of our custom RootedVec type that were storing JS GC
values with stack rooting that is better integrated with the engine.
This ensures that storing nursery-allocated objects in these vectors is
handled correctly during GC, unlike our RootedVec implementation which
trips an assertion in debug mozjs builds.
Testing: No observable difference in non-mozjs builds.
Fixes: part of #40141
---------
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Add an event listener for `pause` to `debugger.js` and the necessary
glue to access it from the `devtools` crate. This returns important
information to know where we are paused, such as the source location and
frame state.
Fix frame and object actor encoding into messages. Use information from
`debugger.js` to correctly fill the fields.
Add a new `frames` list to the thread actor and handle the `frames`
message.
Fix `getEnvironment` reply in the frame actor. It is out of form (has a
`type` field but it doesn't require a followup empty message, it already
counts as a reply), so we need to handle it specially.
Note: For now we are focusing on the protocol side of the debugger, and
this patch only shows where the pause would happen. Pausing Servo itself
will happen in a followup.

Testing: `mach test-devtools` and manual testing. No errors (apart from
#42006).
Part of: #36027
---------
Signed-off-by: eri <eri@igalia.com>
Co-authored-by: atbrakhi <atbrakhi@igalia.com>
Co-authored-by: Josh Matthews <josh@joshmatthews.net>
When building without the `testbinding` feature of `libservo`, we end up
with these compilation warnings (and one error):
```
warning: unused import: `native_from_handlevalue`
--> components/script_bindings/import.rs:108:9
|
108 | native_from_handlevalue, native_from_object_static,
| ^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(unused_imports)]` (part of `#[warn(unused)]`) on by default
warning: unused imports: `DomSlice` and `Dom`
--> components/script_bindings/import.rs:131:34
|
131 | pub(crate) use crate::root::{Dom, DomSlice, MaybeUnreflectedDom, Root};
| ^^^ ^^^^^^^^
warning: unused import: `crate::root::DomRoot`
--> /home/webbeef/servo/target/debug/build/script_bindings-9c5650a8d750af8f/out/DomTypes.rs:3:5
|
3 | use crate::root::DomRoot;
| ^^^^^^^^^^^^^^^^^^^^
warning: unused import: `Maplike`
--> components/script_bindings/import.rs:124:34
|
124 | pub(crate) use crate::like::{Maplike, Setlike};
| ^^^^^^^
warning: `script_bindings` (lib) generated 4 warnings (run `cargo fix --lib -p script_bindings` to apply 3 suggestions)
error[E0412]: cannot find type `IdentityHub` in this scope
--> components/script/dom/debuggerglobalscope.rs:76:63
|
76 | #[cfg(feature = "webgpu")] gpu_id_hub: std::sync::Arc<IdentityHub>,
| ^^^^^^^^^^^ not found in this scope
|
help: consider importing this struct
|
5 + use crate::dom::identityhub::IdentityHub;
|
warning: method `worklet_id` is never used
--> components/script/dom/worklet.rs:121:19
|
95 | impl Worklet {
| ------------ method in this implementation
...
121 | pub(crate) fn worklet_id(&self) -> WorkletId {
| ^^^^^^^^^^
|
= note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default
```
Testing: No test needed, this won't change the default builds.
Signed-off-by: webbeef <me@webbeef.org>
Moves the drop logic for `GPUBindGroupLayout` to an inner struct
`DroppableGPUBindGroupLayout`.
Testing: No tests added
Fixes: Partially #26488
Signed-off-by: Domenico Rizzo <domenico.rizzo@gmail.com>
Moves the drop implementation for `GPUBindGroup` to a separate
`DroppableGPUBindGroup` struct.
Testing: No tests added
Fixes: partially #26488
Signed-off-by: Domenico Rizzo <domenico.rizzo@gmail.com>
Moves the adapter dropping logic from the `GPUAdapter` struct to a new
`DroppableGPUAdapter` struct.
Testing: No tests added.
Fixes: Partially #26488
Signed-off-by: Domenico Rizzo <domenico.rizzo@gmail.com>
Reviewable per commit. First commit adds `&mut JSContext` to
`call_default_constructor`. Second commit adds `&mut JSContext` to
Interface, which in unfortunately required many changes (a lot of
passing `&mut JSContext` down).
Testing: Just a refactor, but should be covered by WPT
Part of #40600
---------
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
Refactors the `CookieStore` to use a separate `DroppableCookieStore`
struct for handling the drop logic.
Testing: No tests added
Fixes: Partially #26488
Signed-off-by: Domenico Rizzo <domenico.rizzo@gmail.com>
Refactors the WebGLRenderingContext to manage resource cleanup via a
dedicated `DroppableWebGLRenderingContext` struct.
Testing: This task is only a refactor, no tests added
Fixes: partially #26488
Signed-off-by: Domenico Rizzo <domenico.rizzo@gmail.com>
Replace `allow` with `expect` lints for `unused`, `unsafe_code`,
`dead_code`, and `non_upper_case_globals`.
Testing: So far just check it compiled on `x86_64-linux` on NixOS. Need
to use the module `system.fontconfig.enable = true;` I think in my NixOS
config.
Part of: #40383
Searching `allow\(.*\)` for `.rs` files shows the following. for
(total_results:total_files) went from `707:386` to `675:368`, a
reduction of `32:18`.
How many files is too many files per PR? I feel like the 20-30 I have is
too big.
---------
Signed-off-by: Wayne Van Son <waynevanson@gmail.com>