aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/bindings/utils.rs
Commit message (Collapse)AuthorAgeFilesLines
* Move generated bindings to script_bindings (#36323)Josh Matthews2025-04-041-105/+6
| | | | | | | | | | | | | | | | | | | | | This is the final step of #1799, where the majority of the generated code for the JS bindings is now compiled as part of the script_bindings build step. The remaining pieces in script must live there because they refer to concrete DOM types; all code in script_bindings is generic over the [DomTypes](https://doc.servo.org/script/dom/bindings/codegen/DomTypes/trait.DomTypes.html) trait. My testing with incremental builds shows me a 12 second reduction in build times on my 2024 M4 Macbook Pro when modifying code in the script crate after these changes. Before this PR those changes took 20 seconds to rebuild Servo, and now they take 8 seconds. Testing: Existing WPT tests ensure no regressions. Fixes: #1799 --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* More miscellaneous script splitting changes (#36220)Josh Matthews2025-03-301-49/+83
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * script: Move HasParent to script_bindings and update imports for InheritTypes. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Make principal creation generic over DOM interface. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Move a bunch of proxy-related code to script_bindings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Make some proxy-related code generic over the DOM interface. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Move DomSlice to script_bindings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Move some utility bindings code to script_bindings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Make enumerating and resolving globals generic over the DOM interface. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Make realm helpers generic over the DOM interface. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Move implementations on concrete DOM types to concrete bindings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Make additional codegen helpers generic over the DOM interface. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Make iterator creation generic over the DOM interface. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Make reporting an exception a generic operation. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Move AsCCharPtrPtr to script_bindings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Formatting. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Address clippy warnings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* Miscellaneous script splitting preparation changes (#36216)Josh Matthews2025-03-291-480/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * script: Move num module to script_bindings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Make JS reflector creation generic over DOM trait. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Move bindings-specific lock to script_bindings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Move DOM proto array code to script_bindings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Move finalizer implementations to script_bindings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Move some error routines to script_bindings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Move some DOM interface conversion routines to script_bindings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Make is_array_like generic over DOM trait. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Use generic interfaces for conditional exposure functions. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Move a bunch of routines used by codegen to script_bindings. 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> --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* Fix check in get_array_index_from_id to return early on ASCII char (#36136)Michael Rees2025-03-251-1/+1
| | | | | | | | | | | | | * fix: wrong ascii check in get_array_index_from_id Signed-off-by: Michael Rees <mrees@noeontheend.com> * Update WPT expectations Signed-off-by: Michael Rees <mrees@noeontheend.com> --------- Signed-off-by: Michael Rees <mrees@noeontheend.com>
* feat: add CanGc argument in get_dictionary_property (#36156)Arya Nair2025-03-251-0/+1
| | | | | | | | | | | | | * feat: add CanGc argument in get_dictionary_property Signed-off-by: Arya Nair <aryaajitnair@gmail.com> * feat: add CanGc argument in get_dictionary_property Signed-off-by: Arya Nair <aryaajitnair@gmail.com> --------- Signed-off-by: Arya Nair <aryaajitnair@gmail.com>
* Use explicit reborrows with mozjs::MutableHandle (#35892)Greg Morenz2025-03-231-2/+2
| | | | | | | | | | | | | | | | | | | | | * Explicitly reborrow MutableHandles Signed-off-by: Greg Morenz <greg-morenz@droid.cafe> * Unify jsapi_wrappers Signed-off-by: Greg Morenz <greg-morenz@droid.cafe> * Format mozjs changes Signed-off-by: Greg Morenz <greg-morenz@droid.cafe> * Update mozjs version Signed-off-by: Greg Morenz <greg-morenz@droid.cafe> --------- Signed-off-by: Greg Morenz <greg-morenz@droid.cafe>
* feat: add can_gc argument to to_frozen_array (#36043)Arya Nair2025-03-191-0/+1
| | | | | | | | | | | | | | | | | | | | | * feat: add can_gc argument to to_frozen_array Signed-off-by: Arya Nair <aryaajitnair@gmail.com> * fix: linting issues Signed-off-by: Arya Nair <aryaajitnair@gmail.com> * feat: add can_gc in binding.conf 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-12/+13
| | | | | | | | | | | | | * 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>
* refactor: add CanGc as argument to exception_to_promise (#35647)Yerkebulan Tulibergenov2025-02-251-9/+14
| | | Signed-off-by: Yerkebulan Tulibergenov <yerkebulan@gmail.com>
* refactor: propagate CanGc arguments through callers (#35591)Auguste Baum2025-02-231-1/+1
| | | Signed-off-by: Auguste Baum <auguste.apple@gmail.com>
* script: Make callbacks generic over DOM interfaces. (#35459)Josh Matthews2025-02-211-0/+9
| | | Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* script: Refer to DOM interfaces with generic types in generated bindings. ↵Josh Matthews2025-02-211-4/+44
| | | | | (#35457) Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* script: make throw_invalid_this and throw_constructor_without_new safe (#35360)Stephen Muss2025-02-071-7/+8
| | | Signed-off-by: Stephen Muss <stephenmuss@gmail.com>
* Move more foundational types to script_bindings (#35280)Josh Matthews2025-02-041-41/+4
| | | | | | | | | | | | | | | | | * script: Move DOMClass to script_bindings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Move DOMJSClass and get_dom_class to script_bindings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Move Castable/DerivedFrom/IDLInterface to script_bindings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* script: Limit public exports. (#34915)Josh Matthews2025-01-101-45/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
* Create two-phase initialization for generated JS engine bindings (#34366)Josh Matthews2024-12-061-0/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * script: Generate a runtime initialization for static JS binding information. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Replace dummy static initializers with OnceLock. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Fix clippy warnings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Only initialize statics for DOM interfaces with interface objects. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Remove one unnecessary Box::leak usage. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Tidy. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Hide thread-unsafe OnceLock usage inside of a wrapper type. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Mark ThreadUnsafeOnceLock::get unsafe. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Simplify ThreadUnsafeOnceLock internals. Signed-off-by: Josh Matthews <josh@joshmatthews.net> --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* Use out parameter for generated methods returning JSVal (#34087)Josh Matthews2024-11-051-5/+7
| | | | | | | | | | | | | | | | | | | | | * Make generated bindings that return a WebIDL `any` value use out parameters. Returning raw JSVal values makes it easier to create GC hazards in code that calls these methods. Accepting a MutableHandle argument instead ensures that the values are rooted by the caller. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Update mozjs. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Fix clippy warnings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* frozen array in XRInputSourcesChangeEvent, update `to_frozen_array` doc (#34100)chickenleaf2024-11-021-1/+1
| | | | | | | | | | | | | | | | | * frozen array in XRInputSourcesChangeEvent, update o_frozen_array doc Signed-off-by: L Ashwin B <lashwinib@gmail.com> * simplified changes Signed-off-by: L Ashwin B <lashwinib@gmail.com> * added tests Signed-off-by: L Ashwin B <lashwinib@gmail.com> --------- Signed-off-by: L Ashwin B <lashwinib@gmail.com>
* tidy: Fix rustdoc warnings and add a tidy check for a common URL issue (#33366)Martin Robinson2024-09-081-2/+2
| | | | | | | | This change fixes all rustdoc errors and also adds a tidy check for a very common rustdoc URL issue. Eventually rustdoc warnings should likely cause the build to fail, but this catches those issues sooner in order to not waste so much developer time. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* jsstring_to_str should accept a NonNull argument for the JS string (#33306)Andriy Sultanov2024-09-051-12/+12
| | | | | | Instead of asserting the raw pointer is not null, force callers to produce a NonNull pointer. Signed-off-by: Andriy Sultanov <sultanovandriy@gmail.com>
* fix: Replace callargs_is_constructing with is_constructing method (#33101)Koki Saito2024-08-181-4/+0
| | | | Signed-off-by: Koki Saito <saitoto828@gmail.com> Co-authored-by: kokisaito <kosaito@indeed.com>
* Add exception to rejection logic in `generic_call` (#32950)Samson2024-08-061-11/+19
| | | | | | | | | | | | | | | | | | | | | * exception in JS Promise Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * EXCEPTION_TO_REJECTION on generic_call Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * PromiseRejectionEvent should handle promise as object Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * expectations Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> --------- Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
* bindings: Convert certain Exceptions into Promise rejections (#32923)Samson2024-08-031-8/+49
| | | | | | | | | | | | | | | | | | | | | | | | | * Impl promise exception to rejection for methods Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * Impl promise exception to rejection for getters Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * Impl promise exception to rejection for static methods Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * Add tests for exception to rejection Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * Expectations Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> --------- Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
* fix: Memory leak from CreateProxyWindowHandler (#32773)Erik Hennig2024-08-011-14/+5
| | | | | | | | | | | | | | | | | * fix: Memory leak from CreateProxyWindowHandler Signed-off-by: ede1998 <online@erik-hennig.me> * fix: memory leak in WindowProxy Signed-off-by: ede1998 <online@erik-hennig.me> * fix: Memory leak in WindowProxyHandler through static Signed-off-by: ede1998 <online@erik-hennig.me> --------- Signed-off-by: ede1998 <online@erik-hennig.me>
* fixed various clippy warnings (#31954)Rosemary Ajayi2024-03-311-1/+1
|
* clippy: Fix a variety of warnings in components/script/dom (#31894)Ekta Siwach2024-03-291-1/+1
|
* 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
* clippy: Fix dereferencing a tuple pattern warnings (#31811)Oluwatobi Sofela2024-03-211-1/+1
|
* Remove repeated imports from generated code (#31711)eri2024-03-211-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | * feat: try to deduplicate imports in codegen * feat: another attempt * feat: start testing imports * feat: clean all global imports * feat: remove shared imports from CGDescriptor * feat: remove redundant imports from CGDescriptor * fix: formatting * fix: remove libc (base level import) * feat: roll back named path changes * feat: last changes and tidy * experiment: move imports into a separate file * fix: extra parenthesis * fix: remove repeated allow statement
* Use FLoat32Array in GamepadPose (#31106)Taym Haddadi2024-01-191-10/+0
| | | | | | | | | | | | | * Use FLoat32Array in GamepadPose Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com> * Remove unused create_typed_array Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com> --------- Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com>
* Strict import formatting (grouping and granularity) (#30325)Samson2023-09-111-37/+31
| | | | | * strict imports formatting * Reformat all imports
* Use MozTools 4 and update mozjs (#30326)Samson2023-09-111-1/+1
| | | | | | | | | | | | | | | | | | | * Update mozjs * moztools4 in bootstrap * no autoconf * tidy * switch to servo-build-deps * update mozjs for real * glue mozjs * fmt * move to servo/mozjs
* Throw type error when calling DOM constructor without new.Josh Matthews2023-05-301-0/+4
|
* Support arbitrary protos when wrapping EventTarget objects.Josh Matthews2023-05-281-0/+4
|
* Format.Josh Matthews2022-11-231-1/+1
|
* Changes for spidermomkey upgrade.Josh Matthews2022-11-231-11/+9
|
* refactor(script): move `crate::dom::bindings::{utils → ↵yvt2021-07-131-45/+0
| | | | principals)::ServoJSPrincipal`
* fix(script): implement the destroy-principals callback correctlyyvt2021-07-121-2/+6
|
* fix(script): apply some of the changes requested in the review comments of ↵yvt2021-07-121-2/+2
| | | | #16501
* feat(script): remove the call to `JS_SetWrapObjectCallbacks`yvt2021-07-111-168/+8
| | | | We don't make CCWs anymore.
* chore(deps): update mozjsyvt2021-07-111-5/+23
| | | | - 798c5b6: Bring `RustJSPrincipals` back
* fix: accommodate to the modern ageyvt2021-07-101-4/+13
|
* Merge remote-tracking branch 'upstream/master' into feat-cow-infrayvt2021-07-101-199/+331
|\ | | | | | | | | `tests/wpt/web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects.html` was reverted to the upstream version.
| * Update mozjs.Josh Matthews2021-02-181-9/+30
| |
| * Added is_platform_obj_staticSean Joseph2020-11-261-4/+19
| |
| * Remove unnecessary generic from private_from_proto_check.Josh Matthews2020-06-041-4/+5
| |
| * Remove WebVRAlan Jeffrey2020-04-081-0/+10
| |
| * Update SpiderMonkeyAnthony Ramine2020-03-061-5/+7
| |
| * add a generic utility to convert a slice into a frozen arrayGregory Terzian2020-01-111-7/+2
| |
| * Handle u32 property indicesKagami Sascha Rosylight2019-11-271-22/+40
| |