aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/script_module.rs
Commit message (Collapse)AuthorAgeFilesLines
* feat: add CanGc argument to Error::to_jsval (#36014)Arya Nair2025-03-171-6/+9
| | | | | | | | | | | | | | | | | * feat: add CanGc argument to Error::to_jsval Signed-off-by: Arya Nair <aryaajitnair@gmail.com> * feat: pass CanGc to gen_type_error Signed-off-by: Arya Nair <aryaajitnair@gmail.com> * fix: linting issues Signed-off-by: Arya Nair <aryaajitnair@gmail.com> --------- Signed-off-by: Arya Nair <aryaajitnair@gmail.com>
* Update rustfmt to the 2024 style edition (#35764)Simon Wülker2025-03-031-11/+11
| | | | | | | | | | | | | * Use 2024 style edition Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Reformat all code Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> --------- Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* Propagate more `CanGc` (#35604)Auguste Baum2025-02-231-1/+1
| | | Signed-off-by: Auguste Baum <auguste.apple@gmail.com>
* Move more bindings types to script_bindings (#35620)Josh Matthews2025-02-231-1/+1
| | | | | | | | | | | | | | | | | | | | | * Move weak references implementation to script_bindings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Move maplike/setlike definitions to script_bindings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Move base error types to script_bindings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Formatting. Signed-off-by: Josh Matthews <josh@joshmatthews.net> --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* refactor: add CanGc as argument to Promise::resolve (#35616)Yerkebulan Tulibergenov2025-02-231-9/+9
| | | Signed-off-by: Yerkebulan Tulibergenov <yerkebulan@gmail.com>
* refactor: propagate CanGc arguments through callers (#35591)Auguste Baum2025-02-231-4/+5
| | | Signed-off-by: Auguste Baum <auguste.apple@gmail.com>
* Propagate `CanGc` arguments through callers in constructors (#35541)Auguste Baum2025-02-201-0/+3
| | | Signed-off-by: Auguste Baum <auguste.apple@gmail.com>
* script: make Error::to_jsval safe (#35411)Stephen Muss2025-02-101-5/+3
| | | Signed-off-by: Stephen Muss <stephenmuss@gmail.com>
* make report_pending_exception safe and adjust callers (#35351)Nolen Scaife2025-02-081-7/+2
| | | Signed-off-by: Nolen Scaife <nolen@scaife.org>
* Move various reflector types and traits to script_bindings (#35279)Josh Matthews2025-02-041-1/+1
| | | | | | | | | | | | | * script: Move Reflector to script_bindings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Extract global() helper from DomObject into new trait. Move DomObject and related traits to script_bindings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* Include `WebViewId` into EmbedderMsg variants where possible (#35211)Delan Azabani2025-01-301-1/+2
| | | | | | | | | | | | | | | | | `EmbedderMsg` was previously paired with an implicit `Option<WebViewId>`, even though almost all variants were either always `Some` or always `None`, depending on whether there was a `WebView involved. This patch adds the `WebViewId` to as many `EmbedderMsg` variants as possible, so we can call their associated `WebView` delegate methods without needing to check and unwrap the `Option`. In many cases, this required more changes to plumb through the `WebViewId`. Notably, all `Request`s now explicitly need a `WebView` or not, in order to ensure that it is passed when appropriate. Signed-off-by: Delan Azabani <dazabani@igalia.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
* script: Feature-gate all crown support. (#35055)Josh Matthews2025-01-181-2/+2
| | | | | | | | | | | | | * script: Feature-gate all crown support. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Use cfg(crown) instead of a cargo feature. Signed-off-by: Josh Matthews <josh@joshmatthews.net> --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* net: Use `RequestId` to cancel fetches instead of creating an IPC channel ↵Martin Robinson2025-01-111-1/+1
| | | | | | | | | | | | | | | | | | (#34883) Instead of creating an IPC channel for every fetch, allow cancelling fetches based on the `RequestId` of the original request. This requires that `RequestId`s be UUIDs so that they are unique between processes that might communicating with the resource process. In addition, the resource process loop now keeps a `HashMap` or `Weak` handles to cancellers and cleans them up. This allows for creating mutiple `FetchCanceller`s in `script` for a single fetch request, allowing integration of the media and video elements to integrate with the `Document` canceller list -- meaning these fetches also get cancelled when the `Document` unloads. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* script: Limit public exports. (#34915)Josh Matthews2025-01-101-41/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * script: Restrict reexport visibility of DOM types. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Mass pub->pub(crate) conversion. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Hide existing dead code warnings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Formatting. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Fix clippy warnings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Formatting. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Fix unit tests. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Fix clippy. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * More formatting. Signed-off-by: Josh Matthews <josh@joshmatthews.net> --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* script: Expose `NodeTraits::owner_global` / `Window::as_global_scope` (#34843)Martin Robinson2025-01-071-1/+1
| | | | | | | | | | | Expose two new helpers and start using them as much as possible. - `NodeTraits::owner_global`: which gets the `GlobalScope` that currenty owns a `Node`. This may be different than `.global()` in the case that the `Node` was adopted by a different `Document`. - `Window::as_global_scope`: A helper to avoid having to cast so much when treating a `Window` like a `GlobalScope`. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* script: Unsilence all main thread `TaskQueue` errors (#34849)Martin Robinson2025-01-071-1/+1
| | | | | | | | | | | | No longer hide errors while queueing tasks on the main thread. This requires creating two types of `TaskSource`s: one for the main thread and one that can be sent to other threads. This makes queueing a bit more efficient on the main thread and more importantly, no longer hides task queue errors. Fixes #25688. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
* script: Move `TaskManager` to `GlobalScope` (#34827)Martin Robinson2025-01-041-6/+1
| | | | | | | | | | | | | | | | | | | | This is a simplification of the internal `TaskQueue` API that moves the `TaskManager` to the `GlobalScope` itself. In addition, the handling of cancellers is moved to the `TaskManager` as well. This means that no arguments other than the `task` are necessary for queueing tasks, which makes the API a lot easier to use and cleaner. `TaskSource` now also keeps a copy of the canceller with it, so that they always know the proper way to cancel any tasks queued on them. There is one complication here. The event loop `sender` for dedicated workers is constantly changing as it is set to `None` when not handling messages. This is because this sender keeps a handle to the main thread's `Worker` object, preventing garbage collection while any messages are still in flight or being handled. This change allows setting the `sender` on the `TaskManager` to `None` to allow proper garbabge collection. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* script: Expose node helpers as `NodeTraits` and give more descriptive names ↵Martin Robinson2025-01-031-4/+3
| | | | | | | | | | | | | (#34832) This puts a few commonly used `Node` helpers into a trait (`NodeTraits`) and gives them more descriptive names and documentation. The renames: - `document_from_node` -> `NodeTraits::owner_document` - `window_from_node` -> `NodeTraits::owner_window` - `stylesheets_owner_from_node<T:` -> `NodeTraits::stylesheet_list_owner` - `containing_shadow_root` -> `NodeTraits::containing_shadow_root` Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* script: Eliminate code duplication in the task queue (#34798)Martin Robinson2025-01-011-1/+1
| | | | | | | | | | | | | | | | Instead of creating a type for each `TaskSource` variety have each `TaskSource` hold the same kind of sender (this was inconsistent before, but each sender was effectively the same trait object), a pipeline, and a `TaskSourceName`. This elminates the need to reimplement the same queuing code for every task source. In addition, have workers hold their own `TaskManager`. This allows just exposing the manager on the `GlobalScope`. Currently the `TaskCanceller` is different, but this will also be eliminated in a followup change. This is a the first step toward having a shared set of `Sender`s on `GlobalScope`. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* Remove referrer policy from document (#34263)shanehandley2024-11-191-2/+17
| | | | | | | | | | | | | | | | | | | | | * Remove the referrer policy from document and rely on its policy container Signed-off-by: Shane Handley <shanehandley@fastmail.com> * Make ReferrerPolicy non-optional, instead using a new enum value to represent the empty string case Signed-off-by: Shane Handley <shanehandley@fastmail.com> * Fix clippy issue Signed-off-by: Shane Handley <shanehandley@fastmail.com> * Fix usage of Option<ReferrerPolicy> in unit test Signed-off-by: Shane Handley <shanehandley@fastmail.com> --------- Signed-off-by: Shane Handley <shanehandley@fastmail.com>
* Add some more CanGc arguments for compiling module scripts. (#34182)Josh Matthews2024-11-131-3/+13
| | | Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* Unminify module scripts. (#34206)Josh Matthews2024-11-121-2/+44
| | | | | | | | | | | | | * script: Unminify module scripts. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Fix clippy. Signed-off-by: Josh Matthews <josh@joshmatthews.net> --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* CanGc fixes from EventTarget::fire_event (#33985)tanishka2024-10-231-1/+1
| | | Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com>
* Resolved potential GC borrow hazards in ModuleTree::append_handler, ↵chickenleaf2024-10-231-33/+35
| | | | | | | | | | | | | | | | | | | | | | | | | ModuleTree::append_dynamic_module_handler, and ModuleTree::fetch_module_descendants' (#33942) * GC borrow hazard ModuleTree fix Signed-off-by: L Ashwin B <lashwinib@gmail.com> * Prevent `stretch` from producing a negative size (#33951) Signed-off-by: Oriol Brufau <obrufau@igalia.com> * reverted debug_assert back to assert Signed-off-by: L Ashwin B <lashwinib@gmail.com> * added can_gc arguments to the function calls Signed-off-by: L Ashwin B <lashwinib@gmail.com> --------- Signed-off-by: L Ashwin B <lashwinib@gmail.com> Signed-off-by: Oriol Brufau <obrufau@igalia.com> Co-authored-by: Oriol Brufau <obrufau@igalia.com>
* Ensure compiled script module object remains rooted while it's being passed ↵Josh Matthews2024-10-231-12/+24
| | | | | around. (#33938) Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* CanGc fixes in `errorevent.rs` (#33960)tanishka2024-10-221-2/+7
| | | | | | | | | | | | | * CanGc fixes in errorevent.rs Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com> * Allow too_many_arguments to avoid lint error Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com> --------- Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com>
* Mark promise creation methods with CanGc (#33928)Josh Matthews2024-10-221-6/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add CanGc annotations to promise constructor. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Propagate CanGc arguments for Promise::new_in_current_realm. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Fix out-of-order entries. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Propagate CanGc from Promise::new. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Suppress clippy warning. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Formatting. Signed-off-by: Josh Matthews <josh@joshmatthews.net> --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* fix clippy warning in components/script (#33878)lwz232024-10-171-1/+1
| | | Signed-off-by: lwz23 <wenzhaoliao@ruc.edu.cn>
* net: Start reducing number of IPCs channels used for fetch with a ↵Martin Robinson2024-10-161-30/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `FetchThread` (#33863) Instead of creating a `ROUTER` for each fetch, create a fetch thread which handles all incoming and outcoming fetch requests. Now messages involving fetches carry a "request id" which indicates which fetch is being addressed by the message. This greatly reduces the number of file descriptors used by fetch. In addition, the interface for kicking off fetches is simplified when using the `Listener` with `Document`s and the `GlobalScope`. This does not fix all leaked file descriptors / mach ports, but greatly eliminates the number used. Now tests can be run without limiting procesess on modern macOS systems. Followup work: 1. There are more instances where fetch is done using the old method. Some of these require more changes in order to be converted to the `FetchThread` approach. 2. Eliminate usage of IPC channels when doing redirects. 3. Also eliminate the IPC channel used for cancel handling. 4. This change opens up the possiblity of controlling the priority of fetch requests. Fixes #29834. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* clippy: Rename various methods and members to conform to naming guidelines ↵Martin Robinson2024-10-101-3/+3
| | | | | | | | | (#33762) This ensure that methods named `new()` do not take `&self` or return `Box<Self>`. In addition, method are renamed (or removed when not necessary) to avoid being prefixed with `from_`. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* Various CanGc fixes in components/script/dom (#33706)webbeef2024-10-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | * Propagate 'can_gc' in IFrame DOM code Signed-off-by: webbeef <me@webbeef.org> * Propagate 'can_gc' in HTML video and image elements Signed-off-by: webbeef <me@webbeef.org> * Propagate 'can_gc' in Blob and dependencies Signed-off-by: webbeef <me@webbeef.org> * Leftover can_gc fixes for HTMLMediaElement Signed-off-by: webbeef <me@webbeef.org> * Address comment Signed-off-by: webbeef <me@webbeef.org> --------- Signed-off-by: webbeef <me@webbeef.org>
* Create HttpStatus to safely deal with HTTP responses status. (#33581)webbeef2024-09-291-16/+18
| | | Signed-off-by: webbeef <me@webbeef.org>
* Propagate `CanGc` from `Document::new()` (#33386)Andriy Sultanov2024-09-091-2/+2
| | | | | | | | | | | | | * Add canGc as a parameter to autogenerated trait methods Signed-off-by: Andriy Sultanov <sultanovandriy@gmail.com> * Propagate CanGc from Document::new() Signed-off-by: Andriy Sultanov <sultanovandriy@gmail.com> --------- Signed-off-by: Andriy Sultanov <sultanovandriy@gmail.com>
* jsstring_to_str should accept a NonNull argument for the JS string (#33306)Andriy Sultanov2024-09-051-1/+1
| | | | | | Instead of asserting the raw pointer is not null, force callers to produce a NonNull pointer. Signed-off-by: Andriy Sultanov <sultanovandriy@gmail.com>
* script: Use the new C string literal in the DOM bindings (#32741)Bumsoo Kim2024-07-111-1/+1
| | | | | | | | | | | | | | | | | * simple conversion to cstrings using as_ptr() Signed-off-by: Bum Kim <bumcrystlbum@gmail.com> * replaced byte strings with c strings using new helper functions Signed-off-by: Bum Kim <bumcrystlbum@gmail.com> * changed &[u8] type parameters to &CStr Signed-off-by: Bum Kim <bumcrystlbum@gmail.com> --------- Signed-off-by: Bum Kim <bumcrystlbum@gmail.com>
* Fix more clippy (#32740)石蕊 (Pi-Cla)2024-07-091-3/+3
|
* Avoid unnecessary clones for URLs (#32694)cybai (Haku)2024-07-081-25/+27
|
* Fixed some clippy warnings in components (#32025)komuhangi2024-04-101-1/+1
| | | | | * Fixed some clippy warnings in components * Updated the simplification of bolean expressions in componets/script/dom/range.rs
* clippy: Allow `too_many_arguments` for all functions (#31962)komuhangi2024-04-011-0/+1
| | | | | This is the start of preventing this in the future. Co-authored-by: Martin Robinson <mrobinson@igalia.com>
* clippy: fixed various clippy warnings in `components/scripts` (#31960)Rosemary Ajayi2024-04-011-1/+1
| | | | | | | | | * fixed various clippy warnings * fixed various clippy warnings * fixed various clippy warnings * fixed various clippy warnings
* clippy: Fix a few problems in `components/scripts` (#31959)Rosemary Ajayi2024-04-011-1/+1
| | | | | * fixed various clippy warnings * fixed various clippy warnings
* clippy: Fix len_zero warnings (#31935)Oluwatobi Sofela2024-03-291-2/+2
|
* fix: omitted the `let` bindings (#31908)Azhar Ismagulova2024-03-271-1/+1
|
* fixes dereferencing on an immutable reference (#31864)Aarya Khandelwal2024-03-261-1/+1
|
* clippy: Fix `explicit_auto_deref` warnings in `components/script` (#31837)Oluwatobi Sofela2024-03-231-5/+5
| | | | | | | | | * clippy: Fix explicit auto-deref warnings * clippy: Fix explicit auto-deref warnings * refactor: Tidy up code * refactor: Fix method not found errors
* clippy: Fix `unnecessary_cast` warnings in `components/script` (#31823)Oluwatobi Sofela2024-03-221-1/+1
| | | | | | | * clippy: Fix unnecessary cast warnings * clippy: Replace redundant field names with their shorthand alternatives * clippy: Delete struct pattern dereferencings
* Fixed the .clone() warnings. (#31819)Aarya Khandelwal2024-03-221-12/+10
|
* clippy: Fix unneeded return statement warnings (#31776)Oluwatobi Sofela2024-03-201-1/+1
|
* clippy: Fix dereferenced warnings (#31770)Oluwatobi Sofela2024-03-201-2/+2
|
* clippy: Fix many warnings in `components/script` (#31717)Richard Dushime2024-03-191-18/+17
| | | | | | | | | | | | | | | | | * Fix Several clippy warnings * Fix Build errors * Fix Unused import * Fix requested changes * Fix rustfmt * Minor fixes --------- Co-authored-by: Martin Robinson <mrobinson@igalia.com>